Commit 52d7c8fc authored by wanglei's avatar wanglei

...

parent 528765db
Pipeline #1385 canceled with stages
...@@ -209,6 +209,12 @@ public class StartActivity extends AppCompatActivity { ...@@ -209,6 +209,12 @@ public class StartActivity extends AppCompatActivity {
}); });
} }
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.e("jumpNext", "onNewIntent jumped=" + jumped.get());
jumpNext();
}
private void jumpNext() { private void jumpNext() {
Log.e("jumpNext", "jumped=" + jumped.get()); Log.e("jumpNext", "jumped=" + jumped.get());
......
...@@ -16,10 +16,12 @@ import androidx.core.app.NotificationCompat ...@@ -16,10 +16,12 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.swiftcleaner.chovey.R import com.swiftcleaner.chovey.R
import com.swiftcleaner.chovey.model.bean.Global
import com.swiftcleaner.chovey.model.bean.Global.NotificationStayCount import com.swiftcleaner.chovey.model.bean.Global.NotificationStayCount
import com.swiftcleaner.chovey.model.bean.Global.NotificationStayDelay import com.swiftcleaner.chovey.model.bean.Global.NotificationStayDelay
import com.swiftcleaner.chovey.model.bean.Global.NotificationStayStatus import com.swiftcleaner.chovey.model.bean.Global.NotificationStayStatus
import com.swiftcleaner.chovey.view.MainActivity import com.swiftcleaner.chovey.view.MainActivity
import com.swiftcleaner.chovey.view.activity.StartActivity
import com.zxdemo.ZxApplication.Companion.isAppInForeground import com.zxdemo.ZxApplication.Companion.isAppInForeground
import com.zxdemo.ZxApplication.Companion.isDeviceLocked import com.zxdemo.ZxApplication.Companion.isDeviceLocked
import com.zxdemo.ZxApplication.Companion.isScreenOn import com.zxdemo.ZxApplication.Companion.isScreenOn
...@@ -133,12 +135,22 @@ object NotificationUtils { ...@@ -133,12 +135,22 @@ object NotificationUtils {
notificationManager.notify(actionId, builder.build()) notificationManager.notify(actionId, builder.build())
} }
fun sendNotification(context: Context, action: String, value: String) { fun sendNotification(context: Context, action: String, value: String) {
var actionId = nextNotificationId var actionId = nextNotificationId
val bigRemoteViews = RemoteViews(context.packageName, R.layout.notification_common) val bigRemoteViews = RemoteViews(context.packageName, R.layout.notification_common)
val smallRemoteViews = RemoteViews(context.packageName, R.layout.notification_common_small) val smallRemoteViews = RemoteViews(context.packageName, R.layout.notification_common_small)
var intentAction = ""
when (actionId) { when (actionId) {
ID_CLEAN_JUNK -> { ID_CLEAN_JUNK -> {
bigRemoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.h_clean)
smallRemoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.h_clean)
val desc = "Clean out junk files to free up space on your phone!"
bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
intentAction = Global.FUNCTION_CLEAN
} }
ID_APP_MANAGER -> { ID_APP_MANAGER -> {
...@@ -162,14 +174,15 @@ object NotificationUtils { ...@@ -162,14 +174,15 @@ object NotificationUtils {
} }
val flag = PendingIntent.FLAG_IMMUTABLE val flag = PendingIntent.FLAG_IMMUTABLE
val btnRequestCode = Random().nextInt(1000) val btnRequestCode = Random().nextInt(1000)
var intent = Intent(context, MainActivity::class.java) val intent = Intent(context, StartActivity::class.java)
intent.putExtra("actionId", actionId) intent.putExtra("actionId", intentAction)
val btnPendingIntent = PendingIntent.getActivity(context, btnRequestCode, intent, flag) val btnPendingIntent = PendingIntent.getActivity(context, btnRequestCode, intent, flag)
bigRemoteViews.setOnClickPendingIntent(R.id.fl_btn, btnPendingIntent) bigRemoteViews.setOnClickPendingIntent(R.id.fl_btn, btnPendingIntent)
smallRemoteViews.setOnClickPendingIntent(R.id.tv_btn, btnPendingIntent) smallRemoteViews.setOnClickPendingIntent(R.id.tv_btn, btnPendingIntent)
val open = SpUtils.getInstance().getInt(NotificationStayStatus, 0) val open = SpUtils.getInstance().getInt(NotificationStayStatus, 0)
if (open == 1) { if (open == 1) {
return
val num = SpUtils.getInstance().getInt(NotificationStayCount, 5) val num = SpUtils.getInstance().getInt(NotificationStayCount, 5)
val delay = SpUtils.getInstance().getInt(NotificationStayDelay, 4000).toLong() val delay = SpUtils.getInstance().getInt(NotificationStayDelay, 4000).toLong()
handlerThread = HandlerThread("NotificationHandlerThread") handlerThread = HandlerThread("NotificationHandlerThread")
...@@ -191,7 +204,7 @@ object NotificationUtils { ...@@ -191,7 +204,7 @@ object NotificationUtils {
intent, intent,
bigRemoteViews, bigRemoteViews,
smallRemoteViews, smallRemoteViews,
"titletitle", "",
action, action,
value, isStay = true value, isStay = true
) )
...@@ -208,7 +221,7 @@ object NotificationUtils { ...@@ -208,7 +221,7 @@ object NotificationUtils {
intent, intent,
bigRemoteViews, bigRemoteViews,
smallRemoteViews, smallRemoteViews,
"titletitle", "",
action, action,
value, isStay = false value, isStay = false
) )
......
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