diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-06-12 21:13:09 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-12 21:13:09 +0200 |
commit | 232de4436c05f40f7f3a7c8afceaedb9cf2d7674 (patch) | |
tree | 6ed82a8ab08570f57c2256bfaab6be60315f34f3 /src | |
parent | ab2b46fd727c4a468359917eef461824827fe06a (diff) |
add permission exception for android < Marshmallow
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 17 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/startUI.java | 13 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 6c93a3acc..16d49ccf7 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -126,6 +126,8 @@ public class ConversationActivity extends XmppActivity private AtomicBoolean mRedirected = new AtomicBoolean(false); private Pair<Integer, Intent> mPostponedActivityResult; + long FirstStartTime = 0; + @SuppressLint("NewApi") private static List<Uri> extractUriFromIntent(final Intent intent) { List<Uri> uris = new ArrayList<>(); @@ -1313,11 +1315,16 @@ 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"); - } + Bundle extras = getIntent().getExtras(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (extras != null) { + FirstStartTime = extras.getLong("FirstStart"); + Log.d(Config.LOGTAG, "Get first start time from StartUI: " + FirstStartTime); + } + } else { + FirstStartTime = System.currentTimeMillis(); + Log.d(Config.LOGTAG, "Device is running Android < SDK 23, no restart required: " + FirstStartTime); + } if (mPendingConferenceInvite != null) { mPendingConferenceInvite.execute(this); diff --git a/src/main/java/eu/siacs/conversations/ui/startUI.java b/src/main/java/eu/siacs/conversations/ui/startUI.java index e69db94aa..5b919dbad 100644 --- a/src/main/java/eu/siacs/conversations/ui/startUI.java +++ b/src/main/java/eu/siacs/conversations/ui/startUI.java @@ -41,22 +41,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); if (EasyPermissions.hasPermissions(this, perms)) { // Already have permission, start ConversationsActivity - String PREFS_NAME = "FirstStart"; - SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); - long FirstStartTime = FirstStart.getLong("FirstStart", 0); + 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); startActivity(intent); finish(); } else { // set first start to 0 if there are permissions to request - String PREFS_NAME = "FirstStart"; - long FirstStartTime = 0; - SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); + Log.d(Config.LOGTAG, "Requesting required permissions"); SharedPreferences.Editor editor = FirstStart.edit(); - editor.putLong("FirstStart", FirstStartTime); + editor.putLong("FirstStart", 0); editor.commit(); // Do not have permissions, request them now EasyPermissions.requestPermissions(this, getString(R.string.request_permissions_message), |