Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代码清理 #3

Merged
merged 12 commits into from
Oct 4, 2024
2 changes: 1 addition & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
| ![](assets/Screenshot_20240924-230507.png) | ![](assets/Screenshot_20240924-230519.png) | ![](assets/Screenshot_20240924-231504.png) |
|:-------------:|:-------------:|:-------------:|

## 功能

1. 正选/反选删除媒体文件
2. 定期通知提醒整理媒体文件

## 注意
本应用「按原样提供」,由于涉及到对本地数据的读写,请谨慎使用。
Expand All @@ -20,4 +24,5 @@
1. 手势功能可能存在问题
2. 手势性能/外观有待优化
3. 设计视频预览的展示性能存在问题
4. 权限设置完成后的检测存在问题,需要退出一次应用
4. 通知可能不能按照预期发送
5. 尚未出现的问题
20 changes: 6 additions & 14 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ keystoreProperties.load(FileInputStream(keystorePropertiesFile))

android {
namespace = "top.maary.oblivionis"
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "top.maary.oblivionis"
minSdk = 31
targetSdk = 34
versionCode = 2
versionName = "1.0-alpha-0930"
targetSdk = 35
versionCode = 3
versionName = "1.0-alpha-1003"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -130,29 +130,21 @@ dependencies {
implementation(libs.coil)
implementation(libs.coil.compose)
implementation(libs.coil3.coil.video)

implementation(libs.accompanist.permissions)

implementation(libs.androidx.room.runtime)
annotationProcessor(libs.androidx.room.compiler)

// To use Kotlin Symbol Processing (KSP)
ksp(libs.androidx.room.compiler)

// optional - Kotlin Extensions and Coroutines support for Room
implementation(libs.androidx.room.ktx)

implementation(libs.androidx.media3.exoplayer)
implementation(libs.androidx.media3.exoplayer.dash)
implementation(libs.androidx.media3.ui)

implementation(libs.compose.video)
implementation(libs.androidx.media3.session)

implementation(libs.androidx.foundation)

implementation(libs.androidx.datastore.preferences)

implementation("androidx.compose.material:material-icons-extended:1.7.2")
implementation(libs.androidx.material.icons.extended)
implementation(libs.androidx.constraintlayout.compose)

}
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<uses-permission
android:name="android.permission.MANAGE_MEDIA"
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/top/maary/oblivionis/NotificationHelper.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package top.maary.oblivionis

import android.Manifest
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.compose.ui.res.stringResource
import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat

Expand Down Expand Up @@ -47,6 +49,13 @@ class NotificationHelper(private val context: Context) {
.setAutoCancel(true)
.build()

if (ActivityCompat.checkSelfPermission(
context,
Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED
) {
return
}
NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, notification)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import top.maary.oblivionis.data.ImageRepository

class OblivionisApplication: Application() {

val database by lazy { ImageDatabase.getDataBase(this) }
private val database by lazy { ImageDatabase.getDataBase(this) }
val repository by lazy { ImageRepository(database.imageDao()) }

}
8 changes: 4 additions & 4 deletions app/src/main/java/top/maary/oblivionis/OblivionisScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import top.maary.oblivionis.data.PreferenceRepository
import top.maary.oblivionis.ui.ActionScreen
import top.maary.oblivionis.ui.EntryScreen
import top.maary.oblivionis.ui.RecycleScreen
import top.maary.oblivionis.ui.WelcomeScreen
import top.maary.oblivionis.ui.screen.ActionScreen
import top.maary.oblivionis.ui.screen.EntryScreen
import top.maary.oblivionis.ui.screen.RecycleScreen
import top.maary.oblivionis.ui.screen.WelcomeScreen
import top.maary.oblivionis.ui.screen.SettingsScreen
import top.maary.oblivionis.viewmodel.ActionViewModel
import top.maary.oblivionis.viewmodel.NotificationViewModel
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/top/maary/oblivionis/data/ImageDatabase.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package top.maary.oblivionis.data;
package top.maary.oblivionis.data

import android.content.Context
import androidx.room.AutoMigration
import androidx.room.Database;
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package top.maary.oblivionis.data

import android.util.Log
import androidx.annotation.WorkerThread
import kotlinx.coroutines.flow.Flow

Expand All @@ -9,19 +8,12 @@ class ImageRepository(private val imageDao: ImageDao) {
val allMarks: Flow<List<MediaStoreImage>>? = imageDao.getAllMarks()
val allExcludes: Flow<List<MediaStoreImage>>? = imageDao.getAllExcludes()

// suspend fun getAllMarks(): List<MediaStoreImage>? {
// return imageDao.getAllMarks()
// }

@WorkerThread
suspend fun mark(image: MediaStoreImage) {
// if (image.isMarked and image.isExcluded) image.isMarked = false
Log.v("OBLIVIONIS", "MARK ${image.isMarked} ${image.isExcluded}")
imageDao.mark(image)
}

suspend fun unmark(image: MediaStoreImage) {
Log.v("OBLIVIONIS", "UNMARK ${image.isMarked} ${image.isExcluded}")
if (image.isMarked and image.isExcluded) {
imageDao.updateIsMarked(image.id, false)
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package top.maary.oblivionis.data

import android.content.Context
import androidx.compose.ui.res.stringResource
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
Expand All @@ -20,7 +19,7 @@ class PreferenceRepository(private val context: Context) {
val NOTIFICATION_INTERVAL = intPreferencesKey("NOTIFICATION_INTERVAL")
val NOTIFICATION_INTERVAL_CAL_FIXED = booleanPreferencesKey("NOTIFICATION_INTERVAL_CAL_FIXED")
val NOTIFICATION_INTERVAL_START = intPreferencesKey("NOTIFICATION_INTERVAL_START")
val NOTIFICATION_TIME = stringPreferencesKey("NOTFICATION_TIME")
val NOTIFICATION_TIME = stringPreferencesKey("NOTIFICATION_TIME")
}

val permissionGranted = context.dataStore.data.map { preferences ->
Expand Down
Loading
Loading