Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
srtvprateek committed Mar 30, 2024
1 parent 21c0492 commit 0f9a67d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ import com.squareup.moshi.JsonClass
@Keep
@JsonClass(generateAdapter = true)
internal data class SharedPrefFile(
val label: String,
val label: CharSequence,
val isDefault: Boolean
) : SelectorOption() {
override fun displayText(): String = label

override fun isSame(other: Any): Boolean {
return other is SharedPrefFile && other.label == this.label
}
override fun displayText(): CharSequence = label
}

internal data class SharedPrefKeyValuePair(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package com.pluto.plugins.preferences.utils
import android.content.Context
import android.content.SharedPreferences
import androidx.preference.PreferenceManager
import com.pluto.plugins.preferences.R
import com.pluto.plugins.preferences.ui.SharedPrefFile
import com.pluto.plugins.preferences.ui.SharedPrefKeyValuePair
import com.pluto.plugins.preferences.utils.SharedPrefUtils.Companion.DEFAULT
import com.pluto.plugins.preferences.utils.SharedPrefUtils.Companion.isPlutoPref
import com.pluto.utilities.DebugLog
import com.pluto.utilities.extensions.color
import com.pluto.utilities.spannable.createSpan
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
Expand All @@ -31,7 +34,7 @@ internal class SharedPrefUtils(private val context: Context) {
}
}
set(value) {
preferences.selectedPreferenceFiles = moshiAdapter.toJson(value.map { it.label })
preferences.selectedPreferenceFiles = moshiAdapter.toJson(value.map { it.label.toString() })
field = value
}

Expand Down Expand Up @@ -76,8 +79,8 @@ private fun Context.getSharePreferencesFiles(): ArrayList<SharedPrefFile> {
if (!isPlutoPref(it)) {
list.add(
if (it == "${packageName}_preferences.xml") {
SharedPrefFile(DEFAULT, true)
// SharedPrefFile(createSpan { append(italic(light(fontColor(DEFAULT, color(R.color.pluto___text_dark_60))))) }, true)
// SharedPrefFile(DEFAULT, true)
SharedPrefFile(createSpan { append(italic(light(fontColor(DEFAULT, color(R.color.pluto___text_dark_60))))) }, true)
} else {
val label = it.replace(".xml", "", true)
SharedPrefFile(label, false)
Expand All @@ -93,12 +96,12 @@ private fun Context.getPrefManager(file: SharedPrefFile): SharedPreferences =
if (file.isDefault) {
PreferenceManager.getDefaultSharedPreferences(this)
} else {
getSharedPreferences(file.label, Context.MODE_PRIVATE)
getSharedPreferences(file.label.toString(), Context.MODE_PRIVATE)
}

private fun Context.getPrefKeyValueMap(file: SharedPrefFile): Pair<CharSequence, List<SharedPrefKeyValuePair>> {
val prefManager = getPrefManager(file)
val list = prefManager.list(file.label, file.isDefault)
val list = prefManager.list(file.label.toString(), file.isDefault)
return Pair(file.label, list)
}

Expand Down

0 comments on commit 0f9a67d

Please sign in to comment.