mirror of
				https://github.com/fankes/termux-app.git
				synced 2025-10-25 13:19:21 +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.app.TermuxConstants.TERMUX_APP.TERMUX_ACTIVITY; | ||||
| import com.termux.app.input.BellHandler; | ||||
| import com.termux.app.input.extrakeys.ExtraKeysView; | ||||
| import com.termux.app.input.FullScreenWorkAround; | ||||
| import com.termux.app.terminal.BellHandler; | ||||
| import com.termux.app.terminal.TermuxViewClient; | ||||
| 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.TermuxSharedProperties; | ||||
| 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"; | ||||
|  | ||||
|     /** 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 | ||||
|      * {@link #bindService(Intent, ServiceConnection, int)}, and obtained and stored in | ||||
| @@ -121,6 +114,15 @@ public final class TermuxActivity extends Activity implements ServiceConnection | ||||
|      */ | ||||
|     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)}. */ | ||||
|     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 boolean showNow = mSettings.toggleShowExtraKeys(TermuxActivity.this); | ||||
|         viewPager.setVisibility(showNow ? View.VISIBLE : View.GONE); | ||||
| @@ -585,7 +587,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection | ||||
|     } | ||||
|  | ||||
|     @SuppressLint("InflateParams") | ||||
|     void renameSession(final TerminalSession sessionToRename) { | ||||
|     public void renameSession(final TerminalSession sessionToRename) { | ||||
|         if (sessionToRename == null) return; | ||||
|         DialogUtils.textInput(this, R.string.session_rename_title, sessionToRename.mSessionName, R.string.session_rename_positive_button, text -> { | ||||
|             sessionToRename.mSessionName = text; | ||||
| @@ -607,7 +609,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection | ||||
|     } | ||||
|  | ||||
|     @Nullable | ||||
|     TerminalSession getCurrentTermSession() { | ||||
|     public TerminalSession getCurrentTermSession() { | ||||
|         return mTerminalView.getCurrentSession(); | ||||
|     } | ||||
|  | ||||
| @@ -660,11 +662,11 @@ public final class TermuxActivity extends Activity implements ServiceConnection | ||||
|         unbindService(this); | ||||
|     } | ||||
|  | ||||
|     DrawerLayout getDrawer() { | ||||
|     public DrawerLayout getDrawer() { | ||||
|         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) { | ||||
|             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(); | ||||
| @@ -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. */ | ||||
|     void switchToSession(TerminalSession session) { | ||||
|     public void switchToSession(TerminalSession session) { | ||||
|         if (mTerminalView.attachSession(session)) { | ||||
|             noteSessionInfo(); | ||||
|             updateBackgroundColor(); | ||||
| @@ -835,7 +837,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection | ||||
|         return urlSet; | ||||
|     } | ||||
|  | ||||
|     void showUrlSelection() { | ||||
|     public void showUrlSelection() { | ||||
|         String text = null; | ||||
|         if (getCurrentTermSession() != null) { | ||||
|             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); | ||||
|         mTerminalView.setTextSize(mSettings.getFontSize()); | ||||
|     } | ||||
|  | ||||
|     void doPaste() { | ||||
|     public void doPaste() { | ||||
|         ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | ||||
|         ClipData clipData = clipboard.getPrimaryClip(); | ||||
|         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.widget.Toast; | ||||
|  | ||||
| import androidx.annotation.NonNull; | ||||
| import androidx.annotation.Nullable; | ||||
|  | ||||
| import com.termux.app.input.extrakeys.ExtraKeysInfo; | ||||
| import com.termux.app.input.KeyboardShortcut; | ||||
| import com.termux.app.terminal.extrakeys.ExtraKeysInfo; | ||||
| import com.termux.app.terminal.KeyboardShortcut; | ||||
|  | ||||
| import org.json.JSONException; | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| package com.termux.app.input; | ||||
| package com.termux.app.terminal; | ||||
| 
 | ||||
| import android.content.Context; | ||||
| import android.os.Handler; | ||||
| @@ -1,4 +1,4 @@ | ||||
| package com.termux.app.input; | ||||
| package com.termux.app.terminal; | ||||
| 
 | ||||
| import android.graphics.Rect; | ||||
| import android.view.View; | ||||
| @@ -1,4 +1,4 @@ | ||||
| package com.termux.app.input; | ||||
| package com.termux.app.terminal; | ||||
| 
 | ||||
| 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.media.AudioManager; | ||||
| import android.view.Gravity; | ||||
| @@ -8,8 +9,9 @@ import android.view.KeyEvent; | ||||
| import android.view.MotionEvent; | ||||
| import android.view.inputmethod.InputMethodManager; | ||||
| 
 | ||||
| import com.termux.app.input.KeyboardShortcut; | ||||
| import com.termux.app.input.extrakeys.ExtraKeysView; | ||||
| import com.termux.app.TermuxActivity; | ||||
| import com.termux.app.TermuxService; | ||||
| import com.termux.app.terminal.extrakeys.ExtraKeysView; | ||||
| import com.termux.app.settings.properties.TermuxPropertyConstants; | ||||
| import com.termux.terminal.KeyHandler; | ||||
| import com.termux.terminal.TerminalEmulator; | ||||
| @@ -44,22 +46,22 @@ public final class TermuxViewClient implements TerminalViewClient { | ||||
|     @Override | ||||
|     public void onSingleTapUp(MotionEvent e) { | ||||
|         InputMethodManager mgr = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE); | ||||
|         mgr.showSoftInput(mActivity.mTerminalView, InputMethodManager.SHOW_IMPLICIT); | ||||
|         mgr.showSoftInput(mActivity.getTerminalView(), InputMethodManager.SHOW_IMPLICIT); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean shouldBackButtonBeMappedToEscape() { | ||||
|         return mActivity.mProperties.isBackKeyTheEscapeKey(); | ||||
|         return mActivity.getProperties().isBackKeyTheEscapeKey(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean shouldEnforeCharBasedInput() { | ||||
|         return mActivity.mProperties.isEnforcingCharBasedInput(); | ||||
|         return mActivity.getProperties().isEnforcingCharBasedInput(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean shouldUseCtrlSpaceWorkaround() { | ||||
|         return mActivity.mProperties.isUsingCtrlSpaceWorkaround(); | ||||
|         return mActivity.getProperties().isUsingCtrlSpaceWorkaround(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @@ -68,6 +70,7 @@ public final class TermuxViewClient implements TerminalViewClient { | ||||
|         mActivity.getDrawer().setDrawerLockMode(copyMode ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED : DrawerLayout.LOCK_MODE_UNLOCKED); | ||||
|     } | ||||
| 
 | ||||
|     @SuppressLint("RtlHardcoded") | ||||
|     @Override | ||||
|     public boolean onKeyDown(int keyCode, KeyEvent e, TerminalSession currentSession) { | ||||
|         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); | ||||
|                 imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); | ||||
|             } else if (unicodeChar == 'm'/* menu */) { | ||||
|                 mActivity.mTerminalView.showContextMenu(); | ||||
|                 mActivity.getTerminalView().showContextMenu(); | ||||
|             } else if (unicodeChar == 'r'/* rename */) { | ||||
|                 mActivity.renameSession(currentSession); | ||||
|             } else if (unicodeChar == 'c'/* create */) { | ||||
| @@ -108,7 +111,7 @@ public final class TermuxViewClient implements TerminalViewClient { | ||||
|                 mActivity.changeFontSize(false); | ||||
|             } else if (unicodeChar >= '1' && unicodeChar <= '9') { | ||||
|                 int num = unicodeChar - '1'; | ||||
|                 TermuxService service = mActivity.mTermService; | ||||
|                 TermuxService service = mActivity.getTermService(); | ||||
|                 if (service.getSessions().size() > num) | ||||
|                     mActivity.switchToSession(service.getSessions().get(num)); | ||||
|             } | ||||
| @@ -126,12 +129,12 @@ public final class TermuxViewClient implements TerminalViewClient { | ||||
| 
 | ||||
|     @Override | ||||
|     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 | ||||
|     public boolean readAltKey() { | ||||
|         return (mActivity.mExtraKeysView != null && mActivity.mExtraKeysView.readSpecialButton(ExtraKeysView.SpecialButton.ALT)); | ||||
|         return (mActivity.getExtraKeysView() != null && mActivity.getExtraKeysView().readSpecialButton(ExtraKeysView.SpecialButton.ALT)); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @@ -242,7 +245,7 @@ public final class TermuxViewClient implements TerminalViewClient { | ||||
|                 return true; | ||||
|             } | ||||
| 
 | ||||
|             List<KeyboardShortcut> shortcuts = mActivity.mProperties.getSessionShortcuts(); | ||||
|             List<KeyboardShortcut> shortcuts = mActivity.getProperties().getSessionShortcuts(); | ||||
|             if (!shortcuts.isEmpty()) { | ||||
|                 int codePointLowerCase = Character.toLowerCase(codePoint); | ||||
|                 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. */ | ||||
|     private boolean handleVirtualKeys(int keyCode, KeyEvent event, boolean down) { | ||||
|         InputDevice inputDevice = event.getDevice(); | ||||
|         if (mActivity.mProperties.areVirtualVolumeKeysDisabled()) { | ||||
|         if (mActivity.getProperties().areVirtualVolumeKeysDisabled()) { | ||||
|             return false; | ||||
|         } else if (inputDevice != null && inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) { | ||||
|             // Do not steal dedicated buttons from a full external keyboard. | ||||
| @@ -293,5 +296,4 @@ public final class TermuxViewClient implements TerminalViewClient { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @@ -1,4 +1,4 @@ | ||||
| package com.termux.app.input.extrakeys; | ||||
| package com.termux.app.terminal.extrakeys; | ||||
| 
 | ||||
| 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.JSONException; | ||||
| @@ -1,4 +1,4 @@ | ||||
| package com.termux.app.input.extrakeys; | ||||
| package com.termux.app.terminal.extrakeys; | ||||
| 
 | ||||
| import android.annotation.SuppressLint; | ||||
| import android.content.Context; | ||||
| @@ -1,5 +1,5 @@ | ||||
| <?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" | ||||
|     style="?android:attr/buttonBarStyle" | ||||
|     android:layout_width="match_parent" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user