add a switch for toggling Pull-to-refresh

This commit is contained in:
tibbi 2018-02-24 00:21:46 +01:00
parent 9280533c74
commit a5372f97a3
7 changed files with 38 additions and 12 deletions

View File

@ -46,7 +46,7 @@ ext {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:3.12.24' implementation 'com.simplemobiletools:commons:3.13.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
implementation 'com.android.support:multidex:1.0.2' implementation 'com.android.support:multidex:1.0.2'
implementation 'com.google.code.gson:gson:2.8.2' implementation 'com.google.code.gson:gson:2.8.2'

View File

@ -137,6 +137,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
directories_horizontal_fastscroller.updateBubbleColors() directories_horizontal_fastscroller.updateBubbleColors()
directories_vertical_fastscroller.updateBubbleColors() directories_vertical_fastscroller.updateBubbleColors()
directories_refresh_layout.isEnabled = config.enablePullToRefresh
invalidateOptionsMenu() invalidateOptionsMenu()
directories_empty_text_label.setTextColor(config.textColor) directories_empty_text_label.setTextColor(config.textColor)
directories_empty_text.setTextColor(getAdjustedPrimaryColor()) directories_empty_text.setTextColor(getAdjustedPrimaryColor())
@ -622,7 +623,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun setupScrollDirection() { private fun setupScrollDirection() {
val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFolders == VIEW_TYPE_GRID val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFolders == VIEW_TYPE_GRID
directories_refresh_layout.isEnabled = !config.scrollHorizontally
directories_vertical_fastscroller.isHorizontal = false directories_vertical_fastscroller.isHorizontal = false
directories_vertical_fastscroller.beGoneIf(allowHorizontalScroll) directories_vertical_fastscroller.beGoneIf(allowHorizontalScroll)

View File

@ -134,6 +134,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
media_horizontal_fastscroller.updateBubbleColors() media_horizontal_fastscroller.updateBubbleColors()
media_vertical_fastscroller.updateBubbleColors() media_vertical_fastscroller.updateBubbleColors()
media_refresh_layout.isEnabled = config.enablePullToRefresh
tryloadGallery() tryloadGallery()
invalidateOptionsMenu() invalidateOptionsMenu()
media_empty_text_label.setTextColor(config.textColor) media_empty_text_label.setTextColor(config.textColor)
@ -329,8 +330,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private fun setupScrollDirection() { private fun setupScrollDirection() {
val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFiles == VIEW_TYPE_GRID val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFiles == VIEW_TYPE_GRID
media_refresh_layout.isEnabled = !config.scrollHorizontally
media_vertical_fastscroller.isHorizontal = false media_vertical_fastscroller.isHorizontal = false
media_vertical_fastscroller.beGoneIf(allowHorizontalScroll) media_vertical_fastscroller.beGoneIf(allowHorizontalScroll)

View File

@ -57,6 +57,7 @@ class SettingsActivity : SimpleActivity() {
setupShowMediaCount() setupShowMediaCount()
setupKeepLastModified() setupKeepLastModified()
setupShowInfoBubble() setupShowInfoBubble()
setupEnablePullToRefresh()
setupOneFingerZoom() setupOneFingerZoom()
setupAllowInstantChange() setupAllowInstantChange()
setupReplaceZoomableImages() setupReplaceZoomableImages()
@ -310,6 +311,14 @@ class SettingsActivity : SimpleActivity() {
} }
} }
private fun setupEnablePullToRefresh() {
settings_enable_pull_to_refresh.isChecked = config.enablePullToRefresh
settings_enable_pull_to_refresh_holder.setOnClickListener {
settings_enable_pull_to_refresh.toggle()
config.enablePullToRefresh = settings_enable_pull_to_refresh.isChecked
}
}
private fun setupOneFingerZoom() { private fun setupOneFingerZoom() {
settings_one_finger_zoom.isChecked = config.oneFingerZoom settings_one_finger_zoom.isChecked = config.oneFingerZoom
settings_one_finger_zoom_holder.setOnClickListener { settings_one_finger_zoom_holder.setOnClickListener {

View File

@ -233,10 +233,6 @@ class Config(context: Context) : BaseConfig(context) {
return Gson().fromJson<ArrayList<AlbumCover>>(albumCovers, listType) ?: ArrayList(1) return Gson().fromJson<ArrayList<AlbumCover>>(albumCovers, listType) ?: ArrayList(1)
} }
var scrollHorizontally: Boolean
get() = prefs.getBoolean(SCROLL_HORIZONTALLY, false)
set(scrollHorizontally) = prefs.edit().putBoolean(SCROLL_HORIZONTALLY, scrollHorizontally).apply()
var hideSystemUI: Boolean var hideSystemUI: Boolean
get() = prefs.getBoolean(HIDE_SYSTEM_UI, false) get() = prefs.getBoolean(HIDE_SYSTEM_UI, false)
set(hideSystemUI) = prefs.edit().putBoolean(HIDE_SYSTEM_UI, hideSystemUI).apply() set(hideSystemUI) = prefs.edit().putBoolean(HIDE_SYSTEM_UI, hideSystemUI).apply()

View File

@ -30,7 +30,6 @@ const val HIDE_FOLDER_TOOLTIP_SHOWN = "hide_folder_tooltip_shown"
const val EXCLUDED_FOLDERS = "excluded_folders" const val EXCLUDED_FOLDERS = "excluded_folders"
const val INCLUDED_FOLDERS = "included_folders" const val INCLUDED_FOLDERS = "included_folders"
const val ALBUM_COVERS = "album_covers" const val ALBUM_COVERS = "album_covers"
const val SCROLL_HORIZONTALLY = "scroll_horizontally"
const val HIDE_SYSTEM_UI = "hide_system_ui" const val HIDE_SYSTEM_UI = "hide_system_ui"
const val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate" const val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate"
const val DELETE_EMPTY_FOLDERS = "delete_empty_folders" const val DELETE_EMPTY_FOLDERS = "delete_empty_folders"

View File

@ -401,6 +401,29 @@
android:textAllCaps="true" android:textAllCaps="true"
android:textSize="@dimen/smaller_text_size"/> android:textSize="@dimen/smaller_text_size"/>
<RelativeLayout
android:id="@+id/settings_show_info_bubble_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/activity_margin"
android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_show_info_bubble"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/show_info_bubble"/>
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/settings_scroll_horizontally_holder" android:id="@+id/settings_scroll_horizontally_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -425,7 +448,7 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/settings_show_info_bubble_holder" android:id="@+id/settings_enable_pull_to_refresh_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin" android:layout_marginTop="@dimen/medium_margin"
@ -436,14 +459,14 @@
android:paddingTop="@dimen/activity_margin"> android:paddingTop="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat <com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_show_info_bubble" android:id="@+id/settings_enable_pull_to_refresh"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@null" android:background="@null"
android:clickable="false" android:clickable="false"
android:paddingLeft="@dimen/medium_margin" android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin" android:paddingStart="@dimen/medium_margin"
android:text="@string/show_info_bubble"/> android:text="@string/enable_pull_to_refresh"/>
</RelativeLayout> </RelativeLayout>