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,38 +312,51 @@ 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) {
R.id.sort -> showSortingDialog()
R.id.filter -> showFilterMediaDialog()
R.id.open_camera -> launchCamera()
R.id.show_all -> showAllMedia()
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 super.onOptionsItemSelected(item)
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()
R.id.show_all -> showAllMedia()
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) {
@ -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,68 +1,90 @@
<?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="wrap_content">
android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/directories_switch_searching"
<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"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/switch_to_file_search"
android:visibility="gone" />
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.simplemobiletools.commons.views.MyTextView
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"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/directories_switch_searching"
android:layout_width="match_parent"
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
android:id="@+id/directories_grid"
<com.simplemobiletools.commons.views.MyTextView
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_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" />
android:layout_height="wrap_content"
app:supportSwipeToRefresh="true">
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/directories_grid"
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