-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow changing toolbar icon and codes (#1110)
- Loading branch information
Showing
14 changed files
with
432 additions
and
88 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
124 changes: 43 additions & 81 deletions
124
app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardIconsSet.kt
Large diffs are not rendered by default.
Oops, something went wrong.
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,16 @@ | ||
package helium314.keyboard.latin | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import helium314.keyboard.latin.settings.Settings | ||
import kotlinx.serialization.json.Json | ||
|
||
fun customIconNames(prefs: SharedPreferences) = runCatching { | ||
Json.decodeFromString<Map<String, String>>(prefs.getString(Settings.PREF_CUSTOM_ICON_NAMES, "")!!) | ||
}.getOrElse { emptyMap() } | ||
|
||
fun customIconIds(context: Context, prefs: SharedPreferences) = customIconNames(prefs) | ||
.mapNotNull { entry -> | ||
val id = runCatching { context.resources.getIdentifier(entry.value, "drawable", context.packageName) }.getOrNull() | ||
id?.let { entry.key to it } | ||
} |
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.