-
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a setting button for managing shown tabs
- Loading branch information
Showing
6 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ManageVisibleTabsDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |