wrap the sorting dialog in a scrollview

This commit is contained in:
tibbi 2016-12-03 21:00:55 +01:00
parent 747e007fd0
commit 49247ee9f1
3 changed files with 77 additions and 70 deletions

View File

@ -34,36 +34,36 @@ class ChangeSortingDialog(val activity: Activity, val isDirectorySorting: Boolea
} }
private fun setupSortRadio() { private fun setupSortRadio() {
val sortingRadio = view.dialog_radio_sorting val sortingRadio = view.sorting_dialog_radio_sorting
var sortBtn = sortingRadio.dialog_radio_name var sortBtn = sortingRadio.sorting_dialog_radio_name
if (currSorting and SORT_BY_DATE != 0) { if (currSorting and SORT_BY_DATE != 0) {
sortBtn = sortingRadio.dialog_radio_date sortBtn = sortingRadio.sorting_dialog_radio_date
} else if (currSorting and SORT_BY_SIZE != 0) { } else if (currSorting and SORT_BY_SIZE != 0) {
sortBtn = sortingRadio.dialog_radio_size sortBtn = sortingRadio.sorting_dialog_radio_size
} }
sortBtn.isChecked = true sortBtn.isChecked = true
} }
private fun setupOrderRadio() { private fun setupOrderRadio() {
val orderRadio = view.dialog_radio_order val orderRadio = view.sorting_dialog_radio_order
var orderBtn = orderRadio.dialog_radio_ascending var orderBtn = orderRadio.sorting_dialog_radio_ascending
if (currSorting and SORT_DESCENDING != 0) { if (currSorting and SORT_DESCENDING != 0) {
orderBtn = orderRadio.dialog_radio_descending orderBtn = orderRadio.sorting_dialog_radio_descending
} }
orderBtn.isChecked = true orderBtn.isChecked = true
} }
override fun onClick(dialog: DialogInterface, which: Int) { override fun onClick(dialog: DialogInterface, which: Int) {
val sortingRadio = view.dialog_radio_sorting val sortingRadio = view.sorting_dialog_radio_sorting
var sorting = when (sortingRadio.checkedRadioButtonId) { var sorting = when (sortingRadio.checkedRadioButtonId) {
R.id.dialog_radio_name -> SORT_BY_NAME R.id.sorting_dialog_radio_name -> SORT_BY_NAME
R.id.dialog_radio_date -> SORT_BY_DATE R.id.sorting_dialog_radio_date -> SORT_BY_DATE
else -> SORT_BY_SIZE else -> SORT_BY_SIZE
} }
if (view.dialog_radio_order.checkedRadioButtonId == R.id.dialog_radio_descending) { if (view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
sorting = sorting or SORT_DESCENDING sorting = sorting or SORT_DESCENDING
} }

View File

@ -1,20 +1,26 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/dialog_holder" <ScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sorting_dialog_scrollview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
<LinearLayout
android:id="@+id/sorting_dialog_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="@dimen/activity_margin" android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin" android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"> android:paddingTop="@dimen/activity_margin">
<RadioGroup <RadioGroup
android:id="@+id/dialog_radio_sorting" android:id="@+id/sorting_dialog_radio_sorting"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<RadioButton <RadioButton
android:id="@+id/dialog_radio_name" android:id="@+id/sorting_dialog_radio_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding" android:paddingBottom="@dimen/medium_padding"
@ -22,7 +28,7 @@
android:text="@string/name"/> android:text="@string/name"/>
<RadioButton <RadioButton
android:id="@+id/dialog_radio_date" android:id="@+id/sorting_dialog_radio_date"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding" android:paddingBottom="@dimen/medium_padding"
@ -30,7 +36,7 @@
android:text="@string/date"/> android:text="@string/date"/>
<RadioButton <RadioButton
android:id="@+id/dialog_radio_size" android:id="@+id/sorting_dialog_radio_size"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding" android:paddingBottom="@dimen/medium_padding"
@ -46,12 +52,12 @@
android:background="@color/light_grey"/> android:background="@color/light_grey"/>
<RadioGroup <RadioGroup
android:id="@+id/dialog_radio_order" android:id="@+id/sorting_dialog_radio_order"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<RadioButton <RadioButton
android:id="@+id/dialog_radio_ascending" android:id="@+id/sorting_dialog_radio_ascending"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding" android:paddingBottom="@dimen/medium_padding"
@ -59,7 +65,7 @@
android:text="@string/ascending"/> android:text="@string/ascending"/>
<RadioButton <RadioButton
android:id="@+id/dialog_radio_descending" android:id="@+id/sorting_dialog_radio_descending"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding" android:paddingBottom="@dimen/medium_padding"
@ -67,3 +73,4 @@
android:text="@string/descending"/> android:text="@string/descending"/>
</RadioGroup> </RadioGroup>
</LinearLayout> </LinearLayout>
</ScrollView>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_holder" android:id="@+id/sorting_dialog_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"