diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationActivity.java | 11 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/StartUI.java | 12 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index 5126be565..0c2b620b4 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -151,6 +151,8 @@ public class ConversationActivity extends XmppActivity long FirstStartTime = -1; + String PREF_FIRST_START = "FirstStart"; + public Conversation getSelectedConversation() { return this.mSelectedConversation; } @@ -1349,8 +1351,8 @@ public class ConversationActivity extends XmppActivity Bundle extras = getIntent().getExtras(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (extras != null && extras.containsKey("FirstStart")) { - FirstStartTime = extras.getLong("FirstStart"); + if (extras != null && extras.containsKey(PREF_FIRST_START)) { + FirstStartTime = extras.getLong(PREF_FIRST_START); Log.d(Config.LOGTAG, "Get first start time from StartUI: " + FirstStartTime); } } else { @@ -1369,11 +1371,10 @@ public class ConversationActivity extends XmppActivity if (FirstStartTime == 0) { Log.d(Config.LOGTAG, "First start time: " + FirstStartTime + ", restarting App"); //write first start timestamp to file - String PREFS_NAME = "FirstStart"; FirstStartTime = System.currentTimeMillis(); - SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); + SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREF_FIRST_START, Context.MODE_PRIVATE); SharedPreferences.Editor editor = FirstStart.edit(); - editor.putLong("FirstStart", FirstStartTime); + editor.putLong(PREF_FIRST_START, FirstStartTime); editor.commit(); // restart Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName()); diff --git a/src/main/java/de/pixart/messenger/ui/StartUI.java b/src/main/java/de/pixart/messenger/ui/StartUI.java index 7cc71f919..102484756 100644 --- a/src/main/java/de/pixart/messenger/ui/StartUI.java +++ b/src/main/java/de/pixart/messenger/ui/StartUI.java @@ -27,11 +27,11 @@ public class StartUI extends AppCompatActivity implements EasyPermissions.PermissionCallbacks { private static final int NeededPermissions = 1000; - String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -42,21 +42,21 @@ public class StartUI extends AppCompatActivity @AfterPermissionGranted(NeededPermissions) private void requestNeededPermissions() { - String PREFS_NAME = "FirstStart"; - SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); - long FirstStartTime = FirstStart.getLong("FirstStart", 0); + String PREF_FIRST_START = "FirstStart"; + SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREF_FIRST_START, Context.MODE_PRIVATE); + long FirstStartTime = FirstStart.getLong(PREF_FIRST_START, 0); if (EasyPermissions.hasPermissions(this, perms)) { // Already have permission, start ConversationsActivity Log.d(Config.LOGTAG, "All permissions granted, starting " + getString(R.string.app_name) + "(" + FirstStartTime + ")"); Intent intent = new Intent(this, ConversationActivity.class); - intent.putExtra("FirstStart", FirstStartTime); + intent.putExtra(PREF_FIRST_START, FirstStartTime); startActivity(intent); finish(); } else { // set first start to 0 if there are permissions to request Log.d(Config.LOGTAG, "Requesting required permissions"); SharedPreferences.Editor editor = FirstStart.edit(); - editor.putLong("FirstStart", 0); + editor.putLong(PREF_FIRST_START, 0); editor.commit(); // Do not have permissions, request them now EasyPermissions.requestPermissions(this, getString(R.string.request_permissions_message), |