From 17f70f5e62c4c5bee31d418bb4c94fd356e36cec Mon Sep 17 00:00:00 2001 From: Ryan Hansberry Date: Wed, 7 Oct 2015 11:20:21 -0700 Subject: Move old copying logic to TerminalView. Add comments to TerminalView. --- .../main/java/org/connectbot/ConsoleActivity.java | 95 +--------------------- 1 file changed, 1 insertion(+), 94 deletions(-) (limited to 'app/src/main/java/org/connectbot/ConsoleActivity.java') diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java index ba97f45..15b5e63 100644 --- a/app/src/main/java/org/connectbot/ConsoleActivity.java +++ b/app/src/main/java/org/connectbot/ConsoleActivity.java @@ -137,9 +137,6 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne private MenuItem disconnect, copy, paste, portForward, resize, urlscan; - protected TerminalBridge copySource = null; - private int lastTouchRow, lastTouchCol; - private boolean forcedOrientation; private Handler handler = new Handler(); @@ -669,78 +666,6 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne } } }); - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - pager.setOnTouchListener(new OnTouchListener() { - public boolean onTouch(View v, MotionEvent event) { - TerminalBridge bridge = adapter.getCurrentTerminalView().bridge; - - boolean isCopyingInProgress = - (copySource != null && copySource.isSelectingForCopy()); - - // when copying, highlight the area - if (isCopyingInProgress) { - SelectionArea area = copySource.getSelectionArea(); - int row = (int) Math.floor(event.getY() / bridge.charHeight); - int col = (int) Math.floor(event.getX() / bridge.charWidth); - - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - // recording starting area - if (area.isSelectingOrigin()) { - area.setRow(row); - area.setColumn(col); - lastTouchRow = row; - lastTouchCol = col; - copySource.redraw(); - } - return true; - case MotionEvent.ACTION_MOVE: - /* ignore when user hasn't moved since last time so - * we can fine-tune with directional pad - */ - if (row == lastTouchRow && col == lastTouchCol) - return true; - - // if the user moves, start the selection for other corner - area.finishSelectingOrigin(); - - // update selected area - area.setRow(row); - area.setColumn(col); - lastTouchRow = row; - lastTouchCol = col; - copySource.redraw(); - return true; - case MotionEvent.ACTION_UP: - /* If they didn't move their finger, maybe they meant to - * select the rest of the text with the directional pad. - */ - if (area.getLeft() == area.getRight() && - area.getTop() == area.getBottom()) { - return true; - } - - // copy selected area to clipboard - String copiedText = area.copyFrom(copySource.buffer); - - clipboard.setText(copiedText); - Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_done, copiedText.length()), Toast.LENGTH_LONG).show(); - // fall through to clear state - - case MotionEvent.ACTION_CANCEL: - // make sure we clear any highlighted area - area.reset(); - copySource.setSelectingForCopy(false); - copySource.redraw(); - return true; - } - } - - return true; - } - }); - } } /** @@ -843,7 +768,7 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne copy.setEnabled(activeTerminal); copy.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - startCopyMode(); + adapter.getCurrentTerminalView().startPreHoneycombCopyMode(); Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG).show(); return true; } @@ -1110,24 +1035,6 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne super.onSaveInstanceState(savedInstanceState); } - /** - * Only intended for pre-Honeycomb devices. - */ - private void startCopyMode() { - // mark as copying and reset any previous bounds - TerminalView terminalView = (TerminalView) adapter.getCurrentTerminalView(); - copySource = terminalView.bridge; - - SelectionArea area = copySource.getSelectionArea(); - area.reset(); - area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows()); - - copySource.setSelectingForCopy(true); - - // Make sure we show the initial selection - copySource.redraw(); - } - /** * Save the currently shown {@link TerminalView} as the default. This is * saved back down into {@link TerminalManager} where we can read it again -- cgit v1.2.3