Black theme - Apply to settings
This commit is contained in:
parent
4b09e5d106
commit
ca384748ea
|
@ -70,7 +70,7 @@ public class SettingsFragment extends Fragment {
|
||||||
private Context context;
|
private Context context;
|
||||||
private static final int ACTIVITY_CHOOSE_FILE = 411;
|
private static final int ACTIVITY_CHOOSE_FILE = 411;
|
||||||
private TextView set_folder;
|
private TextView set_folder;
|
||||||
int count1, count2 = 0;
|
int count1, count2, count3 = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -428,25 +428,56 @@ public class SettingsFragment extends Fragment {
|
||||||
file_chooser.setVisibility(View.GONE);
|
file_chooser.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final SwitchCompat set_night_mode = rootView.findViewById(R.id.set_night_mode);
|
final Spinner set_night_mode = rootView.findViewById(R.id.set_night_mode);
|
||||||
set_night_mode.setChecked(theme == Helper.THEME_DARK);
|
ArrayAdapter<CharSequence> adapterTheme = ArrayAdapter.createFromResource(getContext(),
|
||||||
set_night_mode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
R.array.settings_theme, android.R.layout.simple_spinner_item);
|
||||||
|
set_night_mode.setAdapter(adapterTheme);
|
||||||
|
|
||||||
|
int positionSpinnerTheme;
|
||||||
|
switch (sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK)){
|
||||||
|
case Helper.THEME_DARK:
|
||||||
|
positionSpinnerTheme = 0;
|
||||||
|
break;
|
||||||
|
case Helper.THEME_LIGHT:
|
||||||
|
positionSpinnerTheme = 1;
|
||||||
|
break;
|
||||||
|
case Helper.THEME_BLACK:
|
||||||
|
positionSpinnerTheme = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
positionSpinnerTheme = 0;
|
||||||
|
}
|
||||||
|
set_night_mode.setSelection(positionSpinnerTheme);
|
||||||
|
set_night_mode.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
if( count3 > 0){
|
||||||
editor.putInt(Helper.SET_THEME, isChecked?Helper.THEME_DARK:Helper.THEME_LIGHT);
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.apply();
|
switch (position){
|
||||||
if( isChecked){
|
case 0:
|
||||||
|
editor.putInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
editor.putInt(Helper.SET_THEME, Helper.THEME_LIGHT);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
editor.putInt(Helper.SET_THEME, Helper.THEME_BLACK);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
}
|
||||||
if( getActivity() != null)
|
if( getActivity() != null)
|
||||||
getActivity().setTheme(R.style.AppThemeDark);
|
getActivity().recreate();
|
||||||
|
Intent intent = new Intent(context, MainActivity.class);
|
||||||
|
intent.putExtra(INTENT_ACTION, CHANGE_THEME_INTENT);
|
||||||
|
startActivity(intent);
|
||||||
}else {
|
}else {
|
||||||
if( getActivity() != null)
|
count3++;
|
||||||
getActivity().setTheme(R.style.AppTheme);
|
|
||||||
}
|
}
|
||||||
getActivity().recreate();
|
}
|
||||||
Intent intent = new Intent(context, MainActivity.class);
|
@Override
|
||||||
intent.putExtra(INTENT_ACTION, CHANGE_THEME_INTENT);
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
startActivity(intent);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -248,8 +248,10 @@ public class Helper {
|
||||||
public static final int ATTACHMENT_ALWAYS = 1;
|
public static final int ATTACHMENT_ALWAYS = 1;
|
||||||
public static final int ATTACHMENT_WIFI = 2;
|
public static final int ATTACHMENT_WIFI = 2;
|
||||||
public static final int ATTACHMENT_ASK = 3;
|
public static final int ATTACHMENT_ASK = 3;
|
||||||
|
|
||||||
public static final int THEME_LIGHT = 1;
|
public static final int THEME_LIGHT = 1;
|
||||||
public static final int THEME_DARK = 2;
|
public static final int THEME_DARK = 2;
|
||||||
|
public static final int THEME_BLACK = 3;
|
||||||
|
|
||||||
public static final int LED_COLOUR = 0;
|
public static final int LED_COLOUR = 0;
|
||||||
|
|
||||||
|
|
|
@ -314,15 +314,11 @@
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/set_night_mode"/>
|
android:text="@string/set_theme"/>
|
||||||
<android.support.v7.widget.SwitchCompat
|
<Spinner
|
||||||
android:id="@+id/set_night_mode"
|
android:id="@+id/set_night_mode"
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- TOOTS visibility -->
|
<!-- TOOTS visibility -->
|
||||||
|
|
|
@ -302,6 +302,8 @@
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- THEME -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -311,15 +313,11 @@
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/set_night_mode"/>
|
android:text="@string/set_theme"/>
|
||||||
<android.support.v7.widget.SwitchCompat
|
<Spinner
|
||||||
android:id="@+id/set_night_mode"
|
android:id="@+id/set_night_mode"
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- TOOTS visibility -->
|
<!-- TOOTS visibility -->
|
||||||
|
|
|
@ -352,6 +352,12 @@
|
||||||
<item>No</item>
|
<item>No</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="settings_theme">
|
||||||
|
<item>Dark</item>
|
||||||
|
<item>Light</item>
|
||||||
|
<item>Black</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="settings_resize_picture">
|
<string-array name="settings_resize_picture">
|
||||||
<item>No</item>
|
<item>No</item>
|
||||||
<item>512 Kb</item>
|
<item>512 Kb</item>
|
||||||
|
@ -526,6 +532,7 @@
|
||||||
<string name="poxy_port">Port</string>
|
<string name="poxy_port">Port</string>
|
||||||
<string name="poxy_login">Login</string>
|
<string name="poxy_login">Login</string>
|
||||||
<string name="poxy_password">Password</string>
|
<string name="poxy_password">Password</string>
|
||||||
|
<string name="set_theme">Theme:</string>
|
||||||
<string-array translatable="false" name="proxy_type_choice">
|
<string-array translatable="false" name="proxy_type_choice">
|
||||||
<item>HTTP</item>
|
<item>HTTP</item>
|
||||||
<item>SOCKS</item>
|
<item>SOCKS</item>
|
||||||
|
|
Loading…
Reference in New Issue