Added switches to preference screen to select which notifications to display,

fixed sorting of typable entries
This commit is contained in:
PhilippC 2013-04-06 15:09:54 +02:00
parent dd6b376abf
commit 59c13861ae
9 changed files with 544 additions and 473 deletions

View File

@ -1,8 +1,13 @@
package keepass2android.kbbridge; package keepass2android.kbbridge;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
public class KeyboardData { public class KeyboardData {
public static HashMap<String, String> availableFields = new HashMap<String, String>();
public static List<StringForTyping> availableFields = new ArrayList<StringForTyping>();
public static String entryName; public static String entryName;
public static void clear() public static void clear()

View File

@ -1,11 +1,15 @@
package keepass2android.kbbridge; package keepass2android.kbbridge;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
public class KeyboardDataBuilder { public class KeyboardDataBuilder {
private HashMap<String, String> availableFields = new HashMap<String, String>(); private ArrayList<StringForTyping> availableFields = new ArrayList<StringForTyping>();
public void addPair(String displayName, String valueToType) public void addPair(String displayName, String valueToType)
{ {
availableFields.put(displayName, valueToType); StringForTyping pair = new StringForTyping();
pair.displayName = displayName;
pair.value = valueToType;
availableFields.add(pair);
} }
public void commit() public void commit()

View File

@ -40,6 +40,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import keepass2android.kbbridge.StringForTyping;
import keepass2android.softkeyboard.R; import keepass2android.softkeyboard.R;
/** /**
@ -449,14 +450,14 @@ public class KP2AKeyboard extends InputMethodService implements
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
String title = "Keepass2Android"; String title = "Keepass2Android";
HashMap<String, String> availableFields = keepass2android.kbbridge.KeyboardData.availableFields; List<StringForTyping> availableFields = keepass2android.kbbridge.KeyboardData.availableFields;
final ArrayList<String> items = new ArrayList<String>(); final ArrayList<String> items = new ArrayList<String>();
final ArrayList<String> values = new ArrayList<String>(); final ArrayList<String> values = new ArrayList<String>();
for (HashMap.Entry<String, String> entry : availableFields.entrySet()) for (StringForTyping entry : availableFields)
{ {
String key = entry.getKey(); String key = entry.displayName;
String value = entry.getValue(); String value = entry.value;
items.add(key); items.add(key);
values.add(value); values.add(value);
} }

File diff suppressed because it is too large Load Diff

View File

@ -62,6 +62,12 @@
<string name="SuggestionsURL">https://keepass2android.codeplex.com/workitem/list/basic</string> <string name="SuggestionsURL">https://keepass2android.codeplex.com/workitem/list/basic</string>
<string name="TranslationURL">http://crowdin.net/project/keepass2android</string> <string name="TranslationURL">http://crowdin.net/project/keepass2android</string>
<string name="CopyToClipboardNotification_key">ShowCopyToClipboardNotification</string>
<bool name="CopyToClipboardNotification_default">true</bool>
<string name="UseKp2aKeyboard_key">ShowKp2aKeyboardNotification</string>
<bool name="UseKp2aKeyboard_default">true</bool>
<string name="clipboard_timeout_default">300000</string> <string name="clipboard_timeout_default">300000</string>
<string-array name="clipboard_timeout_values"> <string-array name="clipboard_timeout_values">
<item>30000</item> <item>30000</item>

View File

@ -206,6 +206,11 @@
<string name="credentials_dialog_title">Enter server credentials</string> <string name="credentials_dialog_title">Enter server credentials</string>
<string name="UseFileTransactions_title">File transactions</string> <string name="UseFileTransactions_title">File transactions</string>
<string name="UseFileTransactions_summary">Use file transactions for writing databases</string> <string name="UseFileTransactions_summary">Use file transactions for writing databases</string>
<string name="ShowCopyToClipboardNotification_title">Clipboard notifications</string>
<string name="ShowCopyToClipboardNotification_summary">Make username and password accessible through the notification bar and clipboard. Beware of password sniffers!</string>
<string name="ShowKp2aKeyboardNotification_title">KP2A keyboard notification</string>
<string name="ShowKp2aKeyboardNotification_summary">Make full entry accessible through the KP2A keyboard (recommended).</string>
<string name="AskOverwriteBinary">Do you want to overwrite the existing binary with the same name?</string> <string name="AskOverwriteBinary">Do you want to overwrite the existing binary with the same name?</string>
<string name="AskOverwriteBinary_title">Overwrite existing binary?</string> <string name="AskOverwriteBinary_title">Overwrite existing binary?</string>
<string name="AskOverwriteBinary_yes">Overwrite</string> <string name="AskOverwriteBinary_yes">Overwrite</string>

View File

@ -85,13 +85,22 @@
android:entryValues="@array/list_size_values" android:entryValues="@array/list_size_values"
android:dialogTitle="@string/list_size_summary" android:dialogTitle="@string/list_size_summary"
android:defaultValue="@string/list_size_default"/> android:defaultValue="@string/list_size_default"/>
<CheckBoxPreference
<CheckBoxPreference
android:enabled="true" android:enabled="true"
android:persistent="true" android:persistent="true"
android:summary="@string/UseFileTransactions_summary" android:summary="@string/ShowCopyToClipboardNotification_summary"
android:defaultValue="true" android:defaultValue="@bool/CopyToClipboardNotification_default"
android:title="@string/UseFileTransactions_title" android:title="@string/ShowCopyToClipboardNotification_title"
android:key="@string/UseFileTransactions_key" /> android:key="@string/CopyToClipboardNotification_key" />
<CheckBoxPreference
android:enabled="true"
android:persistent="true"
android:summary="@string/ShowKp2aKeyboardNotification_summary"
android:defaultValue="@bool/UseKp2aKeyboard_default"
android:title="@string/ShowKp2aKeyboardNotification_title"
android:key="@string/UseKp2aKeyboard_key" />
<CheckBoxPreference <CheckBoxPreference
android:enabled="true" android:enabled="true"
@ -115,6 +124,13 @@
android:defaultValue="@string/BinaryDirectory_default" android:defaultValue="@string/BinaryDirectory_default"
android:title="@string/BinaryDirectory_title" android:title="@string/BinaryDirectory_title"
android:key="@string/BinaryDirectory_key" /> android:key="@string/BinaryDirectory_key" />
<CheckBoxPreference
android:enabled="true"
android:persistent="true"
android:summary="@string/UseFileTransactions_summary"
android:defaultValue="true"
android:title="@string/UseFileTransactions_title"
android:key="@string/UseFileTransactions_key" />
</PreferenceScreen> </PreferenceScreen>
</PreferenceScreen> </PreferenceScreen>

View File

@ -154,34 +154,44 @@ namespace keepass2android
String entryName = entry.Strings.ReadSafe(PwDefs.TitleField); String entryName = entry.Strings.ReadSafe(PwDefs.TitleField);
if (entry.Strings.ReadSafe(PwDefs.PasswordField).Length > 0) ISharedPreferences prefs = Android.Preferences.PreferenceManager.GetDefaultSharedPreferences(this);
if (prefs.GetBoolean(GetString(Resource.String.CopyToClipboardNotification_key), Resources.GetBoolean(Resource.Boolean.CopyToClipboardNotification_default)))
{ {
// only show notification if password is available
Notification password = GetNotification(Intents.COPY_PASSWORD, Resource.String.copy_password, Resource.Drawable.notify, entryName);
password.DeleteIntent = createDeleteIntent(NOTIFY_PASSWORD); if (entry.Strings.ReadSafe(PwDefs.PasswordField).Length > 0)
mNM.Notify(NOTIFY_PASSWORD, password); {
mNumElementsToWaitFor++; // only show notification if password is available
Notification password = GetNotification(Intents.COPY_PASSWORD, Resource.String.copy_password, Resource.Drawable.notify, entryName);
} password.DeleteIntent = createDeleteIntent(NOTIFY_PASSWORD);
mNM.Notify(NOTIFY_PASSWORD, password);
if (entry.Strings.ReadSafe(PwDefs.UserNameField).Length > 0) mNumElementsToWaitFor++;
{
// only show notification if username is available }
Notification username = GetNotification(Intents.COPY_USERNAME, Resource.String.copy_username, Resource.Drawable.notify, entryName);
username.DeleteIntent = createDeleteIntent(NOTIFY_USERNAME); if (entry.Strings.ReadSafe(PwDefs.UserNameField).Length > 0)
mNumElementsToWaitFor++; {
mNM.Notify(NOTIFY_USERNAME, username); // only show notification if username is available
Notification username = GetNotification(Intents.COPY_USERNAME, Resource.String.copy_username, Resource.Drawable.notify, entryName);
username.DeleteIntent = createDeleteIntent(NOTIFY_USERNAME);
mNumElementsToWaitFor++;
mNM.Notify(NOTIFY_USERNAME, username);
}
} }
//keyboard if (prefs.GetBoolean(GetString(Resource.String.UseKp2aKeyboard_key), Resources.GetBoolean(Resource.Boolean.UseKp2aKeyboard_default)))
if (makeAccessibleForKeyboard(entry))
{ {
// only show notification if username is available
Notification keyboard = GetNotification(Intents.CHECK_KEYBOARD, Resource.String.available_through_keyboard, Resource.Drawable.notify_keyboard, entryName); //keyboard
keyboard.DeleteIntent = createDeleteIntent(NOTIFY_KEYBOARD); if (makeAccessibleForKeyboard(entry))
mNumElementsToWaitFor++; {
mNM.Notify(NOTIFY_KEYBOARD, keyboard); // only show notification if username is available
Notification keyboard = GetNotification(Intents.CHECK_KEYBOARD, Resource.String.available_through_keyboard, Resource.Drawable.notify_keyboard, entryName);
keyboard.DeleteIntent = createDeleteIntent(NOTIFY_KEYBOARD);
mNumElementsToWaitFor++;
mNM.Notify(NOTIFY_KEYBOARD, keyboard);
}
} }
if (mNumElementsToWaitFor == 0) if (mNumElementsToWaitFor == 0)
@ -189,7 +199,7 @@ namespace keepass2android
StopSelf(); StopSelf();
return; return;
} }
mCopyToClipBroadcastReceiver = new CopyToClipboardBroadcastReceiver(entry, this); mCopyToClipBroadcastReceiver = new CopyToClipboardBroadcastReceiver(entry, this);
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();