mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-07 10:42:07 +00:00
* SyncthingActivity: Reformat code * Add status light to toolbar * MainActivity: Add status light indicating if syncthing is running (fixes #187) * New colors for status light * Tri-state status light
This commit is contained in:
parent
8a2fe3ceec
commit
461d65d9b3
3 changed files with 46 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.AppCompatRadioButton
|
||||
android:id="@+id/btnActive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:visibility="gone"
|
||||
app:buttonTint="#76ff03"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatRadioButton
|
||||
android:id="@+id/btnStarting"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:visibility="gone"
|
||||
app:buttonTint="#fff103"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatRadioButton
|
||||
android:id="@+id/btnDisabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:visibility="gone"
|
||||
app:buttonTint="#ffae03"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
Loading…
Reference in a new issue