-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature|optimize|build] Support hide the duplicate title present in …
…description; support swipe on article item; migrate feed screen, media screen, article screen, search screen to Compose; update dependencies
- Loading branch information
Showing
126 changed files
with
3,381 additions
and
2,634 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.skyd.anivu.ext | ||
|
||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.ui.graphics.Color | ||
import com.skyd.anivu.model.preference.appearance.DarkModePreference | ||
import com.skyd.anivu.ui.local.LocalDarkMode | ||
|
||
@Stable | ||
@Composable | ||
@ReadOnlyComposable | ||
infix fun Color.alwaysLight(isAlways: Boolean): Color { | ||
val colorScheme = MaterialTheme.colorScheme | ||
return if (isAlways && DarkModePreference.inDark(value = LocalDarkMode.current)) { | ||
when (this) { | ||
colorScheme.primary -> colorScheme.onPrimary | ||
colorScheme.secondary -> colorScheme.onSecondary | ||
colorScheme.tertiary -> colorScheme.onTertiary | ||
colorScheme.background -> colorScheme.onBackground | ||
colorScheme.error -> colorScheme.onError | ||
colorScheme.surface -> colorScheme.onSurface | ||
colorScheme.surfaceVariant -> colorScheme.onSurfaceVariant | ||
colorScheme.primaryContainer -> colorScheme.onPrimaryContainer | ||
colorScheme.secondaryContainer -> colorScheme.onSecondaryContainer | ||
colorScheme.tertiaryContainer -> colorScheme.onTertiaryContainer | ||
colorScheme.errorContainer -> colorScheme.onErrorContainer | ||
colorScheme.inverseSurface -> colorScheme.inverseOnSurface | ||
|
||
colorScheme.onPrimary -> colorScheme.primary | ||
colorScheme.onSecondary -> colorScheme.secondary | ||
colorScheme.onTertiary -> colorScheme.tertiary | ||
colorScheme.onBackground -> colorScheme.background | ||
colorScheme.onError -> colorScheme.error | ||
colorScheme.onSurface -> colorScheme.surface | ||
colorScheme.onSurfaceVariant -> colorScheme.surfaceVariant | ||
colorScheme.onPrimaryContainer -> colorScheme.primaryContainer | ||
colorScheme.onSecondaryContainer -> colorScheme.secondaryContainer | ||
colorScheme.onTertiaryContainer -> colorScheme.tertiaryContainer | ||
colorScheme.onErrorContainer -> colorScheme.errorContainer | ||
colorScheme.inverseOnSurface -> colorScheme.inverseSurface | ||
|
||
else -> Color.Unspecified | ||
} | ||
} else { | ||
this | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...java/com/skyd/anivu/model/preference/behavior/article/ArticleSwipeLeftActionPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.skyd.anivu.model.preference.behavior.article | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import com.skyd.anivu.R | ||
import com.skyd.anivu.base.BasePreference | ||
import com.skyd.anivu.ext.dataStore | ||
import com.skyd.anivu.ext.getOrDefault | ||
import com.skyd.anivu.ext.put | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
object ArticleSwipeLeftActionPreference : BasePreference<String> { | ||
private const val ARTICLE_SWIPE_LEFT_ACTION = "articleSwipeLeftAction" | ||
|
||
const val READ = "Read" | ||
const val SHOW_ENCLOSURES = "ShowEnclosures" | ||
|
||
val values = arrayOf(READ, SHOW_ENCLOSURES) | ||
|
||
override val default = SHOW_ENCLOSURES | ||
|
||
val key = stringPreferencesKey(ARTICLE_SWIPE_LEFT_ACTION) | ||
|
||
fun put(context: Context, scope: CoroutineScope, value: String) { | ||
scope.launch(Dispatchers.IO) { | ||
context.dataStore.put(key, value) | ||
} | ||
} | ||
|
||
override fun fromPreferences(preferences: Preferences): String = preferences[key] ?: default | ||
|
||
fun toDisplayName( | ||
context: Context, | ||
value: String = context.dataStore.getOrDefault(this), | ||
): String = when (value) { | ||
READ -> context.getString(R.string.article_action_read) | ||
SHOW_ENCLOSURES -> context.getString(R.string.article_action_show_enclosures) | ||
else -> context.getString(R.string.unknown) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../main/java/com/skyd/anivu/model/preference/behavior/article/ArticleTapActionPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.skyd.anivu.model.preference.behavior.article | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import com.skyd.anivu.R | ||
import com.skyd.anivu.base.BasePreference | ||
import com.skyd.anivu.ext.dataStore | ||
import com.skyd.anivu.ext.getOrDefault | ||
import com.skyd.anivu.ext.put | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
object ArticleTapActionPreference : BasePreference<String> { | ||
private const val ARTICLE_TAP_ACTION = "articleTapAction" | ||
|
||
const val READ = "Read" | ||
const val SHOW_ENCLOSURES = "ShowEnclosures" | ||
|
||
val values = arrayOf(READ, SHOW_ENCLOSURES) | ||
|
||
override val default = READ | ||
|
||
val key = stringPreferencesKey(ARTICLE_TAP_ACTION) | ||
|
||
fun put(context: Context, scope: CoroutineScope, value: String) { | ||
scope.launch(Dispatchers.IO) { | ||
context.dataStore.put(key, value) | ||
} | ||
} | ||
|
||
override fun fromPreferences(preferences: Preferences): String = preferences[key] ?: default | ||
|
||
fun toDisplayName( | ||
context: Context, | ||
value: String = context.dataStore.getOrDefault(this), | ||
): String = when (value) { | ||
READ -> context.getString(R.string.article_action_read) | ||
SHOW_ENCLOSURES -> context.getString(R.string.article_action_show_enclosures) | ||
else -> context.getString(R.string.unknown) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...java/com/skyd/anivu/model/preference/behavior/article/DeduplicateTitleInDescPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.skyd.anivu.model.preference.behavior.article | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.booleanPreferencesKey | ||
import com.skyd.anivu.base.BasePreference | ||
import com.skyd.anivu.ext.dataStore | ||
import com.skyd.anivu.ext.put | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
object DeduplicateTitleInDescPreference : BasePreference<Boolean> { | ||
private const val DEDUPLICATE_TITLE_IN_DESC = "deduplicateTitleInDesc" | ||
override val default = true | ||
|
||
val key = booleanPreferencesKey(DEDUPLICATE_TITLE_IN_DESC) | ||
|
||
fun put(context: Context, scope: CoroutineScope, value: Boolean) { | ||
scope.launch(Dispatchers.IO) { | ||
context.dataStore.put(key, value) | ||
} | ||
} | ||
|
||
override fun fromPreferences(preferences: Preferences): Boolean = preferences[key] ?: default | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.