-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Support showing similar stickers on Add Screen
- Loading branch information
Showing
23 changed files
with
389 additions
and
68 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
26 changes: 26 additions & 0 deletions
26
.../java/com/skyd/rays/model/preference/search/imagesearch/AddScreenImageSearchPreference.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.rays.model.preference.search.imagesearch | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.booleanPreferencesKey | ||
import com.skyd.rays.ext.dataStore | ||
import com.skyd.rays.ext.put | ||
import com.skyd.rays.model.preference.BasePreference | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
object AddScreenImageSearchPreference : BasePreference<Boolean> { | ||
private const val ADD_SCREEN_IMAGE_SEARCH = "addScreenImageSearch" | ||
override val default = false | ||
|
||
val key = booleanPreferencesKey(ADD_SCREEN_IMAGE_SEARCH) | ||
|
||
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 | ||
} |
26 changes: 26 additions & 0 deletions
26
.../com/skyd/rays/model/preference/search/imagesearch/ImageSearchMaxResultCountPreference.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.rays.model.preference.search.imagesearch | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.intPreferencesKey | ||
import com.skyd.rays.ext.dataStore | ||
import com.skyd.rays.ext.put | ||
import com.skyd.rays.model.preference.BasePreference | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
object ImageSearchMaxResultCountPreference : BasePreference<Int> { | ||
private const val IMAGE_SEARCH_MAX_RESULT_COUNT = "imageSearchMaxResultCount" | ||
override val default = 20 | ||
|
||
val key = intPreferencesKey(IMAGE_SEARCH_MAX_RESULT_COUNT) | ||
|
||
fun put(context: Context, scope: CoroutineScope, value: Int) { | ||
scope.launch(Dispatchers.IO) { | ||
context.dataStore.put(key, value) | ||
} | ||
} | ||
|
||
override fun fromPreferences(preferences: Preferences): Int = 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.