From 6977dc082faf3358e40ef786fb3a877528c68ea5 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Sat, 1 Feb 2020 16:21:53 +0100 Subject: [PATCH] Fixed texts being incorrect if injected from context --- app/src/main/java/com/topjohnwu/magisk/di/ApplicationModule.kt | 3 ++- app/src/main/java/com/topjohnwu/magisk/utils/TransitiveText.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/di/ApplicationModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/ApplicationModule.kt index 979e6c304..574c90abe 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/ApplicationModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/ApplicationModule.kt @@ -8,6 +8,7 @@ import android.os.Build import android.os.Bundle import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.preference.PreferenceManager +import com.topjohnwu.magisk.core.ResourceMgr import com.topjohnwu.magisk.utils.RxBus import org.koin.core.qualifier.named import org.koin.dsl.module @@ -17,7 +18,7 @@ val Protected = named("protected") val applicationModule = module { single { RxBus() } - factory { get().resources } + factory { ResourceMgr.resource } factory { get().packageManager } factory(Protected) { createDEContext(get()) } single(SUTimeout) { get(Protected).getSharedPreferences("su_timeout", 0) } diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/TransitiveText.kt b/app/src/main/java/com/topjohnwu/magisk/utils/TransitiveText.kt index 9ff4efa6a..7181223b6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/TransitiveText.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/TransitiveText.kt @@ -4,6 +4,7 @@ import android.content.res.Resources import android.widget.TextView import androidx.databinding.BindingAdapter import androidx.databinding.InverseBindingAdapter +import com.topjohnwu.magisk.extensions.get sealed class TransitiveText { @@ -47,7 +48,7 @@ fun CharSequence.asTransitive() = TransitiveText.String(this) @BindingAdapter("android:text") fun TextView.setText(text: TransitiveText) { - this.text = text.getText(resources) + this.text = text.getText(get()) } @InverseBindingAdapter(attribute = "android:text", event = "android:textAttrChanged")