lets actually use a different toolbar at the pdf viewer
This commit is contained in:
parent
8aa0536dcf
commit
6c815df53d
|
@ -2,15 +2,14 @@ package com.simplemobiletools.filemanager.pro.activities
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.print.PrintAttributes
|
||||
import android.print.PrintManager
|
||||
import android.view.WindowInsetsController
|
||||
import android.view.WindowManager
|
||||
import android.widget.RelativeLayout
|
||||
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
|
||||
|
@ -26,17 +25,15 @@ class PDFViewerActivity : SimpleActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
useDynamicTheme = false
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_pdf_viewer)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
if (checkAppSideloading()) {
|
||||
return
|
||||
}
|
||||
|
||||
window.decorView.setBackgroundColor(getProperBackgroundColor())
|
||||
top_shadow.layoutParams.height = statusBarHeight + actionBarHeight
|
||||
checkNotchSupport()
|
||||
|
||||
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
||||
|
@ -44,6 +41,7 @@ class PDFViewerActivity : SimpleActivity() {
|
|||
pdf_viewer_toolbar.title = realFilePath.getFilenameFromPath()
|
||||
}
|
||||
|
||||
setupMenu()
|
||||
checkIntent()
|
||||
if (isRPlus()) {
|
||||
window.insetsController?.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
||||
|
@ -52,26 +50,22 @@ class PDFViewerActivity : SimpleActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
supportActionBar?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
window.statusBarColor = Color.TRANSPARENT
|
||||
setTranslucentNavigation()
|
||||
setupToolbar(pdf_viewer_toolbar, NavigationIcon.Arrow)
|
||||
}
|
||||
|
||||
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() {
|
||||
private fun setupMenu() {
|
||||
(pdf_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||
pdf_viewer_toolbar.menu.apply {
|
||||
findItem(R.id.menu_print).isVisible = realFilePath.isNotEmpty()
|
||||
findItem(R.id.menu_print).setOnMenuItemClickListener {
|
||||
printText()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pdf_viewer_toolbar.setNavigationOnClickListener {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,6 +116,15 @@ class PDFViewerActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
top_shadow.animate().alpha(newAlpha).start()
|
||||
pdf_viewer_appbar.animate().alpha(newAlpha).withStartAction {
|
||||
if (newAlpha == 1f) {
|
||||
pdf_viewer_appbar.beVisible()
|
||||
}
|
||||
}.withEndAction {
|
||||
if (newAlpha == 0f) {
|
||||
pdf_viewer_appbar.beGone()
|
||||
}
|
||||
}.start()
|
||||
|
||||
// return false to also toggle scroll handle
|
||||
return true
|
||||
|
|
|
@ -1,43 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout 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:id="@+id/pdf_viewer_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<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/top_shadow_height"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/gradient_background_flipped"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/pdf_viewer_app_bar_layout"
|
||||
android:id="@+id/pdf_viewer_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp">
|
||||
|
||||
<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" />
|
||||
app:navigationIcon="@drawable/ic_arrow_left_vector" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/pdf_viewer_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<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>
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue