Merge branch 'fuckcolours' into develop

This commit is contained in:
Bipin
2021-01-12 14:05:10 +01:00
10 changed files with 245 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ import android.view.View;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -13,11 +14,13 @@ import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction;
import com.a1.nextlocation.MainActivity;
import com.a1.nextlocation.R;
import org.jetbrains.annotations.NotNull;
@@ -29,6 +32,7 @@ public class SettingsFragment extends Fragment {
private SharedPreferences.Editor editor;
private SwitchCompat fontSwitch;
private SwitchCompat imperialSwitch;
private SwitchCompat colorBlindMode;
private Refreshable refreshable;
@Override
@@ -42,6 +46,7 @@ public class SettingsFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
editor = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).edit();
}
@Override
@@ -94,17 +99,37 @@ public class SettingsFragment extends Fragment {
if(fontSwitch.isChecked())
{
requireActivity().setTheme(R.style.Theme_NextLocationBig);
editor.putBoolean("fontSwitch",true);
editor.apply();
}
if(!fontSwitch.isChecked())
{
requireActivity().setTheme(R.style.Theme_NextLocation);
editor.putBoolean("fontSwitch",false);
editor.apply();
requireActivity().setTheme(R.style.Theme_NextLocation);;
}
editor.putBoolean("fontSwitch",fontSwitch.isChecked());
editor.apply();
editor.commit();
});
this.colorBlindMode = view.findViewById(R.id.colourblindSwitch);
this.colorBlindMode.setChecked(sharedPreferences.getBoolean("colorBlindModeSwitch", false));
this.colorBlindMode.setOnClickListener(view1 -> {
editor.putBoolean("colorBlindModeSwitch", colorBlindMode.isChecked());
editor.apply();
editor.commit();
if (colorBlindMode.isChecked()){
requireActivity().setTheme(R.style.Theme_NextLocation);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
getActivity().recreate();
System.out.println("AAN");
}else if (!colorBlindMode.isChecked()){
requireActivity().setTheme(R.style.Theme_NextLocation);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
getActivity().recreate();
System.out.println("UIT");
}
});
}
private void initializeLanguageDropdown(View view) {