Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
LaunchActivity: Change alarm icon by state
Browse files Browse the repository at this point in the history
Signed-off-by: Fung <[email protected]>
  • Loading branch information
fython committed Jun 14, 2017
1 parent e324c0b commit 7037b0f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
26 changes: 23 additions & 3 deletions app/src/main/java/info/papdt/blackblub/ui/LaunchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class LaunchActivity extends Activity implements PopupMenu.OnMenuItemClic
private DiscreteSeekBar mSeekbar;
private static MaterialAnimatedSwitch mSwitch;
private TextView mModeText;
private ImageButton mSchedulerBtn;

private PopupMenu popupMenu;
private AlertDialog mAlertDialog, mModeDialog;
Expand Down Expand Up @@ -240,7 +241,13 @@ public void onClick(View view) {
});
menuBtn.setOnTouchListener(popupMenu.getDragToOpenListener());

findViewById(R.id.btn_scheduler).setOnClickListener(new View.OnClickListener() {
mSchedulerBtn = findViewById(R.id.btn_scheduler);
if (mNightScreenSettings.getBoolean(NightScreenSettings.KEY_AUTO_MODE, false)) {
mSchedulerBtn.setImageResource(R.drawable.ic_alarm_black_24dp);
} else {
mSchedulerBtn.setImageResource(R.drawable.ic_alarm_off_black_24dp);
}
mSchedulerBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Expand All @@ -252,7 +259,7 @@ public void onClick(View view) {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
new SchedulerDialog(LaunchActivity.this).show();
showSchedulerDialog();
}
})
.setNeutralButton(R.string.dialog_button_go_to_set, new DialogInterface.OnClickListener() {
Expand All @@ -270,8 +277,8 @@ public void onClick(DialogInterface dialogInterface, int i) {
.show();
return;
}
showSchedulerDialog();
}
new SchedulerDialog(LaunchActivity.this).show();
}
});

Expand All @@ -284,6 +291,19 @@ public void onClick(View view) {
});
}

private void showSchedulerDialog() {
new SchedulerDialog(this, new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
if (mNightScreenSettings.getBoolean(NightScreenSettings.KEY_AUTO_MODE, false)) {
mSchedulerBtn.setImageResource(R.drawable.ic_alarm_black_24dp);
} else {
mSchedulerBtn.setImageResource(R.drawable.ic_alarm_off_black_24dp);
}
}
}).show();
}

@Override
public void onPause() {
super.onPause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public SchedulerDialog(Context context) {
init();
}

public SchedulerDialog(Context context, OnDismissListener onDismissListener) {
super(context);
if (context instanceof Activity) setOwnerActivity((Activity) context);
if (onDismissListener != null) setOnDismissListener(onDismissListener);
init();
}

public SchedulerDialog(Context context, int themeResId) {
super(context, themeResId);
if (context instanceof Activity) setOwnerActivity((Activity) context);
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_alarm_off_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,6c3.87,0 7,3.13 7,7 0,0.84 -0.16,1.65 -0.43,2.4l1.52,1.52c0.58,-1.19 0.91,-2.51 0.91,-3.92 0,-4.97 -4.03,-9 -9,-9 -1.41,0 -2.73,0.33 -3.92,0.91L9.6,6.43C10.35,6.16 11.16,6 12,6zM22,5.72l-4.6,-3.86 -1.29,1.53 4.6,3.86L22,5.72zM2.92,2.29L1.65,3.57 2.98,4.9l-1.11,0.93 1.42,1.42 1.11,-0.94 0.8,0.8C3.83,8.69 3,10.75 3,13c0,4.97 4.02,9 9,9 2.25,0 4.31,-0.83 5.89,-2.2l2.2,2.2 1.27,-1.27L3.89,3.27l-0.97,-0.98zM16.47,18.39C15.26,19.39 13.7,20 12,20c-3.87,0 -7,-3.13 -7,-7 0,-1.7 0.61,-3.26 1.61,-4.47l9.86,9.86zM8.02,3.28L6.6,1.86l-0.86,0.71 1.42,1.42 0.86,-0.71z"/>
</vector>

0 comments on commit 7037b0f

Please sign in to comment.