-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for disabling soft keyboard completely with the "soft_key…
…board_enabled" SharedPreferences key Users can toggle the state from Settings -> Keyboard I/O -> Soft Keyboard toggle. Android phone should also have an internal setting for disabling soft keyboard when a hardware keyboard is connected in Language and Input android settings or from the input mode selection notification, but the above setting will be Termux app specific and will allow soft keyboard to still be shown in other apps. The `TermuxPreferenceConstants` classes has been updated to `v0.7.0`. Check its Changelog section for info on changes.
- Loading branch information
1 parent
04da4b2
commit 2a8d5e2
Showing
8 changed files
with
155 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/termux/app/fragments/settings/TerminalIOPreferencesFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.termux.app.fragments.settings; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import androidx.preference.PreferenceDataStore; | ||
import androidx.preference.PreferenceFragmentCompat; | ||
import androidx.preference.PreferenceManager; | ||
|
||
import com.termux.R; | ||
import com.termux.app.settings.preferences.TermuxAppSharedPreferences; | ||
|
||
public class TerminalIOPreferencesFragment extends PreferenceFragmentCompat { | ||
|
||
@Override | ||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { | ||
PreferenceManager preferenceManager = getPreferenceManager(); | ||
preferenceManager.setPreferenceDataStore(TerminalIOPreferencesDataStore.getInstance(getContext())); | ||
|
||
setPreferencesFromResource(R.xml.terminal_io_preferences, rootKey); | ||
} | ||
|
||
} | ||
|
||
class TerminalIOPreferencesDataStore extends PreferenceDataStore { | ||
|
||
private final Context mContext; | ||
private final TermuxAppSharedPreferences mPreferences; | ||
|
||
private static TerminalIOPreferencesDataStore mInstance; | ||
|
||
private TerminalIOPreferencesDataStore(Context context) { | ||
mContext = context; | ||
mPreferences = new TermuxAppSharedPreferences(context); | ||
} | ||
|
||
public static synchronized TerminalIOPreferencesDataStore getInstance(Context context) { | ||
if (mInstance == null) { | ||
mInstance = new TerminalIOPreferencesDataStore(context.getApplicationContext()); | ||
} | ||
return mInstance; | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void putBoolean(String key, boolean value) { | ||
if(key == null) return; | ||
|
||
switch (key) { | ||
case "soft_keyboard_enabled": | ||
mPreferences.setSoftKeyboardEnabled(value); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean getBoolean(String key, boolean defValue) { | ||
switch (key) { | ||
case "soft_keyboard_enabled": | ||
return mPreferences.getSoftKeyboardEnabled(); | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<PreferenceCategory | ||
app:key="keyboard" | ||
app:title="@string/keyboard_header"> | ||
|
||
<SwitchPreferenceCompat | ||
app:key="soft_keyboard_enabled" | ||
app:summaryOff="@string/soft_keyboard_off" | ||
app:summaryOn="@string/soft_keyboard_on" | ||
app:title="@string/soft_keyboard_title" /> | ||
|
||
</PreferenceCategory> | ||
|
||
</PreferenceScreen> |