Skip to content

Commit 171a4e4

Browse files
authored
Merge pull request #512 from Aga-C/pull-to-refresh-option
Added an option to disable pull-to-refresh (#223)
2 parents ef6cd65 + 2c9438d commit 171a4e4

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SettingsActivity.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SettingsActivity : SimpleActivity() {
3333
setupChangeDateTimeFormat()
3434
setupFontSize()
3535
setupShowHidden()
36+
setupEnablePullToRefresh()
3637
setupPressBackTwice()
3738
setupHiddenItemPasswordProtection()
3839
setupAppPasswordProtection()
@@ -52,7 +53,7 @@ class SettingsActivity : SimpleActivity() {
5253

5354
private fun setupSectionColors() {
5455
val adjustedPrimaryColor = getAdjustedPrimaryColor()
55-
arrayListOf(visibility_label, file_operations_label, security_label).forEach {
56+
arrayListOf(visibility_label, scrolling_label, file_operations_label, security_label).forEach {
5657
it.setTextColor(adjustedPrimaryColor)
5758
}
5859
}
@@ -125,6 +126,14 @@ class SettingsActivity : SimpleActivity() {
125126
config.showHidden = settings_show_hidden.isChecked
126127
}
127128

129+
private fun setupEnablePullToRefresh() {
130+
settings_enable_pull_to_refresh.isChecked = config.enablePullToRefresh
131+
settings_enable_pull_to_refresh_holder.setOnClickListener {
132+
settings_enable_pull_to_refresh.toggle()
133+
config.enablePullToRefresh = settings_enable_pull_to_refresh.isChecked
134+
}
135+
}
136+
128137
private fun setupPressBackTwice() {
129138
settings_press_back_twice.isChecked = config.pressBackTwice
130139
settings_press_back_twice_holder.setOnClickListener {

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
2424
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
2525
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
2626
import com.simplemobiletools.filemanager.pro.models.ListItem
27+
import kotlinx.android.synthetic.main.items_fragment.*
2728
import kotlinx.android.synthetic.main.items_fragment.view.*
2829
import java.io.File
2930
import java.util.*
@@ -63,6 +64,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
6364
if (currentPath != "") {
6465
breadcrumbs.updateColor(textColor)
6566
}
67+
items_swipe_refresh.isEnabled = activity?.config?.enablePullToRefresh != false
6668
}
6769

6870
override fun setupFontSize() {
@@ -378,7 +380,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
378380
skipItemUpdating = false
379381
lastSearchedText = ""
380382

381-
items_swipe_refresh.isEnabled = true
383+
items_swipe_refresh.isEnabled = activity?.config?.enablePullToRefresh != false
382384
items_fastscroller.beVisible()
383385
items_placeholder.beGone()
384386
items_placeholder_2.beGone()

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
7474
updateTextColor(textColor)
7575
initDrawables()
7676
}
77+
78+
recents_swipe_refresh.isEnabled = activity?.config?.enablePullToRefresh != false
7779
}
7880

7981
private fun setupLayoutManager() {

app/src/main/res/layout/activity_settings.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,39 @@
206206

207207
</RelativeLayout>
208208

209+
<com.simplemobiletools.commons.views.MyTextView
210+
android:id="@+id/scrolling_label"
211+
android:layout_width="wrap_content"
212+
android:layout_height="wrap_content"
213+
android:layout_marginStart="@dimen/bigger_margin"
214+
android:layout_marginTop="@dimen/section_margin"
215+
android:text="@string/scrolling"
216+
android:textAllCaps="true"
217+
android:textSize="@dimen/smaller_text_size" />
218+
219+
<RelativeLayout
220+
android:id="@+id/settings_enable_pull_to_refresh_holder"
221+
android:layout_width="match_parent"
222+
android:layout_height="wrap_content"
223+
android:layout_marginTop="@dimen/medium_margin"
224+
android:background="?attr/selectableItemBackground"
225+
android:paddingStart="@dimen/normal_margin"
226+
android:paddingTop="@dimen/activity_margin"
227+
android:paddingEnd="@dimen/normal_margin"
228+
android:paddingBottom="@dimen/activity_margin">
229+
230+
<com.simplemobiletools.commons.views.MySwitchCompat
231+
android:id="@+id/settings_enable_pull_to_refresh"
232+
android:layout_width="match_parent"
233+
android:layout_height="wrap_content"
234+
android:background="@null"
235+
android:clickable="false"
236+
android:paddingStart="@dimen/medium_margin"
237+
android:text="@string/enable_pull_to_refresh"
238+
app:switchPadding="@dimen/medium_margin" />
239+
240+
</RelativeLayout>
241+
209242
<com.simplemobiletools.commons.views.MyTextView
210243
android:id="@+id/file_operations_label"
211244
android:layout_width="wrap_content"

0 commit comments

Comments
 (0)