mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Option to disable notifications #7
This commit is contained in:
@@ -69,6 +69,8 @@ import java.util.Timer;
|
|||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static com.keepassdroid.settings.PrefsUtil.isClipboardNotificationsEnable;
|
||||||
|
|
||||||
public class EntryActivity extends LockCloseHideActivity {
|
public class EntryActivity extends LockCloseHideActivity {
|
||||||
public static final String KEY_ENTRY = "entry";
|
public static final String KEY_ENTRY = "entry";
|
||||||
public static final String KEY_REFRESH_POS = "refresh_pos";
|
public static final String KEY_REFRESH_POS = "refresh_pos";
|
||||||
@@ -153,7 +155,6 @@ public class EntryActivity extends LockCloseHideActivity {
|
|||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
UUID uuid = Types.bytestoUUID(i.getByteArrayExtra(KEY_ENTRY));
|
UUID uuid = Types.bytestoUUID(i.getByteArrayExtra(KEY_ENTRY));
|
||||||
mPos = i.getIntExtra(KEY_REFRESH_POS, -1);
|
mPos = i.getIntExtra(KEY_REFRESH_POS, -1);
|
||||||
assert(uuid != null);
|
|
||||||
|
|
||||||
mEntry = db.pm.entries.get(uuid);
|
mEntry = db.pm.entries.get(uuid);
|
||||||
if (mEntry == null) {
|
if (mEntry == null) {
|
||||||
@@ -171,37 +172,41 @@ public class EntryActivity extends LockCloseHideActivity {
|
|||||||
fillData(false);
|
fillData(false);
|
||||||
|
|
||||||
setupEditButtons();
|
setupEditButtons();
|
||||||
|
|
||||||
// Notification Manager
|
// If notifications enabled in settings
|
||||||
mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
if (isClipboardNotificationsEnable(getApplicationContext())) {
|
||||||
|
// Notification Manager
|
||||||
if ( mEntry.getPassword().length() > 0 ) {
|
mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
// only show notification if password is available
|
|
||||||
Notification password = getNotification(Intents.COPY_PASSWORD, R.string.copy_password);
|
if (mEntry.getPassword().length() > 0) {
|
||||||
mNM.notify(NOTIFY_PASSWORD, password);
|
// only show notification if password is available
|
||||||
}
|
Notification password = getNotification(Intents.COPY_PASSWORD, R.string.copy_password);
|
||||||
|
mNM.notify(NOTIFY_PASSWORD, password);
|
||||||
if ( mEntry.getUsername().length() > 0 ) {
|
}
|
||||||
// only show notification if username is available
|
|
||||||
Notification username = getNotification(Intents.COPY_USERNAME, R.string.copy_username);
|
if (mEntry.getUsername().length() > 0) {
|
||||||
mNM.notify(NOTIFY_USERNAME, username);
|
// only show notification if username is available
|
||||||
}
|
Notification username = getNotification(Intents.COPY_USERNAME, R.string.copy_username);
|
||||||
|
mNM.notify(NOTIFY_USERNAME, username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mIntentReceiver = new BroadcastReceiver() {
|
mIntentReceiver = new BroadcastReceiver() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
if ( action != null) {
|
||||||
if ( action.equals(Intents.COPY_USERNAME) ) {
|
if (action.equals(Intents.COPY_USERNAME)) {
|
||||||
String username = mEntry.getUsername();
|
String username = mEntry.getUsername();
|
||||||
if ( username.length() > 0 ) {
|
if (username.length() > 0) {
|
||||||
timeoutCopyToClipboard(username);
|
timeoutCopyToClipboard(username);
|
||||||
}
|
}
|
||||||
} else if ( action.equals(Intents.COPY_PASSWORD) ) {
|
} else if (action.equals(Intents.COPY_PASSWORD)) {
|
||||||
String password = new String(mEntry.getPassword());
|
String password = mEntry.getPassword();
|
||||||
if ( password.length() > 0 ) {
|
if (password.length() > 0) {
|
||||||
timeoutCopyToClipboard(new String(mEntry.getPassword()));
|
timeoutCopyToClipboard(password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,4 +49,10 @@ public class PrefsUtil {
|
|||||||
ctx.getResources()
|
ctx.getResources()
|
||||||
.getStringArray(R.array.list_password_generator_options_default_values))));
|
.getStringArray(R.array.list_password_generator_options_default_values))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isClipboardNotificationsEnable(Context ctx) {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||||
|
return prefs.getBoolean(ctx.getString(R.string.clipboard_notifications_key),
|
||||||
|
ctx.getResources().getBoolean(R.bool.clipboard_notifications_default));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,8 @@
|
|||||||
<string name="password_size_summary">Définir la taille par défaut du mot de passe généré</string>
|
<string name="password_size_summary">Définir la taille par défaut du mot de passe généré</string>
|
||||||
<string name="list_password_generator_options_title">Caractères de mot de passe</string>
|
<string name="list_password_generator_options_title">Caractères de mot de passe</string>
|
||||||
<string name="list_password_generator_options_summary">Définir les caractères par défaut du générateur de mot de passe</string>
|
<string name="list_password_generator_options_summary">Définir les caractères par défaut du générateur de mot de passe</string>
|
||||||
|
<string name="clipboard_notifications_title">Notifications du presse-papiers</string>
|
||||||
|
<string name="clipboard_notifications_summary">Activer les notifications du presse-papiers pour copier le nom d\'utilisateur et le mot de passe</string>
|
||||||
|
|
||||||
<string-array name="clipboard_timeout_options">
|
<string-array name="clipboard_timeout_options">
|
||||||
<item>30 secondes</item>
|
<item>30 secondes</item>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
<string name="timeout_key" translatable="false">timeout_key</string>
|
<string name="timeout_key" translatable="false">timeout_key</string>
|
||||||
<string name="saf_key" translatable="false">storage_access_framework_key</string>
|
<string name="saf_key" translatable="false">storage_access_framework_key</string>
|
||||||
<string name="setting_style_key" translatable="false">setting_style_key</string>
|
<string name="setting_style_key" translatable="false">setting_style_key</string>
|
||||||
|
<string name="clipboard_notifications_key" translatable="false">clipboard_notifications_key</string>
|
||||||
|
|
||||||
<bool name="maskpass_default" translatable="false">true</bool>
|
<bool name="maskpass_default" translatable="false">true</bool>
|
||||||
<bool name="keyfile_default" translatable="false">true</bool>
|
<bool name="keyfile_default" translatable="false">true</bool>
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
<bool name="omitbackup_default" translatable="false">true</bool>
|
<bool name="omitbackup_default" translatable="false">true</bool>
|
||||||
<bool name="recentfile_default" translatable="false">true</bool>
|
<bool name="recentfile_default" translatable="false">true</bool>
|
||||||
<bool name="saf_default" translatable="false">false</bool>
|
<bool name="saf_default" translatable="false">false</bool>
|
||||||
|
<bool name="clipboard_notifications_default" translatable="false">true</bool>
|
||||||
|
|
||||||
<string name="clipboard_timeout_default" translatable="false">300000</string>
|
<string name="clipboard_timeout_default" translatable="false">300000</string>
|
||||||
<string-array name="clipboard_timeout_values">
|
<string-array name="clipboard_timeout_values">
|
||||||
|
|||||||
@@ -206,6 +206,8 @@
|
|||||||
<string name="password_size_summary">Set the default size of the generated password</string>
|
<string name="password_size_summary">Set the default size of the generated password</string>
|
||||||
<string name="list_password_generator_options_title">Password characters</string>
|
<string name="list_password_generator_options_title">Password characters</string>
|
||||||
<string name="list_password_generator_options_summary">Set the default password generator characters</string>
|
<string name="list_password_generator_options_summary">Set the default password generator characters</string>
|
||||||
|
<string name="clipboard_notifications_title">Clipboard Notifications</string>
|
||||||
|
<string name="clipboard_notifications_summary">Enable clipboard notifications to copy username and password</string>
|
||||||
|
|
||||||
<string-array name="clipboard_timeout_options">
|
<string-array name="clipboard_timeout_options">
|
||||||
<item>30 seconds</item>
|
<item>30 seconds</item>
|
||||||
|
|||||||
@@ -49,6 +49,11 @@
|
|||||||
android:defaultValue="@bool/saf_default"
|
android:defaultValue="@bool/saf_default"
|
||||||
android:title="@string/use_saf_title"
|
android:title="@string/use_saf_title"
|
||||||
android:key="@string/saf_key"/>
|
android:key="@string/saf_key"/>
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="@string/clipboard_notifications_key"
|
||||||
|
android:title="@string/clipboard_notifications_title"
|
||||||
|
android:defaultValue="@bool/clipboard_notifications_default"
|
||||||
|
android:summary="@string/clipboard_notifications_summary" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user