updating the remaining activities

This commit is contained in:
tibbi 2022-07-23 23:06:40 +02:00
parent 70848a1840
commit 8aa0536dcf
6 changed files with 220 additions and 148 deletions

View file

@ -2,12 +2,11 @@ package com.simplemobiletools.filemanager.pro.activities
import android.graphics.Paint
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.filemanager.pro.R
import com.simplemobiletools.filemanager.pro.adapters.ManageFavoritesAdapter
@ -18,21 +17,23 @@ class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_favorites)
setupOptionsMenu()
updateFavorites()
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_favorites, menu)
updateMenuItemColors(menu)
return true
override fun onResume() {
super.onResume()
setupToolbar(manage_favorites_toolbar, NavigationIcon.Arrow)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.add_favorite -> addFavorite()
else -> return super.onOptionsItemSelected(item)
private fun setupOptionsMenu() {
manage_favorites_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.add_favorite -> addFavorite()
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
return true
}
private fun updateFavorites() {

View file

@ -10,6 +10,7 @@ import androidx.appcompat.widget.SearchView
import androidx.core.view.MenuItemCompat
import androidx.recyclerview.widget.GridLayoutManager
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
@ -26,7 +27,6 @@ import com.simplemobiletools.filemanager.pro.helpers.*
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
import com.simplemobiletools.filemanager.pro.models.ListItem
import kotlinx.android.synthetic.main.activity_mimetypes.*
import kotlinx.android.synthetic.main.items_fragment.view.*
import java.util.*
class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
@ -41,8 +41,11 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_mimetypes)
setupOptionsMenu()
refreshMenuItems()
currentMimeType = intent.getStringExtra(SHOW_MIMETYPE) ?: return
title = getString(
mimetypes_toolbar.title = getString(
when (currentMimeType) {
IMAGES -> R.string.images
VIDEOS -> R.string.videos
@ -65,17 +68,15 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
mimetypes_fastscroller.updateColors(getProperPrimaryColor())
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu, menu)
setupSearch(menu)
updateMenuItemColors(menu)
return true
override fun onResume() {
super.onResume()
setupToolbar(mimetypes_toolbar, NavigationIcon.Arrow, searchMenuItem = searchMenuItem)
}
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
private fun refreshMenuItems() {
val currentViewType = config.getFolderViewType(currentMimeType)
menu!!.apply {
mimetypes_toolbar.menu.apply {
findItem(R.id.add_favorite).isVisible = false
findItem(R.id.remove_favorite).isVisible = false
findItem(R.id.go_to_favorite).isVisible = false
@ -92,23 +93,23 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
findItem(R.id.increase_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT
findItem(R.id.reduce_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt > 1
}
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.sort -> showSortingDialog()
R.id.toggle_filename -> toggleFilenameVisibility()
R.id.change_view_type -> changeViewType()
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount()
else -> return super.onOptionsItemSelected(item)
private fun setupOptionsMenu() {
setupSearch(mimetypes_toolbar.menu)
mimetypes_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.sort -> showSortingDialog()
R.id.toggle_filename -> toggleFilenameVisibility()
R.id.change_view_type -> changeViewType()
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount()
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
return true
}
override fun refreshFragment() {

View file

@ -6,12 +6,11 @@ import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.print.PrintAttributes
import android.print.PrintManager
import android.view.Menu
import android.view.MenuItem
import android.view.WindowInsetsController
import android.view.WindowManager
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.isPiePlus
import com.simplemobiletools.commons.helpers.isRPlus
@ -27,9 +26,10 @@ class PDFViewerActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_pdf_viewer)
setupOptionsMenu()
refreshMenuItems()
if (checkAppSideloading()) {
return
@ -41,7 +41,7 @@ class PDFViewerActivity : SimpleActivity() {
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
realFilePath = intent.extras?.get(REAL_FILE_PATH)?.toString() ?: ""
supportActionBar?.title = realFilePath.getFilenameFromPath()
pdf_viewer_toolbar.title = realFilePath.getFilenameFromPath()
}
checkIntent()
@ -55,24 +55,24 @@ class PDFViewerActivity : SimpleActivity() {
supportActionBar?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
window.statusBarColor = Color.TRANSPARENT
setTranslucentNavigation()
setupToolbar(pdf_viewer_toolbar, NavigationIcon.Arrow)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_pdf_viewer, menu)
menu.apply {
private fun setupOptionsMenu() {
pdf_viewer_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.menu_print -> printText()
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
}
private fun refreshMenuItems() {
pdf_viewer_toolbar.menu.apply {
findItem(R.id.menu_print).isVisible = realFilePath.isNotEmpty()
}
updateMenuItemColors(menu, forceWhiteIcons = true)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_print -> printText()
else -> return super.onOptionsItemSelected(item)
}
return true
}
private fun checkIntent() {
@ -98,7 +98,7 @@ class PDFViewerActivity : SimpleActivity() {
val filename = getFilenameFromUri(uri)
if (filename.isNotEmpty()) {
supportActionBar?.title = filename
pdf_viewer_toolbar.title = filename
}
}

View file

@ -1,48 +1,71 @@
<?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:tools="http://schemas.android.com/tools"
android:id="@+id/manage_favorites_wrapper"
android:id="@+id/manage_favorites_coordinator"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/manage_favorites_list"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/manage_favorites_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"
tools:itemCount="4"
tools:listitem="@layout/item_manage_favorite" />
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/manage_favorites_placeholder"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/manage_favorites_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_favorites"
app:title="@string/manage_favorites"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/manage_favorites_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/small_margin"
android:alpha="0.8"
android:gravity="center"
android:lineSpacingExtra="@dimen/tiny_margin"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:text="@string/favorites_activity_placeholder"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/manage_favorites_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/manage_favorites_placeholder"
android:layout_centerHorizontal="true"
android:background="@drawable/ripple_all_corners"
android:gravity="center"
android:padding="@dimen/normal_margin"
android:text="@string/add_favorites"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/manage_favorites_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"
tools:itemCount="4"
tools:listitem="@layout/item_manage_favorite" />
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/manage_favorites_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/small_margin"
android:alpha="0.8"
android:gravity="center"
android:lineSpacingExtra="@dimen/tiny_margin"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:text="@string/favorites_activity_placeholder"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/manage_favorites_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/manage_favorites_placeholder"
android:layout_centerHorizontal="true"
android:background="@drawable/ripple_all_corners"
android:gravity="center"
android:padding="@dimen/normal_margin"
android:text="@string/add_favorites"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,54 +1,77 @@
<?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/mimetypes_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:id="@+id/mimetypes_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/mimetypes_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:alpha="0.8"
android:gravity="center"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:text="@string/no_items_found"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/mimetypes_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mimetypes_placeholder"
android:layout_centerHorizontal="true"
android:alpha="0.8"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/type_2_characters"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/mimetypes_fastscroller"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/mimetypes_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/mimetypes_list"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/mimetypes_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layoutAnimation="@anim/layout_animation"
android:paddingTop="@dimen/small_margin"
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" />
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu"
app:title=""
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/mimetypes_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/mimetypes_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:alpha="0.8"
android:gravity="center"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:text="@string/no_items_found"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/mimetypes_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mimetypes_placeholder"
android:layout_centerHorizontal="true"
android:alpha="0.8"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/type_2_characters"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/mimetypes_fastscroller"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/mimetypes_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layoutAnimation="@anim/layout_animation"
android:paddingTop="@dimen/small_margin"
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,19 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pdf_viewer_wrapper"
<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/pdf_viewer_coordinator"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdf_viewer"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/pdf_viewer_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="wrap_content">
<ImageView
android:id="@+id/top_shadow"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/pdf_viewer_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_pdf_viewer"
app:title="@string/pdf_viewer"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/pdf_viewer_wrapper"
android:layout_width="match_parent"
android:layout_height="@dimen/default_status_action_height"
android:background="@drawable/gradient_background_flipped"
android:contentDescription="@null" />
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</RelativeLayout>
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdf_viewer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/top_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/default_status_action_height"
android:background="@drawable/gradient_background_flipped"
android:contentDescription="@null" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>