Skip to content

Commit 0c648d4

Browse files
committed
adding some top menu related improvements
1 parent 4e5d55b commit 0c648d4

File tree

7 files changed

+42
-28
lines changed

7 files changed

+42
-28
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ android {
5858
}
5959

6060
dependencies {
61-
implementation 'com.github.SimpleMobileTools:Simple-Commons:2e11262b38'
61+
implementation 'com.github.SimpleMobileTools:Simple-Commons:f07ca31126'
6262
implementation 'com.github.Stericson:RootTools:df729dcb13'
6363
implementation 'com.github.Stericson:RootShell:1.6'
6464
implementation 'com.alexvasilkov:gesture-views:2.5.2'

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ class MainActivity : SimpleActivity() {
414414
}
415415

416416
private fun toggleFilenameVisibility() {
417+
config.displayFilenames = !config.displayFilenames
417418
getAllFragments().forEach {
418419
it?.toggleFilenameVisibility()
419420
}
@@ -455,8 +456,10 @@ class MainActivity : SimpleActivity() {
455456
}
456457

457458
private fun changeViewType() {
458-
ChangeViewTypeDialog(this, getCurrentFragment().currentPath) {
459-
getCurrentFragment().refreshItems()
459+
ChangeViewTypeDialog(this, getCurrentFragment().currentPath, getCurrentFragment() is ItemsFragment) {
460+
getAllFragments().forEach {
461+
it?.refreshItems()
462+
}
460463
}
461464
}
462465

@@ -472,7 +475,9 @@ class MainActivity : SimpleActivity() {
472475

473476
private fun toggleTemporarilyShowHidden(show: Boolean) {
474477
config.temporarilyShowHidden = show
475-
openPath(getCurrentFragment().currentPath)
478+
getAllFragments().forEach {
479+
it?.refreshItems()
480+
}
476481
}
477482

478483
private fun launchAbout() {

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeViewTypeDialog.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ package com.simplemobiletools.filemanager.pro.dialogs
33
import android.view.View
44
import androidx.appcompat.app.AlertDialog
55
import com.simplemobiletools.commons.activities.BaseSimpleActivity
6+
import com.simplemobiletools.commons.extensions.beGone
7+
import com.simplemobiletools.commons.extensions.beVisibleIf
68
import com.simplemobiletools.commons.extensions.setupDialogStuff
79
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
810
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
911
import com.simplemobiletools.filemanager.pro.R
1012
import com.simplemobiletools.filemanager.pro.extensions.config
1113
import kotlinx.android.synthetic.main.dialog_change_view_type.view.*
1214

13-
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
15+
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String = "", showFolderCheck: Boolean = true, val callback: () -> Unit) {
1416
private var view: View
1517
private var config = activity.config
1618

@@ -24,6 +26,11 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String =
2426
}
2527

2628
change_view_type_dialog_radio.check(viewToCheck)
29+
if (!showFolderCheck) {
30+
use_for_this_folder_divider.beGone()
31+
change_view_type_dialog_use_for_this_folder.beGone()
32+
}
33+
2734
change_view_type_dialog_use_for_this_folder.apply {
2835
isChecked = config.hasCustomViewType(this@ChangeViewTypeDialog.path)
2936
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
477477
}
478478

479479
override fun toggleFilenameVisibility() {
480-
context?.config?.displayFilenames = !context!!.config.displayFilenames
481480
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
482481
}
483482

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
4444
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {}
4545

4646
private fun getRecents(callback: (recents: ArrayList<ListItem>) -> Unit) {
47+
val showHidden = context?.config?.shouldShowHidden ?: return
4748
val uri = MediaStore.Files.getContentUri("external")
4849
val projection = arrayOf(
4950
MediaStore.Files.FileColumns.DATA,
@@ -52,7 +53,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
5253
MediaStore.Files.FileColumns.SIZE
5354
)
5455

55-
val sortOrder = "${MediaStore.Files.FileColumns.DATE_MODIFIED} DESC LIMIT 50"
56+
val sortOrder = "${MediaStore.Files.FileColumns.DATE_MODIFIED} DESC"
5657
val cursor = context?.contentResolver?.query(uri, projection, null, null, sortOrder)
5758
val listItems = arrayListOf<ListItem>()
5859

@@ -64,7 +65,9 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
6465
val size = cursor.getLongValue(MediaStore.Files.FileColumns.SIZE)
6566
val modified = cursor.getLongValue(MediaStore.Files.FileColumns.DATE_MODIFIED) * 1000
6667
val fileDirItem = ListItem(path, name, false, 0, size, modified, false)
67-
listItems.add(fileDirItem)
68+
if (showHidden || !name.startsWith(".")) {
69+
listItems.add(fileDirItem)
70+
}
6871
} while (cursor.moveToNext())
6972
}
7073
}
@@ -77,12 +80,10 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
7780
private fun getRecyclerAdapter() = recents_list.adapter as? ItemsAdapter
7881

7982
override fun toggleFilenameVisibility() {
80-
context?.config?.displayFilenames = !context!!.config.displayFilenames
8183
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
8284
}
8385

8486
override fun increaseColumnCount() {
85-
context?.config?.fileColumnCnt = ++(recents_list.layoutManager as MyGridLayoutManager).spanCount
8687
columnCountChanged()
8788
}
8889

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
android:layout_height="match_parent"
3131
android:clipToPadding="false"
3232
android:layoutAnimation="@anim/layout_animation"
33+
android:paddingTop="@dimen/medium_margin"
3334
android:scrollbars="none"
3435
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" />
3536
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

app/src/main/res/menu/menu.xml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,73 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto">
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
44
<item
55
android:id="@+id/search"
66
android:icon="@drawable/ic_search_vector"
77
android:title="@string/search"
88
app:actionViewClass="androidx.appcompat.widget.SearchView"
9-
app:showAsAction="collapseActionView|always"/>
9+
app:showAsAction="collapseActionView|always" />
1010
<item
1111
android:id="@+id/go_home"
1212
android:icon="@drawable/ic_home_vector"
1313
android:title="@string/go_to_home_folder"
14-
app:showAsAction="always"/>
14+
app:showAsAction="always" />
1515
<item
1616
android:id="@+id/go_to_favorite"
1717
android:icon="@drawable/ic_folder_open_vector"
1818
android:title="@string/go_to_favorite"
19-
app:showAsAction="always"/>
19+
app:showAsAction="always" />
2020
<item
2121
android:id="@+id/sort"
2222
android:icon="@drawable/ic_sort_vector"
2323
android:title="@string/sort_by"
24-
app:showAsAction="ifRoom"/>
24+
app:showAsAction="ifRoom" />
2525
<item
2626
android:id="@+id/add_favorite"
2727
android:icon="@drawable/ic_star_off_vector"
2828
android:title="@string/add_to_favorites"
29-
app:showAsAction="ifRoom"/>
29+
app:showAsAction="ifRoom" />
3030
<item
3131
android:id="@+id/remove_favorite"
3232
android:icon="@drawable/ic_star_on_vector"
3333
android:title="@string/remove_from_favorites"
34-
app:showAsAction="ifRoom"/>
34+
app:showAsAction="ifRoom" />
3535
<item
3636
android:id="@+id/toggle_filename"
3737
android:icon="@drawable/ic_label_vector"
3838
android:title="@string/toggle_filename"
3939
app:showAsAction="ifRoom" />
40-
<item
41-
android:id="@+id/set_as_home"
42-
android:title="@string/set_as_home_folder"
43-
app:showAsAction="never"/>
4440
<item
4541
android:id="@+id/change_view_type"
42+
android:icon="@drawable/ic_change_view_vector"
4643
android:title="@string/change_view_type"
47-
app:showAsAction="never"/>
44+
app:showAsAction="ifRoom" />
45+
<item
46+
android:id="@+id/set_as_home"
47+
android:title="@string/set_as_home_folder"
48+
app:showAsAction="never" />
4849
<item
4950
android:id="@+id/temporarily_show_hidden"
5051
android:title="@string/temporarily_show_hidden"
51-
app:showAsAction="never"/>
52+
app:showAsAction="never" />
5253
<item
5354
android:id="@+id/stop_showing_hidden"
5455
android:title="@string/stop_showing_hidden"
55-
app:showAsAction="never"/>
56+
app:showAsAction="never" />
5657
<item
5758
android:id="@+id/increase_column_count"
5859
android:title="@string/increase_column_count"
59-
app:showAsAction="never"/>
60+
app:showAsAction="never" />
6061
<item
6162
android:id="@+id/reduce_column_count"
6263
android:title="@string/reduce_column_count"
63-
app:showAsAction="never"/>
64+
app:showAsAction="never" />
6465
<item
6566
android:id="@+id/settings"
6667
android:title="@string/settings"
67-
app:showAsAction="never"/>
68+
app:showAsAction="never" />
6869
<item
6970
android:id="@+id/about"
7071
android:title="@string/about"
71-
app:showAsAction="never"/>
72+
app:showAsAction="never" />
7273
</menu>

0 commit comments

Comments
 (0)