[new] new project
@@ -0,0 +1,2 @@
|
||||
/build
|
||||
/release/
|
||||
@@ -0,0 +1,108 @@
|
||||
import com.android.build.api.variant.FilterConfiguration
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.koin.compiler)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.xingheyuzhuan.shiguangschedule"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.starschedule"
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
splits {
|
||||
abi {
|
||||
isEnable = true
|
||||
exclude("mips", "mips64", "armeabi", "riscv64", "x86")
|
||||
isUniversalApk = false
|
||||
include("armeabi-v7a", "arm64-v8a", "x86_64")
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
androidResources {
|
||||
generateLocaleConfig = false
|
||||
localeFilters += listOf("zh", "zh-rCN")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":shared"))
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
implementation(libs.androidx.work.runtime.ktx)
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.foundation)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.animation)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.compose.components.resources)
|
||||
implementation(libs.androidx.datastore.core)
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
implementation(libs.kotlinx.datetime)
|
||||
implementation(platform(libs.koin.bom))
|
||||
implementation(libs.koin.core)
|
||||
implementation(libs.koin.android)
|
||||
implementation(libs.koin.androidx.workmanager)
|
||||
implementation(libs.koin.compose)
|
||||
implementation(libs.koin.compose.viewmodel)
|
||||
implementation(libs.koin.annotations)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
}
|
||||
|
||||
androidComponents {
|
||||
onVariants { variant ->
|
||||
val buildType = variant.buildType ?: ""
|
||||
val versionName = android.defaultConfig.versionName ?: ""
|
||||
|
||||
variant.outputs.forEach { output ->
|
||||
val abiFilter = output.filters.find {
|
||||
it.filterType == FilterConfiguration.FilterType.ABI
|
||||
}?.identifier ?: "universal"
|
||||
|
||||
// 动态设置输出的 APK 文件名
|
||||
output.outputFileName.set("starschedule-v${versionName}-${abiFilter}-${buildType}.apk")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
# -------------------------------------------------------------------------
|
||||
# R8/ProGuard 混淆配置文件
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# 基础全局设置 ---
|
||||
-keepattributes SourceFile,LineNumberTable,Signature,InnerClasses,EnclosingMethod,AnnotationDefault,*Annotation*
|
||||
|
||||
# 依赖注入 (Koin) ---
|
||||
# 保留 Koin 核心类及 DSL 相关
|
||||
-keep class org.koin.** { *; }
|
||||
|
||||
# 保留 Koin Annotations 及其生成的模块 (KSP 路径)
|
||||
-keep class org.koin.ksp.generated.** { *; }
|
||||
-keep @org.koin.core.annotation.Module class * { *; }
|
||||
|
||||
# 确保 Koin 能够调用被注解类的构造函数进行依赖注入
|
||||
-keepclassmembers class * {
|
||||
@org.koin.core.annotation.Single <init>(...);
|
||||
@org.koin.core.annotation.Factory <init>(...);
|
||||
@org.koin.core.annotation.KoinViewModel <init>(...);
|
||||
@org.koin.core.annotation.Named <init>(...);
|
||||
}
|
||||
|
||||
# 原生组件与 WorkManager
|
||||
-keep public class * extends android.appwidget.AppWidgetProvider {
|
||||
public void *(android.content.Context, android.content.Intent);
|
||||
<init>();
|
||||
}
|
||||
-keep class com.xingheyuzhuan.shiguangschedule.widget.** { *; }
|
||||
-keep class * extends androidx.work.ListenableWorker {
|
||||
public <init>(android.content.Context, androidx.work.WorkerParameters);
|
||||
}
|
||||
|
||||
# 网络库 (Ktor)
|
||||
-dontwarn io.ktor.**
|
||||
|
||||
# 日志与极致优化
|
||||
-keep class org.slf4j.impl.** { *; }
|
||||
|
||||
# 移除 Android 系统调试日志 (v/d/i/w)
|
||||
-assumenosideeffects class android.util.Log {
|
||||
public static int v(...);
|
||||
public static int d(...);
|
||||
public static int i(...);
|
||||
public static int w(...);
|
||||
}
|
||||
|
||||
# 数据解析 (Kotlinx Serialization & Wire Protobuf) ---
|
||||
-keep class kotlin.Metadata { *; }
|
||||
-keep @kotlinx.serialization.Serializable class * { ** Companion; }
|
||||
-keepclassmembers class * { *** write$Self(...); <init>(int, ...); }
|
||||
-keep class **$$serializer { *; }
|
||||
|
||||
-keep class * implements com.squareup.wire.Message {
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
-keep class * implements com.squareup.wire.WireEnum { *; }
|
||||
-keepclassmembers class * implements com.squareup.wire.Message {
|
||||
public static *** ADAPTER;
|
||||
}
|
||||
-keep class * extends com.squareup.wire.ProtoAdapter { *; }
|
||||
|
||||
|
||||
# 数据模型与数据库
|
||||
-dontwarn androidx.sqlite.**
|
||||
-keep class androidx.sqlite.** { *; }
|
||||
-keep class com.xingheyuzhuan.shiguangschedule.shared.** { *; }
|
||||
-keep class com.xingheyuzhuan.shiguangschedule.data.db.** { *; }
|
||||
-keep class com.xingheyuzhuan.shiguangschedule.data.model.** { *; }
|
||||
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.POST_PROMOTED_NOTIFICATIONS" />
|
||||
|
||||
<application
|
||||
android:name=".MyApplication"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.shiguangschedule"
|
||||
tools:targetApi="33"
|
||||
android:enableOnBackInvokedCallback="true">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.shiguangschedule">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
android:name=".service.CourseAlarmReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver
|
||||
android:name=".widget.tiny.TinyNativeProvider"
|
||||
android:label="@string/widget_name_tiny"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/shiguangschedule_tiny_widget" />
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".widget.compact.CompactNativeProvider"
|
||||
android:label="@string/widget_name_compact"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/shiguangschedule_compact_widget" />
|
||||
</receiver>
|
||||
|
||||
|
||||
<receiver
|
||||
android:name=".widget.double_days.DoubleDaysNativeProvider"
|
||||
android:label="@string/widget_name_double_days"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/shiguangschedule_double_days_widget" />
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".widget.list_vertical.ListVerticalNativeProvider"
|
||||
android:exported="false"
|
||||
android:label="@string/widget_name_list_vertical">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/shiguangschedule_list_vertical_widget" />
|
||||
</receiver>
|
||||
|
||||
|
||||
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
tools:node="remove" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
||||
|
After Width: | Height: | Size: 83 KiB |
@@ -0,0 +1,18 @@
|
||||
package com.xingheyuzhuan.shiguangschedule
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
App()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xingheyuzhuan.shiguangschedule
|
||||
|
||||
import android.app.Application
|
||||
import androidx.work.Configuration
|
||||
import com.xingheyuzhuan.shiguangschedule.data.di.SharedModule
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.android.ext.koin.androidLogger
|
||||
import org.koin.androidx.workmanager.koin.workManagerFactory
|
||||
import org.koin.core.annotation.ComponentScan
|
||||
import org.koin.core.annotation.KoinApplication
|
||||
import org.koin.core.annotation.Module
|
||||
import org.koin.plugin.module.dsl.startKoin
|
||||
|
||||
@Module(includes = [
|
||||
SharedModule::class
|
||||
])
|
||||
@ComponentScan("com.xingheyuzhuan.shiguangschedule")
|
||||
class AppModule
|
||||
|
||||
@KoinApplication(modules = [AppModule::class])
|
||||
class ScheduleAppConfig
|
||||
|
||||
class MyApplication : Application(), Configuration.Provider {
|
||||
|
||||
override val workManagerConfiguration: Configuration
|
||||
get() = Configuration.Builder().build()
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
startKoin<ScheduleAppConfig> {
|
||||
androidLogger()
|
||||
androidContext(this@MyApplication)
|
||||
workManagerFactory()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.data.sync
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.xingheyuzhuan.shiguangschedule.data.repository.StyleSettingsRepository
|
||||
import com.xingheyuzhuan.shiguangschedule.service.CourseNotificationWorker
|
||||
import com.xingheyuzhuan.shiguangschedule.service.DndSchedulerWorker
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.updateAllWidgets
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import org.koin.core.annotation.Single
|
||||
|
||||
/**
|
||||
* 平台层同步管理器(Android 端)。
|
||||
* 仅负责响应共享层 (KMP) 的同步完成信号与 Android 本地样式更新,执行系统 Widget 刷新及 WorkManager 调度。
|
||||
*/
|
||||
@Single(createdAtStart = true)
|
||||
class SyncManager(
|
||||
private val appContext: Context,
|
||||
private val widgetDataSynchronizer: WidgetDataSynchronizer,
|
||||
private val styleSettingsRepository: StyleSettingsRepository
|
||||
) {
|
||||
|
||||
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
|
||||
init {
|
||||
// 1. 监听 KMP 共享层的同步完成信号(包含了课表变更与通知/自动化设置变更)
|
||||
widgetDataSynchronizer.syncCompletedFlow
|
||||
.onEach {
|
||||
Log.d("SyncManager", "收到共享层同步完成通知,正在调度 Worker 任务及刷新小组件...")
|
||||
triggerNotificationWorker()
|
||||
DndSchedulerWorker.enqueueWork(appContext)
|
||||
updateAllWidgets(appContext)
|
||||
}
|
||||
.launchIn(scope)
|
||||
|
||||
// 2. 监听 Android 端专属的样式更新事件
|
||||
styleSettingsRepository.styleUpdatedFlow
|
||||
.onEach {
|
||||
Log.d("SyncManager", "收到样式更改通知,正在刷新小组件...")
|
||||
updateAllWidgets(appContext)
|
||||
}
|
||||
.launchIn(scope)
|
||||
|
||||
Log.d("SyncManager", "Android 平台同步调度器初始化完毕。")
|
||||
}
|
||||
|
||||
private fun triggerNotificationWorker() {
|
||||
val workRequest = OneTimeWorkRequestBuilder<CourseNotificationWorker>().build()
|
||||
WorkManager.getInstance(appContext).enqueueUniqueWork(
|
||||
"CourseNotificationWorker_Sync_Update",
|
||||
ExistingWorkPolicy.REPLACE,
|
||||
workRequest
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.service
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.content.getSystemService
|
||||
import com.xingheyuzhuan.shiguangschedule.MainActivity
|
||||
import com.xingheyuzhuan.shiguangschedule.R
|
||||
import com.xingheyuzhuan.shiguangschedule.data.model.AutoControlMode
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.updateAllWidgets
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import com.xingheyuzhuan.shiguangschedule.data.repository.AppSettingsRepository
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
/**
|
||||
* 课程闹钟与模式切换广播接收器。
|
||||
*/
|
||||
class CourseAlarmReceiver : BroadcastReceiver(), KoinComponent {
|
||||
|
||||
private val appSettingsRepository: AppSettingsRepository by inject()
|
||||
|
||||
companion object {
|
||||
const val NOTIFICATION_CHANNEL_ID = "course_notification_channel"
|
||||
const val EXTRA_COURSE_NAME = "course_name"
|
||||
const val EXTRA_COURSE_POSITION = "course_position"
|
||||
const val EXTRA_COURSE_TEACHER = "extra_course_teacher"
|
||||
const val EXTRA_COURSE_ID = "course_id"
|
||||
|
||||
const val EXTRA_DND_ACTION = "extra_dnd_action"
|
||||
const val DND_ACTION_START = "dnd_action_start"
|
||||
const val DND_ACTION_END = "dnd_action_end"
|
||||
|
||||
const val EXTRA_ALARM_SLOT_ID = "EXTRA_ALARM_SLOT_ID"
|
||||
// 覆盖 50001 (DND) 到 50110 (Course Reminders)
|
||||
private const val SLOT_START = 50001
|
||||
private const val SLOT_END = 50110
|
||||
|
||||
const val ACTION_DISMISS_NOTIFICATION = "com.xingheyuzhuan.shiguangschedule.ACTION_DISMISS_NOTIFICATION"
|
||||
|
||||
private const val ALARM_IDS_PREFS = "alarm_ids_prefs"
|
||||
private const val KEY_ACTIVE_ALARM_IDS = "active_alarm_ids"
|
||||
private const val TAG = "CourseAlarmReceiver"
|
||||
|
||||
fun toggleMode(context: Context, enableMode: Boolean, modeType: AutoControlMode) {
|
||||
val audioManager = context.getSystemService<AudioManager>()
|
||||
val notificationManager = context.getSystemService<NotificationManager>()
|
||||
if (audioManager == null || notificationManager == null) return
|
||||
if (!notificationManager.isNotificationPolicyAccessGranted) return
|
||||
when (modeType) {
|
||||
AutoControlMode.DND -> {
|
||||
notificationManager.setInterruptionFilter(
|
||||
if (enableMode) NotificationManager.INTERRUPTION_FILTER_PRIORITY
|
||||
else NotificationManager.INTERRUPTION_FILTER_ALL
|
||||
)
|
||||
}
|
||||
AutoControlMode.SILENT -> {
|
||||
audioManager.ringerMode = if (enableMode) AudioManager.RINGER_MODE_SILENT
|
||||
else AudioManager.RINGER_MODE_NORMAL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
context?.let { ctx ->
|
||||
if (intent?.action == ACTION_DISMISS_NOTIFICATION) {
|
||||
val notifyId = intent.getIntExtra("target_notification_id", -1)
|
||||
if (notifyId != -1) {
|
||||
val nm = ctx.getSystemService<NotificationManager>()
|
||||
nm?.cancel(notifyId)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val slotId = intent?.getIntExtra(EXTRA_ALARM_SLOT_ID, -1) ?: -1
|
||||
val dndAction = intent?.getStringExtra(EXTRA_DND_ACTION)
|
||||
|
||||
if (intent?.data != null || (slotId !in SLOT_START..SLOT_END && dndAction.isNullOrEmpty())) {
|
||||
Log.d(TAG, "已拦截非法或旧版闹钟。")
|
||||
return
|
||||
}
|
||||
|
||||
val pendingResult = goAsync()
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
try {
|
||||
val appSettings = appSettingsRepository.getAppSettingsOnce()
|
||||
val modeToUse = appSettings.autoControlMode
|
||||
val isCompatMode = appSettings.compatWearableSync
|
||||
|
||||
if (!dndAction.isNullOrEmpty()) {
|
||||
when (dndAction) {
|
||||
DND_ACTION_START -> toggleMode(ctx, true, modeToUse)
|
||||
DND_ACTION_END -> {
|
||||
toggleMode(ctx, false, modeToUse)
|
||||
DndSchedulerWorker.enqueueWork(ctx)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val courseName = intent?.getStringExtra(EXTRA_COURSE_NAME).takeUnless { it.isNullOrEmpty() }
|
||||
?: ctx.getString(R.string.notification_unknown_course)
|
||||
|
||||
val position = intent?.getStringExtra(EXTRA_COURSE_POSITION).takeUnless { it.isNullOrEmpty() }
|
||||
?: ctx.getString(R.string.notification_unknown_position)
|
||||
val teacher = intent?.getStringExtra(EXTRA_COURSE_TEACHER) ?: ""
|
||||
val courseIdString = intent?.getStringExtra(EXTRA_COURSE_ID)
|
||||
|
||||
if (!courseIdString.isNullOrEmpty()) {
|
||||
showNotification(ctx, slotId, courseName, position, teacher, isCompatMode)
|
||||
removeAlarmIdFromPrefs(ctx, courseIdString)
|
||||
updateAllWidgets(ctx)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "onReceive 异常", e)
|
||||
} finally {
|
||||
pendingResult.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showNotification(
|
||||
context: Context,
|
||||
notificationId: Int,
|
||||
name: String,
|
||||
position: String,
|
||||
teacher: String,
|
||||
isCompatMode: Boolean
|
||||
) {
|
||||
val nm = context.getSystemService<NotificationManager>() ?: return
|
||||
|
||||
val alertTitle = context.getString(R.string.notification_title_course_alert)
|
||||
val posLabel = context.getString(R.string.label_position)
|
||||
val teacherLabel = context.getString(R.string.label_teacher)
|
||||
val closeActionText = context.getString(R.string.action_close)
|
||||
val liveStatusText = context.getString(R.string.notification_live_status_preparing)
|
||||
|
||||
if (nm.getNotificationChannel(NOTIFICATION_CHANNEL_ID) == null) {
|
||||
val channel = NotificationChannel(
|
||||
NOTIFICATION_CHANNEL_ID,
|
||||
context.getString(R.string.item_course_reminder),
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
)
|
||||
nm.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
val dismissIntent = Intent(context, CourseAlarmReceiver::class.java).apply {
|
||||
action = ACTION_DISMISS_NOTIFICATION
|
||||
putExtra("target_notification_id", notificationId)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
identifier = notificationId.toString()
|
||||
}
|
||||
}
|
||||
val dismissPI = PendingIntent.getBroadcast(
|
||||
context, notificationId, dismissIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
|
||||
val bigTextStyle = NotificationCompat.BigTextStyle()
|
||||
.setBigContentTitle(name)
|
||||
.bigText("$posLabel: $position\n$teacherLabel: $teacher")
|
||||
|
||||
val builder = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher))
|
||||
.setContentTitle(name)
|
||||
.setContentText("$posLabel: $position")
|
||||
.setSubText(alertTitle)
|
||||
.setStyle(bigTextStyle)
|
||||
|
||||
// 非兼容模式应用
|
||||
.setOngoing(!isCompatMode)
|
||||
.setAutoCancel(isCompatMode)
|
||||
|
||||
.setCategory(NotificationCompat.CATEGORY_EVENT)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setShowWhen(true)
|
||||
.addAction(0, closeActionText, dismissPI)
|
||||
.setContentIntent(
|
||||
PendingIntent.getActivity(
|
||||
context, 0, Intent(context, MainActivity::class.java),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
)
|
||||
|
||||
// Android 16 实时更新特性
|
||||
if (Build.VERSION.SDK_INT >= 36) {
|
||||
builder.setRequestPromotedOngoing(true)
|
||||
builder.setShortCriticalText(liveStatusText)
|
||||
}
|
||||
|
||||
nm.notify(notificationId, builder.build())
|
||||
}
|
||||
|
||||
private fun removeAlarmIdFromPrefs(context: Context, courseId: String) {
|
||||
val sp = context.getSharedPreferences(ALARM_IDS_PREFS, Context.MODE_PRIVATE)
|
||||
val currentIds = sp.getStringSet(KEY_ACTIVE_ALARM_IDS, null)?.toMutableSet()
|
||||
if (currentIds != null) {
|
||||
currentIds.remove(courseId)
|
||||
sp.edit { putStringSet(KEY_ACTIVE_ALARM_IDS, currentIds) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.service
|
||||
|
||||
import android.app.AlarmManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.xingheyuzhuan.shiguangschedule.data.repository.AppSettingsRepository
|
||||
import com.xingheyuzhuan.shiguangschedule.data.repository.WidgetRepository
|
||||
import kotlinx.coroutines.flow.first
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.LocalTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import org.koin.android.annotation.KoinWorker
|
||||
|
||||
/**
|
||||
* 课程提醒同步服务
|
||||
*
|
||||
*/
|
||||
@KoinWorker
|
||||
class CourseNotificationWorker(
|
||||
appContext: Context,
|
||||
workerParams: WorkerParameters,
|
||||
private val appSettingsRepository: AppSettingsRepository,
|
||||
private val widgetRepository: WidgetRepository
|
||||
) : CoroutineWorker(appContext, workerParams) {
|
||||
|
||||
private val alarmManager = appContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
|
||||
companion object {
|
||||
private const val TAG = "CourseNotificationWorker"
|
||||
private const val WIDGET_SYNC_DAYS = 7L
|
||||
|
||||
private const val ALARM_SLOT_START_ID = 50010
|
||||
private const val ALARM_SLOT_COUNT = 101
|
||||
}
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
return try {
|
||||
val appSettings = appSettingsRepository.getAppSettings().first()
|
||||
|
||||
// 论开关状态,先清空 50010 - 50110 范围内的所有旧闹钟槽位
|
||||
cancelAllAlarms()
|
||||
|
||||
// 如果开关没开,清理完直接结束
|
||||
if (!appSettings.reminderEnabled) return Result.success()
|
||||
|
||||
val remindBeforeMinutes = appSettings.remindBeforeMinutes
|
||||
val now = LocalDateTime.now()
|
||||
val startDate = now.toLocalDate().format(DateTimeFormatter.ISO_LOCAL_DATE)
|
||||
val endDate = now.toLocalDate().plusDays(WIDGET_SYNC_DAYS).format(DateTimeFormatter.ISO_LOCAL_DATE)
|
||||
|
||||
// 获取未来课程
|
||||
val coursesToRemind = widgetRepository.getWidgetCoursesByDateRange(startDate, endDate).first()
|
||||
.filter { !it.isSkipped }
|
||||
|
||||
val zoneId = ZoneId.systemDefault()
|
||||
|
||||
// 按顺序为未来课程分配槽位并设置闹钟
|
||||
coursesToRemind.take(ALARM_SLOT_COUNT).forEachIndexed { index, course ->
|
||||
val courseDate = LocalDate.parse(course.date)
|
||||
val startDT = LocalDateTime.of(courseDate, LocalTime.parse(course.startTime))
|
||||
val remindTime = startDT.minusMinutes(remindBeforeMinutes.toLong())
|
||||
|
||||
if (remindTime.isAfter(now)) {
|
||||
setAlarmInternal(
|
||||
requestCode = ALARM_SLOT_START_ID + index,
|
||||
courseId = course.id,
|
||||
triggerTime = remindTime.atZone(zoneId).toInstant().toEpochMilli(),
|
||||
name = course.name,
|
||||
position = course.position,
|
||||
teacher = course.teacher
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Result.success()
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "同步课程提醒失败", e)
|
||||
Result.failure()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setAlarmInternal(
|
||||
requestCode: Int,
|
||||
courseId: String,
|
||||
triggerTime: Long,
|
||||
name: String,
|
||||
position: String,
|
||||
teacher: String
|
||||
) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms()) {
|
||||
Log.w(TAG, "缺少精确闹钟权限,无法设置提醒")
|
||||
return
|
||||
}
|
||||
|
||||
val intent = Intent(applicationContext, CourseAlarmReceiver::class.java).apply {
|
||||
this.action = "com.xingheyuzhuan.shiguangschedule.ACTION_COURSE_REMIND"
|
||||
putExtra(CourseAlarmReceiver.EXTRA_ALARM_SLOT_ID, requestCode)
|
||||
putExtra(CourseAlarmReceiver.EXTRA_COURSE_ID, courseId)
|
||||
putExtra(CourseAlarmReceiver.EXTRA_COURSE_NAME, name)
|
||||
putExtra(CourseAlarmReceiver.EXTRA_COURSE_POSITION, position)
|
||||
putExtra(CourseAlarmReceiver.EXTRA_COURSE_TEACHER, teacher)
|
||||
}
|
||||
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
applicationContext,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
|
||||
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerTime, pendingIntent)
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理 50010 - 50110 范围内的所有槽位,确保无残留
|
||||
*/
|
||||
private fun cancelAllAlarms() {
|
||||
for (i in 0 until ALARM_SLOT_COUNT) {
|
||||
val requestCode = ALARM_SLOT_START_ID + i
|
||||
val intent = Intent(applicationContext, CourseAlarmReceiver::class.java).apply {
|
||||
this.action = "com.xingheyuzhuan.shiguangschedule.ACTION_COURSE_REMIND"
|
||||
}
|
||||
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
applicationContext,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_NO_CREATE or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
|
||||
pendingIntent?.let {
|
||||
alarmManager.cancel(it)
|
||||
it.cancel()
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "已清理课程提醒所有历史槽位 (50010-50110)")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.service
|
||||
|
||||
import android.app.AlarmManager
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import androidx.core.content.getSystemService
|
||||
import com.xingheyuzhuan.shiguangschedule.data.repository.AppSettingsRepository
|
||||
import com.xingheyuzhuan.shiguangschedule.data.repository.WidgetRepository
|
||||
import kotlinx.coroutines.flow.first
|
||||
import org.koin.android.annotation.KoinWorker
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.LocalTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* WorkManager 用于调度上课时行为模式(勿扰/静音)开启/关闭闹钟的 Worker。
|
||||
*/
|
||||
@KoinWorker
|
||||
class DndSchedulerWorker(
|
||||
appContext: Context,
|
||||
workerParams: WorkerParameters,
|
||||
private val appSettingsRepository: AppSettingsRepository,
|
||||
private val widgetRepository: WidgetRepository
|
||||
) : CoroutineWorker(appContext, workerParams) {
|
||||
|
||||
private val alarmManager = appContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
private val notificationManager = appContext.getSystemService<NotificationManager>()
|
||||
?: throw IllegalStateException("NotificationManager not available")
|
||||
|
||||
companion object {
|
||||
const val DND_SCHEDULER_WORK_TAG = "dnd_scheduler_worker_tag"
|
||||
private const val TAG = "DndSchedulerWorker"
|
||||
private const val DND_SCHEDULER_CHECK_DAYS = 7L
|
||||
private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.ROOT)
|
||||
|
||||
// 50000 作为基准 ID
|
||||
private const val DND_ALARM_ID_BASE = 50000
|
||||
|
||||
fun enqueueWork(context: Context) {
|
||||
val workRequest = OneTimeWorkRequestBuilder<DndSchedulerWorker>()
|
||||
.setConstraints(Constraints.Builder().setRequiredNetworkType(NetworkType.NOT_REQUIRED).build())
|
||||
.addTag(DND_SCHEDULER_WORK_TAG)
|
||||
.build()
|
||||
|
||||
WorkManager.getInstance(context).enqueueUniqueWork(
|
||||
DND_SCHEDULER_WORK_TAG,
|
||||
ExistingWorkPolicy.REPLACE,
|
||||
workRequest
|
||||
)
|
||||
Log.d(TAG, "上课时自动模式调度器已重新排队。")
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
val appSettings = appSettingsRepository.getAppSettings().first()
|
||||
|
||||
if (!appSettings.autoModeEnabled) {
|
||||
Log.d(TAG, "上课时自动模式开关已关闭,取消所有模式闹钟。")
|
||||
cancelDndAlarms()
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
if (!notificationManager.isNotificationPolicyAccessGranted) {
|
||||
Log.w(TAG, "勿扰模式权限未授予")
|
||||
}
|
||||
|
||||
val shouldBeModeOn = isCurrentlyInDndTime()
|
||||
Log.d(TAG, "当前模式状态校准:$shouldBeModeOn")
|
||||
|
||||
// 调度前先清理旧闹钟
|
||||
cancelDndAlarms()
|
||||
|
||||
val (nextStartAlarm, nextEndAlarm) = findNextDndAlarmTimes(DND_SCHEDULER_CHECK_DAYS)
|
||||
|
||||
if (nextStartAlarm == null && nextEndAlarm == null) {
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
nextStartAlarm?.let { scheduleDndAlarm(it, isStartAction = true) }
|
||||
nextEndAlarm?.let { scheduleDndAlarm(it, isStartAction = false) }
|
||||
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
private suspend fun findNextDndAlarmTimes(checkDays: Long): Pair<LocalDateTime?, LocalDateTime?> {
|
||||
val now = LocalDateTime.now(ZoneId.systemDefault())
|
||||
val startDate = now.toLocalDate().format(DATE_FORMATTER)
|
||||
val endDate = now.toLocalDate().plusDays(checkDays - 1).format(DATE_FORMATTER)
|
||||
|
||||
val courses = widgetRepository.getWidgetCoursesByDateRange(startDate, endDate).first()
|
||||
.filter { !it.isSkipped }
|
||||
|
||||
var nextStartAlarm: LocalDateTime? = null
|
||||
var nextEndAlarm: LocalDateTime? = null
|
||||
|
||||
for (course in courses) {
|
||||
val courseDate = LocalDate.parse(course.date, DATE_FORMATTER)
|
||||
val startDateTime = courseDate.atTime(LocalTime.parse(course.startTime))
|
||||
val endDateTime = courseDate.atTime(LocalTime.parse(course.endTime))
|
||||
|
||||
if (startDateTime.isAfter(now)) {
|
||||
if (nextStartAlarm == null || startDateTime.isBefore(nextStartAlarm)) nextStartAlarm = startDateTime
|
||||
}
|
||||
if (endDateTime.isAfter(now)) {
|
||||
if (nextEndAlarm == null || endDateTime.isBefore(nextEndAlarm)) nextEndAlarm = endDateTime
|
||||
}
|
||||
}
|
||||
return Pair(nextStartAlarm, nextEndAlarm)
|
||||
}
|
||||
|
||||
private suspend fun isCurrentlyInDndTime(): Boolean {
|
||||
val now = LocalDateTime.now(ZoneId.systemDefault())
|
||||
val todayStr = now.toLocalDate().format(DATE_FORMATTER)
|
||||
val courses = widgetRepository.getWidgetCoursesByDateRange(todayStr, todayStr).first()
|
||||
.filter { !it.isSkipped }
|
||||
val nowTime = now.toLocalTime()
|
||||
for (course in courses) {
|
||||
val startTime = LocalTime.parse(course.startTime)
|
||||
val endTime = LocalTime.parse(course.endTime)
|
||||
if (!nowTime.isBefore(startTime) && nowTime.isBefore(endTime)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置一个精确的模式闹钟。
|
||||
*/
|
||||
private fun scheduleDndAlarm(dateTime: LocalDateTime, isStartAction: Boolean) {
|
||||
val triggerTimeMillis = dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()
|
||||
|
||||
// 50001 为开启,50002 为关闭
|
||||
val dndActionValue = if (isStartAction) CourseAlarmReceiver.DND_ACTION_START else CourseAlarmReceiver.DND_ACTION_END
|
||||
val requestCode = DND_ALARM_ID_BASE + if (isStartAction) 1 else 2
|
||||
|
||||
val intent = Intent(applicationContext, CourseAlarmReceiver::class.java).apply {
|
||||
this.action = "com.xingheyuzhuan.shiguangschedule.ACTION_COURSE_REMIND"
|
||||
putExtra(CourseAlarmReceiver.EXTRA_DND_ACTION, dndActionValue)
|
||||
putExtra(CourseAlarmReceiver.EXTRA_ALARM_SLOT_ID, requestCode)
|
||||
}
|
||||
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
applicationContext,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
if (!alarmManager.canScheduleExactAlarms()) {
|
||||
Log.w(TAG, "无法设置精确闹钟:缺少权限")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerTimeMillis, pendingIntent)
|
||||
Log.i(TAG, "已调度模式闹钟 [${if(isStartAction) "开启" else "关闭"}]: $dateTime (ID: $requestCode)")
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消所有由模式 Scheduler 设置的闹钟。
|
||||
*/
|
||||
private fun cancelDndAlarms() {
|
||||
// 循环注销 50001 (开启) 和 50002 (关闭)
|
||||
listOf(1, 2).forEach { offset ->
|
||||
val requestCode = DND_ALARM_ID_BASE + offset
|
||||
val intent = Intent(applicationContext, CourseAlarmReceiver::class.java).apply {
|
||||
this.action = "com.xingheyuzhuan.shiguangschedule.ACTION_COURSE_REMIND"
|
||||
}
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
applicationContext,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_NO_CREATE or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
pendingIntent?.let {
|
||||
alarmManager.cancel(it)
|
||||
it.cancel()
|
||||
val label = if (offset == 1) "开启" else "关闭"
|
||||
Log.d(TAG, "已从系统注销模式[$label]闹钟,ID: $requestCode")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.xingheyuzhuan.shiguangschedule.data.sync.WidgetDataSynchronizer
|
||||
import org.koin.android.annotation.KoinWorker
|
||||
|
||||
/**
|
||||
* 负责每15分钟更新一次小组件UI的Worker。
|
||||
* 它直接调用所有小组件的UI更新,确保UI及时刷新。
|
||||
*/
|
||||
@KoinWorker
|
||||
class WidgetUiUpdateWorker(
|
||||
appContext: Context,
|
||||
workerParams: WorkerParameters
|
||||
) : CoroutineWorker(appContext, workerParams) {
|
||||
override suspend fun doWork(): Result {
|
||||
Log.d("WidgetSync", "WidgetUiUpdateWorker 开始执行")
|
||||
updateAllWidgets(applicationContext)
|
||||
return Result.success()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 负责每天执行一次完整数据同步的Worker。
|
||||
* 它调用 WidgetDataSynchronizer 的 syncNow() 方法,同步主数据库数据。
|
||||
*/
|
||||
@KoinWorker
|
||||
class FullDataSyncWorker(
|
||||
appContext: Context,
|
||||
workerParams: WorkerParameters,
|
||||
private val widgetDataSynchronizer: WidgetDataSynchronizer
|
||||
) : CoroutineWorker(appContext, workerParams) {
|
||||
override suspend fun doWork(): Result {
|
||||
Log.d("WidgetSync", "FullDataSyncWorker 开始执行")
|
||||
try {
|
||||
widgetDataSynchronizer.syncNow()
|
||||
return Result.success()
|
||||
} catch (e: Exception) {
|
||||
return Result.failure()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.datastore.core.DataStore
|
||||
import com.xingheyuzhuan.shiguangschedule.data.model.ScheduleGridStyle
|
||||
import com.xingheyuzhuan.shiguangschedule.data.model.schedule_style.ScheduleGridStyleProto
|
||||
import com.xingheyuzhuan.shiguangschedule.data.model.toProto
|
||||
import com.xingheyuzhuan.shiguangschedule.data.repository.WidgetRepository
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.compact.CompactNativeProvider
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.compact.CompactNativeRenderer
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.double_days.DoubleDaysNativeProvider
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.double_days.DoubleDaysNativeRenderer
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.list_vertical.ListVerticalNativeProvider
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.list_vertical.ListVerticalNativeRenderer
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.tiny.TinyNativeProvider
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.tiny.TinyNativeRenderer
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import java.time.LocalDate
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
// 创建一个局部的注入代理中心,用于在全局顶层方法中安全提取注入实例
|
||||
private object WidgetDependencyContainer : KoinComponent {
|
||||
val repository: WidgetRepository by inject()
|
||||
val styleDataStore: DataStore<ScheduleGridStyleProto> by inject()
|
||||
}
|
||||
|
||||
/**
|
||||
* 小组件统一分发中心
|
||||
* 负责从 Repository 提取数据并分发给所有 4 种规格的原生 Renderer
|
||||
*/
|
||||
suspend fun updateAllWidgets(context: Context) {
|
||||
try {
|
||||
// 1. 从 Koin 容器中动态获取单例化的仓库与 DataStore
|
||||
val repository = WidgetDependencyContainer.repository
|
||||
val styleDataStore = WidgetDependencyContainer.styleDataStore
|
||||
|
||||
// 2. 准备基础数据
|
||||
val today = LocalDate.now()
|
||||
val tomorrow = today.plusDays(1)
|
||||
|
||||
val dbCourses = withTimeoutOrNull(3.seconds) {
|
||||
repository.getWidgetCoursesByDateRange(today.toString(), tomorrow.toString()).first()
|
||||
} ?: emptyList()
|
||||
|
||||
val currentWeek = withTimeoutOrNull(2.seconds) {
|
||||
repository.getCurrentWeekFlow().first()
|
||||
} ?: 0
|
||||
|
||||
val currentStyle = withTimeoutOrNull(2.seconds) {
|
||||
styleDataStore.data.first()
|
||||
}
|
||||
|
||||
val finalStyleToSync = if (currentStyle == null || currentStyle.course_color_maps.isEmpty()) {
|
||||
ScheduleGridStyle.DEFAULT.toProto()
|
||||
} else {
|
||||
currentStyle
|
||||
}
|
||||
|
||||
// 3. 构造数据快照 (Protobuf)
|
||||
val courseProtoList = dbCourses.map { course ->
|
||||
WidgetCourseProto(
|
||||
id = course.id,
|
||||
name = course.name,
|
||||
teacher = course.teacher,
|
||||
position = course.position,
|
||||
start_time = course.startTime,
|
||||
end_time = course.endTime,
|
||||
color_int = course.colorInt,
|
||||
is_skipped = course.isSkipped,
|
||||
date = course.date
|
||||
)
|
||||
}
|
||||
|
||||
val snapshot = WidgetSnapshot(
|
||||
current_week = currentWeek,
|
||||
style = finalStyleToSync,
|
||||
courses = courseProtoList
|
||||
)
|
||||
|
||||
// 4. 定义所有原生尺寸的映射列表
|
||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||
val nativeConfigs = listOf(
|
||||
TinyNativeProvider::class.java to TinyNativeRenderer::render,
|
||||
CompactNativeProvider::class.java to CompactNativeRenderer::render,
|
||||
DoubleDaysNativeProvider::class.java to DoubleDaysNativeRenderer::render,
|
||||
ListVerticalNativeProvider::class.java to ListVerticalNativeRenderer::render
|
||||
)
|
||||
|
||||
// 5. 统一分发更新
|
||||
nativeConfigs.forEachIndexed { index, (providerClass, renderFunc) ->
|
||||
val componentName = ComponentName(context, providerClass)
|
||||
val ids = appWidgetManager.getAppWidgetIds(componentName)
|
||||
|
||||
if (ids.isNotEmpty()) {
|
||||
if (index > 0) {
|
||||
delay(300.milliseconds)
|
||||
}
|
||||
|
||||
try {
|
||||
val remoteViews = renderFunc(context, snapshot)
|
||||
appWidgetManager.updateAppWidget(componentName, remoteViews)
|
||||
Log.d("WidgetUpdateHelper", "成功刷新规格 ${providerClass.simpleName}")
|
||||
} catch (e: Exception) {
|
||||
Log.e("WidgetUpdateHelper", "规格 ${providerClass.simpleName} 渲染失败", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
Log.e("WidgetUpdateHelper", "更新流程异常: ${e.stackTraceToString()}")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// WorkManagerHelper.kt
|
||||
package com.xingheyuzhuan.shiguangschedule.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* 负责调度和取消小组件相关定期任务的通用帮助类。
|
||||
*/
|
||||
object WorkManagerHelper {
|
||||
|
||||
private const val UI_UPDATE_WORK_NAME = "WidgetUiUpdateWorker_Periodic"
|
||||
private const val FULL_DATA_SYNC_WORK_NAME = "FullDataSyncWorker_Periodic"
|
||||
|
||||
fun schedulePeriodicWork(context: Context) {
|
||||
Log.d("WidgetWorkManager", "正在调度小组件定期任务...")
|
||||
|
||||
// 调度小组件UI更新任务 (每15分钟)
|
||||
val uiUpdateWorkRequest = PeriodicWorkRequestBuilder<WidgetUiUpdateWorker>(15, TimeUnit.MINUTES).build()
|
||||
WorkManager.getInstance(context).enqueueUniquePeriodicWork(
|
||||
UI_UPDATE_WORK_NAME,
|
||||
ExistingPeriodicWorkPolicy.KEEP,
|
||||
uiUpdateWorkRequest
|
||||
)
|
||||
|
||||
// 调度完整数据同步任务 (每天一次)
|
||||
val fullDataSyncWorkRequest = PeriodicWorkRequestBuilder<FullDataSyncWorker>(1, TimeUnit.DAYS).build()
|
||||
WorkManager.getInstance(context).enqueueUniquePeriodicWork(
|
||||
FULL_DATA_SYNC_WORK_NAME,
|
||||
ExistingPeriodicWorkPolicy.UPDATE,
|
||||
fullDataSyncWorkRequest
|
||||
)
|
||||
}
|
||||
|
||||
fun cancelAllWork(context: Context) {
|
||||
Log.d("WidgetWorkManager", "正在取消所有小组件定期任务...")
|
||||
WorkManager.getInstance(context).cancelUniqueWork(UI_UPDATE_WORK_NAME)
|
||||
WorkManager.getInstance(context).cancelUniqueWork(FULL_DATA_SYNC_WORK_NAME)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.compact
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.Context
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WorkManagerHelper
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.updateAllWidgets
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 今日课程(紧凑版)原生小组件接收器
|
||||
*/
|
||||
class CompactNativeProvider : AppWidgetProvider() {
|
||||
private val scope = MainScope()
|
||||
|
||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||
scope.launch {
|
||||
// 触发全局刷新逻辑
|
||||
updateAllWidgets(context)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onEnabled(context: Context) {
|
||||
super.onEnabled(context)
|
||||
// 启动定时任务(15分钟 UI 刷新 + 24小时数据同步)
|
||||
WorkManagerHelper.schedulePeriodicWork(context)
|
||||
}
|
||||
|
||||
override fun onDisabled(context: Context) {
|
||||
super.onDisabled(context)
|
||||
// 只有在确定不再需要后台更新时才取消
|
||||
WorkManagerHelper.cancelAllWork(context)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.compact
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import com.xingheyuzhuan.shiguangschedule.MainActivity
|
||||
import com.xingheyuzhuan.shiguangschedule.R
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WidgetSnapshot
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WidgetCourseProto
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
|
||||
object CompactNativeRenderer {
|
||||
|
||||
fun render(context: Context, snapshot: WidgetSnapshot): RemoteViews {
|
||||
val rv = RemoteViews(context.packageName, R.layout.widget_today_compact_native)
|
||||
|
||||
// 状态彻底重置
|
||||
resetWidgetState(rv)
|
||||
|
||||
// 设置点击跳转
|
||||
val intent = Intent(context, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
context, 0, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
rv.setOnClickPendingIntent(R.id.widget_root, pendingIntent)
|
||||
|
||||
// 数据准备
|
||||
val now = LocalTime.now()
|
||||
val today = LocalDate.now()
|
||||
val tomorrow = today.plusDays(1)
|
||||
val allCourses = snapshot.courses
|
||||
val currentWeek = if (snapshot.current_week <= 0) null else snapshot.current_week
|
||||
|
||||
// 头部基础信息渲染
|
||||
val dateFormatter = DateTimeFormatter.ofPattern("E", Locale.getDefault())
|
||||
rv.setTextViewText(R.id.tv_header_title, today.format(dateFormatter))
|
||||
|
||||
// 渲染周数
|
||||
if (currentWeek != null) {
|
||||
rv.setViewVisibility(R.id.tv_current_week, View.VISIBLE)
|
||||
rv.setTextViewText(R.id.tv_current_week, context.getString(R.string.status_current_week_format, currentWeek))
|
||||
} else {
|
||||
rv.setViewVisibility(R.id.tv_current_week, View.GONE)
|
||||
}
|
||||
|
||||
// 情况 A:假期处理 (直接显示全屏遮罩)
|
||||
if (currentWeek == null) {
|
||||
showStatus(rv, context, context.getString(R.string.title_vacation), context.getString(R.string.widget_vacation_expecting), isFullCover = true)
|
||||
return rv
|
||||
}
|
||||
|
||||
// 核心调度逻辑
|
||||
val todayStr = today.toString()
|
||||
val tomorrowStr = tomorrow.toString()
|
||||
|
||||
val todayRemaining = allCourses.filter {
|
||||
(it.date == todayStr || it.date.isBlank()) && !it.is_skipped && try { LocalTime.parse(it.end_time) > now } catch (e: Exception) { true }
|
||||
}.sortedBy { it.start_time }
|
||||
|
||||
val tomorrowCourses = allCourses.filter { it.date == tomorrowStr && !it.is_skipped }.sortedBy { it.start_time }
|
||||
|
||||
// 决定渲染路径
|
||||
when {
|
||||
todayRemaining.isNotEmpty() -> {
|
||||
// 状态 1:今日剩余
|
||||
renderCourseContent(context, rv, todayRemaining, snapshot, false)
|
||||
}
|
||||
tomorrowCourses.isNotEmpty() -> {
|
||||
// 状态 2:明日预告
|
||||
rv.setTextViewText(R.id.tv_header_title, context.getString(R.string.widget_tomorrow_course_preview))
|
||||
renderCourseContent(context, rv, tomorrowCourses, snapshot, true)
|
||||
}
|
||||
else -> {
|
||||
// 状态 3:今明无课
|
||||
val hasCoursesToday = allCourses.any { it.date == todayStr || it.date.isBlank() }
|
||||
val tip = if (!hasCoursesToday) {
|
||||
context.getString(R.string.text_no_courses_today)
|
||||
} else {
|
||||
context.getString(R.string.widget_today_courses_finished)
|
||||
}
|
||||
showStatus(rv, context, tip, "", isFullCover = false)
|
||||
}
|
||||
}
|
||||
|
||||
return rv
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置所有 View 的可见性。
|
||||
*/
|
||||
private fun resetWidgetState(rv: RemoteViews) {
|
||||
rv.setViewVisibility(R.id.container_full_status, View.GONE)
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_courses, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_status, View.GONE)
|
||||
rv.setViewVisibility(R.id.tv_footer, View.GONE)
|
||||
rv.removeAllViews(R.id.container_courses)
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染具体的课程列表
|
||||
*/
|
||||
private fun renderCourseContent(context: Context, rv: RemoteViews, courses: List<WidgetCourseProto>, snapshot: WidgetSnapshot, isTomorrow: Boolean) {
|
||||
rv.setViewVisibility(R.id.container_courses, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_status, View.GONE)
|
||||
rv.setViewVisibility(R.id.tv_footer, View.VISIBLE)
|
||||
|
||||
courses.forEachIndexed { index, course ->
|
||||
val itemRv = RemoteViews(context.packageName, R.layout.widget_item_course_common)
|
||||
itemRv.setTextViewText(R.id.tv_course_name, course.name)
|
||||
itemRv.setTextViewText(R.id.tv_course_position, course.position)
|
||||
itemRv.setTextViewText(R.id.tv_course_time, "${course.start_time.take(5)}-${course.end_time.take(5)}")
|
||||
|
||||
if (!(course.teacher.isBlank())) {
|
||||
itemRv.setViewVisibility(R.id.tv_course_teacher, View.VISIBLE)
|
||||
itemRv.setTextViewText(R.id.tv_course_teacher, course.teacher)
|
||||
} else {
|
||||
itemRv.setViewVisibility(R.id.tv_course_teacher, View.GONE)
|
||||
}
|
||||
|
||||
// 颜色处理
|
||||
val style = snapshot.style
|
||||
val colorInt = course.color_int
|
||||
if (style != null && colorInt < style.course_color_maps.size) {
|
||||
val colorPair = style.course_color_maps[colorInt]
|
||||
itemRv.setInt(R.id.course_indicator, "setColorFilter",
|
||||
colorPair.light_color.toInt()
|
||||
)
|
||||
itemRv.setInt(R.id.course_indicator_dark, "setColorFilter",
|
||||
colorPair.dark_color.toInt()
|
||||
)
|
||||
}
|
||||
|
||||
rv.addView(R.id.container_courses, itemRv)
|
||||
|
||||
if (index < courses.size - 1) {
|
||||
rv.addView(R.id.container_courses, RemoteViews(context.packageName, R.layout.widget_divider_horizontal))
|
||||
}
|
||||
}
|
||||
|
||||
val footerRes = if (isTomorrow) R.string.widget_course_total_count else R.string.widget_course_remaining_count
|
||||
rv.setTextViewText(R.id.tv_footer, context.getString(footerRes, courses.size))
|
||||
}
|
||||
|
||||
private fun showStatus(rv: RemoteViews, context: Context, title: String, msg: String?, isFullCover: Boolean) {
|
||||
if (isFullCover) {
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_status, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_full_status, View.VISIBLE)
|
||||
rv.setTextViewText(R.id.tv_full_status_title, title)
|
||||
if (!msg.isNullOrBlank()) {
|
||||
rv.setTextViewText(R.id.tv_full_status_msg, msg)
|
||||
rv.setViewVisibility(R.id.tv_full_status_msg, View.VISIBLE)
|
||||
}
|
||||
} else {
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_courses, View.GONE)
|
||||
rv.setViewVisibility(R.id.tv_footer, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_status, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_full_status, View.GONE)
|
||||
rv.setTextViewText(R.id.tv_status_title, title)
|
||||
if (!msg.isNullOrBlank()) {
|
||||
rv.setTextViewText(R.id.tv_status_msg, msg)
|
||||
rv.setViewVisibility(R.id.tv_status_msg, View.VISIBLE)
|
||||
} else {
|
||||
rv.setViewVisibility(R.id.tv_status_msg, View.GONE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.double_days
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.Context
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WorkManagerHelper
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.updateAllWidgets
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class DoubleDaysNativeProvider : AppWidgetProvider() {
|
||||
// 使用 MainScope 处理异步任务
|
||||
private val scope = MainScope()
|
||||
|
||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||
scope.launch {
|
||||
// 当系统请求更新(或数据变化手动触发)时渲染 UI
|
||||
updateAllWidgets(context)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onEnabled(context: Context) {
|
||||
super.onEnabled(context)
|
||||
// 启用更新计划任务表
|
||||
WorkManagerHelper.schedulePeriodicWork(context)
|
||||
|
||||
}
|
||||
|
||||
// 移除最后一个小组件时清除任务表
|
||||
override fun onDisabled(context: Context) {
|
||||
super.onDisabled(context)
|
||||
WorkManagerHelper.cancelAllWork(context)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.double_days
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import com.xingheyuzhuan.shiguangschedule.MainActivity
|
||||
import com.xingheyuzhuan.shiguangschedule.R
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WidgetCourseProto
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WidgetSnapshot
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
|
||||
object DoubleDaysNativeRenderer {
|
||||
|
||||
fun render(context: Context, snapshot: WidgetSnapshot): RemoteViews {
|
||||
val rv = RemoteViews(context.packageName, R.layout.widget_double_days_native)
|
||||
|
||||
// 状态彻底重置
|
||||
resetWidgetState(rv)
|
||||
|
||||
// 点击跳转逻辑
|
||||
val intent = Intent(context, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
context, 0, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
rv.setOnClickPendingIntent(R.id.widget_root, pendingIntent)
|
||||
|
||||
// 全局状态判断
|
||||
val currentWeek = if (snapshot.current_week <= 0) null else snapshot.current_week
|
||||
|
||||
if (currentWeek == null) {
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_vacation, View.VISIBLE)
|
||||
rv.setTextViewText(R.id.tv_vacation_title, context.getString(R.string.title_vacation))
|
||||
rv.setTextViewText(R.id.tv_vacation_msg, context.getString(R.string.widget_vacation_expecting))
|
||||
return rv
|
||||
}
|
||||
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_vacation, View.GONE)
|
||||
rv.setTextViewText(R.id.tv_current_week, context.getString(R.string.status_current_week_format, currentWeek))
|
||||
|
||||
val now = LocalTime.now()
|
||||
val today = LocalDate.now()
|
||||
val tomorrow = today.plusDays(1)
|
||||
val allCourses = snapshot.courses
|
||||
|
||||
// 渲染左侧:今日
|
||||
val todayCourses = allCourses.filter { it.date == today.toString() || it.date.isBlank() }
|
||||
val remainingToday = todayCourses.filter {
|
||||
!it.is_skipped && try { LocalTime.parse(it.end_time) > now } catch (_: Exception) { true }
|
||||
}.sortedBy { it.start_time }
|
||||
|
||||
renderColumn(
|
||||
context, rv,
|
||||
R.id.container_today, R.id.tv_today_date, R.id.tv_today_footer,
|
||||
R.id.empty_today_container,
|
||||
today, remainingToday, remainingToday.size,
|
||||
true, snapshot
|
||||
)
|
||||
|
||||
// 渲染右侧:明日
|
||||
val tomorrowCourses = allCourses.filter { it.date == tomorrow.toString() }
|
||||
val effectiveTomorrow = tomorrowCourses.filter { (!it.is_skipped) }.sortedBy { it.start_time }
|
||||
|
||||
renderColumn(
|
||||
context, rv,
|
||||
R.id.container_tomorrow, R.id.tv_tomorrow_date, R.id.tv_tomorrow_footer,
|
||||
R.id.empty_tomorrow_container,
|
||||
tomorrow, effectiveTomorrow, effectiveTomorrow.size,
|
||||
false, snapshot
|
||||
)
|
||||
|
||||
return rv
|
||||
}
|
||||
|
||||
private fun resetWidgetState(rv: RemoteViews) {
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_vacation, View.GONE)
|
||||
rv.removeAllViews(R.id.container_today)
|
||||
rv.removeAllViews(R.id.container_tomorrow)
|
||||
rv.setViewVisibility(R.id.empty_today_container, View.GONE)
|
||||
rv.setViewVisibility(R.id.empty_tomorrow_container, View.GONE)
|
||||
}
|
||||
|
||||
private fun renderColumn(
|
||||
context: Context,
|
||||
rootRv: RemoteViews,
|
||||
containerId: Int,
|
||||
dateId: Int,
|
||||
footerId: Int,
|
||||
emptyContainerId: Int,
|
||||
date: LocalDate,
|
||||
displayCourses: List<WidgetCourseProto>,
|
||||
totalCount: Int,
|
||||
isToday: Boolean,
|
||||
snapshot: WidgetSnapshot
|
||||
) {
|
||||
// 设置日期标题
|
||||
val prefix = if (isToday) {
|
||||
context.getString(R.string.widget_title_today)
|
||||
} else {
|
||||
context.getString(R.string.widget_title_tomorrow)
|
||||
}
|
||||
val datePattern = date.format(DateTimeFormatter.ofPattern("M.dd E", Locale.getDefault()))
|
||||
rootRv.setTextViewText(dateId, "$prefix $datePattern")
|
||||
|
||||
if (totalCount == 0) {
|
||||
rootRv.setViewVisibility(containerId, View.GONE)
|
||||
rootRv.setViewVisibility(emptyContainerId, View.VISIBLE)
|
||||
rootRv.setViewVisibility(footerId, View.GONE)
|
||||
val emptyTextViewId = if (isToday) R.id.empty_today else R.id.empty_tomorrow
|
||||
rootRv.setTextViewText(emptyTextViewId, context.getString(R.string.text_no_course))
|
||||
} else {
|
||||
rootRv.setViewVisibility(containerId, View.VISIBLE)
|
||||
rootRv.setViewVisibility(emptyContainerId, View.GONE)
|
||||
rootRv.setViewVisibility(footerId, View.VISIBLE)
|
||||
|
||||
// 设置统计文案:今日显示“剩余”,其他显示“共有”
|
||||
val countRes = if (isToday) R.string.widget_course_remaining_count else R.string.widget_course_total_count
|
||||
rootRv.setTextViewText(footerId, context.getString(countRes, totalCount))
|
||||
|
||||
// 循环渲染所有课程
|
||||
displayCourses.forEachIndexed { index, course ->
|
||||
val itemRv = RemoteViews(context.packageName, R.layout.widget_item_course_common)
|
||||
itemRv.setTextViewText(R.id.tv_course_name, course.name)
|
||||
itemRv.setTextViewText(R.id.tv_course_position, course.position)
|
||||
|
||||
val timeRange = "${course.start_time.take(5)}-${course.end_time.take(5)}"
|
||||
itemRv.setTextViewText(R.id.tv_course_time, timeRange)
|
||||
|
||||
if (course.teacher.isNotBlank()) {
|
||||
itemRv.setViewVisibility(R.id.tv_course_teacher, View.VISIBLE)
|
||||
itemRv.setTextViewText(R.id.tv_course_teacher, course.teacher)
|
||||
} else {
|
||||
itemRv.setViewVisibility(R.id.tv_course_teacher, View.GONE)
|
||||
}
|
||||
|
||||
val style = snapshot.style
|
||||
val colorInt = course.color_int
|
||||
if (style != null && colorInt < style.course_color_maps.size) {
|
||||
val colorPair = style.course_color_maps[colorInt]
|
||||
itemRv.setInt(R.id.course_indicator, "setColorFilter",
|
||||
colorPair.light_color.toInt()
|
||||
)
|
||||
itemRv.setInt(R.id.course_indicator_dark, "setColorFilter",
|
||||
colorPair.dark_color.toInt()
|
||||
)
|
||||
}
|
||||
|
||||
rootRv.addView(containerId, itemRv)
|
||||
|
||||
// 无限显示逻辑:只要不是最后一项,就添加横向分割线
|
||||
if (index < displayCourses.size - 1) {
|
||||
rootRv.addView(containerId, RemoteViews(context.packageName, R.layout.widget_divider_horizontal))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.list_vertical
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.Context
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WorkManagerHelper
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.updateAllWidgets
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 垂直列表版小组件接收器
|
||||
* 负责响应系统刷新广播并触发 ListVerticalNativeRenderer 进行渲染
|
||||
*/
|
||||
class ListVerticalNativeProvider : AppWidgetProvider() {
|
||||
private val scope = MainScope()
|
||||
|
||||
/**
|
||||
* 当小组件需要更新时调用(系统定时或手动请求)
|
||||
*/
|
||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||
scope.launch {
|
||||
updateAllWidgets(context)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当第一个该类型的小组件添加到桌面时调用
|
||||
*/
|
||||
override fun onEnabled(context: Context) {
|
||||
super.onEnabled(context)
|
||||
// 确保后台任务正在运行
|
||||
WorkManagerHelper.schedulePeriodicWork(context)
|
||||
}
|
||||
|
||||
/**
|
||||
* 当该类型的最后一个小组件从桌面移除时调用
|
||||
*/
|
||||
override fun onDisabled(context: Context) {
|
||||
super.onDisabled(context)
|
||||
WorkManagerHelper.cancelAllWork(context)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.list_vertical
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import com.xingheyuzhuan.shiguangschedule.MainActivity
|
||||
import com.xingheyuzhuan.shiguangschedule.R
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WidgetSnapshot
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WidgetCourseProto
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
|
||||
object ListVerticalNativeRenderer {
|
||||
|
||||
fun render(context: Context, snapshot: WidgetSnapshot): RemoteViews {
|
||||
val rv = RemoteViews(context.packageName, R.layout.widget_list_vertical_native)
|
||||
|
||||
resetWidgetState(rv)
|
||||
|
||||
val intent = Intent(context, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
context, 0, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
rv.setOnClickPendingIntent(R.id.widget_root, pendingIntent)
|
||||
|
||||
val now = LocalTime.now()
|
||||
val today = LocalDate.now()
|
||||
val tomorrow = today.plusDays(1)
|
||||
val allCourses = snapshot.courses
|
||||
val currentWeek = if (snapshot.current_week <= 0) null else snapshot.current_week
|
||||
|
||||
if (currentWeek == null) {
|
||||
showFullStatus(
|
||||
rv,
|
||||
context.getString(R.string.title_vacation),
|
||||
context.getString(R.string.widget_vacation_expecting)
|
||||
)
|
||||
return rv
|
||||
}
|
||||
|
||||
val todayStr = today.toString()
|
||||
val tomorrowStr = tomorrow.toString()
|
||||
|
||||
val todayRemaining = allCourses.filter {
|
||||
(it.date == todayStr || it.date.isBlank()) && !it.is_skipped && try { LocalTime.parse(it.end_time) > now } catch (_: Exception) { true }
|
||||
}.sortedBy { it.start_time }
|
||||
|
||||
val tomorrowCourses = allCourses.filter {
|
||||
it.date == tomorrowStr && !it.is_skipped
|
||||
}.sortedBy { it.start_time }
|
||||
|
||||
val weekDaysArray = context.resources.getStringArray(R.array.week_days_full_names)
|
||||
val dayOfWeekStr = weekDaysArray[today.dayOfWeek.value - 1]
|
||||
|
||||
when {
|
||||
todayRemaining.isNotEmpty() -> {
|
||||
val weekText = context.getString(R.string.title_current_week, currentWeek.toString())
|
||||
rv.setTextViewText(R.id.tv_header_title, "$weekText $dayOfWeekStr")
|
||||
rv.setTextViewText(R.id.tv_header_count_summary, context.getString(R.string.widget_remaining_courses_format_today, todayRemaining.size))
|
||||
renderCourseContent(context, rv, todayRemaining, snapshot)
|
||||
}
|
||||
tomorrowCourses.isNotEmpty() -> {
|
||||
rv.setTextViewText(R.id.tv_header_title, context.getString(R.string.widget_tomorrow_course_preview))
|
||||
rv.setTextViewText(R.id.tv_header_count_summary, context.getString(R.string.widget_remaining_courses_format_tomorrow, tomorrowCourses.size))
|
||||
renderCourseContent(context, rv, tomorrowCourses, snapshot)
|
||||
}
|
||||
else -> {
|
||||
val hasCoursesToday = allCourses.any { it.date == todayStr || it.date.isBlank() }
|
||||
val tip = if (!hasCoursesToday) context.getString(R.string.text_no_courses_today) else context.getString(R.string.widget_today_courses_finished)
|
||||
val weekText = context.getString(R.string.title_current_week, currentWeek.toString())
|
||||
rv.setTextViewText(R.id.tv_header_title, "$weekText $dayOfWeekStr")
|
||||
showInnerStatus(rv, tip)
|
||||
rv.setTextViewText(R.id.tv_header_count_summary, "")
|
||||
}
|
||||
}
|
||||
return rv
|
||||
}
|
||||
|
||||
private fun resetWidgetState(rv: RemoteViews) {
|
||||
rv.setViewVisibility(R.id.container_full_status, View.GONE)
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_courses, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_status, View.GONE)
|
||||
rv.removeAllViews(R.id.container_courses)
|
||||
}
|
||||
|
||||
private fun renderCourseContent(context: Context, rv: RemoteViews, courses: List<WidgetCourseProto>, snapshot: WidgetSnapshot) {
|
||||
rv.setViewVisibility(R.id.container_courses, View.VISIBLE)
|
||||
|
||||
courses.forEachIndexed { index, course ->
|
||||
val itemRv = RemoteViews(context.packageName, R.layout.widget_item_course_list_node)
|
||||
|
||||
itemRv.setTextViewText(R.id.tv_course_name, course.name)
|
||||
itemRv.setTextViewText(R.id.tv_course_position, course.position)
|
||||
itemRv.setTextViewText(R.id.tv_course_start_time, course.start_time.take(5))
|
||||
itemRv.setTextViewText(R.id.tv_course_end_time, course.end_time.take(5))
|
||||
|
||||
if (course.teacher.isNotBlank()) {
|
||||
itemRv.setViewVisibility(R.id.tv_course_teacher, View.VISIBLE)
|
||||
itemRv.setTextViewText(R.id.tv_course_teacher, course.teacher)
|
||||
} else {
|
||||
itemRv.setViewVisibility(R.id.tv_course_teacher, View.GONE)
|
||||
}
|
||||
|
||||
val style = snapshot.style
|
||||
val colorInt = course.color_int
|
||||
if (style != null && colorInt < style.course_color_maps.size) {
|
||||
val colorPair = style.course_color_maps[colorInt]
|
||||
itemRv.setInt(R.id.course_indicator, "setColorFilter",
|
||||
colorPair.light_color.toInt()
|
||||
)
|
||||
itemRv.setInt(R.id.course_indicator_dark, "setColorFilter",
|
||||
colorPair.dark_color.toInt()
|
||||
)
|
||||
}
|
||||
|
||||
rv.addView(R.id.container_courses, itemRv)
|
||||
|
||||
if (index < courses.size - 1) {
|
||||
rv.addView(R.id.container_courses, RemoteViews(context.packageName, R.layout.widget_divider_horizontal))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showFullStatus(rv: RemoteViews, title: String, msg: String) {
|
||||
rv.setViewVisibility(R.id.inner_content_card, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_full_status, View.VISIBLE)
|
||||
rv.setTextViewText(R.id.tv_full_status_title, title)
|
||||
rv.setTextViewText(R.id.tv_full_status_msg, msg)
|
||||
}
|
||||
|
||||
private fun showInnerStatus(rv: RemoteViews, title: String) {
|
||||
rv.setViewVisibility(R.id.container_courses, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_status, View.VISIBLE)
|
||||
rv.setTextViewText(R.id.tv_status_title, title)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.tiny
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.Context
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WorkManagerHelper
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.updateAllWidgets
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class TinyNativeProvider : AppWidgetProvider() {
|
||||
private val scope = MainScope()
|
||||
|
||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||
scope.launch {
|
||||
updateAllWidgets(context)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onEnabled(context: Context) {
|
||||
super.onEnabled(context)
|
||||
WorkManagerHelper.schedulePeriodicWork(context)
|
||||
}
|
||||
|
||||
override fun onDisabled(context: Context) {
|
||||
super.onDisabled(context)
|
||||
WorkManagerHelper.cancelAllWork(context)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.xingheyuzhuan.shiguangschedule.widget.tiny
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import com.xingheyuzhuan.shiguangschedule.MainActivity
|
||||
import com.xingheyuzhuan.shiguangschedule.R
|
||||
import com.xingheyuzhuan.shiguangschedule.widget.WidgetSnapshot
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
|
||||
object TinyNativeRenderer {
|
||||
|
||||
fun render(context: Context, snapshot: WidgetSnapshot): RemoteViews {
|
||||
val rv = RemoteViews(context.packageName, R.layout.widget_tiny_native)
|
||||
|
||||
// 状态彻底重置
|
||||
resetWidgetState(rv)
|
||||
|
||||
// 设置点击跳转
|
||||
val intent = Intent(context, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(context, 0, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||
rv.setOnClickPendingIntent(R.id.widget_root, pendingIntent)
|
||||
|
||||
// 数据准备
|
||||
val allCourses = snapshot.courses
|
||||
val currentWeek = if (snapshot.current_week <= 0) null else snapshot.current_week
|
||||
val now = LocalTime.now()
|
||||
val todayStr = LocalDate.now().toString()
|
||||
|
||||
// 状态渲染逻辑
|
||||
|
||||
// 情况 A:假期处理
|
||||
if (currentWeek == null) {
|
||||
showStatus(rv, context.getString(R.string.title_vacation), context.getString(R.string.widget_vacation_expecting))
|
||||
return rv
|
||||
}
|
||||
|
||||
// 情况 B:开学期间数据过滤
|
||||
val todayAllCourses = allCourses.filter { it.date == todayStr || it.date.isBlank() }
|
||||
val nextCourse = todayAllCourses.firstOrNull {
|
||||
!it.is_skipped && try {
|
||||
LocalTime.parse(it.end_time) > now
|
||||
} catch (_: Exception) { true }
|
||||
}
|
||||
|
||||
if (nextCourse != null) {
|
||||
// 有课显示逻辑
|
||||
rv.setViewVisibility(R.id.container_info, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.bubble_frame, View.VISIBLE)
|
||||
rv.setViewVisibility(R.id.container_status, View.GONE)
|
||||
|
||||
rv.setTextViewText(R.id.tv_course_name, nextCourse.name)
|
||||
|
||||
val timeText = "${nextCourse.start_time.take(5)} - ${nextCourse.end_time.take(5)}"
|
||||
rv.setTextViewText(R.id.tv_course_time, timeText)
|
||||
rv.setTextViewText(R.id.tv_course_position, nextCourse.position)
|
||||
|
||||
// 剩余课程数统计 (基于原始列表索引)
|
||||
val nextCourseIndex = todayAllCourses.indexOf(nextCourse)
|
||||
val remainingCount = todayAllCourses.size - nextCourseIndex
|
||||
rv.setTextViewText(R.id.tv_remaining_count, remainingCount.toString())
|
||||
|
||||
// 颜色渲染
|
||||
val style = snapshot.style
|
||||
val colorInt = nextCourse.color_int
|
||||
if (style != null && colorInt < style.course_color_maps.size) {
|
||||
val colorPair = style.course_color_maps[colorInt]
|
||||
rv.setInt(R.id.bubble_bg_image, "setColorFilter", colorPair.light_color.toInt())
|
||||
rv.setInt(R.id.bubble_bg_image_dark, "setColorFilter", colorPair.dark_color.toInt())
|
||||
}
|
||||
} else {
|
||||
// 无课状态
|
||||
val tip = if (todayAllCourses.isEmpty()) {
|
||||
context.getString(R.string.text_no_courses_today)
|
||||
} else {
|
||||
context.getString(R.string.widget_today_courses_finished)
|
||||
}
|
||||
showStatus(rv, tip)
|
||||
}
|
||||
|
||||
return rv
|
||||
}
|
||||
|
||||
/**
|
||||
* 核心优化:每次渲染前强制归零可见性,消除跨状态残留
|
||||
*/
|
||||
private fun resetWidgetState(rv: RemoteViews) {
|
||||
rv.setViewVisibility(R.id.container_info, View.GONE)
|
||||
rv.setViewVisibility(R.id.bubble_frame, View.GONE)
|
||||
rv.setViewVisibility(R.id.container_status, View.GONE)
|
||||
}
|
||||
|
||||
private fun showStatus(rv: RemoteViews, title: String, message: String? = null) {
|
||||
rv.setViewVisibility(R.id.container_status, View.VISIBLE)
|
||||
rv.setTextViewText(R.id.tv_status_title, title)
|
||||
|
||||
if (!message.isNullOrBlank()) {
|
||||
rv.setTextViewText(R.id.tv_status_msg, message)
|
||||
rv.setViewVisibility(R.id.tv_status_msg, View.VISIBLE)
|
||||
} else {
|
||||
rv.setViewVisibility(R.id.tv_status_msg, View.GONE)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/widget_bg" />
|
||||
<corners android:radius="21dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M320,560Q337,560 348.5,548.5Q360,537 360,520Q360,503 348.5,491.5Q337,480 320,480Q303,480 291.5,491.5Q280,503 280,520Q280,537 291.5,548.5Q303,560 320,560ZM480,560Q497,560 508.5,548.5Q520,537 520,520Q520,503 508.5,491.5Q497,480 480,480Q463,480 451.5,491.5Q440,503 440,520Q440,537 451.5,548.5Q463,560 480,560ZM640,560Q657,560 668.5,548.5Q680,537 680,520Q680,503 668.5,491.5Q657,480 640,480Q623,480 611.5,491.5Q600,503 600,520Q600,537 611.5,548.5Q623,560 640,560ZM480,880Q405,880 339.5,851.5Q274,823 225.5,774.5Q177,726 148.5,660.5Q120,595 120,520Q120,445 148.5,379.5Q177,314 225.5,265.5Q274,217 339.5,188.5Q405,160 480,160Q555,160 620.5,188.5Q686,217 734.5,265.5Q783,314 811.5,379.5Q840,445 840,520Q840,595 811.5,660.5Q783,726 734.5,774.5Q686,823 620.5,851.5Q555,880 480,880ZM480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520Q480,520 480,520ZM224,94L280,150L110,320L54,264L224,94ZM736,94L906,264L850,320L680,150L736,94ZM480,800Q597,800 678.5,718.5Q760,637 760,520Q760,403 678.5,321.5Q597,240 480,240Q363,240 281.5,321.5Q200,403 200,520Q200,637 281.5,718.5Q363,800 480,800Z"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/widget_bg" />
|
||||
<corners android:radius="18dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<corners android:radius="10dp" />
|
||||
<size android:width="4dp" android:height="40dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/widget_bg" />
|
||||
<corners android:radius="21dp" />
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval"> <solid android:color="#3498DB" />
|
||||
</shape>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?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="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingHorizontal="4dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/course_indicator_dark"
|
||||
android:layout_width="4dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:src="@drawable/widget_indicator_shape" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="6dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="12dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="高等数学" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toStartOf="@+id/tv_course_time"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="教一 101" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="08:00-09:35" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_teacher"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="9dp"
|
||||
tools:text="张老师" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?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"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="60dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:paddingHorizontal="4dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/course_indicator_dark"
|
||||
android:layout_width="4dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/widget_indicator_shape" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_time_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/course_indicator_dark"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_start_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="10.5dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="14:00" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_end_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10.5dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="15:35" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/container_time_vertical"
|
||||
android:layout_marginStart="8dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="13dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="设计模式原理" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="实验楼 B402" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_teacher"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="9dp"
|
||||
tools:text="张建国 教授" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/bubble_bg_dark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bubble_bg_image_dark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/widget_shape_circle_base" />
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginHorizontal="6dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:background="@color/widget_divider" />
|
||||
@@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/widget_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/inner_content_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_bg_rounded"
|
||||
android:orientation="vertical"
|
||||
android:padding="14dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_current_week"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="第 18 周" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_today_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="11dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="今日 1.07 周三" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_today_footer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="8dp"
|
||||
tools:text="剩余 2 节" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_today"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="vertical">
|
||||
<include layout="@layout/widget_item_course_common" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/empty_today_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:id="@+id/empty_today"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="无课程"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="12dp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_divider"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:alpha="0.2"
|
||||
android:background="@color/widget_divider" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tomorrow_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="11dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="明日 1.08 周四" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tomorrow_footer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="8dp"
|
||||
tools:text="共有 4 节" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_tomorrow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="vertical">
|
||||
<include layout="@layout/widget_item_course_common" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/empty_tomorrow_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:id="@+id/empty_tomorrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="无课程"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="12dp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_vacation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_bg_rounded"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="14dp"
|
||||
android:visibility="gone">
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />
|
||||
<TextView
|
||||
android:id="@+id/tv_vacation_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="18dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="暑假快乐" />
|
||||
<TextView
|
||||
android:id="@+id/tv_vacation_msg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="13dp"
|
||||
tools:text="愿你的假期充满阳光" />
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?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="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingHorizontal="4dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/course_indicator"
|
||||
android:layout_width="4dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:src="@drawable/widget_indicator_shape" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="6dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="12dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="高等数学" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toStartOf="@+id/tv_course_time"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="教一 101" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="08:00-09:35" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_teacher"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="9dp"
|
||||
tools:text="张老师" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?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"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="60dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:paddingHorizontal="4dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/course_indicator"
|
||||
android:layout_width="4dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/widget_indicator_shape" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_time_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/course_indicator"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_start_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="10.5dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="14:00" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_end_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10.5dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="15:35" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/container_time_vertical"
|
||||
android:layout_marginStart="8dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="13dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="设计模式原理" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="实验楼 B402" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_teacher"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="9dp"
|
||||
tools:text="张建国 教授" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,111 @@
|
||||
<?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:id="@+id/widget_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/inner_content_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_bg_rounded"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_header_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="14dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="第 8 周 周五" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_header_count_summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="11dp"
|
||||
tools:text="今日还有 3 节课" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_courses"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
tools:visibility="visible">
|
||||
|
||||
<include layout="@layout/widget_item_course_list_node" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/widget_divider"
|
||||
android:alpha="0.2" />
|
||||
|
||||
<include layout="@layout/widget_item_course_list_node" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/widget_divider"
|
||||
android:alpha="0.2" />
|
||||
|
||||
<include layout="@layout/widget_item_course_list_node" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_status_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="13dp"
|
||||
tools:text="今日课程已结束" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_full_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_bg_rounded"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_full_status_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="假期中" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_full_status_msg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="12dp"
|
||||
tools:text="期待新学期" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_loading_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/widget_loading_background">
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="正在加载课程..."
|
||||
android:textColor="@color/loading_text_color" />
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/bubble_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bubble_bg_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/widget_shape_circle_base" /> </FrameLayout>
|
||||
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/widget_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/inner_content_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_bg_rounded"
|
||||
android:orientation="vertical"
|
||||
android:padding="14dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@+id/bubble_frame"
|
||||
android:orientation="vertical"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="14dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="计算机网络" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="12dp"
|
||||
tools:text="08:30 - 23:59" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_course_position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="0dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="12dp"
|
||||
tools:text="实验楼 402" />
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/bubble_frame"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
tools:visibility="visible">
|
||||
|
||||
<include layout="@layout/widget_tiny_circle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_remaining_count"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="11dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="1" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_status_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="15dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="假期中" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_status_msg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="11dp"
|
||||
tools:text="期待新学期" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/widget_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/inner_content_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_bg_rounded"
|
||||
android:orientation="vertical"
|
||||
android:padding="14dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_header_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="11dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="周三" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_footer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_hint"
|
||||
android:textSize="8dp"
|
||||
tools:text="剩余 3 节" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_current_week"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="10dp"
|
||||
tools:text="第 18 周" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_courses"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="vertical">
|
||||
<include layout="@layout/widget_item_course_common" />
|
||||
<include layout="@layout/widget_item_course_common" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="gone">
|
||||
<TextView
|
||||
android:id="@+id/tv_status_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="今日课程已结束" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_full_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_bg_rounded"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:padding="14dp">
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />
|
||||
<TextView
|
||||
android:id="@+id/tv_full_status_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/widget_text_primary"
|
||||
android:textSize="18dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="假期中" />
|
||||
<TextView
|
||||
android:id="@+id/tv_full_status_msg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="@color/widget_text_secondary"
|
||||
android:textSize="13dp"
|
||||
tools:text="期待新学期" />
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1 @@
|
||||
unqualifiedResLocale=zh-CN
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="loading_text_color">#FFFFFFFF</color>
|
||||
<color name="widget_bg">#141218</color> # 深色背景:使用深灰色,避免纯黑拖影
|
||||
<color name="widget_text_primary">#F2F2F7</color> # 主文字:在深色背景下改为接近纯白的亮灰色
|
||||
<color name="widget_text_secondary">#AEA9AF</color> # 次要文字:中灰色,保持视觉层级
|
||||
<color name="widget_text_hint">#8E8E93</color> # 提示文字:深灰色,起到弱化作用
|
||||
<color name="widget_divider">#2C2C2E</color> # 深色分割线:比背景略亮的灰色
|
||||
<color name="widget_course_fallback">#3A3A3C</color> # 深色模式下的课程指示条兜底色
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="loading_text_color">#FF000000</color>
|
||||
<color name="widget_bg">#FEF7FF</color> # 小组件最底层的圆角卡片背景色
|
||||
<color name="widget_text_primary">#2C3E50</color> # 主文字颜色:用于课程名、日期标题、假期大标题
|
||||
<color name="widget_text_secondary">#5D6D7E</color> # 次要文字颜色:用于周次、教师名、上课地点
|
||||
<color name="widget_text_hint">#808B96</color> # 提示文字颜色:用于无课提示、底部的统计页脚
|
||||
<color name="widget_divider">#EAECEE</color> # 分割线颜色:用于垂直分割线和课程间的水平线
|
||||
<color name="widget_course_fallback">#F2F4F4</color> # 课程指示条兜底色:数据异常时的默认灰色
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#73CAF8</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,38 @@
|
||||
<resources>
|
||||
<string name="app_name">星课表</string>
|
||||
<string name="text_no_courses_today">今天没有课程</string>
|
||||
<string name="label_teacher">教师</string>
|
||||
<string name="label_position">地点</string>
|
||||
<string name="title_current_week">第 %1$s 周</string>
|
||||
<string name="title_vacation">假期中</string>
|
||||
<string name="notification_title_course_alert">上课提醒</string>
|
||||
<string name="notification_live_status_preparing">准备上课</string>
|
||||
<string name="notification_unknown_course">未知课程</string>
|
||||
<string name="notification_unknown_position">地点未知</string>
|
||||
<string name="widget_name_tiny">超小课程2x1</string>
|
||||
<string name="widget_name_compact">紧凑课程2x2</string>
|
||||
<string name="widget_name_double_days">近日课程4x2</string>
|
||||
<string name="widget_name_list_vertical">垂直列表课表4xN</string>
|
||||
<string name="widget_tomorrow_course_preview">明日预告</string>
|
||||
<string name="widget_today_courses_finished">今日课程已结束</string>
|
||||
<string name="widget_vacation_expecting">期待新学期</string>
|
||||
<string name="widget_remaining_courses_format_today">今日还有 %1$d 节课</string>
|
||||
<string name="widget_remaining_courses_format_tomorrow">明天有 %1$d 节课</string>
|
||||
<string name="widget_title_today">今天</string>
|
||||
<string name="widget_title_tomorrow">明天</string>
|
||||
<string name="widget_course_remaining_count">剩余 %1$d 节</string>
|
||||
<string name="widget_course_total_count">共有 %1$d 节</string>
|
||||
<string name="item_course_reminder">课程提醒</string>
|
||||
<string name="action_close">关闭</string>
|
||||
<string name="status_current_week_format">第 %1$d 周</string>
|
||||
<string name="text_no_course">无课程</string>
|
||||
<string-array name="week_days_full_names">
|
||||
<item>周一</item>
|
||||
<item>周二</item>
|
||||
<item>周三</item>
|
||||
<item>周四</item>
|
||||
<item>周五</item>
|
||||
<item>周六</item>
|
||||
<item>周日</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.shiguangschedule" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="android:windowBackground">?android:attr/colorBackground</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowAnimationStyle">@style/Animation.App.Activity</item>
|
||||
</style>
|
||||
|
||||
<style name="Animation.App.Activity" parent="@android:style/Animation.Activity">
|
||||
<!-- 禁用 Activity 级别的动画,将转场动画交给 Compose Navigation 处理 -->
|
||||
<item name="android:activityOpenEnterAnimation">@null</item>
|
||||
<item name="android:activityOpenExitAnimation">@null</item>
|
||||
<item name="android:activityCloseEnterAnimation">@null</item>
|
||||
<item name="android:activityCloseExitAnimation">@null</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older than API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<cache-path name="share_temp_files" path="share_temp/" />
|
||||
</paths>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true">
|
||||
<trust-anchors>
|
||||
<certificates src="system" />
|
||||
</trust-anchors>
|
||||
</base-config>
|
||||
</network-security-config>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp"
|
||||
android:minHeight="110dp"
|
||||
android:targetCellWidth="2"
|
||||
android:targetCellHeight="2"
|
||||
android:updatePeriodMillis="1800000"
|
||||
android:initialLayout="@layout/widget_loading_placeholder"
|
||||
android:previewImage="@drawable/widget_preview_compact"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen">
|
||||
</appwidget-provider>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="250dp"
|
||||
android:minHeight="110dp"
|
||||
android:targetCellWidth="4"
|
||||
android:targetCellHeight="2"
|
||||
android:updatePeriodMillis="1800000"
|
||||
android:initialLayout="@layout/widget_loading_placeholder"
|
||||
android:previewImage="@drawable/widget_preview_double_days"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen">
|
||||
</appwidget-provider>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:initialLayout="@layout/widget_loading_placeholder"
|
||||
android:minWidth="250dp"
|
||||
android:minHeight="110dp"
|
||||
android:minResizeWidth="250dp"
|
||||
android:minResizeHeight="70dp"
|
||||
android:updatePeriodMillis="1800000"
|
||||
android:resizeMode="vertical"
|
||||
android:widgetCategory="home_screen"
|
||||
android:previewImage="@drawable/widget_preview_list_vertical"
|
||||
android:targetCellWidth="4"
|
||||
android:targetCellHeight="2">
|
||||
</appwidget-provider>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp"
|
||||
android:minHeight="40dp"
|
||||
android:targetCellWidth="2"
|
||||
android:targetCellHeight="1"
|
||||
android:updatePeriodMillis="1800000"
|
||||
android:initialLayout="@layout/widget_loading_placeholder"
|
||||
android:previewImage="@drawable/widget_preview_tiny"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen">
|
||||
</appwidget-provider>
|
||||