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,37 +268,36 @@ 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) {
|
||||
R.id.sort -> showSortingDialog()
|
||||
R.id.filter -> showFilterMediaDialog()
|
||||
R.id.empty_recycle_bin -> emptyRecycleBin()
|
||||
R.id.empty_disable_recycle_bin -> emptyAndDisableRecycleBin()
|
||||
R.id.restore_all_files -> restoreAllFiles()
|
||||
R.id.toggle_filename -> toggleFilenameVisibility()
|
||||
R.id.open_camera -> launchCamera()
|
||||
R.id.folder_view -> switchToFolderView()
|
||||
R.id.change_view_type -> changeViewType()
|
||||
R.id.group -> showGroupByDialog()
|
||||
R.id.create_new_folder -> createNewFolder()
|
||||
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
|
||||
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
|
||||
R.id.increase_column_count -> increaseColumnCount()
|
||||
R.id.reduce_column_count -> reduceColumnCount()
|
||||
R.id.set_as_default_folder -> setAsDefaultFolder()
|
||||
R.id.unset_as_default_folder -> unsetAsDefaultFolder()
|
||||
R.id.slideshow -> startSlideshow()
|
||||
R.id.settings -> launchSettings()
|
||||
R.id.about -> launchAbout()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
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()
|
||||
R.id.empty_disable_recycle_bin -> emptyAndDisableRecycleBin()
|
||||
R.id.restore_all_files -> restoreAllFiles()
|
||||
R.id.toggle_filename -> toggleFilenameVisibility()
|
||||
R.id.open_camera -> launchCamera()
|
||||
R.id.folder_view -> switchToFolderView()
|
||||
R.id.change_view_type -> changeViewType()
|
||||
R.id.group -> showGroupByDialog()
|
||||
R.id.create_new_folder -> createNewFolder()
|
||||
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
|
||||
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
|
||||
R.id.increase_column_count -> increaseColumnCount()
|
||||
R.id.reduce_column_count -> reduceColumnCount()
|
||||
R.id.set_as_default_folder -> setAsDefaultFolder()
|
||||
R.id.unset_as_default_folder -> unsetAsDefaultFolder()
|
||||
R.id.slideshow -> startSlideshow()
|
||||
R.id.settings -> launchSettings()
|
||||
R.id.about -> launchAbout()
|
||||
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,56 +1,79 @@
|
|||
<?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="wrap_content">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/media_empty_text_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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/media_empty_text_placeholder_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/media_empty_text_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/media_refresh_layout"
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/media_app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/media_fastscroller"
|
||||
<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"
|
||||
android:layout_height="wrap_content"
|
||||
app:supportSwipeToRefresh="true">
|
||||
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.MyRecyclerView
|
||||
android:id="@+id/media_grid"
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/media_empty_text_placeholder_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/media_empty_text_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/media_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/media_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/media_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/media_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/media_columns_vertical_scroll" />
|
||||
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
Loading…
Reference in a new issue