diff options
author | Kenny Root <kenny@the-b.org> | 2009-07-02 06:03:34 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2009-07-02 06:03:34 +0000 |
commit | 9759a0c23ad865f6815b9af01a611ca38984f865 (patch) | |
tree | 39ccac0bd1a6b62d7fb33a2046f762204ccda963 | |
parent | 03801caf2fffefe2b6da8b596b8f767af8a7effc (diff) | |
download | connectbot-9759a0c23ad865f6815b9af01a611ca38984f865.tar.gz connectbot-9759a0c23ad865f6815b9af01a611ca38984f865.tar.bz2 connectbot-9759a0c23ad865f6815b9af01a611ca38984f865.zip |
Allow tap on screen to bring up an icon to open the software keyboard when the hardware keyboard is hidden
git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@348 df292f66-193f-0410-a5fc-6d59da041ff2
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | res/anim/fade_out.xml | 8 | ||||
-rw-r--r-- | res/anim/fade_out_delayed.xml | 8 | ||||
-rw-r--r-- | res/anim/fade_stay_hidden.xml | 14 | ||||
-rw-r--r-- | res/anim/keyboard_fade_in.xml | 6 | ||||
-rw-r--r-- | res/anim/keyboard_fade_out.xml | 6 | ||||
-rw-r--r-- | res/drawable/keyboard_icon.png | bin | 0 -> 3326 bytes | |||
-rw-r--r-- | res/layout/act_console.xml | 12 | ||||
-rw-r--r-- | src/org/connectbot/ConsoleActivity.java | 66 |
9 files changed, 100 insertions, 22 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3d67214..7bc7a96 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,7 +2,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.connectbot" android:versionName="1.6-dev" - android:versionCode="155"> + android:versionCode="156"> <application android:icon="@drawable/icon" diff --git a/res/anim/fade_out.xml b/res/anim/fade_out.xml deleted file mode 100644 index 9ff8724..0000000 --- a/res/anim/fade_out.xml +++ /dev/null @@ -1,8 +0,0 @@ - <alpha - xmlns:android="http://schemas.android.com/apk/res/android" - android:fromAlpha="1.0" - android:toAlpha="0.0" - android:duration="500" - android:startOffset="1000" - android:fillAfter="true" - /> diff --git a/res/anim/fade_out_delayed.xml b/res/anim/fade_out_delayed.xml new file mode 100644 index 0000000..ab7703c --- /dev/null +++ b/res/anim/fade_out_delayed.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<alpha xmlns:android="http://schemas.android.com/apk/res/android" + android:fromAlpha="1.0" + android:toAlpha="0.0" + android:duration="500" + android:startOffset="1000" + android:fillAfter="true" + /> diff --git a/res/anim/fade_stay_hidden.xml b/res/anim/fade_stay_hidden.xml index bfda0d3..a48621a 100644 --- a/res/anim/fade_stay_hidden.xml +++ b/res/anim/fade_stay_hidden.xml @@ -1,7 +1,7 @@ - <alpha - xmlns:android="http://schemas.android.com/apk/res/android" - android:fromAlpha="0.0" - android:toAlpha="0.0" - android:duration="500" - android:fillAfter="true" - /> +<?xml version="1.0" encoding="utf-8"?> +<alpha xmlns:android="http://schemas.android.com/apk/res/android" + android:fromAlpha="0.0" + android:toAlpha="0.0" + android:duration="500" + android:fillAfter="true" + /> diff --git a/res/anim/keyboard_fade_in.xml b/res/anim/keyboard_fade_in.xml new file mode 100644 index 0000000..f1ceea7 --- /dev/null +++ b/res/anim/keyboard_fade_in.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<alpha xmlns:android="http://schemas.android.com/apk/res/android" + android:interpolator="@android:anim/accelerate_interpolator" + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:duration="100" /> diff --git a/res/anim/keyboard_fade_out.xml b/res/anim/keyboard_fade_out.xml new file mode 100644 index 0000000..3c57404 --- /dev/null +++ b/res/anim/keyboard_fade_out.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<alpha xmlns:android="http://schemas.android.com/apk/res/android" + android:interpolator="@android:anim/accelerate_interpolator" + android:fromAlpha="1.0" + android:toAlpha="0.0" + android:duration="100" /> diff --git a/res/drawable/keyboard_icon.png b/res/drawable/keyboard_icon.png Binary files differnew file mode 100644 index 0000000..9205d8b --- /dev/null +++ b/res/drawable/keyboard_icon.png diff --git a/res/layout/act_console.xml b/res/layout/act_console.xml index 6dc0968..4d5fd7c 100644 --- a/res/layout/act_console.xml +++ b/res/layout/act_console.xml @@ -118,4 +118,16 @@ </RelativeLayout> + <ImageView + android:id="@+id/keyboard_button" + android:paddingRight="15dip" + android:paddingBottom="15dip" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" + android:visibility="gone" + android:src="@+drawable/keyboard_icon" + /> + </RelativeLayout> diff --git a/src/org/connectbot/ConsoleActivity.java b/src/org/connectbot/ConsoleActivity.java index bd66b3b..6f59a57 100644 --- a/src/org/connectbot/ConsoleActivity.java +++ b/src/org/connectbot/ConsoleActivity.java @@ -61,8 +61,10 @@ import android.view.View.OnKeyListener; import android.view.View.OnTouchListener; import android.view.animation.Animation; import android.view.animation.AnimationUtils; +import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; +import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -77,6 +79,10 @@ public class ConsoleActivity extends Activity { protected static final int REQUEST_EDIT = 1; + private static final int CLICK_TIME = 250; + private static final float MAX_CLICK_DISTANCE = 25f; + private static final int KEYBOARD_DISPLAY_TIME = 1250; + protected ViewFlipper flip = null; protected TerminalManager bound = null; protected LayoutInflater inflater = null; @@ -98,7 +104,13 @@ public class ConsoleActivity extends Activity { private TextView empty; - private Animation slide_left_in, slide_left_out, slide_right_in, slide_right_out, fade_stay_hidden, fade_out; + private Animation slide_left_in, slide_left_out, slide_right_in, slide_right_out, fade_stay_hidden, fade_out_delayed; + + private Animation keyboard_fade_in, keyboard_fade_out; + private ImageView keyboardButton; + private float lastX, lastY; + + private InputMethodManager inputManager; private MenuItem disconnect, copy, paste, portForward, resize; @@ -107,6 +119,8 @@ public class ConsoleActivity extends Activity { private boolean forcedOrientation; + private Handler handler = new Handler(); + private ServiceConnection connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { bound = ((TerminalManager.TerminalBinder) service).getService(); @@ -170,7 +184,7 @@ public class ConsoleActivity extends Activity { try { // show the requested bridge if found, also fade out overlay flip.setDisplayedChild(requestedIndex); - flip.getCurrentView().findViewById(R.id.terminal_overlay).startAnimation(fade_out); + flip.getCurrentView().findViewById(R.id.terminal_overlay).startAnimation(fade_out_delayed); } catch (NullPointerException npe) { Log.d(TAG, "View went away when we were about to display it", npe); } @@ -375,9 +389,26 @@ public class ConsoleActivity extends Activity { slide_right_in = AnimationUtils.loadAnimation(this, R.anim.slide_right_in); slide_right_out = AnimationUtils.loadAnimation(this, R.anim.slide_right_out); - fade_out = AnimationUtils.loadAnimation(this, R.anim.fade_out); + fade_out_delayed = AnimationUtils.loadAnimation(this, R.anim.fade_out_delayed); fade_stay_hidden = AnimationUtils.loadAnimation(this, R.anim.fade_stay_hidden); + // Preload animation for keyboard button + keyboard_fade_in = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_in); + keyboard_fade_out = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_out); + + inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + keyboardButton = (ImageView) findViewById(R.id.keyboard_button); + keyboardButton.setOnClickListener(new OnClickListener() { + public void onClick(View view) { + View flip = findCurrentView(R.id.console_flip); + if (flip == null) + return; + + inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED); + keyboardButton.setVisibility(View.GONE); + } + }); + // detect fling gestures to switch between terminals final GestureDetector detect = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { private float totalY = 0; @@ -530,8 +561,31 @@ public class ConsoleActivity extends Activity { copySource.redraw(); return true; } + } - + Configuration config = getResources().getConfiguration(); + + if (event.getAction() == MotionEvent.ACTION_DOWN) { + lastX = event.getX(); + lastY = event.getY(); + } else if (event.getAction() == MotionEvent.ACTION_UP + && config.hardKeyboardHidden != Configuration.KEYBOARDHIDDEN_NO + && keyboardButton.getVisibility() == View.GONE + && event.getEventTime() - event.getDownTime() < CLICK_TIME + && Math.abs(event.getX() - lastX) < MAX_CLICK_DISTANCE + && Math.abs(event.getY() - lastY) < MAX_CLICK_DISTANCE) { + keyboardButton.startAnimation(keyboard_fade_in); + keyboardButton.setVisibility(View.VISIBLE); + + handler.postDelayed(new Runnable() { + public void run() { + if (keyboardButton.getVisibility() == View.GONE) + return; + + keyboardButton.startAnimation(keyboard_fade_out); + keyboardButton.setVisibility(View.GONE); + } + }, KEYBOARD_DISPLAY_TIME); } // pass any touch events back to detector @@ -797,7 +851,7 @@ public class ConsoleActivity extends Activity { // show overlay on new slide and start fade overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) - overlay.startAnimation(fade_out); + overlay.startAnimation(fade_out_delayed); } updatePromptVisible(); @@ -825,7 +879,7 @@ public class ConsoleActivity extends Activity { // show overlay on new slide and start fade overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) - overlay.startAnimation(fade_out); + overlay.startAnimation(fade_out_delayed); } updatePromptVisible(); |