Merge pull request #1516 from nextcloud/accountWarningBetaDialog

Warning for corrupt accounts for 2.0.0RC users
This commit is contained in:
Tobias Kaminsky 2017-09-11 08:38:20 +02:00 committed by GitHub
commit 961754e898
3 changed files with 51 additions and 7 deletions

View file

@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 1 error and 512 warnings</span>
<span class="mdl-layout-title">Lint Report: 1 error and 513 warnings</span>

View file

@ -124,6 +124,7 @@ import static com.owncloud.android.db.PreferenceManager.getSortOrder;
public class FileDisplayActivity extends HookActivity
implements FileFragment.ContainerActivity,
OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener {
private static final String KEY_SHOW_ACCOUNT_WARNING = "SHOW_ACCOUNT_WARNING";
private SyncBroadcastReceiver mSyncBroadcastReceiver;
private UploadFinishReceiver mUploadFinishReceiver;
@ -274,6 +275,7 @@ public class FileDisplayActivity extends HookActivity
// always AFTER setContentView(...) in onCreate(); to work around bug in its implementation
upgradeNotificationForInstantUpload();
upgradeNotificationForCorruptAccounts();
}
/**
@ -283,7 +285,7 @@ public class FileDisplayActivity extends HookActivity
private void upgradeNotificationForInstantUpload() {
// check for Android 6+ if legacy instant upload is activated --> disable + show info
if (PreferenceManager.instantPictureUploadEnabled(this) ||
PreferenceManager.instantPictureUploadEnabled(this)) {
PreferenceManager.instantPictureUploadEnabled(this)) {
// remove legacy shared preferences
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
@ -322,6 +324,45 @@ public class FileDisplayActivity extends HookActivity
}
}
/**
* TODO: remove after 2.0.0 final release
*/
private void upgradeNotificationForCorruptAccounts() {
boolean showWarning = PreferenceManager.getDefaultSharedPreferences(this)
.getBoolean(KEY_SHOW_ACCOUNT_WARNING, true);
int version = getVersion();
// check show warning, version > 1.4.3 and <= 2.0.0RCx
if (showWarning && version > 10040299 && version < 20000099) {
final Context context = this;
// show info pop-up
new AlertDialog.Builder(this, R.style.Theme_ownCloud_Dialog)
.setTitle(R.string.common_warning)
.setMessage(R.string.corrupt_account_info)
.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
PreferenceManager.getDefaultSharedPreferences(context)
.edit().putBoolean(KEY_SHOW_ACCOUNT_WARNING, false).apply();
}
})
.setIcon(R.drawable.ic_warning)
.setCancelable(false)
.show();
}
}
public int getVersion() {
int version = 0;
try {
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
return version;
}
return version;
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
@ -474,7 +515,7 @@ public class FileDisplayActivity extends HookActivity
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if(intent.getAction()!=null && intent.getAction().equalsIgnoreCase(ACTION_DETAILS)){
if (intent.getAction() != null && intent.getAction().equalsIgnoreCase(ACTION_DETAILS)) {
setIntent(intent);
setFile(intent.getParcelableExtra(EXTRA_FILE));
}
@ -1034,10 +1075,10 @@ public class FileDisplayActivity extends HookActivity
// all closed
//if PreviewImageActivity called this activity and mDualPane==false then calls PreviewImageActivity again
if((getIntent().getAction()!=null && getIntent().getAction().equalsIgnoreCase(ACTION_DETAILS)) && !mDualPane){
getIntent().setAction(null);
getIntent().putExtra(EXTRA_FILE, (OCFile) null);
startImagePreview(getFile());
if ((getIntent().getAction() != null && getIntent().getAction().equalsIgnoreCase(ACTION_DETAILS)) && !mDualPane) {
getIntent().setAction(null);
getIntent().putExtra(EXTRA_FILE, (OCFile) null);
startImagePreview(getFile());
}
OCFileListFragment listOfFiles = getListOfFilesFragment();

View file

@ -699,4 +699,7 @@
<string name="foreground_service_upload">Uploading files&#8230;</string>
<string name="foreground_service_download">Downloading files&#8230;</string>
<string name="common_warning" translatable="false">Warning</string>
<string name="corrupt_account_info" translatable="false">Accounts have been corrupted in case you have been using a release candidate of 2.0.0 between RC1 and RC5.\n\nWe are sorry to tell you that you need to remove the Nextcloud accounts from your device and need to re-login again completely in order to get fully working login-sessions on this device!</string>
</resources>