1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 06:11:19 +00:00

Fix syncthing version not showing in Drawer (fixes #165) (#166)

Fix Syncthing version not showing in Drawer or incorrectly shown after app first start or update.
Show syncthing native version regardless if syncthing is running or not.
This commit is contained in:
Catfriend1 2018-12-30 16:13:09 +01:00 committed by GitHub
parent 0fcd84da0e
commit 7fb47b3aba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,14 +63,13 @@ public class DrawerFragment extends Fragment implements SyncthingService.OnServi
@Override @Override
public void onServiceStateChange(SyncthingService.State currentState) { public void onServiceStateChange(SyncthingService.State currentState) {
mServiceState = currentState; mServiceState = currentState;
updateButtons(); updateUI();
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
updateLabels(); updateUI();
updateButtons();
} }
@Override @Override
@ -111,8 +110,8 @@ public class DrawerFragment extends Fragment implements SyncthingService.OnServi
mDrawerActionSettings.setOnClickListener(this); mDrawerActionSettings.setOnClickListener(this);
mDrawerActionExit.setOnClickListener(this); mDrawerActionExit.setOnClickListener(this);
updateLabels(); // Initially fill UI elements.
updateButtons(); updateUI();
} }
@Override @Override
@ -120,23 +119,16 @@ public class DrawerFragment extends Fragment implements SyncthingService.OnServi
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
} }
/** private void updateUI() {
* Update static info labels. Boolean synthingRunning = mServiceState == SyncthingService.State.ACTIVE;
*/
private void updateLabels() { // Update static info labels.
if (sharedPreferences != null && mVersion != null) { if (sharedPreferences != null && mVersion != null) {
mVersion.setText(sharedPreferences.getString(Constants.PREF_LAST_BINARY_VERSION, "")); mVersion.setText(sharedPreferences.getString(Constants.PREF_LAST_BINARY_VERSION, ""));
} }
}
/** // Update action button availability. Show buttons if syncthing is running.
* Update action button availability. mVersion.setVisibility(View.VISIBLE);
*/
private void updateButtons() {
Boolean synthingRunning = mServiceState == SyncthingService.State.ACTIVE;
// Show buttons if syncthing is running.
mVersion.setVisibility(synthingRunning ? View.VISIBLE : View.GONE);
mDrawerActionShowQrCode.setVisibility(synthingRunning ? View.VISIBLE : View.GONE); mDrawerActionShowQrCode.setVisibility(synthingRunning ? View.VISIBLE : View.GONE);
mDrawerRecentChanges.setVisibility(synthingRunning ? View.VISIBLE : View.GONE); mDrawerRecentChanges.setVisibility(synthingRunning ? View.VISIBLE : View.GONE);
mDrawerActionWebGui.setVisibility(synthingRunning ? View.VISIBLE : View.GONE); mDrawerActionWebGui.setVisibility(synthingRunning ? View.VISIBLE : View.GONE);