Commit 658fc74b authored by wanglei's avatar wanglei

...

parent bcef19c1
......@@ -36,5 +36,12 @@ class NotificationSendBean(
const val ACTION_ID_TEXT = "action_id_text"
const val ACTION_ID_EMAIL = "action_id_email"
const val ACTION_ID_WEBSITE = "action_id_website"
const val ACTION_ID_CLEAN_JUNK = "action_id_clean_junk"
const val ACTION_ID_WEATHER = "action_id_weather"
const val ACTION_ID_APP_PROCESS = "action_id_app_process"
const val ACTION_ID_WHATSAPP = "action_id_whatsapp"
const val ACTION_ID_SCREEN_SHORT = "action_id_screen_short"
const val ACTION_ID_SIMILAR = "action_id_similar"
const val ACTION_ID_CONSTELLATION = "action_id_constellation"
}
}
\ No newline at end of file
......@@ -4,10 +4,17 @@ import android.content.Context
import com.base.scanqrclear.BuildConfig
import com.base.scanqrclear.MyApplication
import com.base.scanqrclear.bean.NotificationSendBean
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_APP_PROCESS
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_CLEAN_JUNK
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_CONSTELLATION
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_EMAIL
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_SCAN
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_SCREEN_SHORT
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_SIMILAR
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_TEXT
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WEATHER
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WEBSITE
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WHATSAPP
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WIFI
import com.base.scanqrclear.bean.NotificationSendBean.Companion.POPUP_WHERE_ALARM
import com.base.scanqrclear.bean.NotificationSendBean.Companion.POPUP_WHERE_BATTERY
......@@ -47,6 +54,13 @@ object MyNotificationManager {
ACTION_ID_TEXT,
ACTION_ID_EMAIL,
ACTION_ID_WEBSITE,
ACTION_ID_CLEAN_JUNK,
ACTION_ID_WEATHER,
ACTION_ID_APP_PROCESS,
ACTION_ID_WHATSAPP,
ACTION_ID_SCREEN_SHORT,
ACTION_ID_SIMILAR,
ACTION_ID_CONSTELLATION,
)
private var actionIdList = arrayListOf<String>()
......
......@@ -13,12 +13,23 @@ import androidx.core.graphics.drawable.IconCompat
import com.base.scanqrclear.MyApplication
import com.base.scanqrclear.R
import com.base.scanqrclear.bean.NotificationSendBean
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_APP_PROCESS
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_CLEAN_JUNK
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_CONSTELLATION
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_EMAIL
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_SCAN
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_SCREEN_SHORT
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_SIMILAR
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_TEXT
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WEATHER
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WEBSITE
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WHATSAPP
import com.base.scanqrclear.bean.NotificationSendBean.Companion.ACTION_ID_WIFI
import com.base.scanqrclear.bean.WeatherBean
import com.base.scanqrclear.luma.WeatherUtils
import com.base.scanqrclear.ui.start.StartActivity
import com.base.scanqrclear.utils.TimeUtils.formatATime
import com.base.scanqrclear.utils.TimeUtils.isDayOrNight
import kotlin.random.Random
/**
......@@ -104,6 +115,113 @@ object NotificationUiUtil {
sendBean.smallRemoteViews = smallRemoteViews
}
ACTION_ID_CLEAN_JUNK -> {
val smallRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_small)
smallRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.clean_junk_pop))
val bigRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_large)
bigRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.clean_junk_pop))
bigRemoteViews.setImageViewResource(R.id.iv_image, R.mipmap.icon_junk_scan1)
sendBean.bigRemoteViews = bigRemoteViews
sendBean.smallRemoteViews = smallRemoteViews
}
ACTION_ID_APP_PROCESS -> {
val smallRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_small)
smallRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.app_process_pop))
val bigRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_large)
bigRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.app_process_pop))
bigRemoteViews.setImageViewResource(R.id.iv_image, R.mipmap.icon_app_process_1)
sendBean.bigRemoteViews = bigRemoteViews
sendBean.smallRemoteViews = smallRemoteViews
}
ACTION_ID_WHATSAPP -> {
val smallRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_small)
smallRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.whatsapp_pop))
val bigRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_large)
bigRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.whatsapp_pop))
bigRemoteViews.setImageViewResource(R.id.iv_image, R.mipmap.icon_whatsapp_1)
sendBean.bigRemoteViews = bigRemoteViews
sendBean.smallRemoteViews = smallRemoteViews
}
ACTION_ID_SCREEN_SHORT -> {
val smallRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_small)
smallRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.screen_pop))
val bigRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_large)
bigRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.screen_pop))
bigRemoteViews.setImageViewResource(R.id.iv_image, R.mipmap.icon_screenshot_1)
sendBean.bigRemoteViews = bigRemoteViews
sendBean.smallRemoteViews = smallRemoteViews
}
ACTION_ID_SIMILAR -> {
val smallRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_small)
smallRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.similar_pop))
val bigRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_common_large)
bigRemoteViews.setTextViewText(R.id.tv_content, MyApplication.appContext.getString(R.string.similar_pop))
bigRemoteViews.setImageViewResource(R.id.iv_image, R.mipmap.icon_similar)
sendBean.bigRemoteViews = bigRemoteViews
sendBean.smallRemoteViews = smallRemoteViews
}
ACTION_ID_CONSTELLATION -> {
val smallRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_constellation_small)
val bigRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_constellation_big)
sendBean.bigRemoteViews = bigRemoteViews
sendBean.smallRemoteViews = smallRemoteViews
}
ACTION_ID_WEATHER -> {
val weatherBean: WeatherBean = WeatherUtils.getWeatherEntity() ?: return
if (weatherBean.list.isEmpty()) return
val subBean = weatherBean.list[0]
val smallRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_weather_small)
smallRemoteViews.setTextViewText(R.id.tv_city, weatherBean.city)
val min = subBean.tempMin.toInt()
val max = subBean.tempMax.toInt()
smallRemoteViews.setTextViewText(R.id.tv_wendu_now, Random.nextInt(min, max).toString())
val icon = when (WeatherUtils.getWeatherType(subBean.iconDay.toInt())) {
"Sunny day" -> R.mipmap.d_qing
"Cloudy day" -> R.mipmap.d_yin
"Rainy day" -> R.mipmap.d_dayu
"Snowy day" -> R.mipmap.d_xiaxue
"Greasy day" -> R.mipmap.d_wumaishachengbao
"Unknown" -> R.mipmap.d_qing
else -> R.mipmap.d_qing
}
smallRemoteViews.setImageViewResource(R.id.iv_weather, icon)
smallRemoteViews.setTextViewText(R.id.tv_wendu_range, "$min℃/$max℃")
val bigRemoteViews = RemoteViews(MyApplication.appContext.packageName, R.layout.notification_weather_big)
bigRemoteViews.setImageViewResource(R.id.iv_weather_11h, icon)
bigRemoteViews.setImageViewResource(R.id.iv_weather_14h, icon)
bigRemoteViews.setImageViewResource(R.id.iv_weather_17h, icon)
bigRemoteViews.setImageViewResource(R.id.iv_weather_20h, icon)
bigRemoteViews.setImageViewResource(R.id.iv_weather_23h, icon)
bigRemoteViews.setImageViewResource(R.id.iv_weather, icon)
bigRemoteViews.setTextViewText(R.id.tv_wendu_11h, Random.nextInt(min, max).toString())
bigRemoteViews.setTextViewText(R.id.tv_wendu_14h, Random.nextInt(min, max).toString())
bigRemoteViews.setTextViewText(R.id.tv_wendu_17h, Random.nextInt(min, max).toString())
bigRemoteViews.setTextViewText(R.id.tv_wendu_20h, Random.nextInt(min, max).toString())
bigRemoteViews.setTextViewText(R.id.tv_wendu_23h, Random.nextInt(min, max).toString())
bigRemoteViews.setTextViewText(R.id.tv_wendu_now, Random.nextInt(min, max).toString())
bigRemoteViews.setTextViewText(R.id.tv_day_desc, if (isDayOrNight()) subBean.textDay else subBean.textNight)
bigRemoteViews.setTextViewText(R.id.tv_weather_info, "$min℃/$max℃ ${formatATime()}")
}
}
val intent = Intent(sendBean.context, StartActivity::class.java)
......@@ -171,4 +289,6 @@ object NotificationUiUtil {
notificationManager.notify(sendBean.notificationId, builder.build())
}
}
\ No newline at end of file
package com.base.scanqrclear.utils
import android.annotation.SuppressLint
import java.text.SimpleDateFormat
import java.util.Calendar
object TimeUtils {
fun isDayOrNight(): Boolean {
val calendar: Calendar = Calendar.getInstance()
val hour: Int = calendar.get(Calendar.HOUR_OF_DAY)
// 假设早上6点到晚上6点是白天
return if (hour in 6..17) {
// "现在是白天。"
true
} else {
// "现在是晚上。"
false
}
}
@SuppressLint("SimpleDateFormat")
fun formatATime(): String {
val calendar = Calendar.getInstance()
// 格式化时间为 "AM 9:50" 格式
val sdf = SimpleDateFormat("a hh:mm")
return sdf.format(calendar.time)
}
fun isTimeBetweenEightAndTenPM(): Boolean {
val now = Calendar.getInstance()
val hour = now[Calendar.HOUR_OF_DAY] // 获取当前小时数(24小时制)
// 检查当前时间是否在 8 点到 22 点之间
return hour in 8..21
}
fun isTimeBetweenWan17toWan23(): Boolean {
val calendar = Calendar.getInstance()
val currentHour = calendar.get(Calendar.HOUR_OF_DAY) // 获取当前小时数(24小时制)
val isEvening = currentHour in 17..22 // Kotlin中的in运算符用于判断范围
return if (isEvening) {
// 当前时间是晚上17点到23点之间
true
} else {
// 当前时间不是晚上17点到23点之间
false
}
}
@SuppressLint("SimpleDateFormat")
fun Long.formatTimeH(): String {
val dateFormat = SimpleDateFormat("yyyy-M-d H")
return dateFormat.format(this)
}
}
\ 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="#0571ED" />
<corners android:radius="25dp" />
</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:radius="15dp" />
<solid android:color="@color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/white_background">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="24dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/icon_smart" />
<TextView
android:id="@+id/tv_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@string/notification_clean_junk"
android:textColor="@color/color_181b1f"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:gravity="center"
android:background="@drawable/gradient"
android:text="@string/clean"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="33dp"
android:layout_alignParentStart="true"
android:src="@mipmap/img_guangbiao_tuisong" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp"
android:textColor="@color/colorPrimary" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="8dp"
android:paddingEnd="12dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="10dp"
android:gravity="center_vertical"
android:text="@string/notification_clean_junk"
android:textColor="@color/color_181b1f"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingStart="14dp"
android:paddingEnd="14dp"
android:text="@string/clean"
android:textColor="@color/white"
android:textSize="12sp"
android:textStyle="bold"
android:background="@drawable/gradient" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_alignParentEnd="true"
android:src="@mipmap/img_guangbiao_tuisong" />
<TextView
android:id="@+id/tv_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp"
android:textColor="@color/colorPrimary" />
</RelativeLayout>
\ 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_xingzuo"
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="Check out your luck today!"
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: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/x_xingzuo"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tv_desc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="7dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:textColor="@color/black"
android:textSize="14sp"
android:text="Check out your luck today!"
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="13dp"
android:background="@drawable/bg_0571ed_18"
android:gravity="center"
android:text="View"
android:textColor="@color/white"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:background="@mipmap/x_tianqibg"
tools:ignore="ContentDescription" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_wendu_now"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:textColor="@color/white"
android:textSize="30sp"
tools:text="20" />
<TextView
android:textSize="14sp"
android:id="@+id/tv_c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/tv_wendu_now"
android:layout_toEndOf="@id/tv_wendu_now"
android:text="℃"
android:textColor="@color/white"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/iv_weather"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignTop="@id/tv_wendu_now"
android:layout_alignBottom="@id/tv_wendu_now"
android:layout_toEndOf="@id/tv_c"
android:src="@mipmap/d_qing"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="22dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/tishiicon"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tv_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="4dp"
android:textColor="@color/white"
android:textSize="13sp"
tools:text="Cheney" />
</LinearLayout>
<TextView
android:id="@+id/tv_wendu_range"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="15sp"
tools:text="19℃/36℃" />
</LinearLayout>
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
......@@ -281,5 +281,10 @@
<string name="device_ready">Device Ready</string>
<string name="loading_point">loading...</string>
<string name="files">Files</string>
<string name="clean_junk_pop">Clean out junk files to free up space on your phone!</string>
<string name="app_process_pop">app process management for smooth performance.</string>
<string name="whatsapp_pop">Clear whatsapp file to free up space!</string>
<string name="screen_pop">Clear screenshot clutter to free up space!</string>
<string name="similar_pop">Clear similar file to free up space!</string>
</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