Commit 54ffa893 authored by wanglei's avatar wanglei

...

parent 863297d4
...@@ -51,6 +51,8 @@ object ConstObject { ...@@ -51,6 +51,8 @@ object ConstObject {
const val NOTIFICATION_ACTION_READ_DOCUMENTS = "notification_action_read_documents" const val NOTIFICATION_ACTION_READ_DOCUMENTS = "notification_action_read_documents"
const val NOTIFICATION_ACTION_UN_VIEW_FILES = "notification_action_un_view_files" const val NOTIFICATION_ACTION_UN_VIEW_FILES = "notification_action_un_view_files"
const val NOTIFICATION_ACTION_IMPORTANT_DOCUMENT = "notification_action_important_document" const val NOTIFICATION_ACTION_IMPORTANT_DOCUMENT = "notification_action_important_document"
const val NOTIFICATION_ACTION_APP_PROCESS = "notification_action_app_process"
const val NOTIFICATION_ACTION_CLEAN_JUNK = "notification_action_clean_junk"
const val SHORTCUT_SCAN_PDF = "shortcut_scan_pdf" const val SHORTCUT_SCAN_PDF = "shortcut_scan_pdf"
const val SHORTCUT_SPLIT_PDF = "shortcut_split_pdf" const val SHORTCUT_SPLIT_PDF = "shortcut_split_pdf"
......
...@@ -12,6 +12,8 @@ import android.widget.RemoteViews ...@@ -12,6 +12,8 @@ import android.widget.RemoteViews
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.IconCompat import androidx.core.graphics.drawable.IconCompat
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_APP_PROCESS
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_CLEAN_JUNK
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_IMPORTANT_DOCUMENT import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_IMPORTANT_DOCUMENT
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_DOCUMENTS import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_DOCUMENTS
...@@ -30,9 +32,12 @@ import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_status ...@@ -30,9 +32,12 @@ import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_status
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_timer_interval import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_timer_interval
import com.base.pdfviewerscannerwhite.helper.EventUtils import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.ui.cleanjunk.ScanJunkActivity.Companion.fastGetJunkSize
import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.RamUtils.ramPair
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar import java.util.Calendar
import java.util.Locale import java.util.Locale
...@@ -199,6 +204,40 @@ object NotificationUiUtil { ...@@ -199,6 +204,40 @@ object NotificationUiUtil {
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
} }
NOTIFICATION_ACTION_APP_PROCESS -> {
val pair = MyApplication.context.ramPair()
val percent = (pair.first * 100 / pair.second).toInt()
val desc = "Memory is $percent% used"
val smallRemoteViewsVar = RemoteViews(context.packageName, R.layout.notification_memory_small_1)
smallRemoteViewsVar.setProgressBar(R.id.progress_bar, percent, 100, false)
smallRemoteViewsVar.setTextViewText(R.id.tv_desc, desc)
val btnRequestCode = Random.nextInt(1000)
smallRemoteViewsVar.setOnClickPendingIntent(
R.id.tv_btn,
PendingIntent.getActivity(context, btnRequestCode, intent, PendingIntent.FLAG_IMMUTABLE)
)
val bigRemoteViewsVar = RemoteViews(context.packageName, R.layout.notification_memory_big)
sendCustomNotification(context, intent, bigRemoteViewsVar, smallRemoteViewsVar)
}
NOTIFICATION_ACTION_CLEAN_JUNK -> {
var size = fastGetJunkSize(context)
if (size == 0L) {
size = Random.nextLong(1024 * 5, 1024 * 10)
}
val bigRemoteViewsVar = RemoteViews(context.packageName, R.layout.notification_junk_big)
bigRemoteViewsVar.setTextViewText(R.id.tv_size, size.toFormatSize())
val smallRemoteViewsVar = RemoteViews(context.packageName, R.layout.notification_junk_small)
smallRemoteViewsVar.setTextViewText(R.id.tv_size, size.toFormatSize())
sendCustomNotification(context, intent, bigRemoteViewsVar, smallRemoteViewsVar)
}
else -> { else -> {
EventUtils.event("Notification_Error", "unKnow actionId actionId=$actionId") EventUtils.event("Notification_Error", "unKnow actionId actionId=$actionId")
} }
...@@ -267,10 +306,14 @@ object NotificationUiUtil { ...@@ -267,10 +306,14 @@ object NotificationUiUtil {
} }
val looper_actionId = listOf( val looper_actionId = listOf(
NOTIFICATION_ACTION_CLEAN_JUNK,
NOTIFICATION_ACTION_READ_PDF, NOTIFICATION_ACTION_READ_PDF,
NOTIFICATION_ACTION_READ_DOCUMENTS, NOTIFICATION_ACTION_READ_DOCUMENTS,
NOTIFICATION_ACTION_UN_VIEW_FILES, NOTIFICATION_ACTION_UN_VIEW_FILES,
NOTIFICATION_ACTION_IMPORTANT_DOCUMENT NOTIFICATION_ACTION_IMPORTANT_DOCUMENT,
NOTIFICATION_ACTION_APP_PROCESS,
NOTIFICATION_ACTION_CLEAN_JUNK
) )
var actionIdList = arrayListOf<String>() var actionIdList = arrayListOf<String>()
......
...@@ -17,7 +17,9 @@ import com.base.pdfviewerscannerwhite.ads.admob.AdmobBannerUtils ...@@ -17,7 +17,9 @@ import com.base.pdfviewerscannerwhite.ads.admob.AdmobBannerUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_APP_PROCESS
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_BOOKMARK import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_BOOKMARK
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_CLEAN_JUNK
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_DOCUMENT import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_DOCUMENT
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.RECENT_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.RECENT_DATA_TYPE
...@@ -30,6 +32,8 @@ import com.base.pdfviewerscannerwhite.bean.DocumentBean ...@@ -30,6 +32,8 @@ import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityMainBinding import com.base.pdfviewerscannerwhite.databinding.ActivityMainBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.helper.MyApplication import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.ui.appprocess.AppProcessActivity
import com.base.pdfviewerscannerwhite.ui.cleanjunk.ScanJunkActivity
import com.base.pdfviewerscannerwhite.ui.document.excel.ExcelActivity 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.pdf.PdfSelectActivity import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfSelectActivity
...@@ -135,6 +139,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -135,6 +139,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
if (actionId == NOTIFICATION_ACTION_NEW_IMAGE_PDF) { if (actionId == NOTIFICATION_ACTION_NEW_IMAGE_PDF) {
useGmsScanFunction() useGmsScanFunction()
} }
if (actionId == NOTIFICATION_ACTION_APP_PROCESS) {
startActivity(Intent(this, AppProcessActivity::class.java))
}
if (actionId == NOTIFICATION_ACTION_CLEAN_JUNK) {
startActivity(Intent(this, ScanJunkActivity::class.java))
}
} }
private fun closeScanGuide() { private fun closeScanGuide() {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#0571ED" />
<corners android:radius="18dp" />
</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="#ffffff" />
<corners android:radius="15dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 设置背景色 -->
<item android:id="@android:id/background">
<shape>
<solid android:color="#E5E8ED" />
<corners android:radius="2.5dp" />
</shape>
</item>
<!-- 设置进度条颜色 -->
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="2.5dp" />
<solid android:color="#FD4242" />
</shape>
</scale>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="14dp"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:src="@mipmap/moren_logo"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:includeFontPadding="false"
android:text="@string/app_name"
android:textColor="#ff4e4e4e"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:orientation="horizontal">
<ImageView
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="20dp"
android:src="@mipmap/clean"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="8dp"
android:orientation="vertical">
<TextView
android:id="@+id/tv_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF3722"
android:textSize="28sp"
android:textStyle="bold"
tools:text="397KB" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Found a lot of junk files"
android:textColor="@color/black"
android:textSize="14sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_btn"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginHorizontal="25dp"
android:layout_marginVertical="16dp"
android:background="@drawable/bg_0571ed_25"
android:gravity="center"
android:text="Clean"
android:textColor="@color/white"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/bg_ffffff_15">
<ImageView
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:src="@mipmap/clean"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tv_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="2dp"
android:textColor="#FF3722"
android:textSize="15sp"
android:textStyle="bold"
tools:text="1000MB" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="6dp"
android:layout_weight="1"
android:ellipsize="end"
android:singleLine="true"
android:text="Found a lot of junk files"
android:textColor="@color/black"
android:textSize="14sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tv_btn"
android:layout_width="69dp"
android:layout_height="34dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="12dp"
android:background="@drawable/bg_0571ed_25"
android:gravity="center"
android:text="Clean"
android:textColor="@color/white"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<ImageView
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="20dp"
android:src="@mipmap/d_process"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="8dp"
android:orientation="vertical">
<TextView
android:id="@+id/tv_tittle_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile phone memory usage is high?"
android:textColor="@color/black"
android:textSize="14sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tv_tittle_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="App installation successful"
android:textColor="#898989"
android:textSize="12sp"
android:visibility="gone"
tools:ignore="HardcodedText" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_btn"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginHorizontal="25dp"
android:layout_marginVertical="16dp"
android:background="@drawable/bg_0571ed_25"
android:gravity="center"
android:text="Clean"
android:textColor="@color/white"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/bg_ffffff_15">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:src="@mipmap/process_notification"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="7dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="14sp"
tools:text="Memory is 73% used" />
<ProgressBar
android:id="@+id/progress_bar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginTop="6dp"
android:max="100"
android:progressDrawable="@drawable/progressbar_appprocess_notifi"
tools:progress="75" />
</LinearLayout>
<TextView
android:id="@+id/tv_btn"
android:layout_width="69dp"
android:layout_height="34dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="13dp"
android:background="@drawable/bg_0571ed_18"
android:gravity="center"
android:text="Scan"
android:textColor="@color/white"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
\ No newline at end of file
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:src="@mipmap/imagepdf_notifi" android:src="@mipmap/image_notification"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
......
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