diff options
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 26 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/startUI.java | 20 |
2 files changed, 33 insertions, 13 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 3398c74d4..4db939048 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -1313,6 +1313,12 @@ public class ConversationActivity extends XmppActivity this.xmppConnectionService.getNotificationService().setIsInForeground(true); updateConversationList(); + long FirstStartTime = 0; + Bundle extras = getIntent().getExtras(); + if(extras != null) { + FirstStartTime = extras.getLong("FirstStart"); + } + if (mPendingConferenceInvite != null) { mPendingConferenceInvite.execute(this); mToast = Toast.makeText(this, R.string.creating_conference,Toast.LENGTH_LONG); @@ -1325,7 +1331,25 @@ public class ConversationActivity extends XmppActivity if (Config.X509_VERIFICATION) { startActivity(new Intent(this, ManageAccountActivity.class)); } else if (Config.MAGIC_CREATE_DOMAIN != null) { - startActivity(new Intent(this, WelcomeActivity.class)); + 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.Editor editor = FirstStart.edit(); + editor.putLong("FirstStart", FirstStartTime); + editor.commit(); + // restart + Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName()); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + System.exit(0); + } else { + Log.d(Config.LOGTAG, "First start time: " + FirstStartTime); + startActivity(new Intent(this, WelcomeActivity.class)); + } } else { startActivity(new Intent(this, EditAccountActivity.class)); } diff --git a/src/main/java/eu/siacs/conversations/ui/startUI.java b/src/main/java/eu/siacs/conversations/ui/startUI.java index 030a707e9..77ef20c72 100644 --- a/src/main/java/eu/siacs/conversations/ui/startUI.java +++ b/src/main/java/eu/siacs/conversations/ui/startUI.java @@ -1,8 +1,10 @@ package eu.siacs.conversations.ui; import android.Manifest; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.provider.Settings; @@ -34,7 +36,6 @@ public class startUI extends AppCompatActivity Manifest.permission.ACCESS_FINE_LOCATION, }; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -46,7 +47,12 @@ public class startUI extends AppCompatActivity private void requestNeededPermissions() { if (EasyPermissions.hasPermissions(this, perms)) { // Already have permission, start ConversationsActivity - startActivity(new Intent(this, ConversationActivity.class)); + String PREFS_NAME = "FirstStart"; + SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); + long FirstStartTime = FirstStart.getLong("FirstStart", 0); + Intent intent = new Intent (this, ConversationActivity.class); + intent.putExtra("FirstStart", FirstStartTime); + startActivity(intent); finish(); } else { // Do not have permissions, request them now @@ -92,16 +98,6 @@ public class startUI extends AppCompatActivity dialog.show(); } - private void restart() { - //restart app - Log.d(Config.LOGTAG, "Restarting " + getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName())); - Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName()); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - System.exit(0); - } - @Override protected void onDestroy() { super.onDestroy(); |