add a Bright display setting

This commit is contained in:
tibbi 2016-08-01 22:33:02 +02:00
parent 8c6798fbff
commit a62ebb98ca
14 changed files with 52 additions and 2 deletions

View File

@ -29,4 +29,12 @@ public class Config {
public void setIsDarkTheme(boolean isDarkTheme) {
mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply();
}
public boolean getBrightDisplay() {
return mPrefs.getBoolean(Constants.BRIGHT_DISPLAY, false);
}
public void setBrightDisplay(boolean brightDisplay) {
mPrefs.edit().putBoolean(Constants.BRIGHT_DISPLAY, brightDisplay).apply();
}
}

View File

@ -5,4 +5,5 @@ public class Constants {
public static final String PREFS_KEY = "Flashlight";
public static final String IS_FIRST_RUN = "is_first_run";
public static final String IS_DARK_THEME = "is_dark_theme";
public static final String BRIGHT_DISPLAY = "bright_display";
}

View File

@ -13,6 +13,7 @@ import butterknife.OnClick;
public class SettingsActivity extends SimpleActivity {
@BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
@BindView(R.id.settings_bright_display) SwitchCompat mBrightDisplaySwitch;
private static Config mConfig;
@ -24,12 +25,17 @@ public class SettingsActivity extends SimpleActivity {
ButterKnife.bind(this);
setupDarkTheme();
setupBrightDisplay();
}
private void setupDarkTheme() {
mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme());
}
private void setupBrightDisplay() {
mBrightDisplaySwitch.setChecked(mConfig.getBrightDisplay());
}
@OnClick(R.id.settings_dark_theme_holder)
public void handleDarkTheme() {
mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked());
@ -37,6 +43,12 @@ public class SettingsActivity extends SimpleActivity {
restartActivity();
}
@OnClick(R.id.settings_bright_display_holder)
public void handleBrightDisplay() {
mBrightDisplaySwitch.setChecked(!mBrightDisplaySwitch.isChecked());
mConfig.setBrightDisplay(mBrightDisplaySwitch.isChecked());
}
private void restartActivity() {
TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities();
}

View File

@ -36,5 +36,31 @@
android:clickable="false"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_bright_display_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_padding"
android:background="?android:attr/selectableItemBackground"
android:padding="@dimen/activity_margin">
<TextView
android:id="@+id/settings_bright_display_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="@dimen/settings_padding"
android:text="@string/bright_display"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/settings_bright_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@null"
android:clickable="false"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -5,6 +5,7 @@
<!-- Settings -->
<string name="settings">Impostazioni</string>
<string name="dark_theme">Tema scuro</string>
<string name="bright_display">Show a bright display button</string>
<!-- About -->
<string name="about">Informazioni</string>

View File

@ -5,6 +5,7 @@
<!-- Settings -->
<string name="settings">設定</string>
<string name="dark_theme">ダークテーマ</string>
<string name="bright_display">Show a bright display button</string>
<!-- About -->
<string name="about">アプリについて</string>

View File

@ -5,6 +5,7 @@
<!-- Settings -->
<string name="settings">Inställningar</string>
<string name="dark_theme">Mörkt tema</string>
<string name="bright_display">Show a bright display button</string>
<!-- About -->
<string name="about">Om</string>

View File

@ -5,6 +5,7 @@
<!-- Settings -->
<string name="settings">Settings</string>
<string name="dark_theme">Dark theme</string>
<string name="bright_display">Show a bright display button</string>
<!-- About -->
<string name="about">About</string>

View File

@ -2,5 +2,4 @@
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget"
android:minHeight="40dp"
android:minWidth="40dp">
</appwidget-provider>
android:minWidth="40dp"/>