1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-29 15:51:17 +00:00

Dismiss "disabled" dialog when syncthing is available again (ref #127).

This commit is contained in:
Felix Ableitner 2014-09-24 19:28:23 +03:00
parent 9ea8af4774
commit 879616a715
2 changed files with 11 additions and 5 deletions

View file

@ -42,6 +42,8 @@ public class MainActivity extends SyncthingActivity
private AlertDialog mLoadingDialog; private AlertDialog mLoadingDialog;
private AlertDialog mDisabledDialog;
/** /**
* Causes population of repo and node lists, unlocks info drawer. * Causes population of repo and node lists, unlocks info drawer.
*/ */
@ -53,7 +55,7 @@ public class MainActivity extends SyncthingActivity
if (mLoadingDialog != null) { if (mLoadingDialog != null) {
mLoadingDialog.dismiss(); mLoadingDialog.dismiss();
} }
SyncthingService.showDisabledDialog(this); mDisabledDialog = SyncthingService.showDisabledDialog(this);
} else if (mLoadingDialog == null) { } else if (mLoadingDialog == null) {
final SharedPreferences prefs = final SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(MainActivity.this); PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
@ -90,6 +92,9 @@ public class MainActivity extends SyncthingActivity
if (mLoadingDialog != null) { if (mLoadingDialog != null) {
mLoadingDialog.dismiss(); mLoadingDialog.dismiss();
} }
if (mDisabledDialog != null) {
mDisabledDialog.dismiss();
}
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerListener(mDrawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View file

@ -357,8 +357,8 @@ public class SyncthingService extends Service {
* Dialog to be shown when attempting to start syncthing while it is disabled according * Dialog to be shown when attempting to start syncthing while it is disabled according
* to settings (because the device is not charging or wifi is disconnected). * to settings (because the device is not charging or wifi is disconnected).
*/ */
public static void showDisabledDialog(final Activity activity) { public static AlertDialog showDisabledDialog(final Activity activity) {
new AlertDialog.Builder(activity) AlertDialog dialog = new AlertDialog.Builder(activity)
.setTitle(R.string.syncthing_disabled_title) .setTitle(R.string.syncthing_disabled_title)
.setMessage(R.string.syncthing_disabled_message) .setMessage(R.string.syncthing_disabled_message)
.setPositiveButton(R.string.syncthing_disabled_change_settings, .setPositiveButton(R.string.syncthing_disabled_change_settings,
@ -380,8 +380,9 @@ public class SyncthingService extends Service {
} }
} }
) )
.show() .show();
.setCancelable(false); dialog.setCancelable(false);
return dialog;
} }
public String getWebGuiUrl() { public String getWebGuiUrl() {