Skip to content

Commit

Permalink
Optimize top bar
Browse files Browse the repository at this point in the history
[Delete unused code]
[Rewrite check task logic]
[Added collapse and expand action to top bar when click scroll to bottom or top]
[Optimize top bar in small and landscape screen]
[Update dependencies]
  • Loading branch information
Z-Siqi committed Oct 10, 2024
1 parent 103d395 commit 2c43acb
Show file tree
Hide file tree
Showing 21 changed files with 947 additions and 1,026 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6")
implementation("androidx.activity:activity-compose:1.9.2")
implementation(platform("androidx.compose:compose-bom:2024.09.02"))
implementation(platform("androidx.compose:compose-bom:2024.09.03"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3-android:1.3.0")
implementation("androidx.compose.foundation:foundation-android:1.7.2")
implementation("androidx.compose.foundation:foundation-android:1.7.3")
implementation("androidx.work:work-runtime-ktx:2.9.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.09.02"))
androidTestImplementation(platform("androidx.compose:compose-bom:2024.09.03"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
// Navigation
implementation("androidx.navigation:navigation-compose:2.8.1")
implementation("androidx.navigation:navigation-compose:2.8.2")
// Room
ksp("androidx.room:room-compiler:2.6.1")
implementation("androidx.room:room-runtime:2.6.1")
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/com/sqz/checklist/database/DAO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ interface TaskDao {
suspend fun searchedList(search: String): List<Task>


/* Get Value Actions */
@Query("SELECT reminder FROM task WHERE id = :id")
suspend fun getReminderInfo(id: Int): String?


/* Insert & Edit Actions */
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertAll(vararg task: Task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class DelayedNotificationWorker(
content != null &&
notifyId != -1
) {
NotificationObject.create(
val notification = NotificationCreator()
notification.creator(
applicationContext,
channelId = channelId,
channelName = channelName,
Expand All @@ -36,4 +37,4 @@ class DelayedNotificationWorker(
}
return Result.success()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.work.Data
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import com.sqz.checklist.MainActivity
import com.sqz.checklist.R
import java.util.UUID

object NotificationObject {
fun create(
class NotificationCreator {
/** Config delayed notification worker. NOT using to create notification **/
fun creator(
context: Context,
channelId: String,
channelName: String,
Expand All @@ -33,36 +38,26 @@ object NotificationObject {
val notificationManager: NotificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)

val fullScreenIntent = Intent(context, MainActivity::class.java)
val fullScreenPendingIntent = PendingIntent.getActivity(
context, 0,
fullScreenIntent, PendingIntent.FLAG_MUTABLE
)

// Build and show notification
val builder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.task_icon)
.setContentTitle(title)
.setContentText(content)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setFullScreenIntent(fullScreenPendingIntent, true)

with(NotificationManagerCompat.from(context)) {
if (ActivityCompat.checkSelfPermission(
context,
Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED
) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.

val packageManager = context.packageManager
val checkApp1 = try {
packageManager.getPackageInfo("me.piebridge.brevent", 0)
Expand All @@ -88,4 +83,33 @@ object NotificationObject {
this.notify(notifyId, builder.build())
}
}
}

/** Create delayed notification **/
fun create(
channelId: String,
channelName: String,
channelDescription: String,
description: String,
content: String = "",
notifyId: Int,
delayDuration: Long,
timeUnit: java.util.concurrent.TimeUnit,
context: Context
) : UUID {
val workRequest = OneTimeWorkRequestBuilder<DelayedNotificationWorker>()
.setInputData(
Data.Builder()
.putString("channelId", channelId)
.putString("channelName", channelName)
.putString("channelDescription", channelDescription)
.putString("title", description)
.putString("content", content)
.putInt("notifyId", notifyId)
.build()
)
.setInitialDelay(delayDuration, timeUnit)
.build()
WorkManager.getInstance(context).enqueue(workRequest)
return workRequest.id
}
}
Loading

0 comments on commit 2c43acb

Please sign in to comment.