Skip to content

Commit

Permalink
Merge pull request #28 from Carifio24/ui-improvements
Browse files Browse the repository at this point in the history
UI improvements
  • Loading branch information
Carifio24 authored Sep 4, 2023
2 parents 1f7bcad + 5f5ccdd commit d78ea7c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dnd.jon.spellbook;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

public class ShortScrollbarRVScrollView extends ScrollView {
public ShortScrollbarRVScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}

public ShortScrollbarRVScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

public ShortScrollbarRVScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public ShortScrollbarRVScrollView(Context context) {
super(context);
}

// This is the value of scrollY when the RV is fully scrolled
private int yScrollRange() {
return super.computeVerticalScrollRange() - getHeight();
}

@Override
public int computeVerticalScrollExtent() {
final int yRange = yScrollRange();
if (yRange <= 0) {
return 0;
}
return super.computeVerticalScrollExtent() / 5;
}

@Override
public int computeVerticalScrollOffset() {
final int yRange = yScrollRange();
if (yRange <= 0) {
return 0;
}
return getScrollY() * (getHeight() - computeVerticalScrollExtent()) / yRange;
}

}
14 changes: 9 additions & 5 deletions app/src/main/res/layout/character_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,24 @@

</com.google.android.flexbox.FlexboxLayout>

<ScrollView
android:layout_width="wrap_content"
android:layout_height="126dp"
<dnd.jon.spellbook.ShortScrollbarRVScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="126dp"
android:id="@+id/selection_table_scrollview"
android:layout_below="@id/import_character_button_layout"
android:fadeScrollbars="false"
>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/selection_recycler_view"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="4dp"
android:paddingEnd="8dp"
>
</androidx.recyclerview.widget.RecyclerView>
</ScrollView>
</dnd.jon.spellbook.ShortScrollbarRVScrollView>

</RelativeLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/name_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</data>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/name_row"
>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/xml/settings_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<SwitchPreference
android:key="@string/fab_movable_key"
android:title="@string/fab_movable_title"
android:defaultValue="true"
/>

</androidx.preference.PreferenceCategory>
Expand Down

0 comments on commit d78ea7c

Please sign in to comment.