aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/item_portforward.xml12
-rw-r--r--src/org/connectbot/PubkeyListActivity.java46
2 files changed, 39 insertions, 19 deletions
diff --git a/res/layout/item_portforward.xml b/res/layout/item_portforward.xml
index 5ab467c..4cdc14c 100644
--- a/res/layout/item_portforward.xml
+++ b/res/layout/item_portforward.xml
@@ -17,10 +17,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:gravity="left|center_vertical" android:layout_width="wrap_content">
+ android:gravity="left|center_vertical"
+ android:layout_width="fill_parent"
+ android:padding="10dip"
+ >
<TextView
android:id="@android:id/text1"
@@ -28,6 +31,8 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Tunnel Nickname"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
/>
<TextView
@@ -36,6 +41,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Local port 8080 to 192.168.1.1:80"
+ android:layout_below="@android:id/text1"
/>
-</LinearLayout>
+</RelativeLayout>
diff --git a/src/org/connectbot/PubkeyListActivity.java b/src/org/connectbot/PubkeyListActivity.java
index 1569722..076f618 100644
--- a/src/org/connectbot/PubkeyListActivity.java
+++ b/src/org/connectbot/PubkeyListActivity.java
@@ -526,23 +526,37 @@ public class PubkeyListActivity extends ListActivity implements EventListener {
class PubkeyAdapter extends ArrayAdapter<PubkeyBean> {
private List<PubkeyBean> pubkeys;
+ class ViewHolder {
+ public TextView nickname;
+ public TextView caption;
+ public ImageView icon;
+ }
+
public PubkeyAdapter(Context context, List<PubkeyBean> pubkeys) {
super(context, R.layout.item_pubkey, pubkeys);
this.pubkeys = pubkeys;
}
- public View getView(int position, View origView, ViewGroup parent) {
- View view = origView;
- if (view == null)
- view = inflater.inflate(R.layout.item_pubkey, null, false);
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+
+ if (convertView == null) {
+ convertView = inflater.inflate(R.layout.item_pubkey, null, false);
+
+ holder = new ViewHolder();
+
+ holder.nickname = (TextView) convertView.findViewById(android.R.id.text1);
+ holder.caption = (TextView) convertView.findViewById(android.R.id.text2);
+ holder.icon = (ImageView) convertView.findViewById(android.R.id.icon1);
- TextView nickname = (TextView)view.findViewById(android.R.id.text1);
- TextView caption = (TextView)view.findViewById(android.R.id.text2);
- ImageView icon = (ImageView)view.findViewById(android.R.id.icon1);
+ convertView.setTag(holder);
+ } else
+ holder = (ViewHolder) convertView.getTag();
PubkeyBean pubkey = pubkeys.get(position);
- nickname.setText(pubkey.getNickname());
+ holder.nickname.setText(pubkey.getNickname());
boolean imported = PubkeyDatabase.KEY_TYPE_IMPORTED.equals(pubkey.getType());
@@ -550,32 +564,32 @@ public class PubkeyListActivity extends ListActivity implements EventListener {
try {
PEMStructure struct = PEMDecoder.parsePEM(new String(pubkey.getPrivateKey()).toCharArray());
String type = (struct.pemType == PEMDecoder.PEM_RSA_PRIVATE_KEY) ? "RSA" : "DSA";
- caption.setText(String.format("%s unknown-bit", type));
+ holder.caption.setText(String.format("%s unknown-bit", type));
} catch (IOException e) {
Log.e(TAG, "Error decoding IMPORTED public key at " + pubkey.getId(), e);
}
} else {
try {
PublicKey pub = PubkeyUtils.decodePublic(pubkey.getPublicKey(), pubkey.getType());
- caption.setText(PubkeyUtils.describeKey(pub, pubkey.isEncrypted()));
+ holder.caption.setText(PubkeyUtils.describeKey(pub, pubkey.isEncrypted()));
} catch (Exception e) {
Log.e(TAG, "Error decoding public key at " + pubkey.getId(), e);
- caption.setText(R.string.pubkey_unknown_format);
+ holder.caption.setText(R.string.pubkey_unknown_format);
}
}
if (bound == null) {
- icon.setVisibility(View.GONE);
+ holder.icon.setVisibility(View.GONE);
} else {
- icon.setVisibility(View.VISIBLE);
+ holder.icon.setVisibility(View.VISIBLE);
if (bound.isKeyLoaded(pubkey.getNickname()))
- icon.setImageState(new int[] { android.R.attr.state_checked }, true);
+ holder.icon.setImageState(new int[] { android.R.attr.state_checked }, true);
else
- icon.setImageState(new int[] { }, true);
+ holder.icon.setImageState(new int[] { }, true);
}
- return view;
+ return convertView;
}
}
}