mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
Added restart icon to drawer (fixes #420).
This commit is contained in:
parent
4abf49af61
commit
af9c1421cd
11 changed files with 64 additions and 28 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
BIN
src/main/res/drawable-hdpi/ic_autorenew_black_24dp.png
Normal file
BIN
src/main/res/drawable-hdpi/ic_autorenew_black_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 514 B |
BIN
src/main/res/drawable-mdpi/ic_autorenew_black_24dp.png
Normal file
BIN
src/main/res/drawable-mdpi/ic_autorenew_black_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 375 B |
BIN
src/main/res/drawable-xhdpi/ic_autorenew_black_24dp.png
Normal file
BIN
src/main/res/drawable-xhdpi/ic_autorenew_black_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 675 B |
BIN
src/main/res/drawable-xxhdpi/ic_autorenew_black_24dp.png
Normal file
BIN
src/main/res/drawable-xxhdpi/ic_autorenew_black_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 929 B |
BIN
src/main/res/drawable-xxxhdpi/ic_autorenew_black_24dp.png
Normal file
BIN
src/main/res/drawable-xxxhdpi/ic_autorenew_black_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
5
src/main/res/drawable/ic_autorenew_black_24dp.xml
Normal file
5
src/main/res/drawable/ic_autorenew_black_24dp.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/ic_autorenew_black_24dp" android:state_enabled="false" />
|
||||
<item android:drawable="@drawable/ic_autorenew_black_24dp" />
|
||||
</selector>
|
|
@ -217,6 +217,15 @@
|
|||
android:drawableStart="@drawable/ic_attach_money_black_24dp"
|
||||
android:text="@string/donate" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/drawerActionRestart"
|
||||
style="@style/Widget.Syncthing.TextView.Label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:drawableLeft="@drawable/ic_autorenew_black_24dp"
|
||||
android:drawableStart="@drawable/ic_autorenew_black_24dp"
|
||||
android:text="@string/restart" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/drawerActionExit"
|
||||
style="@style/Widget.Syncthing.TextView.Label"
|
||||
|
|
|
@ -97,6 +97,8 @@
|
|||
|
||||
<string name="donate_url" translatable="false">https://tip4commit.com/github/syncthing/syncthing-android</string>
|
||||
|
||||
<string name="restart">Restart</string>
|
||||
|
||||
<!-- FolderSettingsFragment -->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue