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,69 +1,76 @@
<?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:layout_width="match_parent" android:id="@+id/sorting_dialog_scrollview"
android:layout_height="match_parent" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="match_parent">
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
<RadioGroup <LinearLayout
android:id="@+id/dialog_radio_sorting" android:id="@+id/sorting_dialog_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
<RadioButton <RadioGroup
android:id="@+id/dialog_radio_name" 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">
android:paddingBottom="@dimen/medium_padding"
android:paddingTop="@dimen/medium_padding"
android:text="@string/name"/>
<RadioButton <RadioButton
android:id="@+id/dialog_radio_date" android:id="@+id/sorting_dialog_radio_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding"
android:paddingTop="@dimen/medium_padding"
android:text="@string/name"/>
<RadioButton
android:id="@+id/sorting_dialog_radio_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding"
android:paddingTop="@dimen/medium_padding"
android:text="@string/date"/>
<RadioButton
android:id="@+id/sorting_dialog_radio_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding"
android:paddingTop="@dimen/medium_padding"
android:text="@string/size"/>
</RadioGroup>
<ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="1px"
android:paddingBottom="@dimen/medium_padding" android:layout_marginBottom="@dimen/medium_padding"
android:paddingTop="@dimen/medium_padding" android:layout_marginTop="@dimen/medium_padding"
android:text="@string/date"/> android:background="@color/light_grey"/>
<RadioButton <RadioGroup
android:id="@+id/dialog_radio_size" 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">
android:paddingBottom="@dimen/medium_padding"
android:paddingTop="@dimen/medium_padding"
android:text="@string/size"/>
</RadioGroup>
<ImageView <RadioButton
android:layout_width="match_parent" android:id="@+id/sorting_dialog_radio_ascending"
android:layout_height="1px" android:layout_width="match_parent"
android:layout_marginBottom="@dimen/medium_padding" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_padding" android:paddingBottom="@dimen/medium_padding"
android:background="@color/light_grey"/> android:paddingTop="@dimen/medium_padding"
android:text="@string/ascending"/>
<RadioGroup <RadioButton
android:id="@+id/dialog_radio_order" 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"
<RadioButton android:paddingTop="@dimen/medium_padding"
android:id="@+id/dialog_radio_ascending" android:text="@string/descending"/>
android:layout_width="match_parent" </RadioGroup>
android:layout_height="wrap_content" </LinearLayout>
android:paddingBottom="@dimen/medium_padding" </ScrollView>
android:paddingTop="@dimen/medium_padding"
android:text="@string/ascending"/>
<RadioButton
android:id="@+id/dialog_radio_descending"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_padding"
android:paddingTop="@dimen/medium_padding"
android:text="@string/descending"/>
</RadioGroup>
</LinearLayout>

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"