Fixed setting custom channels and switching between official ones being broken

This commit is contained in:
Viktor De Pasquale
2019-05-23 18:11:23 +02:00
parent dabe6267b9
commit df78fd2d41
7 changed files with 90 additions and 55 deletions
@@ -12,6 +12,8 @@ import androidx.core.view.isVisible
import androidx.preference.*
import androidx.recyclerview.widget.RecyclerView
import com.topjohnwu.magisk.App
import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.KConfig
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.data.repository.ModuleRepository
import com.topjohnwu.magisk.data.repository.SettingRepository
@@ -64,4 +66,19 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(),
else
view.setPadding(0, view.paddingTop, view.paddingRight, view.paddingBottom)
}
protected fun setCustomUpdateChannel(userRepo: String) {
KConfig.customUpdateChannel = userRepo
}
protected fun getChannelCompat(channel: Int): KConfig.UpdateChannel {
return when (channel) {
Config.Value.DEFAULT_CHANNEL -> KConfig.UpdateChannel.STABLE
Config.Value.BETA_CHANNEL -> KConfig.UpdateChannel.BETA
Config.Value.CANARY_CHANNEL -> KConfig.UpdateChannel.CANARY
Config.Value.CANARY_DEBUG_CHANNEL -> KConfig.UpdateChannel.CANARY_DEBUG
Config.Value.CUSTOM_CHANNEL -> KConfig.UpdateChannel.CUSTOM
else -> KConfig.updateChannel
}
}
}