restyling media activity
This commit is contained in:
parent
4ed9b0be5c
commit
3a9dc3e28d
2 changed files with 121 additions and 85 deletions
|
@ -101,6 +101,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
return
|
||||
}
|
||||
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
storeStateVariables()
|
||||
|
||||
if (mShowAll) {
|
||||
|
@ -158,6 +160,15 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
setupAdapter()
|
||||
}
|
||||
|
||||
val navigation = if (mShowAll) {
|
||||
NavigationIcon.None
|
||||
} else {
|
||||
NavigationIcon.Arrow
|
||||
}
|
||||
|
||||
setupToolbar(media_toolbar, navigation, searchMenuItem = mSearchMenuItem)
|
||||
refreshMenuItems()
|
||||
|
||||
media_fastscroller.updateColors(primaryColor)
|
||||
media_refresh_layout.isEnabled = config.enablePullToRefresh
|
||||
getMediaAdapter()?.apply {
|
||||
|
@ -169,10 +180,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
media_empty_text_placeholder_2.setTextColor(getProperPrimaryColor())
|
||||
media_empty_text_placeholder_2.bringToFront()
|
||||
|
||||
if (!mIsSearchOpen) {
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
// do not refresh Random sorted files after opening a fullscreen image and going Back
|
||||
val isRandomSorting = config.getFolderSorting(mPath) and SORT_BY_RANDOM != 0
|
||||
if (mMedia.isEmpty() || !isRandomSorting || (isRandomSorting && !mWasFullscreenViewOpen)) {
|
||||
|
@ -227,12 +234,18 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_media, menu)
|
||||
override fun onBackPressed() {
|
||||
if (mIsSearchOpen && mSearchMenuItem != null) {
|
||||
mSearchMenuItem!!.collapseActionView()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshMenuItems() {
|
||||
val isDefaultFolder = !config.defaultFolder.isEmpty() && File(config.defaultFolder).compareTo(File(mPath)) == 0
|
||||
|
||||
menu.apply {
|
||||
media_toolbar.menu.apply {
|
||||
findItem(R.id.group).isVisible = !config.scrollHorizontally
|
||||
|
||||
findItem(R.id.empty_recycle_bin).isVisible = mPath == RECYCLE_BIN
|
||||
|
@ -255,14 +268,12 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
findItem(R.id.reduce_column_count).isVisible = viewType == VIEW_TYPE_GRID && config.mediaColumnCnt > 1
|
||||
findItem(R.id.toggle_filename).isVisible = viewType == VIEW_TYPE_GRID
|
||||
}
|
||||
|
||||
setupSearch(menu)
|
||||
updateMenuItemColors(menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
private fun setupOptionsMenu() {
|
||||
setupSearch(media_toolbar.menu)
|
||||
media_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.sort -> showSortingDialog()
|
||||
R.id.filter -> showFilterMediaDialog()
|
||||
R.id.empty_recycle_bin -> emptyRecycleBin()
|
||||
|
@ -283,9 +294,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
R.id.slideshow -> startSlideshow()
|
||||
R.id.settings -> launchSettings()
|
||||
R.id.about -> launchAbout()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
else -> return@setOnMenuItemClickListener false
|
||||
}
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun startSlideshow() {
|
||||
|
@ -390,7 +402,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
mPath == config.OTGPath -> getString(R.string.usb)
|
||||
else -> getHumanizedFilename(mPath)
|
||||
}
|
||||
//updateActionBarTitle(if (mShowAll) resources.getString(R.string.all_folders) else dirName)
|
||||
|
||||
media_toolbar.title = if (mShowAll) resources.getString(R.string.all_folders) else dirName
|
||||
getMedia()
|
||||
setupLayoutManager()
|
||||
} else {
|
||||
|
@ -525,7 +538,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
|
||||
private fun changeViewType() {
|
||||
ChangeViewTypeDialog(this, false, mPath) {
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
setupLayoutManager()
|
||||
media_grid.adapter = null
|
||||
setupAdapter()
|
||||
|
@ -653,7 +666,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
mLoadedInitialPhotos = false
|
||||
config.temporarilyShowHidden = show
|
||||
getMedia()
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
|
||||
private fun setupLayoutManager() {
|
||||
|
@ -755,7 +768,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
|
||||
private fun columnCountChanged() {
|
||||
handleGridSpacing()
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
getMediaAdapter()?.apply {
|
||||
notifyItemRangeChanged(0, media.size)
|
||||
}
|
||||
|
@ -947,11 +960,11 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
|
||||
private fun setAsDefaultFolder() {
|
||||
config.defaultFolder = mPath
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
|
||||
private fun unsetAsDefaultFolder() {
|
||||
config.defaultFolder = ""
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,32 @@
|
|||
<?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/media_holder"
|
||||
android:id="@+id/media_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/media_app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/media_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/color_primary"
|
||||
app:menu="@menu/menu_media"
|
||||
app:title="@string/app_launcher_name"
|
||||
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/media_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/media_empty_text_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -53,4 +75,5 @@
|
|||
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
Loading…
Reference in a new issue