diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java index 8b255188..413fae9f 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java @@ -36,6 +36,7 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -114,9 +115,17 @@ public class MainActivity extends SyncthingActivity oneTimeShot = false; } + // Update status light indicating if syncthing is running. + Button btnDisabled = (Button) findViewById(R.id.btnDisabled); + Button btnStarting = (Button) findViewById(R.id.btnStarting); + Button btnActive = (Button) findViewById(R.id.btnActive); + if (btnDisabled != null && btnStarting != null && btnActive != null) { + btnActive.setVisibility(currentState == SyncthingService.State.ACTIVE ? View.VISIBLE : View.GONE); + btnStarting.setVisibility(currentState == SyncthingService.State.STARTING ? View.VISIBLE : View.GONE); + btnDisabled.setVisibility(currentState != SyncthingService.State.ACTIVE && currentState != SyncthingService.State.STARTING ? View.VISIBLE : View.GONE); + } + switch (currentState) { - case STARTING: - break; case ACTIVE: // Check if the usage reporting minimum delay passed by. Boolean usageReportingDelayPassed = (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY); @@ -128,8 +137,6 @@ public class MainActivity extends SyncthingActivity case ERROR: finish(); break; - case DISABLED: - break; } } diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java index 63ccf611..0f920faa 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java @@ -39,8 +39,9 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser super.onPostCreate(savedInstanceState); Toolbar toolbar = findViewById(R.id.toolbar); - if (toolbar == null) + if (toolbar == null) { return; + } setSupportActionBar(toolbar); //noinspection ConstantConditions diff --git a/app/src/main/res/layout/widget_toolbar.xml b/app/src/main/res/layout/widget_toolbar.xml index 5780914c..451b7df4 100644 --- a/app/src/main/res/layout/widget_toolbar.xml +++ b/app/src/main/res/layout/widget_toolbar.xml @@ -10,4 +10,36 @@ android:elevation="@dimen/toolbar_elevation" app:titleMarginStart="16dp" android:theme="@style/ThemeOverlay.Syncthing.Toolbar" - android:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> + android:popupTheme="@style/ThemeOverlay.AppCompat.Light" > + + + + + + + + + + + + \ No newline at end of file