aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-10-31 16:51:02 +0100
committerChristian Schneppe <christian@pix-art.de>2017-10-31 16:51:02 +0100
commit0eba73df9ce05f27385ce50f97bdeb2f30c6ed9d (patch)
treed47c4a9db37ed63573067321506c3d91c0f53411 /src
parenta96a8243f682c63f3e16863a4238498036fee56e (diff)
rename some variables/strings
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java11
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartUI.java12
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),