mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
add a setting button for managing shown tabs
This commit is contained in:
@@ -11,6 +11,7 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.dialogs.ManageVisibleTabsDialog
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
@@ -28,6 +29,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
setupUseEnglish()
|
setupUseEnglish()
|
||||||
setupManageFavorites()
|
setupManageFavorites()
|
||||||
|
setupManageShownTabs()
|
||||||
setupChangeDateTimeFormat()
|
setupChangeDateTimeFormat()
|
||||||
setupFontSize()
|
setupFontSize()
|
||||||
setupShowHidden()
|
setupShowHidden()
|
||||||
@@ -76,6 +78,12 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupManageShownTabs() {
|
||||||
|
settings_manage_tabs_holder.setOnClickListener {
|
||||||
|
ManageVisibleTabsDialog(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupChangeDateTimeFormat() {
|
private fun setupChangeDateTimeFormat() {
|
||||||
settings_change_date_time_format_holder.setOnClickListener {
|
settings_change_date_time_format_holder.setOnClickListener {
|
||||||
ChangeDateTimeFormatDialog(this) {}
|
ChangeDateTimeFormatDialog(this) {}
|
||||||
|
@@ -0,0 +1,49 @@
|
|||||||
|
package com.simplemobiletools.filemanager.pro.dialogs
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.commons.helpers.*
|
||||||
|
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
|
import com.simplemobiletools.filemanager.pro.helpers.ALL_TABS_MASK
|
||||||
|
|
||||||
|
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
||||||
|
private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_tabs, null)
|
||||||
|
private val tabs = LinkedHashMap<Int, Int>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
tabs.apply {
|
||||||
|
put(TAB_FILES, R.id.manage_visible_tabs_files)
|
||||||
|
put(TAB_RECENT_FILES, R.id.manage_visible_tabs_recent_files)
|
||||||
|
}
|
||||||
|
|
||||||
|
val showTabs = activity.config.showTabs
|
||||||
|
for ((key, value) in tabs) {
|
||||||
|
view.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder(activity)
|
||||||
|
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.create().apply {
|
||||||
|
activity.setupDialogStuff(view, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun dialogConfirmed() {
|
||||||
|
var result = 0
|
||||||
|
for ((key, value) in tabs) {
|
||||||
|
if (view.findViewById<MyAppCompatCheckbox>(value).isChecked) {
|
||||||
|
result += key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == 0) {
|
||||||
|
result = ALL_TABS_MASK
|
||||||
|
}
|
||||||
|
|
||||||
|
activity.config.showTabs = result
|
||||||
|
}
|
||||||
|
}
|
@@ -117,4 +117,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var displayFilenames: Boolean
|
var displayFilenames: Boolean
|
||||||
get() = prefs.getBoolean(DISPLAY_FILE_NAMES, true)
|
get() = prefs.getBoolean(DISPLAY_FILE_NAMES, true)
|
||||||
set(displayFilenames) = prefs.edit().putBoolean(DISPLAY_FILE_NAMES, displayFilenames).apply()
|
set(displayFilenames) = prefs.edit().putBoolean(DISPLAY_FILE_NAMES, displayFilenames).apply()
|
||||||
|
|
||||||
|
var showTabs: Int
|
||||||
|
get() = prefs.getInt(SHOW_TABS, ALL_TABS_MASK)
|
||||||
|
set(showTabs) = prefs.edit().putInt(SHOW_TABS, showTabs).apply()
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ const val VIEW_TYPE_PREFIX = "view_type_folder_"
|
|||||||
const val FILE_COLUMN_CNT = "file_column_cnt"
|
const val FILE_COLUMN_CNT = "file_column_cnt"
|
||||||
const val FILE_LANDSCAPE_COLUMN_CNT = "file_landscape_column_cnt"
|
const val FILE_LANDSCAPE_COLUMN_CNT = "file_landscape_column_cnt"
|
||||||
const val DISPLAY_FILE_NAMES = "display_file_names"
|
const val DISPLAY_FILE_NAMES = "display_file_names"
|
||||||
|
const val SHOW_TABS = "show_tabs"
|
||||||
|
|
||||||
// open as
|
// open as
|
||||||
const val OPEN_AS_DEFAULT = 0
|
const val OPEN_AS_DEFAULT = 0
|
||||||
|
@@ -76,6 +76,27 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_manage_tabs_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:paddingStart="@dimen/normal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
android:paddingEnd="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/settings_manage_tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:paddingStart="@dimen/medium_margin"
|
||||||
|
android:text="@string/manage_shown_tabs" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/settings_change_date_time_format_holder"
|
android:id="@+id/settings_change_date_time_format_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
33
app/src/main/res/layout/dialog_manage_visible_tabs.xml
Normal file
33
app/src/main/res/layout/dialog_manage_visible_tabs.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/manage_visible_tabs_scroll_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/manage_visible_tabs_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingStart="@dimen/activity_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
android:paddingEnd="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
|
android:id="@+id/manage_visible_tabs_files"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_margin"
|
||||||
|
android:text="@string/files_tab" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
|
android:id="@+id/manage_visible_tabs_recent_files"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_margin"
|
||||||
|
android:text="@string/recent_files_tab" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
Reference in New Issue
Block a user