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

View file

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

View file

@ -1,68 +1,90 @@
<?xml version="1.0" encoding="utf-8"?> <?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" 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_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyTextView <com.google.android.material.appbar.AppBarLayout
android:id="@+id/directories_switch_searching" 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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" app:layout_behavior="@string/appbar_scrolling_view_behavior">
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/switch_to_file_search"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/directories_empty_placeholder" android:id="@+id/directories_switch_searching"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/directories_switch_searching"
android:alpha="0.8"
android:gravity="center_horizontal"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:text="@string/no_media_with_filters"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/directories_empty_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/directories_empty_placeholder"
android:layout_centerHorizontal="true"
android:background="@drawable/ripple_all_corners"
android:padding="@dimen/activity_margin"
android:text="@string/change_filters_underlined"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/directories_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/directories_switch_searching">
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/directories_fastscroller"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:supportSwipeToRefresh="true"> android:background="?attr/selectableItemBackground"
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/switch_to_file_search"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyRecyclerView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/directories_grid" android:id="@+id/directories_empty_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/directories_switch_searching"
android:alpha="0.8"
android:gravity="center_horizontal"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:text="@string/no_media_with_filters"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/directories_empty_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/directories_empty_placeholder"
android:layout_centerHorizontal="true"
android:background="@drawable/ripple_all_corners"
android:padding="@dimen/activity_margin"
android:text="@string/change_filters_underlined"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/directories_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/directories_switch_searching">
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/directories_fastscroller"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layoutAnimation="@anim/layout_animation" app:supportSwipeToRefresh="true">
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager"
app:spanCount="@integer/directory_columns_vertical_scroll" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller> <com.simplemobiletools.commons.views.MyRecyclerView
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> android:id="@+id/directories_grid"
</RelativeLayout> android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutAnimation="@anim/layout_animation"
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager"
app:spanCount="@integer/directory_columns_vertical_scroll" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

File diff suppressed because it is too large Load diff