mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change locking method to better support locking from search results.
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
KeePassDroid (0.4.1)
|
||||
* Fix timeout locking crashes
|
||||
* Fix lock from search screen.
|
||||
|
||||
KeePassDroid (0.4)
|
||||
* Support adding groups
|
||||
|
||||
KeePassDroid (0.3.4)
|
||||
* Add context menus
|
||||
* Deal with crash when resuming activity after the process has been killed
|
||||
|
||||
@@ -195,13 +195,17 @@ public class EntryActivity extends LockingActivity {
|
||||
Toast.makeText(this, R.string.no_url_handler, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
|
||||
case MENU_COPY_USER:
|
||||
timeoutCopyToClipboard(mEntry.username);
|
||||
return true;
|
||||
|
||||
case MENU_COPY_PASS:
|
||||
timeoutCopyToClipboard(new String(mEntry.getPassword()));
|
||||
return true;
|
||||
|
||||
case MENU_LOCK:
|
||||
KeePass.db.shutdown = true;
|
||||
setResult(KeePass.EXIT_LOCK);
|
||||
finish();
|
||||
return true;
|
||||
|
||||
@@ -141,6 +141,7 @@ public abstract class GroupBaseActivity extends LockingListActivity {
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
case MENU_LOCK:
|
||||
KeePass.db.shutdown = true;
|
||||
setResult(KeePass.EXIT_LOCK);
|
||||
finish();
|
||||
return true;
|
||||
@@ -153,16 +154,4 @@ public abstract class GroupBaseActivity extends LockingListActivity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode == KeePass.EXIT_LOCK ) {
|
||||
setResult(KeePass.EXIT_LOCK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,40 +20,15 @@
|
||||
package com.android.keepass;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import com.android.keepass.intents.TimeoutIntents;
|
||||
|
||||
public class LockManager {
|
||||
private final BroadcastReceiver mIntentReceiver;
|
||||
private final Activity mAct;
|
||||
|
||||
public LockManager(Activity act) {
|
||||
mAct = act;
|
||||
|
||||
mIntentReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if ( action.equals(TimeoutIntents.LOCK) ) {
|
||||
KeePass.db.clear();
|
||||
mAct.setResult(KeePass.EXIT_LOCK);
|
||||
mAct.finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(TimeoutIntents.LOCK);
|
||||
act.registerReceiver(mIntentReceiver, filter);
|
||||
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
mAct.unregisterReceiver(mIntentReceiver);
|
||||
}
|
||||
|
||||
public void startTimeout() {
|
||||
|
||||
@@ -33,13 +33,6 @@ public class LockingActivity extends Activity {
|
||||
mLM = new LockManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mLM.cleanUp();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
@@ -52,6 +45,11 @@ public class LockingActivity extends Activity {
|
||||
super.onResume();
|
||||
|
||||
mLM.stopTimeout();
|
||||
|
||||
if ( KeePass.db.shutdown ) {
|
||||
setResult(KeePass.EXIT_LOCK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,13 +32,6 @@ public class LockingListActivity extends ListActivity {
|
||||
mLM = new LockManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mLM.cleanUp();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
@@ -49,7 +42,12 @@ public class LockingListActivity extends ListActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
|
||||
mLM.stopTimeout();
|
||||
|
||||
if ( KeePass.db.shutdown ) {
|
||||
setResult(KeePass.EXIT_LOCK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,4 @@
|
||||
public class TimeoutIntents {
|
||||
public static final String START = "com.android.keepass.timeout.start";
|
||||
public static final String CANCEL = "com.android.keepass.timeout.cancel";
|
||||
public static final String LOCK = "com.android.keepass.timeout.lock";
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.content.IntentFilter;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.android.keepass.KeePass;
|
||||
import com.android.keepass.intents.TimeoutIntents;
|
||||
|
||||
public class TimeoutService extends Service {
|
||||
@@ -90,7 +91,9 @@ public class TimeoutService extends Service {
|
||||
public void run() {
|
||||
timeout = true;
|
||||
|
||||
sendBroadcast(new Intent(TimeoutIntents.LOCK));
|
||||
if ( KeePass.db != null ) {
|
||||
KeePass.db.shutdown = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user