changeset 223:61ed3984fc1d

proper labels on the soft 24 function keypad
author Carl Byington <carl@five-ten-sg.com>
date Tue, 08 Jul 2014 17:20:07 -0700
parents c438c2ff0052
children abf17d9431eb
files res/drawable-hdpi/btn_close_normal.png res/drawable-hdpi/btn_close_pressed.png res/drawable-hdpi/btn_close_selected.png res/drawable-hdpi/keyboard_popup_panel_trans_background.9.png res/drawable-ldpi/btn_close_normal.png res/drawable-ldpi/btn_close_pressed.png res/drawable-ldpi/btn_close_selected.png res/drawable-ldpi/keyboard_popup_panel_trans_background.9.png res/drawable-mdpi/btn_close_normal.png res/drawable-mdpi/btn_close_pressed.png res/drawable-mdpi/btn_close_selected.png res/drawable-mdpi/keyboard_popup_panel_trans_background.9.png res/drawable-xhdpi/btn_close_normal.png res/drawable-xhdpi/btn_close_pressed.png res/drawable-xhdpi/btn_close_selected.png res/drawable-xhdpi/keyboard_popup_panel_trans_background.9.png res/drawable/btn_close.xml res/layout/string_picker.xml res/layout/string_picker_button.xml src/com/five_ten_sg/connectbot/service/TerminalBridge.java src/com/five_ten_sg/connectbot/util/StringPickerDialog.java
diffstat 21 files changed, 270 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
Binary file res/drawable-hdpi/btn_close_normal.png has changed
Binary file res/drawable-hdpi/btn_close_pressed.png has changed
Binary file res/drawable-hdpi/btn_close_selected.png has changed
Binary file res/drawable-hdpi/keyboard_popup_panel_trans_background.9.png has changed
Binary file res/drawable-ldpi/btn_close_normal.png has changed
Binary file res/drawable-ldpi/btn_close_pressed.png has changed
Binary file res/drawable-ldpi/btn_close_selected.png has changed
Binary file res/drawable-ldpi/keyboard_popup_panel_trans_background.9.png has changed
Binary file res/drawable-mdpi/btn_close_normal.png has changed
Binary file res/drawable-mdpi/btn_close_pressed.png has changed
Binary file res/drawable-mdpi/btn_close_selected.png has changed
Binary file res/drawable-mdpi/keyboard_popup_panel_trans_background.9.png has changed
Binary file res/drawable-xhdpi/btn_close_normal.png has changed
Binary file res/drawable-xhdpi/btn_close_pressed.png has changed
Binary file res/drawable-xhdpi/btn_close_selected.png has changed
Binary file res/drawable-xhdpi/keyboard_popup_panel_trans_background.9.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/drawable/btn_close.xml	Tue Jul 08 17:20:07 2014 -0700
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_pressed="false" android:state_focused="false"
+        android:drawable="@+drawable/btn_close_normal" />
+
+    <item android:state_pressed="true"
+        android:drawable="@+drawable/btn_close_pressed" />
+
+    <item android:state_focused="true"
+        android:drawable="@+drawable/btn_close_selected" />
+</selector>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/string_picker.xml	Tue Jul 08 17:20:07 2014 -0700
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (C) 2008 The Android Open Source Project
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:layout_width="304dp"
+    android:layout_height="match_parent"
+    android:background="@drawable/keyboard_popup_panel_trans_background">
+
+    <GridView
+    android:id="@+id/stringPicker"
+    android:layout_width="0dp"
+    android:layout_height="wrap_content"
+    android:layout_weight="1"
+    android:padding="4dp"
+    android:verticalSpacing="8dp"
+    android:horizontalSpacing="8dp"
+    android:gravity="start"
+    android:drawSelectorOnTop="false"
+    android:numColumns="4"
+    android:columnWidth="48dp"
+    android:fadingEdge="none"
+    android:layout_gravity="center_vertical"
+    android:listSelector="#0000"
+    />
+
+    <Button
+    android:id="@+id/cancel"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:background="@drawable/btn_close"
+    android:layout_gravity="center_vertical"
+    />
+</LinearLayout>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/string_picker_button.xml	Tue Jul 08 17:20:07 2014 -0700
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<Button xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:clickable="false"
+    android:focusable="false"
+    android:textAppearance="?android:attr/textAppearanceSmallInverse"
+    android:textColor="#FF000000"
+/>
--- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Tue Jul 08 10:46:40 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Tue Jul 08 17:20:07 2014 -0700
@@ -40,6 +40,7 @@
 import com.five_ten_sg.connectbot.transport.TransportFactory;
 import com.five_ten_sg.connectbot.util.HostDatabase;
 import com.five_ten_sg.connectbot.util.PreferenceConstants;
