reworked permissions
This commit is contained in:
parent
764bc0b887
commit
50889004f3
2 changed files with 95 additions and 76 deletions
|
@ -49,9 +49,7 @@
|
|||
</receiver>
|
||||
|
||||
<activity
|
||||
android:name=".ui.StartUI"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
||||
android:name=".ui.ConversationActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="stateHidden">
|
||||
|
@ -62,9 +60,10 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.ConversationActivity"
|
||||
android:name=".ui.StartUI"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
||||
android:windowSoftInputMode="stateHidden">
|
||||
</activity>
|
||||
<activity
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.siacs.conversations.ui;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActionBar;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -129,6 +130,8 @@ public class ConversationActivity extends XmppActivity
|
|||
private AtomicBoolean mRedirected = new AtomicBoolean(false);
|
||||
private Pair<Integer, Intent> mPostponedActivityResult;
|
||||
|
||||
private boolean PermissionGranted = false;
|
||||
|
||||
FileUtils mFileUtils;
|
||||
|
||||
long FirstStartTime = -1;
|
||||
|
@ -1254,6 +1257,35 @@ public class ConversationActivity extends XmppActivity
|
|||
public void onStart() {
|
||||
super.onStart();
|
||||
this.mRedirected.set(false);
|
||||
|
||||
//Permission check
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (extras != null && extras.containsKey("FirstStart")) {
|
||||
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 (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);
|
||||
}
|
||||
// end
|
||||
if (this.xmppConnectionServiceBound) {
|
||||
this.onBackendConnected();
|
||||
}
|
||||
|
@ -1319,16 +1351,6 @@ public class ConversationActivity extends XmppActivity
|
|||
this.xmppConnectionService.getNotificationService().setIsInForeground(true);
|
||||
updateConversationList();
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (extras != null && extras.containsKey("FirstStart")) {
|
||||
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) {
|
||||
if (mPendingConferenceInvite.execute(this)) {
|
||||
|
@ -1338,71 +1360,69 @@ public class ConversationActivity extends XmppActivity
|
|||
mPendingConferenceInvite = null;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
final Intent intent = getIntent();
|
||||
if (xmppConnectionService.getAccounts().size() == 0) {
|
||||
if (mRedirected.compareAndSet(false, true)) {
|
||||
if (Config.X509_VERIFICATION) {
|
||||
startActivity(new Intent(this, ManageAccountActivity.class));
|
||||
} else if (Config.MAGIC_CREATE_DOMAIN != null) {
|
||||
Log.d(Config.LOGTAG, "First start time: " + FirstStartTime);
|
||||
startActivity(new Intent(this, WelcomeActivity.class));
|
||||
} else {
|
||||
startActivity(new Intent(this, EditAccountActivity.class));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
} else if (conversationList.size() <= 0) {
|
||||
if (mRedirected.compareAndSet(false, true)) {
|
||||
Account pendingAccount = xmppConnectionService.getPendingAccount();
|
||||
if (pendingAccount == null) {
|
||||
Intent startConversationActivity = new Intent(this, StartConversationActivity.class);
|
||||
intent.putExtra("init", true);
|
||||
startActivity(startConversationActivity);
|
||||
} else {
|
||||
switchToAccount(pendingAccount, true);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
} else if (selectConversationByUuid(mOpenConverstaion)) {
|
||||
if (mPanelOpen) {
|
||||
showConversationsOverview();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
||||
|| checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
Intent intent = new Intent (this, StartUI.class);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
if (isConversationsOverviewHideable()) {
|
||||
openConversation();
|
||||
updateActionBarTitle(true);
|
||||
}
|
||||
PermissionGranted = true;
|
||||
}
|
||||
this.mConversationFragment.reInit(getSelectedConversation());
|
||||
mOpenConverstaion = null;
|
||||
} else if (intent != null && ACTION_VIEW_CONVERSATION.equals(intent.getAction())) {
|
||||
clearPending();
|
||||
handleViewConversationIntent(intent);
|
||||
intent.setAction(Intent.ACTION_MAIN);
|
||||
} else if (getSelectedConversation() == null) {
|
||||
showConversationsOverview();
|
||||
clearPending();
|
||||
setSelectedConversation(conversationList.get(0));
|
||||
this.mConversationFragment.reInit(getSelectedConversation());
|
||||
} else {
|
||||
this.mConversationFragment.messageListAdapter.updatePreferences();
|
||||
this.mConversationFragment.messagesView.invalidateViews();
|
||||
this.mConversationFragment.setupIme();
|
||||
PermissionGranted = true;
|
||||
}
|
||||
|
||||
final Intent intent = getIntent();
|
||||
if (PermissionGranted) {
|
||||
if (xmppConnectionService.getAccounts().size() == 0) {
|
||||
if (mRedirected.compareAndSet(false, true)) {
|
||||
if (Config.X509_VERIFICATION) {
|
||||
startActivity(new Intent(this, ManageAccountActivity.class));
|
||||
} else if (Config.MAGIC_CREATE_DOMAIN != null) {
|
||||
Log.d(Config.LOGTAG, "First start time: " + FirstStartTime);
|
||||
startActivity(new Intent(this, WelcomeActivity.class));
|
||||
} else {
|
||||
startActivity(new Intent(this, EditAccountActivity.class));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
} else if (conversationList.size() <= 0) {
|
||||
if (mRedirected.compareAndSet(false, true)) {
|
||||
Account pendingAccount = xmppConnectionService.getPendingAccount();
|
||||
if (pendingAccount == null) {
|
||||
Intent startConversationActivity = new Intent(this, StartConversationActivity.class);
|
||||
intent.putExtra("init", true);
|
||||
startActivity(startConversationActivity);
|
||||
} else {
|
||||
switchToAccount(pendingAccount, true);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
} else if (selectConversationByUuid(mOpenConverstaion)) {
|
||||
if (mPanelOpen) {
|
||||
showConversationsOverview();
|
||||
} else {
|
||||
if (isConversationsOverviewHideable()) {
|
||||
openConversation();
|
||||
updateActionBarTitle(true);
|
||||
}
|
||||
}
|
||||
this.mConversationFragment.reInit(getSelectedConversation());
|
||||
mOpenConverstaion = null;
|
||||
} else if (intent != null && ACTION_VIEW_CONVERSATION.equals(intent.getAction())) {
|
||||
clearPending();
|
||||
handleViewConversationIntent(intent);
|
||||
intent.setAction(Intent.ACTION_MAIN);
|
||||
} else if (getSelectedConversation() == null) {
|
||||
showConversationsOverview();
|
||||
clearPending();
|
||||
setSelectedConversation(conversationList.get(0));
|
||||
this.mConversationFragment.reInit(getSelectedConversation());
|
||||
} else {
|
||||
this.mConversationFragment.messageListAdapter.updatePreferences();
|
||||
this.mConversationFragment.messagesView.invalidateViews();
|
||||
this.mConversationFragment.setupIme();
|
||||
}
|
||||
}
|
||||
|
||||
if (xmppConnectionService.getAccounts().size() != 0) {
|
||||
|
|
Reference in a new issue