Skip to content

Commit

Permalink
start using jetpacc compost
Browse files Browse the repository at this point in the history
  • Loading branch information
kawaiiDango committed Sep 13, 2024
1 parent da8fb82 commit 55807be
Show file tree
Hide file tree
Showing 254 changed files with 16,687 additions and 11,536 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ gem 'jekyll-github-metadata'
gem 'jekyll-titles-from-headings'
gem 'jekyll-optional-front-matter'
gem 'jekyll-default-layout'
gem 'jekyll-commonmark-ghpages'
gem 'jekyll-commonmark-ghpages'
gem 'jekyll-remote-theme'
8 changes: 7 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
title: Pano Scrobbler

# Build settings
theme: jekyll-theme-primer

include:
- "img/*"
Expand All @@ -41,16 +40,23 @@ plugins:
- jekyll-optional-front-matter
- jekyll-default-layout
- jekyll-commonmark-ghpages
- jekyll-remote-theme

keep_files:
- fdroid

remote_theme: pages-themes/hacker@v0.2.0

optional_front_matter:
remove_originals: true

defaults:
-
scope:
path: "" # an empty string here means all files in the project
values:
layout: "page"

# Exclude from processing.
# The following items will not be processed, by default.
# Any item listed under the `exclude:` key here will be automatically added to
Expand Down
23 changes: 19 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ plugins {
alias(libs.plugins.github.release)
alias(libs.plugins.baselineprofile)
alias(libs.plugins.play.publisher)
alias(libs.plugins.compose.compiler)
id(libs.plugins.parcelize.get().pluginId)

}

android {
Expand Down Expand Up @@ -72,6 +74,7 @@ android {
buildFeatures {
viewBinding = true
buildConfig = true
compose = true
}

buildTypes {
Expand Down Expand Up @@ -162,40 +165,52 @@ dependencies {
implementation(libs.appcompat)
implementation(libs.core)
implementation(libs.fragment)
implementation(libs.preference.ktx)
implementation(libs.media)
implementation(libs.palette.ktx)
implementation(libs.recyclerview)
implementation(libs.lifecycle.runtime)
implementation(libs.lifecycle.viewmodel)
implementation(libs.lifecycle.viewmodel.compose)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.fragment.compose)
implementation(libs.androidx.navigation.ui)
implementation(libs.androidx.core.remoteviews)
implementation(libs.androidx.transition)
implementation(libs.androidx.activity)
implementation(libs.activity)
implementation(libs.activity.compose)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.work.runtime)
implementation(libs.kotlinx.serialization.json)
implementation(libs.android.snowfall)
implementation(libs.kotlin.csv.jvm)
implementation(libs.androidx.viewpager)
implementation(platform(libs.compose.bom))
implementation(libs.ui)
implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.compose.material3)
implementation(libs.compose.material.icons.extended)
implementation(libs.compose.shimmer)
implementation(libs.datastore.core)
implementation(libs.paging.compose)
debugImplementation(libs.ui.tooling)
debugImplementation(libs.ui.test.manifest)
// viewpager2 doesnt respond to left/right press on TVs, don"t migrate

implementation(libs.material)
implementation(libs.timber)

implementation(libs.okhttp)
implementation(libs.krate)
implementation(libs.krate.kotlinx)
implementation(libs.harmony)
implementation(libs.kumo.core)
implementation(libs.mpAndroidChart)
implementation(libs.nestedscrollwebview)
implementation(libs.skeletonlayout)
implementation(libs.coil)
implementation(libs.coil.compose)
implementation(libs.coil.gif)
implementation(libs.coil.network.okhttp)

Expand Down
3 changes: 0 additions & 3 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
-dontwarn org.slf4j.impl.StaticLoggerBinder
# A resource is loaded with a relative path so the package of this class must be preserved.
#-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keepclassmembers class androidx.preference.PreferenceManager {
private android.content.SharedPreferences mSharedPreferences;
}

# temporary workarounds for https://issuetracker.google.com/issues/349649095
-keep class * implements com.google.firebase.components.ComponentRegistrar { void <init>(); }
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@
android:windowSoftInputMode="adjustPan" />

<activity
android:name=".widget.ChartsWidgetActivity"
android:name=".widget.ChartsWidgetConfigActivity"
android:configChanges="keyboard|keyboardHidden|navigation"
android:exported="true"
android:theme="@style/AppTheme.Wallpaper">
android:theme="@style/AppThemeWithWallpaper">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
Expand Down
51 changes: 23 additions & 28 deletions app/src/main/java/com/arn/scrobble/DigestWorker.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.arn.scrobble

