Files
vpnhotspotmod/mobile/src/main/java/hanson/xyz/vpnhotspotmod/manage/ManageBar.kt
Brian Hanson cdf6094579 - Renamed project namespace to hanson.xyz.vpnhotspotmod
- Added BroadcastReceiver to recive intents to start wifi and bluetooth tether options via tasker
- Modified TetherService to run sticky
- Modified TetherManager to 'monitor' all new interfaces as soon as they are created
2023-06-22 13:34:13 -05:00

48 lines
1.7 KiB
Kotlin

package hanson.xyz.vpnhotspotmod.manage
import android.content.Context
import android.content.Intent
import android.view.View
import androidx.databinding.BaseObservable
import androidx.recyclerview.widget.RecyclerView
import hanson.xyz.vpnhotspotmod.App.Companion.app
import hanson.xyz.vpnhotspotmod.databinding.ListitemManageBinding
import hanson.xyz.vpnhotspotmod.net.TetherOffloadManager
object ManageBar : Manager() {
private const val TAG = "ManageBar"
private const val SETTINGS_PACKAGE = "com.android.settings"
private const val SETTINGS_1 = "com.android.settings.Settings\$TetherSettingsActivity"
private const val SETTINGS_2 = "com.android.settings.TetherSettings"
object Data : BaseObservable() {
val offloadEnabled get() = TetherOffloadManager.enabled
}
class ViewHolder(binding: ListitemManageBinding) : RecyclerView.ViewHolder(binding.root), View.OnClickListener {
init {
binding.data = Data
binding.root.setOnClickListener(this)
}
override fun onClick(v: View?) = start(itemView.context)
}
override val type: Int get() = VIEW_TYPE_MANAGE
fun start(context: Context) {
try {
context.startActivity(Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_1))
} catch (e1: RuntimeException) {
try {
context.startActivity(Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_2))
app.logEvent(TAG) { param(SETTINGS_1, e1.toString()) }
} catch (e2: RuntimeException) {
app.logEvent(TAG) {
param(SETTINGS_1, e1.toString())
param(SETTINGS_2, e2.toString())
}
}
}
}
}