mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-04-03 05:01:07 +02:00
add a Bright display setting
This commit is contained in:
parent
8c6798fbff
commit
a62ebb98ca
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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>
|
||||
|
BIN
app/src/main/res/mipmap-hdpi/bright_display.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/bright_display.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/mipmap-mdpi/bright_display.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/bright_display.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 717 B |
BIN
app/src/main/res/mipmap-xhdpi/bright_display.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/bright_display.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/bright_display.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/bright_display.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/bright_display.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/bright_display.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user