From f2b1ef2c3b041f49fc2c9b9f7463503730289b5f Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 24 Jun 2017 22:07:47 +0200 Subject: [PATCH] handle horizontal scrolling at copy/move destination picker too --- .../gallery/dialogs/ChangeSortingDialog.kt | 2 +- .../gallery/dialogs/PickDirectoryDialog.kt | 32 +++++++++-- .../res/layout/dialog_directory_picker.xml | 56 +++++++++++++++++-- 3 files changed, 78 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt index f6516ee9b..53db0c197 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt @@ -17,7 +17,7 @@ class ChangeSortingDialog(val activity: SimpleActivity, val isDirectorySorting: val path: String = "", val callback: () -> Unit) : DialogInterface.OnClickListener { private var currSorting = 0 - private var config: Config = activity.config + private var config = activity.config private var view: View init { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index cf384829e..7b3c93971 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -1,9 +1,12 @@ package com.simplemobiletools.gallery.dialogs import android.support.v7.app.AlertDialog -import android.support.v7.widget.RecyclerView +import android.support.v7.widget.GridLayoutManager import android.view.LayoutInflater +import android.view.View import com.simplemobiletools.commons.dialogs.FilePickerDialog +import com.simplemobiletools.commons.extensions.beGoneIf +import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.gallery.R @@ -17,12 +20,15 @@ import kotlinx.android.synthetic.main.dialog_directory_picker.view.* class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) { var dialog: AlertDialog - var directoriesGrid: RecyclerView var shownDirectories: ArrayList = ArrayList() + var view: View init { - val view = LayoutInflater.from(activity).inflate(R.layout.dialog_directory_picker, null) - directoriesGrid = view.directories_grid + view = LayoutInflater.from(activity).inflate(R.layout.dialog_directory_picker, null) + (view.directories_grid.layoutManager as GridLayoutManager).apply { + orientation = if (activity.config.scrollHorizontally) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL + spanCount = activity.config.dirColumnCnt + } dialog = AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) @@ -63,6 +69,22 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, dialog.dismiss() } } - directoriesGrid.adapter = adapter + + val scrollHorizontally = activity.config.scrollHorizontally + view.apply { + directories_grid.adapter = adapter + + directories_vertical_fastscroller.isHorizontal = false + directories_vertical_fastscroller.beGoneIf(scrollHorizontally) + + directories_horizontal_fastscroller.isHorizontal = true + directories_horizontal_fastscroller.beVisibleIf(scrollHorizontally) + + if (scrollHorizontally) { + directories_horizontal_fastscroller.setViews(directories_grid) + } else { + directories_vertical_fastscroller.setViews(directories_grid) + } + } } } diff --git a/app/src/main/res/layout/dialog_directory_picker.xml b/app/src/main/res/layout/dialog_directory_picker.xml index ca361da90..821138213 100644 --- a/app/src/main/res/layout/dialog_directory_picker.xml +++ b/app/src/main/res/layout/dialog_directory_picker.xml @@ -1,10 +1,54 @@ - + android:layout_height="wrap_content"> + + + + + + + + + + + + + + +