Develop #5

Merged
SemvdH merged 62 commits from develop into main 2021-01-14 10:55:23 +00:00
6 changed files with 69 additions and 14 deletions
Showing only changes of commit 0663dabca5 - Show all commits

View File

@@ -8,6 +8,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;
@@ -37,6 +38,7 @@ public class MainActivity extends AppCompatActivity implements Refreshable {
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
super.onCreate(savedInstanceState);
// initialize saved language from sharedPreferences

View File

@@ -13,6 +13,7 @@ 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;
@@ -29,6 +30,7 @@ public class SettingsFragment extends Fragment {
private SharedPreferences.Editor editor;
private SwitchCompat fontSwitch;
private SwitchCompat imperialSwitch;
private SwitchCompat colourblindSwitch;
private Refreshable refreshable;
@Override
@@ -94,17 +96,38 @@ 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();
});
//Initialises colourblind mode switchCompat
this.colourblindSwitch = view.findViewById(R.id.colourblindSwitch);
fontSwitch.setChecked(sharedPreferences.getBoolean("colourblindSwitch", false));
//Initial check to see what setting was last chosen
if (colourblindSwitch.isChecked()){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}else if (!colourblindSwitch.isChecked()){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
colourblindSwitch.setOnClickListener(view1 -> {
if (colourblindSwitch.isChecked()){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}else if (!colourblindSwitch.isChecked()){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
editor.putBoolean("colourblindSwitch", colourblindSwitch.isChecked());
editor.apply();
editor.commit();
});
}
private void initializeLanguageDropdown(View view) {

View File

@@ -243,7 +243,7 @@
/>
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/settingsEyesButton"
android:id="@+id/colourblindSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="primaryColour">#FF115571</color>
<color name="secondaryColour">#FF31AFB4</color>
<color name="buttonColour">#FF14212D</color>
<color name="red">#FF0000</color>
</resources>

View File

@@ -2,15 +2,28 @@
<!-- Base application theme. -->
<style name="Theme.NextLocation" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<item name="colorPrimary">@color/primaryColour</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<item name="colorSecondary">@color/secondaryColour</item>
<!-- Customize your theme here. -->
<item name="colorButtonNormal">@color/buttonColour</item>
<item name="colorPrimaryDark">@color/secondaryColour</item>
<item name="android:textSize">16sp</item>
</style>
<style name="Theme.Switches" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorControlActivated">@color/buttonColour</item>
<item name="colorSwitchThumbNormal">@color/primaryColour</item>
</style>
<style name="Theme.NextLocationBig" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/primaryColour</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/secondaryColour</item>
<!-- Customize your theme here. -->
<item name="colorButtonNormal">@color/buttonColour</item>
<item name="colorPrimaryDark">@color/secondaryColour</item>
<item name="android:textSize">24sp</item>
</style>
</resources>

View File

@@ -11,4 +11,7 @@
<color name="secondaryColour">#FF000000</color>
<color name="buttonColour">#FF000000</color>
<color name="red">#FF0000</color>
<color name="primaryColourCB">#FF115571</color>
<color name="secondaryColourCB">#FF31AFB4</color>
<color name="buttonColourCB">#FF14212D</color>
</resources>