Skip to content

Commit

Permalink
Update theme switch
Browse files Browse the repository at this point in the history
  • Loading branch information
billthefarmer committed Oct 24, 2023
1 parent d77eed2 commit e13853c
Show file tree
Hide file tree
Showing 68 changed files with 146 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/billthefarmer/scope/FreqScale.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public FreqScale(Context context, AttributeSet attrs)

Resources resources = getResources();

final TypedArray typedArray = context.obtainStyledAttributes(attrs,
R.styleable.Scope, 0, 0);
final TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.Scope);

textColour = typedArray.getColor(R.styleable.Scope_TextColour,
resources.getColor(android.R.color.black));
Expand Down
28 changes: 22 additions & 6 deletions src/main/java/org/billthefarmer/scope/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,18 @@ protected void onResume()
// Get preferences
getPreferences();

if (last != theme && Build.VERSION.SDK_INT != Build.VERSION_CODES.M)
recreate();
if (last != theme)
{
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M)
{
Intent intent = new Intent(this, getClass());
startActivity(intent);
finish();
}

else
recreate();
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
Expand All @@ -690,17 +700,23 @@ public void onRequestPermissionsResult(int requestCode,
int[] grantResults)
{
if (requestCode == REQUEST_PERMISSIONS)
{
for (int i = 0; i < grantResults.length; i++)
if (permissions[i].equals(Manifest.permission.RECORD_AUDIO) &&
grantResults[i] == PackageManager.PERMISSION_GRANTED)
{
// Granted, recreate or start audio thread
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.M)
recreate();
// Granted, recreate
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M)
{
Intent intent = new Intent(this, getClass());
startActivity(intent);
finish();
}

else
audio.start();
recreate();
}
}
}

// On pause
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/billthefarmer/scope/Scale.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Scale(Context context, AttributeSet attrs)
Resources resources = getResources();

final TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.Scope, 0, 0);
context.obtainStyledAttributes(attrs, R.styleable.Scope);

textColour =
typedArray.getColor(R.styleable.Scope_TextColour,
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/billthefarmer/scope/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import android.app.ActionBar;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -119,7 +120,15 @@ public void onSharedPreferenceChanged(SharedPreferences preferences,

if (key.equals(Main.PREF_THEME))
{
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.M)
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M)
{
Intent intent = new
Intent(getActivity(), getActivity().getClass());
getActivity().startActivity(intent);
getActivity().finish();
}

else
getActivity().recreate();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/billthefarmer/scope/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Unit(Context context, AttributeSet attrs)
Resources resources = getResources();

final TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.Scope, 0, 0);
context.obtainStyledAttributes(attrs, R.styleable.Scope);

textColour =
typedArray.getColor(R.styleable.Scope_TextColour,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/billthefarmer/scope/XScale.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public XScale(Context context, AttributeSet attrs)
Resources resources = getResources();

final TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.Scope, 0, 0);
context.obtainStyledAttributes(attrs, R.styleable.Scope);

textColour =
typedArray.getColor(R.styleable.Scope_TextColour,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/billthefarmer/scope/YScale.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public YScale(Context context, AttributeSet attrs)
Resources resources = getResources();

final TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.Scope, 0, 0);
context.obtainStyledAttributes(attrs, R.styleable.Scope);

textColour =
typedArray.getColor(R.styleable.Scope_TextColour,
Expand Down
Binary file not shown.
Binary file removed src/main/res/drawable-hdpi/ic_clear_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-hdpi/ic_first_page_white_24dp.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/main/res/drawable-hdpi/ic_last_page_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-hdpi/ic_lock_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-hdpi/ic_menu_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-hdpi/ic_sub_white_24dp.png
Binary file not shown.
Binary file not shown.
Binary file removed src/main/res/drawable-mdpi/ic_clear_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-mdpi/ic_first_page_white_24dp.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/main/res/drawable-mdpi/ic_last_page_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-mdpi/ic_lock_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-mdpi/ic_menu_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-mdpi/ic_sub_white_24dp.png
Binary file not shown.
Binary file not shown.
Binary file removed src/main/res/drawable-xhdpi/ic_clear_white_24dp.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/main/res/drawable-xhdpi/ic_last_page_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-xhdpi/ic_lock_white_24dp.png
Binary file not shown.
Binary file removed src/main/res/drawable-xhdpi/ic_menu_white_24dp.png
Diff not rendered.
Binary file removed src/main/res/drawable-xhdpi/ic_sub_white_24dp.png
Diff not rendered.
Diff not rendered.
Binary file removed src/main/res/drawable-xxhdpi/ic_clear_white_24dp.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed src/main/res/drawable-xxhdpi/ic_lock_white_24dp.png
Diff not rendered.
Binary file removed src/main/res/drawable-xxhdpi/ic_menu_white_24dp.png
Diff not rendered.
Binary file removed src/main/res/drawable-xxhdpi/ic_storage_white_24dp.png
Diff not rendered.
Binary file removed src/main/res/drawable-xxhdpi/ic_sub_white_24dp.png
Diff not rendered.
Diff not rendered.
Binary file removed src/main/res/drawable-xxxhdpi/ic_clear_white_24dp.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed src/main/res/drawable-xxxhdpi/ic_lock_white_24dp.png
Diff not rendered.
Diff not rendered.
Binary file removed src/main/res/drawable-xxxhdpi/ic_menu_white_24dp.png
Diff not rendered.
Diff not rendered.
Binary file removed src/main/res/drawable-xxxhdpi/ic_storage_white_24dp.png
Diff not rendered.
Binary file removed src/main/res/drawable-xxxhdpi/ic_sub_white_24dp.png
Diff not rendered.
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_access_time_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_clear_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_first_page_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M18.41,16.59L13.82,12l4.59,-4.59L17,6l-6,6 6,6zM6,6h2v12H6z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_keyboard_arrow_left_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_keyboard_arrow_right_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_last_page_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M5.59,7.41L10.18,12l-4.59,4.59L7,18l6,-6 -6,-6zM16,6h2v12h-2z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_lock_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_looks_one_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14,17h-2L12,9h-2L10,7h4v10z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_menu_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_repeat_one_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M7,7h10v3l4,-4 -4,-4v3L5,5v6h2L7,7zM17,17L7,17v-3l-4,4 4,4v-3h12v-6h-2v4zM13,15L13,9h-1l-2,1v1h1.5v4L13,15z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_storage_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M2,20h20v-4L2,16v4zM4,17h2v2L4,19v-2zM2,4v4h20L22,4L2,4zM6,7L4,7L4,5h2v2zM2,14h20v-4L2,10v4zM4,11h2v2L4,13v-2z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_sub_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M3,13h18v-2L3,11v2z"/>
</vector>

0 comments on commit e13853c

Please sign in to comment.