diff --git a/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java b/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java
index 483cb11f..d46ed172 100644
--- a/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java
+++ b/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java
@@ -90,14 +90,14 @@ public class MainActivity extends SyncthingActivity
public void onApiChange(SyncthingService.State currentState) {
switch (currentState) {
case INIT:
- mLoadingDialog.show();
+ showLoadingDialog();
// Make sure the first start dialog is shown on top.
if (isFirstStart()) {
showFirstStartDialog();
}
break;
case STARTING:
- mLoadingDialog.show();
+ showLoadingDialog();
dismissDisabledDialog();
int permissionState = ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE);
@@ -108,8 +108,8 @@ public class MainActivity extends SyncthingActivity
}
break;
case ACTIVE:
- mLoadingDialog.hide();
dismissDisabledDialog();
+ dismissLoadingDialog();
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mDrawerFragment.requestGuiUpdate();
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
@@ -121,7 +121,7 @@ public class MainActivity extends SyncthingActivity
finish();
break;
case DISABLED:
- mLoadingDialog.hide();
+ dismissLoadingDialog();
if (!isFinishing()) {
mDisabledDialog = SyncthingService.showDisabledDialog(MainActivity.this);
}
@@ -131,7 +131,7 @@ public class MainActivity extends SyncthingActivity
private void dismissDisabledDialog() {
if (mDisabledDialog != null) {
- mDisabledDialog.cancel();
+ mDisabledDialog.dismiss();
mDisabledDialog = null;
}
}
@@ -170,6 +170,34 @@ public class MainActivity extends SyncthingActivity
.show();
}
+ /**
+ * Shows the loading dialog with the correct text ("creating keys" or "loading").
+ */
+ private void showLoadingDialog() {
+ if (mLoadingDialog != null)
+ return;
+
+ LayoutInflater inflater = getLayoutInflater();
+ @SuppressLint("InflateParams")
+ View dialogLayout = inflater.inflate(R.layout.dialog_loading, null);
+ TextView loadingText = (TextView) dialogLayout.findViewById(R.id.loading_text);
+ loadingText.setText((isFirstStart())
+ ? R.string.web_gui_creating_key
+ : R.string.api_loading);
+
+ mLoadingDialog = new AlertDialog.Builder(MainActivity.this)
+ .setCancelable(false)
+ .setView(dialogLayout)
+ .show();
+ }
+
+ private void dismissLoadingDialog() {
+ if (mLoadingDialog != null) {
+ mLoadingDialog.dismiss();
+ mLoadingDialog = null;
+ }
+ }
+
private final FragmentPagerAdapter mSectionsPagerAdapter =
new FragmentPagerAdapter(getSupportFragmentManager()) {
@@ -242,28 +270,13 @@ public class MainActivity extends SyncthingActivity
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mDrawerLayout.setDrawerListener(mDrawerToggle);
setOptimalDrawerWidth(findViewById(R.id.drawer));
-
- LayoutInflater inflater = getLayoutInflater();
- @SuppressLint("InflateParams")
- View dialogLayout = inflater.inflate(R.layout.dialog_loading, null);
- TextView loadingText = (TextView) dialogLayout.findViewById(R.id.loading_text);
- loadingText.setText((isFirstStart())
- ? R.string.web_gui_creating_key
- : R.string.api_loading);
-
- mLoadingDialog = new AlertDialog.Builder(MainActivity.this)
- .setCancelable(false)
- .setView(dialogLayout)
- .create();
}
@Override
public void onDestroy() {
super.onDestroy();
- mLoadingDialog.dismiss();
- if (mDisabledDialog != null) {
- mDisabledDialog.dismiss();
- }
+ dismissDisabledDialog();
+ dismissLoadingDialog();
if (getService() != null) {
getService().unregisterOnApiChangeListener(this);
getService().unregisterOnApiChangeListener(mFolderListFragment);
diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java
index a7b0c368..b991002c 100644
--- a/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java
+++ b/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java
@@ -101,6 +101,8 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
.setOnClickListener(this);
view.findViewById(R.id.drawerActionDonate)
.setOnClickListener(this);
+ view.findViewById(R.id.drawerActionRestart)
+ .setOnClickListener(this);
view.findViewById(R.id.drawerActionSettings)
.setOnClickListener(this);
mExitButton.setOnClickListener(this);
@@ -190,26 +192,31 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
switch (v.getId()) {
case R.id.deviceIdContainer:
RestApi.shareDeviceId(getActivity(), mDeviceId.getText().toString());
- return;
+ break;
case R.id.drawerActionWebGui:
startActivity(new Intent(mActivity, WebGuiActivity.class));
mActivity.closeDrawer();
- return;
+ break;
case R.id.drawerActionDonate:
startActivity(new Intent(ACTION_VIEW, Uri.parse(
getString(R.string.donate_url))));
mActivity.closeDrawer();
- return;
+ break;
case R.id.drawerActionSettings:
startActivity(new Intent(mActivity, SettingsActivity.class)
.setAction(SettingsActivity.ACTION_APP_SETTINGS_FRAGMENT));
mActivity.closeDrawer();
- return;
+ break;
+ case R.id.drawerActionRestart:
+ getContext().startService(new Intent(getContext(), SyncthingService.class)
+ .setAction(SyncthingService.ACTION_RESTART));
+ mActivity.closeDrawer();
+ break;
case R.id.drawerActionExit:
mActivity.stopService(new Intent(mActivity, SyncthingService.class));
mActivity.finish();
mActivity.closeDrawer();
- return;
+ break;
}
}
}
diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java
index f431da82..49a2db44 100644
--- a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java
+++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java
@@ -443,7 +443,7 @@ public class SyncthingService extends Service implements
shutdown();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
sp.unregisterOnSharedPreferenceChangeListener(this);
- LocalBroadcastManager.getInstance(this).unregisterReceiver(this.mItemFinishedBroadcastReceiver);
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(mItemFinishedBroadcastReceiver);
}
private void shutdown() {
diff --git a/src/main/res/drawable-hdpi/ic_autorenew_black_24dp.png b/src/main/res/drawable-hdpi/ic_autorenew_black_24dp.png
new file mode 100644
index 00000000..9207cd98
Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_autorenew_black_24dp.png differ
diff --git a/src/main/res/drawable-mdpi/ic_autorenew_black_24dp.png b/src/main/res/drawable-mdpi/ic_autorenew_black_24dp.png
new file mode 100644
index 00000000..3211b64d
Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_autorenew_black_24dp.png differ
diff --git a/src/main/res/drawable-xhdpi/ic_autorenew_black_24dp.png b/src/main/res/drawable-xhdpi/ic_autorenew_black_24dp.png
new file mode 100644
index 00000000..c5475e94
Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_autorenew_black_24dp.png differ
diff --git a/src/main/res/drawable-xxhdpi/ic_autorenew_black_24dp.png b/src/main/res/drawable-xxhdpi/ic_autorenew_black_24dp.png
new file mode 100644
index 00000000..69644e28
Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_autorenew_black_24dp.png differ
diff --git a/src/main/res/drawable-xxxhdpi/ic_autorenew_black_24dp.png b/src/main/res/drawable-xxxhdpi/ic_autorenew_black_24dp.png
new file mode 100644
index 00000000..f5732bbd
Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_autorenew_black_24dp.png differ
diff --git a/src/main/res/drawable/ic_autorenew_black_24dp.xml b/src/main/res/drawable/ic_autorenew_black_24dp.xml
new file mode 100644
index 00000000..a2e5933b
--- /dev/null
+++ b/src/main/res/drawable/ic_autorenew_black_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/src/main/res/layout/fragment_drawer.xml b/src/main/res/layout/fragment_drawer.xml
index 88feb033..4b71e9a0 100644
--- a/src/main/res/layout/fragment_drawer.xml
+++ b/src/main/res/layout/fragment_drawer.xml
@@ -217,6 +217,15 @@
android:drawableStart="@drawable/ic_attach_money_black_24dp"
android:text="@string/donate" />
+
+
https://tip4commit.com/github/syncthing/syncthing-android
+ Restart
+