import android.app.NotificationManager
import android.content.Context
import android.text.Html
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.navigation.NavDeepLinkBuilder
import androidx.work.Constraints
Expand All @@ -20,10 +18,8 @@ import com.arn.scrobble.api.Scrobblables
import com.arn.scrobble.api.lastfm.Period
import com.arn.scrobble.api.listenbrainz.ListenbrainzRanges
import com.arn.scrobble.charts.TimePeriod
import com.arn.scrobble.main.App
import com.arn.scrobble.main.MainActivity
import com.arn.scrobble.main.MainDialogActivity
import com.arn.scrobble.pref.MainPrefs
import com.arn.scrobble.themes.ColorPatchUtils
import com.arn.scrobble.utils.Stuff
import com.arn.scrobble.utils.Stuff.isChannelEnabled
Expand All @@ -33,6 +29,9 @@ import com.arn.scrobble.utils.Stuff.setUserFirstDayOfWeek
import com.arn.scrobble.utils.UiUtils
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.supervisorScope
import kotlinx.coroutines.withContext
import timber.log.Timber
Expand All @@ -41,14 +40,7 @@ import java.util.concurrent.TimeUnit

class DigestWorker(context: Context, private val workerParameters: WorkerParameters) :
CoroutineWorker(context, workerParameters) {
private val nm by lazy {
ContextCompat.getSystemService(
applicationContext,
NotificationManager::class.java
)!!
}
private val prefs = App.prefs
private val cal by lazy { Calendar.getInstance().setUserFirstDayOfWeek() }
private val cal by lazy { Calendar.getInstance() }

override suspend fun getForegroundInfo() = ForegroundInfo(
this::class.hashCode(),
Expand All @@ -60,12 +52,9 @@ class DigestWorker(context: Context, private val workerParameters: WorkerParamet

override suspend fun doWork(): Result {
var errored = false
cal.setUserFirstDayOfWeek()

if (nm.isChannelEnabled(
prefs.sharedPreferences,
MainPrefs.CHANNEL_NOTI_DIGEST_WEEKLY
)
) {
if (PlatformStuff.notificationManager.isChannelEnabled(Stuff.CHANNEL_NOTI_DIGEST_WEEKLY)) {
val coExceptionHandler = CoroutineExceptionHandler { coroutineContext, throwable ->
throwable.printStackTrace()
errored = true
Expand Down Expand Up @@ -100,9 +89,12 @@ class DigestWorker(context: Context, private val workerParameters: WorkerParamet

private suspend fun fetchAndNotify(period: Period) {
supervisorScope {
val notificationsOnLockscreen =
PlatformStuff.mainPrefs.data.map { it.notificationsOnLockscreen }.first()

val limit = 3
val notificationTextList = mutableListOf<String>()
val scrobblable = Scrobblables.current ?: return@supervisorScope
val scrobblable = Scrobblables.current.value ?: return@supervisorScope

val timePeriod = TimePeriod(period).apply {
tag = when (period) {
Expand Down Expand Up @@ -154,9 +146,9 @@ class DigestWorker(context: Context, private val workerParameters: WorkerParamet
val notificationText = Html.fromHtml(notificationTextList.joinToString("<br>\n"))

val channelId = if (period == Period.WEEK)
MainPrefs.CHANNEL_NOTI_DIGEST_WEEKLY
Stuff.CHANNEL_NOTI_DIGEST_WEEKLY
else
MainPrefs.CHANNEL_NOTI_DIGEST_MONTHLY
Stuff.CHANNEL_NOTI_DIGEST_MONTHLY

val launchPi = NavDeepLinkBuilder(applicationContext)
.setComponentName(MainActivity::class.java)
Expand Down Expand Up @@ -197,13 +189,13 @@ class DigestWorker(context: Context, private val workerParameters: WorkerParamet
.bigText(notificationText)
)
.setVisibility(
if (prefs.notificationsOnLockscreen)
if (notificationsOnLockscreen)
NotificationCompat.VISIBILITY_PUBLIC
else
NotificationCompat.VISIBILITY_SECRET
)

nm.notify(channelId, period.ordinal, nb.build())
PlatformStuff.notificationManager.notify(channelId, period.ordinal, nb.build())
}
}

Expand All @@ -222,7 +214,7 @@ class DigestWorker(context: Context, private val workerParameters: WorkerParamet
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()

val scheduleTimes = getScheduleTimes()
val scheduleTimes = runBlocking { getScheduleTimes() }

fun enqueue(period: String) {
val inputData = Data.Builder()
Expand Down Expand Up @@ -250,13 +242,16 @@ class DigestWorker(context: Context, private val workerParameters: WorkerParamet
Timber.i("scheduling ${DigestWorker::class.java.simpleName}")
}

private fun getScheduleTimes(): Map<String, Long> {
val prefs = App.prefs
private suspend fun getScheduleTimes(): Map<String, Long> {
val storedDigestSeconds = PlatformStuff.mainPrefs.data
.map { it.digestSeconds }.first()

val digestSeconds = storedDigestSeconds ?: (60..(30 * 60)).random()

if (prefs.digestSeconds == null)
prefs.digestSeconds = (60..(30 * 60)).random()
if (storedDigestSeconds == null)
PlatformStuff.mainPrefs.updateData { it.copy(digestSeconds = digestSeconds) }

val secondsToAdd = -(prefs.digestSeconds ?: 60)
val secondsToAdd = -digestSeconds

val timesMap = mutableMapOf<String, Long>()

Expand Down
30 changes: 14 additions & 16 deletions app/src/main/java/com/arn/scrobble/ListenAlong.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import android.app.PendingIntent
import android.content.Intent
import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import com.arn.scrobble.api.Scrobblables
import com.arn.scrobble.api.lastfm.Track
import com.arn.scrobble.main.App
import com.arn.scrobble.main.MainActivity
import com.arn.scrobble.pref.MainPrefs
import com.arn.scrobble.themes.ColorPatchUtils
import com.arn.scrobble.utils.Stuff
import kotlinx.coroutines.delay
Expand All @@ -29,12 +26,12 @@ object ListenAlong {

suspend fun fetchTrackLoop(username: String) {
while (true) {
val track = Scrobblables.current!!.getRecents(
val track = Scrobblables.current.value?.getRecents(
1,
username,
limit = 1,
).map { it.entries.firstOrNull() }
.getOrNull()
)?.map { it.entries.firstOrNull() }
?.getOrNull()
if (track != null && (track.artist.name != currentTrack?.artist?.name || track.name != currentTrack?.name)) {
currentTrack = track

Expand All @@ -49,43 +46,44 @@ object ListenAlong {
}

private fun showNotification(username: String) {
nm = ContextCompat.getSystemService(App.application, NotificationManager::class.java)!!
val application = PlatformStuff.application
val nm = PlatformStuff.notificationManager

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
nm.createNotificationChannel(
NotificationChannel(
CHANNEL_ID,
App.application.getString(R.string.listen_along),
application.getString(R.string.listen_along),
NotificationManager.IMPORTANCE_LOW
)
)
}

val intent = Intent(App.application, MainActivity::class.java)
val intent = Intent(application, MainActivity::class.java)
val launchIntent = PendingIntent.getActivity(
App.application, 8, intent,
application, 8, intent,
Stuff.updateCurrentOrImmutable
)
val notification =
NotificationCompat.Builder(App.application, MainPrefs.CHANNEL_NOTI_PENDING)
NotificationCompat.Builder(application, Stuff.CHANNEL_NOTI_PENDING)
.setSmallIcon(R.drawable.vd_noti_persistent)
.setPriority(Notification.PRIORITY_LOW)
.setOngoing(true)
.setContentIntent(launchIntent)
.apply { color = (ColorPatchUtils.getNotiColor(App.application) ?: return@apply) }
.apply { color = (ColorPatchUtils.getNotiColor(application) ?: return@apply) }
.addAction(
NotificationCompat.Action(
R.drawable.vd_cancel, App.application.getString(R.string.close),
R.drawable.vd_cancel, application.getString(R.string.close),
PendingIntent.getBroadcast(
App.application, NOTIFICATION_ID,
application, NOTIFICATION_ID,
Intent(NLService.iLISTEN_ALONG)
.setPackage(App.application.packageName)
.setPackage(application.packageName)
.putExtra(STOP_EXTRA, true),
Stuff.updateCurrentOrImmutable
)
)
)
.setContentTitle(App.application.getString(R.string.listen_along))
.setContentTitle(application.getString(R.string.listen_along))
.setContentText(username)
.build()

Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/arn/scrobble/MasterSwitchQS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import android.os.Build
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
import com.arn.scrobble.main.App
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking

@RequiresApi(Build.VERSION_CODES.N)
class MasterSwitchQS : TileService() {

override fun onClick() {
qsTile ?: return
val isActive = qsTile.state == Tile.STATE_ACTIVE
App.prefs.scrobblerEnabled = !isActive

runBlocking { PlatformStuff.mainPrefs.updateData { it.copy(scrobblerEnabled = !isActive) } }
setActive(!isActive)
}

override fun onStartListening() {
qsTile ?: return
val isActive = App.prefs.scrobblerEnabled
val isActive =
runBlocking { PlatformStuff.mainPrefs.data.map { it.scrobblerEnabled }.first() }
setActive(isActive)
}

Expand Down
Loading

0 comments on commit 55807be

Please sign in to comment.