+import com.five_ten_sg.connectbot.util.StringPickerDialog;
 import android.app.AlertDialog;
 import android.content.Context;
 import android.graphics.Bitmap;
@@ -1261,32 +1262,32 @@
      * Function keys dialog
      */
     public boolean showFKeysDialog() {
-        final String pickerString = "1234567890abcdefghijklmn";
+        final String []pickerString = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24"};
         final HashMap<String,Integer> keymap = new HashMap<String,Integer>();
-        keymap.put("1", vt320.KEY_F1);
-        keymap.put("2", vt320.KEY_F2);
-        keymap.put("3", vt320.KEY_F3);
-        keymap.put("4", vt320.KEY_F4);
-        keymap.put("5", vt320.KEY_F5);
-        keymap.put("6", vt320.KEY_F6);
-        keymap.put("7", vt320.KEY_F7);
-        keymap.put("8", vt320.KEY_F8);
-        keymap.put("9", vt320.KEY_F9);
-        keymap.put("0", vt320.KEY_F10);
-        keymap.put("a", vt320.KEY_F11);
-        keymap.put("b", vt320.KEY_F12);
-        keymap.put("c", vt320.KEY_F13);
-        keymap.put("d", vt320.KEY_F14);
-        keymap.put("e", vt320.KEY_F15);
-        keymap.put("f", vt320.KEY_F16);
-        keymap.put("g", vt320.KEY_F17);
-        keymap.put("h", vt320.KEY_F18);
-        keymap.put("i", vt320.KEY_F19);
-        keymap.put("j", vt320.KEY_F20);
-        keymap.put("k", vt320.KEY_F21);
-        keymap.put("l", vt320.KEY_F22);
-        keymap.put("m", vt320.KEY_F23);
-        keymap.put("n", vt320.KEY_F24);
+        keymap.put("F1", vt320.KEY_F1);
+        keymap.put("F2", vt320.KEY_F2);
+        keymap.put("F3", vt320.KEY_F3);
+        keymap.put("F4", vt320.KEY_F4);
+        keymap.put("F5", vt320.KEY_F5);
+        keymap.put("F6", vt320.KEY_F6);
+        keymap.put("F7", vt320.KEY_F7);
+        keymap.put("F8", vt320.KEY_F8);
+        keymap.put("F9", vt320.KEY_F9);
+        keymap.put("F10", vt320.KEY_F10);
+        keymap.put("F11", vt320.KEY_F11);
+        keymap.put("F12", vt320.KEY_F12);
+        keymap.put("F13", vt320.KEY_F13);
+        keymap.put("F14", vt320.KEY_F14);
+        keymap.put("F15", vt320.KEY_F15);
+        keymap.put("F16", vt320.KEY_F16);
+        keymap.put("F17", vt320.KEY_F17);
+        keymap.put("F18", vt320.KEY_F18);
+        keymap.put("F19", vt320.KEY_F19);
+        keymap.put("F20", vt320.KEY_F20);
+        keymap.put("F21", vt320.KEY_F21);
+        keymap.put("F22", vt320.KEY_F22);
+        keymap.put("F23", vt320.KEY_F23);
+        keymap.put("F24", vt320.KEY_F24);
 
         CharSequence str = "";
         Editable content = Editable.Factory.getInstance().newEditable(str);
@@ -1294,7 +1295,7 @@
         if (parent == null)
             return false;
 
-        CharacterPickerDialog cpd = new CharacterPickerDialog(parent.getContext(),
+        StringPickerDialog cpd = new StringPickerDialog(parent.getContext(),
         parent, content, pickerString, true) {
             private void buttonPressed(CharSequence result) {
                 String s = result.toString();
@@ -1303,7 +1304,7 @@
             }
             @Override
             public void onItemClick(AdapterView p, View v, int pos, long id) {
-                final String result = String.valueOf(pickerString.charAt(pos));
+                final String result = pickerString[pos];
                 buttonPressed(result);
             }
             @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/five_ten_sg/connectbot/util/StringPickerDialog.java	Tue Jul 08 17:20:07 2014 -0700
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.five_ten_sg.connectbot.util;
+
+import com.five_ten_sg.connectbot.R;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.text.*;
+import android.view.LayoutInflater;
+import android.view.View.OnClickListener;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.GridView;
+
+/**
+ * Dialog for choosing accented characters related to a base character.
+ */
+public class StringPickerDialog extends Dialog
+        implements OnItemClickListener, OnClickListener {
+    private View mView;
+    private Editable mText;
+    private String []mOptions;
+    private boolean mInsert;
+    private LayoutInflater mInflater;
+    private Button mCancelButton;
+
+    /**
+     * Creates a new StringPickerDialog that presents the specified
+     * <code>options</code> for insertion or replacement (depending on
+     * the sense of <code>insert</code>) into <code>text</code>.
+     */
+    public StringPickerDialog(Context context, View view,
+                                 Editable text, String []options,
+                                 boolean insert) {
+        //super(context, com.android.internal.R.style.Theme_Panel);
+
+        //Resources res = Resources.getSystem();
+        //int id = res.getIdentifier("Theme_Panel", "style", "android");
+        //int id = android.R.style.Theme_Panel;
+        super(context, android.R.style.Theme_Panel);
+        mView = view;
+        mText = text;
+        mOptions = options;
+        mInsert = insert;
+        mInflater = LayoutInflater.from(context);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        WindowManager.LayoutParams params = getWindow().getAttributes();
+        params.token = mView.getApplicationWindowToken();
+        params.type = params.TYPE_APPLICATION_ATTACHED_DIALOG;
+        params.flags = params.flags | Window.FEATURE_NO_TITLE;
+
+        setContentView(R.layout.string_picker);
+
+        GridView grid = (GridView) findViewById(R.id.stringPicker);
+        grid.setAdapter(new OptionsAdapter(getContext()));
+        grid.setOnItemClickListener(this);
+
+        mCancelButton = (Button) findViewById(R.id.cancel);
+        mCancelButton.setOnClickListener(this);
+    }
+
+    /**
+     * Handles clicks on the character buttons.
+     */
+    public void onItemClick(AdapterView parent, View view, int position, long id) {
+        String result = mOptions[position];
+        replaceCharacterAndClose(result);
+    }
+
+    private void replaceCharacterAndClose(CharSequence replace) {
+        int selEnd = Selection.getSelectionEnd(mText);
+        if (mInsert || selEnd == 0) {
+            mText.insert(selEnd, replace);
+        } else {
+            mText.replace(selEnd - 1, selEnd, replace);
+        }
+
+        dismiss();
+    }
+
+    /**
+     * Handles clicks on the Cancel button.
+     */
+    public void onClick(View v) {
+        if (v == mCancelButton) {
+            dismiss();
+        } else if (v instanceof Button) {
+            CharSequence result = ((Button) v).getText();
+            replaceCharacterAndClose(result);
+        }
+    }
+
+    private class OptionsAdapter extends BaseAdapter {
+
+        public OptionsAdapter(Context context) {
+            super();
+        }
+
+        public View getView(int position, View convertView, ViewGroup parent) {
+            Button b = (Button)
+                mInflater.inflate(R.layout.string_picker_button, null);
+            b.setText(mOptions[position]);
+            b.setOnClickListener(StringPickerDialog.this);
+            return b;
+        }
+
+        public final int getCount() {
+            return mOptions.length;
+        }
+
+        public final Object getItem(int position) {
+            return mOptions[position];
+        }
+
+        public final long getItemId(int position) {
+            return position;
+        }
+    }
+}