Changes for settings

* Remove un-related options from seetings that we wont use ( we use chroot system's su to open shell with proper env exports )
* Some misc change for shortcuts option
This commit is contained in:
Martin Valba 2023-01-08 19:14:34 +02:00
parent 8120184b00
commit 19d02b409f
3 changed files with 1 additions and 54 deletions

View File

@ -2,10 +2,7 @@ package com.offsec.nhterm.ui.settings
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import com.offsec.nhterm.R
import com.offsec.nhterm.component.config.NeoPreference
import com.offsec.nhterm.utils.runApt
/**
* @author kiva
@ -17,34 +14,6 @@ class GeneralSettingsActivity : BasePreferenceActivity() {
supportActionBar?.title = getString(R.string.general_settings)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
addPreferencesFromResource(R.xml.setting_general)
val currentShell = NeoPreference.getLoginShellName()
findPreference(getString(R.string.key_general_shell)).setOnPreferenceChangeListener { _, value ->
val shellName = value.toString()
val newShell = NeoPreference.findLoginProgram(shellName)
if (newShell == null) {
requestInstallShell(shellName, currentShell)
} else {
postChangeShell(shellName)
}
return@setOnPreferenceChangeListener true
}
}
private fun postChangeShell(shellName: String) = NeoPreference.setLoginShellName(shellName)
private fun requestInstallShell(shellName: String, currentShell: String) {
AlertDialog.Builder(this)
.setTitle(getString(R.string.shell_not_found, shellName))
.setMessage(R.string.shell_not_found_message)
.setPositiveButton(R.string.install) { _, _ ->
runApt("install", "-y", shellName) {
it.onSuccess { postChangeShell(shellName) }
}
}
.setNegativeButton(android.R.string.no, null)
.setOnDismissListener { postChangeShell(currentShell) }
.show()
}
override fun onBuildHeaders(target: MutableList<Header>?) {

View File

@ -4,8 +4,7 @@
android:shortcutId="new_session"
android:enabled="true"
android:icon="@drawable/ic_new_session"
android:shortcutShortLabel="@string/new_session"
tools:targetApi="n_mr1">
android:shortcutShortLabel="@string/new_session">
<intent
android:action="android.intent.action.RUN"
android:targetPackage="com.offsec.nhterm"

View File

@ -1,24 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:defaultValue="bash"
android:entries="@array/pref_general_shell_entries"
android:entryValues="@array/pref_general_shell_entries"
android:key="@string/key_general_shell"
android:summary="@string/pref_general_shell_desc"
android:title="@string/pref_general_shell"/>
<EditTextPreference
android:key="@string/key_general_initial_command"
android:summary="@string/pref_general_initial_command_desc"
android:title="@string/pref_general_initial_command"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_general_vibrate"
android:summary="@string/pref_general_vibrate_desc"
android:title="@string/pref_general_vibrate"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_generaL_backspace_map_to_esc"
@ -31,13 +17,6 @@
android:summary="@string/pref_general_volume_as_control_desc"
android:title="@string/pref_general_volume_as_control"/>
<CheckBoxPreference
android:defaultValue="false"
android:visibility="gone"
android:key="@string/key_general_use_execve_wrapper"
android:summary="@string/pref_general_use_execve_wrapper_desc"
android:title="@string/pref_general_use_execve_wrapper"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_general_enable_word_based_ime"