From d13d568d1effb0e9913b1bc8ec4b6d7e4cc0e02d Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Thu, 30 Oct 2008 20:15:42 +0000 Subject: * Add icons for PubkeyListActivity and an empty-list hint TextView * Make sure setMargins in terminal emulation can't be fooled * Don't force ConsoleActivity to run in landscape orientation --- src/de/mud/terminal/VDUBuffer.java | 10 +++------- src/org/connectbot/GeneratePubkeyActivity.java | 12 +++++++----- src/org/connectbot/PubkeyListActivity.java | 23 +++++++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/de/mud/terminal/VDUBuffer.java b/src/de/mud/terminal/VDUBuffer.java index cb77ad6..35dbb49 100644 --- a/src/de/mud/terminal/VDUBuffer.java +++ b/src/de/mud/terminal/VDUBuffer.java @@ -615,17 +615,13 @@ public class VDUBuffer { } /** - * Set the scroll margins simultaneously. If they're backwards, swap them. - * If they're out of bounds, trim them. + * Set the scroll margins simultaneously. If they're out of bounds, trim them. * @param l1 line that is the top * @param l2 line that is the bottom */ public void setMargins(int l1, int l2) { - if (l1 > l2) { - int temp = l2; - l2 = l1; - l1 = temp; - } + if (l1 > l2) + return; if (l1 < 0) l1 = 0; diff --git a/src/org/connectbot/GeneratePubkeyActivity.java b/src/org/connectbot/GeneratePubkeyActivity.java index d33ffb3..690c6ec 100644 --- a/src/org/connectbot/GeneratePubkeyActivity.java +++ b/src/org/connectbot/GeneratePubkeyActivity.java @@ -18,20 +18,16 @@ package org.connectbot; -import java.security.Key; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.PrivateKey; import java.security.PublicKey; import java.security.SecureRandom; -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; - import org.connectbot.util.EntropyDialog; import org.connectbot.util.EntropyView; -import org.connectbot.util.PubkeyDatabase; import org.connectbot.util.OnEntropyGatheredListener; +import org.connectbot.util.PubkeyDatabase; import org.connectbot.util.PubkeyUtils; import android.app.Activity; @@ -166,10 +162,16 @@ public class GeneratePubkeyActivity extends Activity implements OnEntropyGathere if (!hasFocus) { try { bits = Integer.parseInt(bitsText.getText().toString()); + if (bits < minBits) { + bits = minBits; + bitsText.setText(String.valueOf(bits)); + } } catch (NumberFormatException nfe) { bits = DEFAULT_BITS; bitsText.setText(String.valueOf(bits)); } + + bitsSlider.setProgress(bits - minBits); } } }); diff --git a/src/org/connectbot/PubkeyListActivity.java b/src/org/connectbot/PubkeyListActivity.java index a8b2bed..c05d024 100644 --- a/src/org/connectbot/PubkeyListActivity.java +++ b/src/org/connectbot/PubkeyListActivity.java @@ -18,16 +18,9 @@ package org.connectbot; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; import java.security.PublicKey; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.EncodedKeySpec; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.X509EncodedKeySpec; import java.util.EventListener; -import org.connectbot.util.EntropyView; import org.connectbot.util.PubkeyDatabase; import org.connectbot.util.PubkeyUtils; @@ -51,6 +44,7 @@ import android.view.ViewGroup; import android.view.MenuItem.OnMenuItemClickListener; import android.widget.AdapterView; import android.widget.CursorAdapter; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; @@ -71,8 +65,6 @@ public class PubkeyListActivity extends ListActivity implements EventListener { if(this.pubkeydb == null) this.pubkeydb = new PubkeyDatabase(this); - - this.updateCursor(); ListView list = this.getListView(); this.registerForContextMenu(list); @@ -99,6 +91,7 @@ public class PubkeyListActivity extends ListActivity implements EventListener { this.clipboard = (ClipboardManager)this.getSystemService(CLIPBOARD_SERVICE); } + @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); @@ -173,9 +166,14 @@ public class PubkeyListActivity extends ListActivity implements EventListener { }; protected void updateCursor() { - this.pubkeys = this.pubkeydb.allPubkeys(); + if (this.pubkeys != null) { + pubkeys.requery(); + return; + } + this.pubkeys = this.pubkeydb.allPubkeys(); this.setListAdapter(new PubkeyCursorAdapter(this, this.pubkeys)); + this.startManagingCursor(pubkeys); } class PubkeyCursorAdapter extends CursorAdapter { @@ -199,6 +197,7 @@ public class PubkeyListActivity extends ListActivity implements EventListener { public void bindView(View view, Context context, Cursor cursor) { TextView text1 = (TextView) view.findViewById(android.R.id.text1); TextView text2 = (TextView) view.findViewById(android.R.id.text2); + ImageView icon1 = (ImageView) view.findViewById(android.R.id.icon1); text1.setText(cursor.getString(mNickname)); @@ -211,8 +210,12 @@ public class PubkeyListActivity extends ListActivity implements EventListener { } catch (Exception e) { e.printStackTrace(); + text2.setText(R.string.pubkey_unknown_format); Log.e(TAG, "Error decoding public key at " + cursor.toString()); } + + if (encrypted == 0) + icon1.setImageResource(R.drawable.pubkey_unlocked); } @Override -- cgit v1.2.3