12
12
import de .slackspace .openkeepass .domain .KeePassFile ;
13
13
import de .slackspace .openkeepass .exception .KeePassDatabaseUnreadableException ;
14
14
15
+ import static org .sorz .lab .tinykeepass .keepass .KeePassHelper .getDatabaseFile ;
16
+ import static org .sorz .lab .tinykeepass .keepass .KeePassHelper .hasDatabaseConfigured ;
17
+
15
18
public class MainActivity extends BaseActivity {
16
19
private final static String TAG = MainActivity .class .getName ();
17
20
@@ -24,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
24
27
.add (R .id .fragment_container , new DatabaseLockedFragment ())
25
28
.commit ();
26
29
27
- if (!hasConfiguredDatabase ( )) {
30
+ if (!hasDatabaseConfigured ( this )) {
28
31
doConfigureDatabase ();
29
32
finish ();
30
33
} else {
@@ -45,17 +48,13 @@ public void onNewIntent(Intent intent) {
45
48
showEntryList ();
46
49
}
47
50
48
- public boolean hasConfiguredDatabase () {
49
- return KeePassStorage .get () != null || getDatabaseFile ().canRead ();
50
- }
51
-
52
51
public void doUnlockDatabase () {
53
52
if (KeePassStorage .get () != null ) {
54
53
showEntryList ();
55
54
} else {
56
55
getDatabaseKeys (keys -> {
57
56
try {
58
- KeePassFile db = KeePassDatabase .getInstance (getDatabaseFile ())
57
+ KeePassFile db = KeePassDatabase .getInstance (getDatabaseFile (this ))
59
58
.openDatabase (keys .get (0 ));
60
59
KeePassStorage .set (this , db );
61
60
} catch (KeePassDatabaseUnreadableException | UnsupportedOperationException e ) {
@@ -98,7 +97,7 @@ public void doSyncDatabase() {
98
97
99
98
public void doCleanDatabase () {
100
99
KeePassStorage .set (this , null );
101
- if (!getDatabaseFile ().delete ())
100
+ if (!getDatabaseFile (this ).delete ())
102
101
Log .w (TAG , "fail to delete database file" );
103
102
getSecureStringStorage ().clear ();
104
103
snackbar (getString (R .string .clean_config_ok ), Snackbar .LENGTH_SHORT ).show ();
0 commit comments