updating main and settings activities

This commit is contained in:
tibbi 2022-07-27 12:03:34 +02:00
parent c5f56edf66
commit 4ed9b0be5c
5 changed files with 1191 additions and 1128 deletions

View File

@ -78,7 +78,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:2327fff588'
implementation 'com.github.SimpleMobileTools:Simple-Commons:becd38a3b7'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'

View File

@ -109,6 +109,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent ||
mIsGetAnyContentIntent || mIsSetWallpaperIntent
setupOptionsMenu()
refreshMenuItems()
directories_refresh_layout.setOnRefreshListener { getDirectories() }
storeStateVariables()
checkWhatsNewDialog()
@ -179,6 +182,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
mDateFormat = config.dateFormat
mTimeFormat = getTimeFormat()
setupToolbar(directories_toolbar, searchMenuItem = mSearchMenuItem)
refreshMenuItems()
if (mStoredAnimateGifs != config.animateGifs) {
getRecyclerAdapter()?.updateAnimateGifs(config.animateGifs)
}
@ -221,7 +227,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
directories_empty_placeholder_2.bringToFront()
if (!mIsSearchOpen) {
invalidateOptionsMenu()
refreshMenuItems()
if (mIsPasswordProtectionPending && !mWasProtectionHandled) {
handleAppPasswordProtection {
mWasProtectionHandled = it
@ -278,7 +284,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
override fun onBackPressed() {
if (config.groupDirectSubfolders) {
if (mIsSearchOpen && mSearchMenuItem != null) {
mSearchMenuItem!!.collapseActionView()
} else if (config.groupDirectSubfolders) {
if (mCurrentPathPrefix.isEmpty()) {
super.onBackPressed()
} else {
@ -291,13 +299,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
if (mIsThirdPartyIntent) {
menuInflater.inflate(R.menu.menu_main_intent, menu)
} else {
menuInflater.inflate(R.menu.menu_main, menu)
private fun refreshMenuItems() {
if (!mIsThirdPartyIntent) {
val useBin = config.useRecycleBin
menu.apply {
directories_toolbar.menu.apply {
findItem(R.id.increase_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt < MAX_COLUMN_COUNT
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1
findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders
@ -307,18 +312,30 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
}
menu.findItem(R.id.temporarily_show_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && !config.shouldShowHidden
menu.findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden
directories_toolbar.menu.apply {
findItem(R.id.temporarily_show_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && !config.shouldShowHidden
findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden
menu.findItem(R.id.temporarily_show_excluded).isVisible = !menu.findItem(R.id.temporarily_show_hidden).isVisible && !config.temporarilyShowExcluded
menu.findItem(R.id.stop_showing_excluded).isVisible = !menu.findItem(R.id.temporarily_show_hidden).isVisible && config.temporarilyShowExcluded
updateMenuItemColors(menu)
return true
findItem(R.id.temporarily_show_excluded).isVisible = !findItem(R.id.temporarily_show_hidden).isVisible && !config.temporarilyShowExcluded
findItem(R.id.stop_showing_excluded).isVisible = !findItem(R.id.temporarily_show_hidden).isVisible && config.temporarilyShowExcluded
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
private fun setupOptionsMenu() {
val menuId = if (mIsThirdPartyIntent) {
R.menu.menu_main_intent
} else {
R.menu.menu_main
}
directories_toolbar.inflateMenu(menuId)
if (!mIsThirdPartyIntent) {
setupSearch(directories_toolbar.menu)
}
directories_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.sort -> showSortingDialog()
R.id.filter -> showFilterMediaDialog()
R.id.open_camera -> launchCamera()
@ -336,9 +353,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
R.id.set_as_default_folder -> setAsDefaultFolder()
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
else -> return super.onOptionsItemSelected(item)
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
return true
}
override fun onSaveInstanceState(outState: Bundle) {
@ -553,7 +571,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun changeViewType() {
ChangeViewTypeDialog(this, true) {
invalidateOptionsMenu()
refreshMenuItems()
setupLayoutManager()
directories_grid.adapter = null
setupAdapter(getRecyclerAdapter()?.dirs ?: mDirs)
@ -575,7 +593,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
config.temporarilyShowHidden = show
directories_grid.adapter = null
getDirectories()
invalidateOptionsMenu()
refreshMenuItems()
}
private fun tryToggleTemporarilyShowExcluded() {
@ -593,7 +611,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
config.temporarilyShowExcluded = show
directories_grid.adapter = null
getDirectories()
invalidateOptionsMenu()
refreshMenuItems()
}
override fun deleteFolders(folders: ArrayList<File>) {
@ -724,7 +742,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun toggleRecycleBin(show: Boolean) {
config.showRecycleBinAtFolders = show
invalidateOptionsMenu()
refreshMenuItems()
ensureBackgroundThread {
var dirs = getCurrentlyDisplayedDirs()
if (!show) {
@ -756,7 +774,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
private fun columnCountChanged() {
invalidateOptionsMenu()
refreshMenuItems()
getRecyclerAdapter()?.apply {
notifyItemRangeChanged(0, dirs.size)
}
@ -1162,7 +1180,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun setAsDefaultFolder() {
config.defaultFolder = ""
invalidateOptionsMenu()
refreshMenuItems()
}
private fun openDefaultFolder() {

View File

@ -35,6 +35,7 @@ class SettingsActivity : SimpleActivity() {
override fun onResume() {
super.onResume()
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
setupSettingItems()
}
@ -89,7 +90,6 @@ class SettingsActivity : SimpleActivity() {
setupClearCache()
setupExportSettings()
setupImportSettings()
invalidateOptionsMenu()
arrayOf(
settings_color_customization_label,

View File

@ -1,10 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/directories_holder"
android:id="@+id/directories_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/directories_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/directories_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/directories_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/directories_switch_searching"
android:layout_width="match_parent"
@ -65,4 +86,5 @@
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,10 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/settings_scrollview"
android:id="@+id/settings_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/settings_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/settings_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/settings"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/settings_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="@+id/settings_holder"
android:layout_width="match_parent"
@ -1043,4 +1065,5 @@
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>