-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to disable terminal margin adjustment from termux settings
Previously in (3213502) support was added with `disable-terminal-margin-adjustment` `termux.properties` property to disable terminal margin adjustment in case in causes screen flickering or other issues on some devices. It has now been removed in (7aefd94) and moved to Termux Settings since if it causes issues at startup and users can't access `termux.properties` file from the terminal, they will have to use SAF or root to access it, which will require an external app. Users can set the value from the `Termux Settings` -> `Termux` -> `Terminal View` -> `Terminal Margin Adjustment` toggle. The `Termux Settings` can be accessed from left drawer in termux and from the android launcher shortcut for Termux Settings, usually accessible by long holding on Termux icon.
- Loading branch information
1 parent
7aefd94
commit e0ad9ff
Showing
7 changed files
with
137 additions
and
2 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
77 changes: 77 additions & 0 deletions
77
...c/main/java/com/termux/app/fragments/settings/termux/TerminalViewPreferencesFragment.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,77 @@ | ||
package com.termux.app.fragments.settings.termux; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Keep; | ||
import androidx.preference.PreferenceDataStore; | ||
import androidx.preference.PreferenceFragmentCompat; | ||
import androidx.preference.PreferenceManager; | ||
|
||
import com.termux.R; | ||
import com.termux.shared.settings.preferences.TermuxAppSharedPreferences; | ||
|
||
@Keep | ||
public class TerminalViewPreferencesFragment extends PreferenceFragmentCompat { | ||
|
||
@Override | ||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { | ||
Context context = getContext(); | ||
if (context == null) return; | ||
|
||
PreferenceManager preferenceManager = getPreferenceManager(); | ||
preferenceManager.setPreferenceDataStore(TerminalViewPreferencesDataStore.getInstance(context)); | ||
|
||
setPreferencesFromResource(R.xml.termux_terminal_view_preferences, rootKey); | ||
} | ||
|
||
} | ||
|
||
class TerminalViewPreferencesDataStore extends PreferenceDataStore { | ||
|
||
private final Context mContext; | ||
private final TermuxAppSharedPreferences mPreferences; | ||
|
||
private static TerminalViewPreferencesDataStore mInstance; | ||
|
||
private TerminalViewPreferencesDataStore(Context context) { | ||
mContext = context; | ||
mPreferences = TermuxAppSharedPreferences.build(context, true); | ||
} | ||
|
||
public static synchronized TerminalViewPreferencesDataStore getInstance(Context context) { | ||
if (mInstance == null) { | ||
mInstance = new TerminalViewPreferencesDataStore(context); | ||
} | ||
return mInstance; | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void putBoolean(String key, boolean value) { | ||
if (mPreferences == null) return; | ||
if (key == null) return; | ||
|
||
switch (key) { | ||
case "terminal_margin_adjustment": | ||
mPreferences.setTerminalMarginAdjustment(value); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean getBoolean(String key, boolean defValue) { | ||
if (mPreferences == null) return false; | ||
|
||
switch (key) { | ||
case "terminal_margin_adjustment": | ||
return mPreferences.isTerminalMarginAdjustmentEnabled(); | ||
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
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="view" | ||
app:title="@string/termux_terminal_view_view_header"> | ||
|
||
<SwitchPreferenceCompat | ||
app:key="terminal_margin_adjustment" | ||
app:summaryOff="@string/termux_terminal_view_terminal_margin_adjustment_off" | ||
app:summaryOn="@string/termux_terminal_view_terminal_margin_adjustment_on" | ||
app:title="@string/termux_terminal_view_terminal_margin_adjustment_title" /> | ||
|
||
</PreferenceCategory> | ||
|
||
</PreferenceScreen> |
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