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;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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 void clear()

View File

@ -1,11 +1,15 @@
package keepass2android.kbbridge;
import java.util.ArrayList;
import java.util.HashMap;
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)
{
availableFields.put(displayName, valueToType);
StringForTyping pair = new StringForTyping();
pair.displayName = displayName;
pair.value = valueToType;
availableFields.add(pair);
}
public void commit()

View File

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

View File

@ -206,6 +206,11 @@
<string name="credentials_dialog_title">Enter server credentials</string>
<string name="UseFileTransactions_title">File transactions</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_title">Overwrite existing binary?</string>
<string name="AskOverwriteBinary_yes">Overwrite</string>

View File

@ -85,13 +85,22 @@
android:entryValues="@array/list_size_values"
android:dialogTitle="@string/list_size_summary"
android:defaultValue="@string/list_size_default"/>
<CheckBoxPreference
<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" />
android:summary="@string/ShowCopyToClipboardNotification_summary"
android:defaultValue="@bool/CopyToClipboardNotification_default"
android:title="@string/ShowCopyToClipboardNotification_title"
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
android:enabled="true"
@ -115,6 +124,13 @@
android:defaultValue="@string/BinaryDirectory_default"
android:title="@string/BinaryDirectory_title"
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>

View File

@ -154,34 +154,44 @@ namespace keepass2android
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);
mNM.Notify(NOTIFY_PASSWORD, password);
mNumElementsToWaitFor++;
if (entry.Strings.ReadSafe(PwDefs.PasswordField).Length > 0)
{
// only show notification if password is available
Notification password = GetNotification(Intents.COPY_PASSWORD, Resource.String.copy_password, Resource.Drawable.notify, entryName);
}
if (entry.Strings.ReadSafe(PwDefs.UserNameField).Length > 0)
{
// 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);
password.DeleteIntent = createDeleteIntent(NOTIFY_PASSWORD);
mNM.Notify(NOTIFY_PASSWORD, password);
mNumElementsToWaitFor++;
}
if (entry.Strings.ReadSafe(PwDefs.UserNameField).Length > 0)
{
// 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 (makeAccessibleForKeyboard(entry))
if (prefs.GetBoolean(GetString(Resource.String.UseKp2aKeyboard_key), Resources.GetBoolean(Resource.Boolean.UseKp2aKeyboard_default)))
{
// 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);
//keyboard
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.DeleteIntent = createDeleteIntent(NOTIFY_KEYBOARD);
mNumElementsToWaitFor++;
mNM.Notify(NOTIFY_KEYBOARD, keyboard);
}
}
if (mNumElementsToWaitFor == 0)
@ -189,7 +199,7 @@ namespace keepass2android
StopSelf();
return;
}
mCopyToClipBroadcastReceiver = new CopyToClipboardBroadcastReceiver(entry, this);
IntentFilter filter = new IntentFilter();