diff --git a/src/main/java/org/billthefarmer/siggen/Main.java b/src/main/java/org/billthefarmer/siggen/Main.java index c42fac6..3a49b32 100644 --- a/src/main/java/org/billthefarmer/siggen/Main.java +++ b/src/main/java/org/billthefarmer/siggen/Main.java @@ -32,6 +32,9 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; import android.media.AudioFormat; import android.media.AudioManager; import android.media.AudioTrack; @@ -118,6 +121,11 @@ public class Main extends Activity private Scale scale; private Display display; + private Drawable check_on; + private Drawable check_off; + private Drawable radio_on; + private Drawable radio_off; + private SeekBar duty; private SeekBar fine; private SeekBar level; @@ -183,6 +191,15 @@ protected void onCreate(Bundle savedInstanceState) fine = findViewById(R.id.fine); level = findViewById(R.id.level); + Resources.Theme current = getTheme(); + TypedArray array = + current.obtainStyledAttributes(R.styleable.Siggen); + check_on = array.getDrawable(R.styleable.Siggen_check_on); + check_off = array.getDrawable(R.styleable.Siggen_check_off); + radio_on = array.getDrawable(R.styleable.Siggen_radio_on); + radio_off = array.getDrawable(R.styleable.Siggen_radio_off); + array.recycle(); + // Get wake lock PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOCK); @@ -759,14 +776,14 @@ public void onClick(View v) if (audio != null) audio.waveform = Audio.SINE; ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_on_background, 0, 0, 0); + radio_on, null, null, null); v = findViewById(R.id.square); ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_off_background, 0, 0, 0); + radio_off, null, null, null); v = findViewById(R.id.sawtooth); ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_off_background, 0, 0, 0); + radio_off, null, null, null); break; // Square @@ -774,14 +791,14 @@ public void onClick(View v) if (audio != null) audio.waveform = Audio.SQUARE; ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_on_background, 0, 0, 0); + radio_on, null, null, null); v = findViewById(R.id.sine); ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_off_background, 0, 0, 0); + radio_off, null, null, null); v = findViewById(R.id.sawtooth); ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_off_background, 0, 0, 0); + radio_off, null, null, null); break; // Sawtooth @@ -789,14 +806,14 @@ public void onClick(View v) if (audio != null) audio.waveform = Audio.SAWTOOTH; ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_on_background, 0, 0, 0); + radio_on, null, null, null); v = findViewById(R.id.sine); ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_off_background, 0, 0, 0); + radio_off, null, null, null); v = findViewById(R.id.square); ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.radiobutton_off_background, 0, 0, 0); + radio_off, null, null, null); break; // Mute @@ -806,11 +823,11 @@ public void onClick(View v) if (audio.mute) ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.checkbox_on_background, 0, 0, 0); + check_on, null, null, null); else ((Button) v).setCompoundDrawablesWithIntrinsicBounds( - android.R.drawable.checkbox_off_background, 0, 0, 0); + check_off, null, null, null); break; // Back diff --git a/src/main/res/drawable/ic_check_box_black_24dp.xml b/src/main/res/drawable/ic_check_box_black_24dp.xml new file mode 100644 index 0000000..9948171 --- /dev/null +++ b/src/main/res/drawable/ic_check_box_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_check_box_outline_blank_black_24dp.xml b/src/main/res/drawable/ic_check_box_outline_blank_black_24dp.xml new file mode 100644 index 0000000..cf8bfa2 --- /dev/null +++ b/src/main/res/drawable/ic_check_box_outline_blank_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_check_box_outline_blank_white_24dp.xml b/src/main/res/drawable/ic_check_box_outline_blank_white_24dp.xml new file mode 100644 index 0000000..3ecf661 --- /dev/null +++ b/src/main/res/drawable/ic_check_box_outline_blank_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_check_box_white_24dp.xml b/src/main/res/drawable/ic_check_box_white_24dp.xml new file mode 100644 index 0000000..473788c --- /dev/null +++ b/src/main/res/drawable/ic_check_box_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_radio_button_checked_black_24dp.xml b/src/main/res/drawable/ic_radio_button_checked_black_24dp.xml new file mode 100644 index 0000000..a5025ae --- /dev/null +++ b/src/main/res/drawable/ic_radio_button_checked_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_radio_button_checked_white_24dp.xml b/src/main/res/drawable/ic_radio_button_checked_white_24dp.xml new file mode 100644 index 0000000..f6e8a94 --- /dev/null +++ b/src/main/res/drawable/ic_radio_button_checked_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_radio_button_unchecked_black_24dp.xml b/src/main/res/drawable/ic_radio_button_unchecked_black_24dp.xml new file mode 100644 index 0000000..f61549b --- /dev/null +++ b/src/main/res/drawable/ic_radio_button_unchecked_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_radio_button_unchecked_white_24dp.xml b/src/main/res/drawable/ic_radio_button_unchecked_white_24dp.xml new file mode 100644 index 0000000..42988f2 --- /dev/null +++ b/src/main/res/drawable/ic_radio_button_unchecked_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/layout-large/main.xml b/src/main/res/layout-large/main.xml index 8a41388..f0ded90 100644 --- a/src/main/res/layout-large/main.xml +++ b/src/main/res/layout-large/main.xml @@ -85,7 +85,7 @@ android:layout_below="@id/display" android:layout_alignLeft="@id/display" android:layout_alignParentRight="true" - android:drawableLeft="@android:drawable/radiobutton_on_background" + android:drawableLeft="?attr/radio_on" android:drawablePadding="8dp" android:text="@string/sine" /> @@ -96,7 +96,7 @@ android:layout_below="@id/sine" android:layout_alignLeft="@id/display" android:layout_alignParentRight="true" - android:drawableLeft="@android:drawable/radiobutton_off_background" + android:drawableLeft="?attr/radio_off" android:drawablePadding="8dp" android:text="@string/square" /> @@ -107,7 +107,7 @@ android:layout_below="@id/square" android:layout_alignLeft="@id/display" android:layout_alignParentRight="true" - android:drawableLeft="@android:drawable/radiobutton_off_background" + android:drawableLeft="?attr/radio_off" android:drawablePadding="8dp" android:text="@string/sawtooth" /> @@ -118,7 +118,7 @@ android:layout_below="@id/sawtooth" android:layout_alignLeft="@id/display" android:layout_alignParentRight="true" - android:drawableLeft="@android:drawable/checkbox_off_background" + android:drawableLeft="?attr/check_off" android:drawablePadding="8dp" android:text="@string/mute" /> diff --git a/src/main/res/layout-small/main.xml b/src/main/res/layout-small/main.xml index f6d3e1e..482631a 100644 --- a/src/main/res/layout-small/main.xml +++ b/src/main/res/layout-small/main.xml @@ -93,7 +93,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0" - android:drawableLeft="@android:drawable/radiobutton_on_background" + android:drawableLeft="?attr/radio_on" android:drawablePadding="8dp" android:text="@string/s" /> @@ -102,7 +102,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0" - android:drawableLeft="@android:drawable/radiobutton_off_background" + android:drawableLeft="?attr/radio_off" android:drawablePadding="8dp" android:text="@string/q" /> @@ -111,7 +111,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0" - android:drawableLeft="@android:drawable/radiobutton_off_background" + android:drawableLeft="?attr/radio_off" android:drawablePadding="8dp" android:text="@string/w" /> @@ -161,7 +161,7 @@ android:layout_alignBottom="@id/lower" android:layout_toLeftOf="@id/more" android:layout_toRightOf="@id/less" - android:drawableLeft="@android:drawable/checkbox_off_background" + android:drawableLeft="?attr/check_off" android:drawablePadding="8dp" android:text="@string/mute" /> diff --git a/src/main/res/layout/main.xml b/src/main/res/layout/main.xml index b691347..84e843d 100644 --- a/src/main/res/layout/main.xml +++ b/src/main/res/layout/main.xml @@ -93,7 +93,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0" - android:drawableLeft="@android:drawable/radiobutton_on_background" + android:drawableLeft="?attr/radio_on" android:drawablePadding="8dp" android:text="@string/sin" /> @@ -102,7 +102,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0" - android:drawableLeft="@android:drawable/radiobutton_off_background" + android:drawableLeft="?attr/radio_off" android:drawablePadding="8dp" android:text="@string/squ" /> @@ -111,7 +111,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0" - android:drawableLeft="@android:drawable/radiobutton_off_background" + android:drawableLeft="?attr/radio_off" android:drawablePadding="8dp" android:text="@string/saw" /> @@ -161,7 +161,7 @@ android:layout_alignBottom="@id/lower" android:layout_toLeftOf="@id/more" android:layout_toRightOf="@id/less" - android:drawableLeft="@android:drawable/checkbox_off_background" + android:drawableLeft="?attr/check_off" android:drawablePadding="8dp" android:text="@string/mute" /> diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index f498c6d..aa605f9 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -8,6 +8,10 @@ + + + + diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml index 6bddabd..ae36eaa 100644 --- a/src/main/res/values/styles.xml +++ b/src/main/res/values/styles.xml @@ -26,6 +26,10 @@ @drawable/ic_forward @drawable/ic_chevron_right_black_24dp @drawable/ic_chevron_left_black_24dp + @drawable/ic_radio_button_unchecked_black_24dp + @drawable/ic_radio_button_checked_black_24dp + @drawable/ic_check_box_outline_blank_black_24dp + @drawable/ic_check_box_black_24dp @drawable/ic_action_about @drawable/ic_action_brightness_high_light @@ -53,6 +57,10 @@ @drawable/ic_forward_dark @drawable/ic_chevron_right_white_24dp @drawable/ic_chevron_left_white_24dp + @drawable/ic_radio_button_unchecked_white_24dp + @drawable/ic_radio_button_checked_white_24dp + @drawable/ic_check_box_outline_blank_white_24dp + @drawable/ic_check_box_white_24dp @drawable/ic_action_about_dark @drawable/ic_action_brightness_high