mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 11:09:49 +08:00
Fixed: Fixed extra keys not showing properly on Android 5
Related issue #739
This commit is contained in:
@@ -173,7 +173,7 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
|||||||
|
|
||||||
private int mNavBarHeight;
|
private int mNavBarHeight;
|
||||||
|
|
||||||
private int mTerminalToolbarDefaultHeight;
|
private float mTerminalToolbarDefaultHeight;
|
||||||
|
|
||||||
|
|
||||||
private static final int CONTEXT_MENU_SELECT_URL_ID = 0;
|
private static final int CONTEXT_MENU_SELECT_URL_ID = 0;
|
||||||
@@ -528,7 +528,7 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
|||||||
if (terminalToolbarViewPager == null) return;
|
if (terminalToolbarViewPager == null) return;
|
||||||
|
|
||||||
ViewGroup.LayoutParams layoutParams = terminalToolbarViewPager.getLayoutParams();
|
ViewGroup.LayoutParams layoutParams = terminalToolbarViewPager.getLayoutParams();
|
||||||
layoutParams.height = (int) Math.round(mTerminalToolbarDefaultHeight *
|
layoutParams.height = Math.round(mTerminalToolbarDefaultHeight *
|
||||||
(mTermuxTerminalExtraKeys.getExtraKeysInfo() == null ? 0 : mTermuxTerminalExtraKeys.getExtraKeysInfo().getMatrix().length) *
|
(mTermuxTerminalExtraKeys.getExtraKeysInfo() == null ? 0 : mTermuxTerminalExtraKeys.getExtraKeysInfo().getMatrix().length) *
|
||||||
mProperties.getTerminalToolbarHeightScaleFactor());
|
mProperties.getTerminalToolbarHeightScaleFactor());
|
||||||
terminalToolbarViewPager.setLayoutParams(layoutParams);
|
terminalToolbarViewPager.setLayoutParams(layoutParams);
|
||||||
@@ -835,6 +835,10 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
|||||||
return (ViewPager) findViewById(R.id.terminal_toolbar_view_pager);
|
return (ViewPager) findViewById(R.id.terminal_toolbar_view_pager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getTerminalToolbarDefaultHeight() {
|
||||||
|
return mTerminalToolbarDefaultHeight;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isTerminalViewSelected() {
|
public boolean isTerminalViewSelected() {
|
||||||
return getTerminalToolbarViewPager().getCurrentItem() == 0;
|
return getTerminalToolbarViewPager().getCurrentItem() == 0;
|
||||||
}
|
}
|
||||||
@@ -960,7 +964,7 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
|||||||
|
|
||||||
if (mExtraKeysView != null) {
|
if (mExtraKeysView != null) {
|
||||||
mExtraKeysView.setButtonTextAllCaps(mProperties.shouldExtraKeysTextBeAllCaps());
|
mExtraKeysView.setButtonTextAllCaps(mProperties.shouldExtraKeysTextBeAllCaps());
|
||||||
mExtraKeysView.reload(mTermuxTerminalExtraKeys.getExtraKeysInfo());
|
mExtraKeysView.reload(mTermuxTerminalExtraKeys.getExtraKeysInfo(), mTerminalToolbarDefaultHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update NightMode.APP_NIGHT_MODE
|
// Update NightMode.APP_NIGHT_MODE
|
||||||
|
@@ -47,7 +47,8 @@ public class TerminalToolbarViewPager {
|
|||||||
extraKeysView.setExtraKeysViewClient(mActivity.getTermuxTerminalExtraKeys());
|
extraKeysView.setExtraKeysViewClient(mActivity.getTermuxTerminalExtraKeys());
|
||||||
extraKeysView.setButtonTextAllCaps(mActivity.getProperties().shouldExtraKeysTextBeAllCaps());
|
extraKeysView.setButtonTextAllCaps(mActivity.getProperties().shouldExtraKeysTextBeAllCaps());
|
||||||
mActivity.setExtraKeysView(extraKeysView);
|
mActivity.setExtraKeysView(extraKeysView);
|
||||||
extraKeysView.reload(mActivity.getTermuxTerminalExtraKeys().getExtraKeysInfo());
|
extraKeysView.reload(mActivity.getTermuxTerminalExtraKeys().getExtraKeysInfo(),
|
||||||
|
mActivity.getTerminalToolbarDefaultHeight());
|
||||||
|
|
||||||
// apply extra keys fix if enabled in prefs
|
// apply extra keys fix if enabled in prefs
|
||||||
if (mActivity.getProperties().isUsingFullScreen() && mActivity.getProperties().isUsingFullScreenWorkAround()) {
|
if (mActivity.getProperties().isUsingFullScreen() && mActivity.getProperties().isUsingFullScreenWorkAround()) {
|
||||||
|
@@ -60,7 +60,7 @@ import com.termux.shared.theme.ThemeUtils;
|
|||||||
* in {@link ExtraKeysView#ExtraKeysView(Context, AttributeSet)} by calling the respective functions.
|
* in {@link ExtraKeysView#ExtraKeysView(Context, AttributeSet)} by calling the respective functions.
|
||||||
* If you extend {@link ExtraKeysView}, you can also set them in the constructor, but do call super().
|
* If you extend {@link ExtraKeysView}, you can also set them in the constructor, but do call super().
|
||||||
*
|
*
|
||||||
* After this you will have to make a call to {@link ExtraKeysView#reload(ExtraKeysInfo) and pass
|
* After this you will have to make a call to {@link ExtraKeysView#reload(ExtraKeysInfo, float) and pass
|
||||||
* it the {@link ExtraKeysInfo} to load and display the extra keys. Read its class javadocs for more
|
* it the {@link ExtraKeysInfo} to load and display the extra keys. Read its class javadocs for more
|
||||||
* info on how to create it.
|
* info on how to create it.
|
||||||
*
|
*
|
||||||
@@ -379,9 +379,11 @@ public final class ExtraKeysView extends GridLayout {
|
|||||||
* Reload this instance of {@link ExtraKeysView} with the info passed in {@code extraKeysInfo}.
|
* Reload this instance of {@link ExtraKeysView} with the info passed in {@code extraKeysInfo}.
|
||||||
*
|
*
|
||||||
* @param extraKeysInfo The {@link ExtraKeysInfo} that defines the necessary info for the extra keys.
|
* @param extraKeysInfo The {@link ExtraKeysInfo} that defines the necessary info for the extra keys.
|
||||||
|
* @param heightPx The height in pixels of the parent surrounding the {@link ExtraKeysView}. It must
|
||||||
|
* be a single child.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
public void reload(ExtraKeysInfo extraKeysInfo) {
|
public void reload(ExtraKeysInfo extraKeysInfo, float heightPx) {
|
||||||
if (extraKeysInfo == null)
|
if (extraKeysInfo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -469,7 +471,11 @@ public final class ExtraKeysView extends GridLayout {
|
|||||||
|
|
||||||
LayoutParams param = new GridLayout.LayoutParams();
|
LayoutParams param = new GridLayout.LayoutParams();
|
||||||
param.width = 0;
|
param.width = 0;
|
||||||
|
if(Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
param.height = (int)(heightPx + 0.5);
|
||||||
|
} else {
|
||||||
param.height = 0;
|
param.height = 0;
|
||||||
|
}
|
||||||
param.setMargins(0, 0, 0, 0);
|
param.setMargins(0, 0, 0, 0);
|
||||||
param.columnSpec = GridLayout.spec(col, GridLayout.FILL, 1.f);
|
param.columnSpec = GridLayout.spec(col, GridLayout.FILL, 1.f);
|
||||||
param.rowSpec = GridLayout.spec(row, GridLayout.FILL, 1.f);
|
param.rowSpec = GridLayout.spec(row, GridLayout.FILL, 1.f);
|
||||||
|
Reference in New Issue
Block a user