From 8024089bde7657270dce1f4cd530a46a3f7f854f Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Sun, 6 Oct 2019 12:06:31 +0200 Subject: [PATCH] Added indication of whether the manager is hidden --- .../java/com/topjohnwu/magisk/extensions/XString.kt | 8 ++++++++ .../topjohnwu/magisk/redesign/home/HomeViewModel.kt | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/extensions/XString.kt b/app/src/main/java/com/topjohnwu/magisk/extensions/XString.kt index fb0a65840..ad24a1a9e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/extensions/XString.kt +++ b/app/src/main/java/com/topjohnwu/magisk/extensions/XString.kt @@ -4,6 +4,14 @@ import android.content.res.Resources val specialChars = arrayOf('!', '@', '#', '$', '%', '&', '?') +fun String.replaceRandomWithSpecial(passes: Int): String { + var string = this + repeat(passes) { + string = string.replaceRandomWithSpecial() + } + return string +} + fun String.replaceRandomWithSpecial(): String { var random: Char do { diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt index 73431298e..2eb5b60cb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt @@ -7,6 +7,8 @@ import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.Info import com.topjohnwu.magisk.R import com.topjohnwu.magisk.data.repository.MagiskRepository +import com.topjohnwu.magisk.extensions.packageName +import com.topjohnwu.magisk.extensions.replaceRandomWithSpecial import com.topjohnwu.magisk.extensions.res import com.topjohnwu.magisk.model.entity.MagiskJson import com.topjohnwu.magisk.model.entity.ManagerJson @@ -43,6 +45,15 @@ class HomeViewModel( } } + val stateHideManagerName = R.string.manager.res().let { + val result = R.string.manager.res() + if (packageName != BuildConfig.APPLICATION_ID) { + result.replaceRandomWithSpecial(3) + } else { + result + } + } + val itemsMainline = listOf(HomeItem.PayPal.Mainline, HomeItem.Patreon, HomeItem.Twitter.Mainline) val itemsApp =