Skip to content

Commit

Permalink
Add level buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
billthefarmer committed Feb 10, 2023
1 parent 8028406 commit 9bd6222
Show file tree
Hide file tree
Showing 24 changed files with 123 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath 'com.android.tools.build:gradle:7.4.1'
}
}

Expand Down
57 changes: 52 additions & 5 deletions src/main/java/org/billthefarmer/siggen/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ protected void onResume()

if (dark != darkTheme && Build.VERSION.SDK_INT != Build.VERSION_CODES.M)
recreate();

checkButtons();
}

// Restore state
Expand Down Expand Up @@ -747,11 +749,30 @@ public void onClick(View v)

// Higher
case R.id.higher:
{
int progress = fine.getProgress();
fine.setProgress(++progress);
}
break;
if (fine != null)
{
int progress = fine.getProgress();
fine.setProgress(++progress);
}
break;

// Less
case R.id.less:
if (level != null)
{
int progress = level.getProgress();
level.setProgress(--progress);
}
break;

// More
case R.id.more:
if (level != null)
{
int progress = level.getProgress();
level.setProgress(++progress);
}
break;
}
}

Expand Down Expand Up @@ -934,6 +955,14 @@ private void setupWidgets()
if (v != null)
v.setOnClickListener(this);

v = findViewById(R.id.less);
if (v != null)
v.setOnClickListener(this);

v = findViewById(R.id.more);
if (v != null)
v.setOnClickListener(this);

if (fine != null)
{
fine.setOnSeekBarChangeListener(this);
Expand Down Expand Up @@ -967,6 +996,24 @@ private void setupWidgets()
v.setOnClickListener(this);
}

private void checkButtons()
{
final View v = findViewById(R.id.mute);
if (v != null)
v.postDelayed(() ->
{
int width = v.getWidth();
View l = findViewById(R.id.less);
if (l != null && width < l.getWidth())
{
l.setVisibility(View.GONE);
View m = findViewById(R.id.more);
if (m != null)
m.setVisibility(View.GONE);
}
}, DELAY);
}

// setupPhoneStateListener
private void setupPhoneStateListener()
{
Expand Down
Binary file added src/main/res/drawable-hdpi/ic_action_collapse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/res/drawable-hdpi/ic_action_expand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/ic_action_expand_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-mdpi/ic_action_collapse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/res/drawable-mdpi/ic_action_expand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-mdpi/ic_action_expand_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xhdpi/ic_action_collapse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/res/drawable-xhdpi/ic_action_expand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xxhdpi/ic_action_collapse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/res/drawable-xxhdpi/ic_action_expand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/main/res/layout-large/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@
android:src="?attr/previous"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/fine"
android:layout_toRightOf="@id/lower"
android:layout_marginBottom="8dp"
android:src="?attr/expand"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/fine"
android:layout_toLeftOf="@id/higher"
android:layout_marginBottom="8dp"
android:src="?attr/collapse"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/higher"
android:layout_width="wrap_content"
Expand Down
22 changes: 20 additions & 2 deletions src/main/res/layout-small/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@
android:src="?attr/previous"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/waveform"
android:layout_toRightOf="@id/lower"
android:src="?attr/expand"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/waveform"
android:layout_toLeftOf="@id/higher"
android:src="?attr/collapse"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/higher"
android:layout_width="wrap_content"
Expand All @@ -141,8 +159,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/waveform"
android:layout_alignBottom="@id/lower"
android:layout_toLeftOf="@id/higher"
android:layout_toRightOf="@id/lower"
android:layout_toLeftOf="@id/more"
android:layout_toRightOf="@id/less"
android:drawableLeft="@android:drawable/checkbox_off_background"
android:drawablePadding="8dp"
android:text="@string/mute" />
Expand Down
22 changes: 20 additions & 2 deletions src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@
android:src="?attr/previous"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/waveform"
android:layout_toRightOf="@id/lower"
android:src="?attr/expand"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/waveform"
android:layout_toLeftOf="@id/higher"
android:src="?attr/collapse"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/higher"
android:layout_width="wrap_content"
Expand All @@ -141,8 +159,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/waveform"
android:layout_alignBottom="@id/lower"
android:layout_toLeftOf="@id/higher"
android:layout_toRightOf="@id/lower"
android:layout_toLeftOf="@id/more"
android:layout_toRightOf="@id/less"
android:drawableLeft="@android:drawable/checkbox_off_background"
android:drawablePadding="8dp"
android:text="@string/mute" />
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<item
android:id="@+id/bookmark"
android:icon="@drawable/ic_action_expand"
android:icon="@drawable/ic_action_expand_dark"
android:showAsAction="ifRoom"
android:title="@string/bookmark" />

Expand Down
4 changes: 3 additions & 1 deletion src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

<declare-styleable name="Siggen">
<attr name="back" format="reference" />
<attr name="collapse" format="reference" />
<attr name="expand" format="reference" />
<attr name="forward" format="reference" />
<attr name="previous" format="reference" />
<attr name="next" format="reference" />
<attr name="previous" format="reference" />

<attr name="pref_about" format="reference" />
<attr name="pref_dark_theme" format="reference" />
Expand Down
8 changes: 6 additions & 2 deletions src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
-->

<item name="back">@drawable/ic_back</item>
<item name="collapse">@drawable/ic_action_collapse</item>
<item name="expand">@drawable/ic_action_expand</item>
<item name="forward">@drawable/ic_forward</item>
<item name="previous">@drawable/ic_action_previous_item</item>
<item name="next">@drawable/ic_action_next_item</item>
<item name="previous">@drawable/ic_action_previous_item</item>

<item name="pref_about">@drawable/ic_action_about</item>
<item name="pref_dark_theme">@drawable/ic_action_brightness_high_light</item>
Expand All @@ -47,9 +49,11 @@
-->

<item name="back">@drawable/ic_back_dark</item>
<item name="collapse">@drawable/ic_action_collapse_dark</item>
<item name="expand">@drawable/ic_action_expand_dark</item>
<item name="forward">@drawable/ic_forward_dark</item>
<item name="previous">@drawable/ic_action_previous_item_dark</item>
<item name="next">@drawable/ic_action_next_item_dark</item>
<item name="previous">@drawable/ic_action_previous_item_dark</item>

<item name="pref_about">@drawable/ic_action_about_dark</item>
<item name="pref_dark_theme">@drawable/ic_action_brightness_high</item>
Expand Down

0 comments on commit 9bd6222

Please sign in to comment.