Commit bfa4cd0d authored by wanglei's avatar wanglei

...

parent 12e4231e
...@@ -45,6 +45,11 @@ object ConstObject { ...@@ -45,6 +45,11 @@ object ConstObject {
const val NOTIFICATION_ACTION_BOOKMARK = "notification_action_bookmark" const val NOTIFICATION_ACTION_BOOKMARK = "notification_action_bookmark"
const val NOTIFICATION_ACTION_NEW_IMAGE_PDF = "notification_action_new_image_pdf" const val NOTIFICATION_ACTION_NEW_IMAGE_PDF = "notification_action_new_image_pdf"
const val NOTIFICATION_ACTION_READ_PDF = "notification_action_read_pdf"
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_IMPORTANT_DOCUMENT = "notification_action_important_document"
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"
const val SHORTCUT_MERGE_PDF = "shortcut_merge_pdf" const val SHORTCUT_MERGE_PDF = "shortcut_merge_pdf"
......
...@@ -12,7 +12,11 @@ import android.widget.RemoteViews ...@@ -12,7 +12,11 @@ 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_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_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_UN_VIEW_FILES
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_count import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_count
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_end import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_end
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_interval import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_interval
...@@ -115,6 +119,46 @@ object NotificationUiUtil { ...@@ -115,6 +119,46 @@ object NotificationUiUtil {
smallRemoteViews.setTextViewText(R.id.tv_desc, desc) smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
} }
NOTIFICATION_ACTION_READ_PDF -> {
val tittle = context.getString(R.string.read_your_pdf_file)
val desc = context.getString(R.string.did_you_miss_this_pdf_file)
bigRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
}
NOTIFICATION_ACTION_READ_DOCUMENTS -> {
val tittle = context.getString(R.string.read_more_phone_documents)
val desc = context.getString(R.string.click_to_read_and_edit_your_document)
bigRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
}
NOTIFICATION_ACTION_UN_VIEW_FILES -> {
val tittle = context.getString(R.string.there_are_unviewed_files)
val desc = context.getString(R.string.click_to_read_now)
bigRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
}
NOTIFICATION_ACTION_IMPORTANT_DOCUMENT -> {
val tittle = context.getString(R.string.don_t_miss_important_documents)
val desc = context.getString(R.string.view_now)
bigRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
}
} }
} }
...@@ -187,4 +231,20 @@ object NotificationUiUtil { ...@@ -187,4 +231,20 @@ object NotificationUiUtil {
lastPopupTime = System.currentTimeMillis() lastPopupTime = System.currentTimeMillis()
} }
val looper_actionId = listOf(
NOTIFICATION_ACTION_READ_PDF,
NOTIFICATION_ACTION_READ_DOCUMENTS,
NOTIFICATION_ACTION_UN_VIEW_FILES,
NOTIFICATION_ACTION_IMPORTANT_DOCUMENT
)
var actionIdList = arrayListOf<String>()
fun getNextActionId(): String {
if (actionIdList.isEmpty()) {
actionIdList.addAll(looper_actionId)
}
val next = actionIdList[0]
actionIdList.removeAt(0)
return next
}
} }
\ No newline at end of file
package com.base.pdfviewerscannerwhite.fcm;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import com.base.pdfviewerscannerwhite.utils.AppPreferences;
import java.util.Objects;
public class ScreenStatusReceiver extends BroadcastReceiver {
private static boolean isDeviceInteractive = true;
private static boolean isSecureLockActive = false;
public static void setupScreenStatusListener(Context context) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_USER_PRESENT);
final Context applicationContext = context.getApplicationContext();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
applicationContext.registerReceiver(new ScreenStatusReceiver(), intentFilter, Context.RECEIVER_EXPORTED);
} else {
applicationContext.registerReceiver(new ScreenStatusReceiver(), intentFilter);
}
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
switch (Objects.requireNonNull(action)) {
case Intent.ACTION_SCREEN_ON:
setDeviceInteractive(true);
break;
case Intent.ACTION_SCREEN_OFF:
setDeviceInteractive(false);
setSecureLockActive(true);
break;
case Intent.ACTION_USER_PRESENT:
setSecureLockActive(false);
if (isDeviceInteractive() && !isSecureLockActive()) {
int secureSetting = Integer.parseInt(AppPreferences.getInstance().getString("lockS", "1"));
if (secureSetting == 1) {
String actionId = NotificationUiUtil.INSTANCE.getNextActionId();
NotificationUiUtil.INSTANCE.sendNotification(context, actionId);
}
}
break;
}
}
private void setDeviceInteractive(boolean interactive) {
isDeviceInteractive = interactive;
}
public static boolean isDeviceInteractive() {
return isDeviceInteractive;
}
private void setSecureLockActive(boolean active) {
isSecureLockActive = active;
}
public static boolean isSecureLockActive() {
return isSecureLockActive;
}
}
\ No newline at end of file
...@@ -6,6 +6,7 @@ import android.content.Intent ...@@ -6,6 +6,7 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import com.base.pdfviewerscannerwhite.fcm.FCMManager import com.base.pdfviewerscannerwhite.fcm.FCMManager
import com.base.pdfviewerscannerwhite.fcm.ScreenStatusReceiver
import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils import com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
...@@ -69,6 +70,7 @@ class MyApplication : Application() { ...@@ -69,6 +70,7 @@ class MyApplication : Application() {
FCMManager.subscribeToTopic(topic) FCMManager.subscribeToTopic(topic)
InstallHelps.init() InstallHelps.init()
initLifeListener() initLifeListener()
ScreenStatusReceiver.setupScreenStatusListener(this)
} }
......
...@@ -85,5 +85,13 @@ ...@@ -85,5 +85,13 @@
<string name="preparing_advertisement">Preparing advertisement...</string> <string name="preparing_advertisement">Preparing advertisement...</string>
<string name="new_image_for_creating_pdf">New image for creating PDF</string> <string name="new_image_for_creating_pdf">New image for creating PDF</string>
<string name="edit_images_to_create_pdf_files">Edit images to create PDF files</string> <string name="edit_images_to_create_pdf_files">Edit images to create PDF files</string>
<string name="read_your_pdf_file">Read your PDF file</string>
<string name="did_you_miss_this_pdf_file">Did you miss this PDF file?</string>
<string name="read_more_phone_documents">Read more phone documents</string>
<string name="click_to_read_and_edit_your_document">Click to read and edit your document</string>
<string name="there_are_unviewed_files">There are unviewed files</string>
<string name="click_to_read_now">Click to read now</string>
<string name="don_t_miss_important_documents">Don\'t miss important documents</string>
<string name="view_now">View Now</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