mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 19:14:04 +08:00
Rename com.termux.app.input package to com.termux.app.terminal
Also moves `TermuxViewClient` into com.termux.app.terminal package
This commit is contained in:
@@ -48,9 +48,10 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.termux.R;
|
import com.termux.R;
|
||||||
import com.termux.app.TermuxConstants.TERMUX_APP.TERMUX_ACTIVITY;
|
import com.termux.app.TermuxConstants.TERMUX_APP.TERMUX_ACTIVITY;
|
||||||
import com.termux.app.input.BellHandler;
|
import com.termux.app.terminal.BellHandler;
|
||||||
import com.termux.app.input.extrakeys.ExtraKeysView;
|
import com.termux.app.terminal.TermuxViewClient;
|
||||||
import com.termux.app.input.FullScreenWorkAround;
|
import com.termux.app.terminal.extrakeys.ExtraKeysView;
|
||||||
|
import com.termux.app.terminal.FullScreenWorkAround;
|
||||||
import com.termux.app.settings.properties.TermuxPropertyConstants;
|
import com.termux.app.settings.properties.TermuxPropertyConstants;
|
||||||
import com.termux.app.settings.properties.TermuxSharedProperties;
|
import com.termux.app.settings.properties.TermuxSharedProperties;
|
||||||
import com.termux.terminal.EmulatorDebug;
|
import com.termux.terminal.EmulatorDebug;
|
||||||
@@ -106,14 +107,6 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
|
|
||||||
private static final String BROADCAST_TERMUX_OPENED = TermuxConstants.TERMUX_PACKAGE_NAME + ".app.OPENED";
|
private static final String BROADCAST_TERMUX_OPENED = TermuxConstants.TERMUX_PACKAGE_NAME + ".app.OPENED";
|
||||||
|
|
||||||
/** The main view of the activity showing the terminal. Initialized in onCreate(). */
|
|
||||||
TerminalView mTerminalView;
|
|
||||||
|
|
||||||
ExtraKeysView mExtraKeysView;
|
|
||||||
|
|
||||||
TermuxPreferences mSettings;
|
|
||||||
TermuxSharedProperties mProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The connection to the {@link TermuxService}. Requested in {@link #onCreate(Bundle)} with a call to
|
* The connection to the {@link TermuxService}. Requested in {@link #onCreate(Bundle)} with a call to
|
||||||
* {@link #bindService(Intent, ServiceConnection, int)}, and obtained and stored in
|
* {@link #bindService(Intent, ServiceConnection, int)}, and obtained and stored in
|
||||||
@@ -121,6 +114,15 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
*/
|
*/
|
||||||
TermuxService mTermService;
|
TermuxService mTermService;
|
||||||
|
|
||||||
|
/** The main view of the activity showing the terminal. Initialized in onCreate(). */
|
||||||
|
TerminalView mTerminalView;
|
||||||
|
|
||||||
|
ExtraKeysView mExtraKeysView;
|
||||||
|
|
||||||
|
TermuxPreferences mSettings;
|
||||||
|
|
||||||
|
TermuxSharedProperties mProperties;
|
||||||
|
|
||||||
/** Initialized in {@link #onServiceConnected(ComponentName, IBinder)}. */
|
/** Initialized in {@link #onServiceConnected(ComponentName, IBinder)}. */
|
||||||
ArrayAdapter<TerminalSession> mListViewAdapter;
|
ArrayAdapter<TerminalSession> mListViewAdapter;
|
||||||
|
|
||||||
@@ -378,7 +380,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleShowExtraKeys() {
|
public void toggleShowExtraKeys() {
|
||||||
final ViewPager viewPager = findViewById(R.id.viewpager);
|
final ViewPager viewPager = findViewById(R.id.viewpager);
|
||||||
final boolean showNow = mSettings.toggleShowExtraKeys(TermuxActivity.this);
|
final boolean showNow = mSettings.toggleShowExtraKeys(TermuxActivity.this);
|
||||||
viewPager.setVisibility(showNow ? View.VISIBLE : View.GONE);
|
viewPager.setVisibility(showNow ? View.VISIBLE : View.GONE);
|
||||||
@@ -585,7 +587,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
void renameSession(final TerminalSession sessionToRename) {
|
public void renameSession(final TerminalSession sessionToRename) {
|
||||||
if (sessionToRename == null) return;
|
if (sessionToRename == null) return;
|
||||||
DialogUtils.textInput(this, R.string.session_rename_title, sessionToRename.mSessionName, R.string.session_rename_positive_button, text -> {
|
DialogUtils.textInput(this, R.string.session_rename_title, sessionToRename.mSessionName, R.string.session_rename_positive_button, text -> {
|
||||||
sessionToRename.mSessionName = text;
|
sessionToRename.mSessionName = text;
|
||||||
@@ -607,7 +609,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
TerminalSession getCurrentTermSession() {
|
public TerminalSession getCurrentTermSession() {
|
||||||
return mTerminalView.getCurrentSession();
|
return mTerminalView.getCurrentSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,11 +662,11 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
unbindService(this);
|
unbindService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawerLayout getDrawer() {
|
public DrawerLayout getDrawer() {
|
||||||
return (DrawerLayout) findViewById(R.id.drawer_layout);
|
return (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addNewSession(boolean failSafe, String sessionName) {
|
public void addNewSession(boolean failSafe, String sessionName) {
|
||||||
if (mTermService.getSessions().size() >= MAX_SESSIONS) {
|
if (mTermService.getSessions().size() >= MAX_SESSIONS) {
|
||||||
new AlertDialog.Builder(this).setTitle(R.string.max_terminals_reached_title).setMessage(R.string.max_terminals_reached_message)
|
new AlertDialog.Builder(this).setTitle(R.string.max_terminals_reached_title).setMessage(R.string.max_terminals_reached_message)
|
||||||
.setPositiveButton(android.R.string.ok, null).show();
|
.setPositiveButton(android.R.string.ok, null).show();
|
||||||
@@ -688,7 +690,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Try switching to session and note about it, but do nothing if already displaying the session. */
|
/** Try switching to session and note about it, but do nothing if already displaying the session. */
|
||||||
void switchToSession(TerminalSession session) {
|
public void switchToSession(TerminalSession session) {
|
||||||
if (mTerminalView.attachSession(session)) {
|
if (mTerminalView.attachSession(session)) {
|
||||||
noteSessionInfo();
|
noteSessionInfo();
|
||||||
updateBackgroundColor();
|
updateBackgroundColor();
|
||||||
@@ -835,7 +837,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
return urlSet;
|
return urlSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showUrlSelection() {
|
public void showUrlSelection() {
|
||||||
String text = null;
|
String text = null;
|
||||||
if (getCurrentTermSession() != null) {
|
if (getCurrentTermSession() != null) {
|
||||||
text = getCurrentTermSession().getEmulator().getScreen().getTranscriptTextWithFullLinesJoined();
|
text = getCurrentTermSession().getEmulator().getScreen().getTranscriptTextWithFullLinesJoined();
|
||||||
@@ -975,12 +977,12 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeFontSize(boolean increase) {
|
public void changeFontSize(boolean increase) {
|
||||||
mSettings.changeFontSize(this, increase);
|
mSettings.changeFontSize(this, increase);
|
||||||
mTerminalView.setTextSize(mSettings.getFontSize());
|
mTerminalView.setTextSize(mSettings.getFontSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void doPaste() {
|
public void doPaste() {
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
ClipData clipData = clipboard.getPrimaryClip();
|
ClipData clipData = clipboard.getPrimaryClip();
|
||||||
if (clipData == null) return;
|
if (clipData == null) return;
|
||||||
@@ -1024,4 +1026,19 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TermuxService getTermService() {
|
||||||
|
return mTermService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TerminalView getTerminalView() {
|
||||||
|
return mTerminalView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtraKeysView getExtraKeysView() {
|
||||||
|
return mExtraKeysView;
|
||||||
|
}
|
||||||
|
public TermuxSharedProperties getProperties() {
|
||||||
|
return mProperties;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -5,11 +5,10 @@ import android.content.res.Configuration;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.termux.app.input.extrakeys.ExtraKeysInfo;
|
import com.termux.app.terminal.extrakeys.ExtraKeysInfo;
|
||||||
import com.termux.app.input.KeyboardShortcut;
|
import com.termux.app.terminal.KeyboardShortcut;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package com.termux.app.input;
|
package com.termux.app.terminal;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.termux.app.input;
|
package com.termux.app.terminal;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.view.View;
|
import android.view.View;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.termux.app.input;
|
package com.termux.app.terminal;
|
||||||
|
|
||||||
public class KeyboardShortcut {
|
public class KeyboardShortcut {
|
||||||
|
|
@@ -1,5 +1,6 @@
|
|||||||
package com.termux.app;
|
package com.termux.app.terminal;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@@ -8,8 +9,9 @@ import android.view.KeyEvent;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import com.termux.app.input.KeyboardShortcut;
|
import com.termux.app.TermuxActivity;
|
||||||
import com.termux.app.input.extrakeys.ExtraKeysView;
|
import com.termux.app.TermuxService;
|
||||||
|
import com.termux.app.terminal.extrakeys.ExtraKeysView;
|
||||||
import com.termux.app.settings.properties.TermuxPropertyConstants;
|
import com.termux.app.settings.properties.TermuxPropertyConstants;
|
||||||
import com.termux.terminal.KeyHandler;
|
import com.termux.terminal.KeyHandler;
|
||||||
import com.termux.terminal.TerminalEmulator;
|
import com.termux.terminal.TerminalEmulator;
|
||||||
@@ -44,22 +46,22 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
@Override
|
@Override
|
||||||
public void onSingleTapUp(MotionEvent e) {
|
public void onSingleTapUp(MotionEvent e) {
|
||||||
InputMethodManager mgr = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager mgr = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
mgr.showSoftInput(mActivity.mTerminalView, InputMethodManager.SHOW_IMPLICIT);
|
mgr.showSoftInput(mActivity.getTerminalView(), InputMethodManager.SHOW_IMPLICIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldBackButtonBeMappedToEscape() {
|
public boolean shouldBackButtonBeMappedToEscape() {
|
||||||
return mActivity.mProperties.isBackKeyTheEscapeKey();
|
return mActivity.getProperties().isBackKeyTheEscapeKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnforeCharBasedInput() {
|
public boolean shouldEnforeCharBasedInput() {
|
||||||
return mActivity.mProperties.isEnforcingCharBasedInput();
|
return mActivity.getProperties().isEnforcingCharBasedInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldUseCtrlSpaceWorkaround() {
|
public boolean shouldUseCtrlSpaceWorkaround() {
|
||||||
return mActivity.mProperties.isUsingCtrlSpaceWorkaround();
|
return mActivity.getProperties().isUsingCtrlSpaceWorkaround();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,6 +70,7 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
mActivity.getDrawer().setDrawerLockMode(copyMode ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED : DrawerLayout.LOCK_MODE_UNLOCKED);
|
mActivity.getDrawer().setDrawerLockMode(copyMode ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED : DrawerLayout.LOCK_MODE_UNLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("RtlHardcoded")
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent e, TerminalSession currentSession) {
|
public boolean onKeyDown(int keyCode, KeyEvent e, TerminalSession currentSession) {
|
||||||
if (handleVirtualKeys(keyCode, e, true)) return true;
|
if (handleVirtualKeys(keyCode, e, true)) return true;
|
||||||
@@ -91,7 +94,7 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||||
} else if (unicodeChar == 'm'/* menu */) {
|
} else if (unicodeChar == 'm'/* menu */) {
|
||||||
mActivity.mTerminalView.showContextMenu();
|
mActivity.getTerminalView().showContextMenu();
|
||||||
} else if (unicodeChar == 'r'/* rename */) {
|
} else if (unicodeChar == 'r'/* rename */) {
|
||||||
mActivity.renameSession(currentSession);
|
mActivity.renameSession(currentSession);
|
||||||
} else if (unicodeChar == 'c'/* create */) {
|
} else if (unicodeChar == 'c'/* create */) {
|
||||||
@@ -108,7 +111,7 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
mActivity.changeFontSize(false);
|
mActivity.changeFontSize(false);
|
||||||
} else if (unicodeChar >= '1' && unicodeChar <= '9') {
|
} else if (unicodeChar >= '1' && unicodeChar <= '9') {
|
||||||
int num = unicodeChar - '1';
|
int num = unicodeChar - '1';
|
||||||
TermuxService service = mActivity.mTermService;
|
TermuxService service = mActivity.getTermService();
|
||||||
if (service.getSessions().size() > num)
|
if (service.getSessions().size() > num)
|
||||||
mActivity.switchToSession(service.getSessions().get(num));
|
mActivity.switchToSession(service.getSessions().get(num));
|
||||||
}
|
}
|
||||||
@@ -126,12 +129,12 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean readControlKey() {
|
public boolean readControlKey() {
|
||||||
return (mActivity.mExtraKeysView != null && mActivity.mExtraKeysView.readSpecialButton(ExtraKeysView.SpecialButton.CTRL)) || mVirtualControlKeyDown;
|
return (mActivity.getExtraKeysView() != null && mActivity.getExtraKeysView().readSpecialButton(ExtraKeysView.SpecialButton.CTRL)) || mVirtualControlKeyDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean readAltKey() {
|
public boolean readAltKey() {
|
||||||
return (mActivity.mExtraKeysView != null && mActivity.mExtraKeysView.readSpecialButton(ExtraKeysView.SpecialButton.ALT));
|
return (mActivity.getExtraKeysView() != null && mActivity.getExtraKeysView().readSpecialButton(ExtraKeysView.SpecialButton.ALT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -242,7 +245,7 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<KeyboardShortcut> shortcuts = mActivity.mProperties.getSessionShortcuts();
|
List<KeyboardShortcut> shortcuts = mActivity.getProperties().getSessionShortcuts();
|
||||||
if (!shortcuts.isEmpty()) {
|
if (!shortcuts.isEmpty()) {
|
||||||
int codePointLowerCase = Character.toLowerCase(codePoint);
|
int codePointLowerCase = Character.toLowerCase(codePoint);
|
||||||
for (int i = shortcuts.size() - 1; i >= 0; i--) {
|
for (int i = shortcuts.size() - 1; i >= 0; i--) {
|
||||||
@@ -278,7 +281,7 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
/** Handle dedicated volume buttons as virtual keys if applicable. */
|
/** Handle dedicated volume buttons as virtual keys if applicable. */
|
||||||
private boolean handleVirtualKeys(int keyCode, KeyEvent event, boolean down) {
|
private boolean handleVirtualKeys(int keyCode, KeyEvent event, boolean down) {
|
||||||
InputDevice inputDevice = event.getDevice();
|
InputDevice inputDevice = event.getDevice();
|
||||||
if (mActivity.mProperties.areVirtualVolumeKeysDisabled()) {
|
if (mActivity.getProperties().areVirtualVolumeKeysDisabled()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (inputDevice != null && inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
|
} else if (inputDevice != null && inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
|
||||||
// Do not steal dedicated buttons from a full external keyboard.
|
// Do not steal dedicated buttons from a full external keyboard.
|
||||||
@@ -293,5 +296,4 @@ public final class TermuxViewClient implements TerminalViewClient {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package com.termux.app.input.extrakeys;
|
package com.termux.app.terminal.extrakeys;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
package com.termux.app.input.extrakeys;
|
package com.termux.app.terminal.extrakeys;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.termux.app.input.extrakeys;
|
package com.termux.app.terminal.extrakeys;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.termux.app.input.extrakeys.ExtraKeysView xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.termux.app.terminal.extrakeys.ExtraKeysView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/extra_keys"
|
android:id="@+id/extra_keys"
|
||||||
style="?android:attr/buttonBarStyle"
|
style="?android:attr/buttonBarStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Reference in New Issue
Block a user