diff --git a/extras/pandroid_event_viewer/ChangeLog b/extras/pandroid_event_viewer/ChangeLog index 031d81b880..ebd45d82f1 100644 --- a/extras/pandroid_event_viewer/ChangeLog +++ b/extras/pandroid_event_viewer/ChangeLog @@ -1,3 +1,7 @@ +2012-06-30 Santiago Munín + * src/pandroid_event_viewer/pandorafms/Main.java: Added a check in order to prevent profile overwritings. + * src/pandroid_event_viewer/pandorafms/Core.java: Added method which finds a string in a list (case insensitive). + 2012-06-29 Santiago Munín * src/pandroid_event_viewer/pandorafms/Main.java: Added a little hack to make it compatible with v4.0.2 * res/layout/main.xml: Added a little hack to make it compatible with v4.0.2 diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java index c8c4c29a54..4b4483551b 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java @@ -31,6 +31,7 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -586,6 +587,23 @@ public class Core { Toast.LENGTH_SHORT).show(); } } + } + /** + * Checks if a string is inside the list (case insensitive). + * + * @param list + * List of strings. + * @param string + * Given value. + * @return If the string is inside the list. + */ + public static boolean containsIgnoreCase(List list, String string) { + Iterator it = list.iterator(); + while (it.hasNext()) { + if (it.next().equalsIgnoreCase(string)) + return true; + } + return false; } } diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java index d204a14205..5d50864a4f 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java @@ -211,14 +211,13 @@ public class Main extends Activity { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: - /* - * if (profiles.contains(profileName.getText() - * .toString())) { Toast.makeText(context, - * R.string.profile_already_exists, - * Toast.LENGTH_SHORT).show(); break; } - */ - // TODO Ask for a confirmation before rewriting the - // profile + if (Core.containsIgnoreCase(profiles, profileName + .getText().toString())) { + Toast.makeText(context, + R.string.profile_already_exists, + Toast.LENGTH_SHORT).show(); + break; + } if (profileName.getText().toString().contains("|")) { Toast.makeText( context,