Commit b1551917 authored by wanglei's avatar wanglei

...

parent 1a82ca9b
...@@ -249,6 +249,7 @@ class DocumentFragment( ...@@ -249,6 +249,7 @@ class DocumentFragment(
(requireActivity() as MainActivity).changeSelectUI(false) (requireActivity() as MainActivity).changeSelectUI(false)
currentPage.changeSelectUi(false)
} }
} }
......
package com.base.pdfviewerscannerwhite.ui.main package com.base.pdfviewerscannerwhite.ui.main
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
...@@ -21,6 +22,7 @@ import com.base.pdfviewerscannerwhite.ui.document.excel.ExcelActivity ...@@ -21,6 +22,7 @@ import com.base.pdfviewerscannerwhite.ui.document.excel.ExcelActivity
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfActivity import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfActivity
import com.base.pdfviewerscannerwhite.ui.document.ppt.PptActivity import com.base.pdfviewerscannerwhite.ui.document.ppt.PptActivity
import com.base.pdfviewerscannerwhite.ui.document.word.WordActivity import com.base.pdfviewerscannerwhite.ui.document.word.WordActivity
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showAppExitDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission import com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
...@@ -102,15 +104,23 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView { ...@@ -102,15 +104,23 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
var isBookmarkAdd: Boolean = false var isBookmarkAdd: Boolean = false
var isToolAdd: Boolean = false var isToolAdd: Boolean = false
@SuppressLint("MissingSuperCall")
override fun onBackPressed() {
LogEx.logDebug(TAG, "onBackPressed")
showAppExitDialog()
}
//OnBackPressedCallback 并将 isEnabled 设置为 false 时,默认的返回键行为将被禁用。
lateinit var callback: OnBackPressedCallback lateinit var callback: OnBackPressedCallback
override fun initListener() { override fun initListener() {
super.initListener() super.initListener()
callback = object : OnBackPressedCallback(false) { callback = object : OnBackPressedCallback(false) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {
LogEx.logDebug(TAG, "handleOnBackPressed")
if (currentFragment is DocumentFragment) { if (currentFragment is DocumentFragment) {
val documentFragment = (currentFragment as DocumentFragment) val documentFragment = (currentFragment as DocumentFragment)
LogEx.logDebug(TAG, "handleOnBackPressed uiMode=${documentFragment.uiMode}")
if (documentFragment.uiMode == ConstObject.UI_MODE_SELECT) { if (documentFragment.uiMode == ConstObject.UI_MODE_SELECT) {
documentFragment.changeSelectUI(false) documentFragment.changeSelectUI(false)
} }
...@@ -118,9 +128,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView { ...@@ -118,9 +128,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
documentFragment.changeSearchUI(false) documentFragment.changeSearchUI(false)
} }
} }
} }
} }
onBackPressedDispatcher.addCallback(callback) onBackPressedDispatcher.addCallback(callback)
......
...@@ -9,6 +9,7 @@ import android.view.View ...@@ -9,6 +9,7 @@ import android.view.View
import android.view.WindowManager import android.view.WindowManager
import androidx.core.widget.addTextChangedListener import androidx.core.widget.addTextChangedListener
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_FINAL_MODIFIED import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_FINAL_MODIFIED
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_LAST_MODIFIED import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_LAST_MODIFIED
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_NAME_A_Z import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_NAME_A_Z
...@@ -439,7 +440,7 @@ object DialogView { ...@@ -439,7 +440,7 @@ object DialogView {
} }
} }
fun Context.showAppExitDialog() { fun Activity.showAppExitDialog() {
val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog) val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog)
val binding = DialogAppExitBinding.inflate(LayoutInflater.from(this)) val binding = DialogAppExitBinding.inflate(LayoutInflater.from(this))
dialog.setContentView(binding.root) dialog.setContentView(binding.root)
...@@ -451,5 +452,14 @@ object DialogView { ...@@ -451,5 +452,14 @@ object DialogView {
val behavior = BottomSheetBehavior.from(parentView) val behavior = BottomSheetBehavior.from(parentView)
//展开 //展开
behavior.state = BottomSheetBehavior.STATE_EXPANDED behavior.state = BottomSheetBehavior.STATE_EXPANDED
AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_app_exit)
binding.tvNo.setOnClickListener {
finish()
}
binding.tvYes.setOnClickListener {
dialog.dismiss()
}
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00B5DC" />
<corners android:radius="10dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topLeftRadius="15dp" android:bottomRightRadius="15dp"/>
<solid android:color="#BFE8F3"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#F1F4F9" />
<corners android:radius="15dp" />
</shape>
\ No newline at end of file
...@@ -7,40 +7,41 @@ ...@@ -7,40 +7,41 @@
android:background="@drawable/bg_ffffff_tlf25" android:background="@drawable/bg_ffffff_tlf25"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
<TextView <TextView
android:id="@+id/tv_tip" android:id="@+id/tv_tip"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="28dp" android:layout_marginTop="28dp"
android:text="Are you sure want to exit the app?" android:text="Are you sure want to exit the app?"
android:textColor="#333333" android:textColor="#333333"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<LinearLayout
<FrameLayout
android:id="@+id/fl_ad"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp" android:layout_marginHorizontal="16dp"
android:background="@color/white" android:layout_marginTop="8dp"
android:orientation="vertical" android:gravity="center_horizontal"
app:layout_constraintBottom_toBottomOf="parent" tools:ignore="Autofill,HardcodedText,LabelFor,TextFields">
app:layout_constraintTop_toBottomOf="@id/tv_tip">
<TextView <View
android:id="@+id/tv_tips"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="30dp" />
android:layout_marginHorizontal="16dp" </FrameLayout>
android:layout_marginTop="32dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:paddingHorizontal="20dp"
android:singleLine="true"
android:textColor="#333333"
android:textSize="18sp"
tools:ignore="Autofill,HardcodedText,LabelFor,TextFields" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -56,7 +57,7 @@ ...@@ -56,7 +57,7 @@
android:layout_height="48dp" android:layout_height="48dp"
app:cardBackgroundColor="#f1f2f6" app:cardBackgroundColor="#f1f2f6"
app:cardCornerRadius="10dp" app:cardCornerRadius="10dp"
app:cardElevation="5dp"> app:cardElevation="0dp">
<TextView <TextView
android:id="@+id/tv_no" android:id="@+id/tv_no"
...@@ -64,7 +65,7 @@ ...@@ -64,7 +65,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:text="@string/cancel" android:text="@string/exit"
android:textColor="#505050" android:textColor="#505050"
android:textSize="18sp" android:textSize="18sp"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
...@@ -78,7 +79,7 @@ ...@@ -78,7 +79,7 @@
android:layout_marginStart="14dp" android:layout_marginStart="14dp"
app:cardBackgroundColor="#00B8DE" app:cardBackgroundColor="#00B8DE"
app:cardCornerRadius="10dp" app:cardCornerRadius="10dp"
app:cardElevation="5dp" app:cardElevation="0dp"
tools:ignore="HardcodedText"> tools:ignore="HardcodedText">
<TextView <TextView
...@@ -86,7 +87,7 @@ ...@@ -86,7 +87,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="@string/ok" android:text="@string/cancel"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="18sp" /> android:textSize="18sp" />
......
<com.google.android.gms.ads.nativead.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/bg_f1f4f9_15">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:baselineAligned="false"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_bfe8f3_tl15_br15"
android:paddingHorizontal="8dp"
android:paddingVertical="5dp"
android:text="Ad"
android:textColor="#00B5DC"
android:textSize="12sp"
tools:ignore="HardcodedText" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/ad_app_icon"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="8dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/ad_headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="#001D29"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/ad_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<com.google.android.gms.ads.nativead.MediaView
android:id="@+id/ad_media"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="10dp" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/ad_call_to_action"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="8dp"
android:background="@drawable/bg_00b5dc_10"
android:gravity="center"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="15sp"
tools:text="Install" />
</LinearLayout>
</com.google.android.gms.ads.nativead.NativeAdView>
\ No newline at end of file
...@@ -70,5 +70,6 @@ ...@@ -70,5 +70,6 @@
<string name="thursday">Thursday</string> <string name="thursday">Thursday</string>
<string name="friday">Friday</string> <string name="friday">Friday</string>
<string name="saturday">Saturday</string> <string name="saturday">Saturday</string>
<string name="exit">Exit</string>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment