diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/theb/provider/HostDb.java | 6 | ||||
-rw-r--r-- | src/org/theb/ssh/HostDbProvider.java | 42 | ||||
-rw-r--r-- | src/org/theb/ssh/HostEditor.java | 9 | ||||
-rw-r--r-- | src/org/theb/ssh/HostsList.java | 31 | ||||
-rw-r--r-- | src/org/theb/ssh/Pubkey.java | 1 | ||||
-rw-r--r-- | src/org/theb/ssh/SecureShell.java | 10 | ||||
-rw-r--r-- | src/org/theb/ssh/TouchEntropy.java | 2 |
7 files changed, 52 insertions, 49 deletions
diff --git a/src/org/theb/provider/HostDb.java b/src/org/theb/provider/HostDb.java index e38396c..9939893 100644 --- a/src/org/theb/provider/HostDb.java +++ b/src/org/theb/provider/HostDb.java @@ -18,13 +18,13 @@ */ package org.theb.provider; -import android.net.ContentURI; +import android.net.Uri; import android.provider.BaseColumns; public final class HostDb { public static final class Hosts implements BaseColumns { - public static final ContentURI CONTENT_URI - = ContentURI.create("content://org.theb.provider.HostDb/hosts"); + public static final Uri CONTENT_URI + = Uri.parse("content://org.theb.provider.HostDb/hosts"); public static final String DEFAULT_SORT_ORDER = "hostname DESC"; diff --git a/src/org/theb/ssh/HostDbProvider.java b/src/org/theb/ssh/HostDbProvider.java index f0eac73..c51a356 100644 --- a/src/org/theb/ssh/HostDbProvider.java +++ b/src/org/theb/ssh/HostDbProvider.java @@ -23,14 +23,15 @@ import java.util.HashMap; import org.theb.provider.HostDb; import android.content.ContentProvider; -import android.content.ContentProviderDatabaseHelper; -import android.content.ContentURIParser; +import android.content.ContentUris; import android.content.ContentValues; -import android.content.QueryBuilder; +import android.content.UriMatcher; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; -import android.net.ContentURI; +import android.database.sqlite.SQLiteOpenHelper; +import android.database.sqlite.SQLiteQueryBuilder; +import android.net.Uri; import android.text.TextUtils; import android.util.Log; @@ -47,9 +48,9 @@ public class HostDbProvider extends ContentProvider { private static final int HOSTS = 1; private static final int HOST_ID = 2; - private static final ContentURIParser URL_MATCHER; + private static final UriMatcher URL_MATCHER; - private static class DatabaseHelper extends ContentProviderDatabaseHelper { + private static class DatabaseHelper extends SQLiteOpenHelper { @Override public void onCreate(SQLiteDatabase db) { @@ -69,7 +70,7 @@ public class HostDbProvider extends ContentProvider { } @Override - public int delete(ContentURI uri, String where, String[] whereArgs) { + public int delete(Uri uri, String where, String[] whereArgs) { int count; switch (URL_MATCHER.match(uri)) { case HOSTS: @@ -77,7 +78,7 @@ public class HostDbProvider extends ContentProvider { break; case HOST_ID: - String segment = uri.getPathSegment(1); + String segment = uri.getPathSegments().get(1); count = mDB.delete("hosts", "_id=" + segment + (!TextUtils.isEmpty(where) ? " AND (" + where @@ -93,7 +94,7 @@ public class HostDbProvider extends ContentProvider { } @Override - public String getType(ContentURI uri) { + public String getType(Uri uri) { switch (URL_MATCHER.match(uri)) { case HOSTS: return "vnd.android.cursor.dir/vnd.theb.host"; @@ -105,7 +106,7 @@ public class HostDbProvider extends ContentProvider { } @Override - public ContentURI insert(ContentURI uri, ContentValues initialValues) { + public Uri insert(Uri uri, ContentValues initialValues) { long rowID; ContentValues values; @@ -137,7 +138,7 @@ public class HostDbProvider extends ContentProvider { rowID = mDB.insert("hosts", "host", values); if (rowID > 0) { - ContentURI newUri = HostDb.Hosts.CONTENT_URI.addId(rowID); + Uri newUri = ContentUris.withAppendedId(HostDb.Hosts.CONTENT_URI, rowID); getContext().getContentResolver().notifyChange(newUri, null); return newUri; } @@ -153,10 +154,9 @@ public class HostDbProvider extends ContentProvider { } @Override - public Cursor query(ContentURI uri, String[] projection, String selection, - String[] selectionArgs, String groupBy, String having, - String sortOrder) { - QueryBuilder qb = new QueryBuilder(); + public Cursor query(Uri uri, String[] projection, String selection, + String[] selectionArgs, String sortOrder) { + SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); switch (URL_MATCHER.match(uri)) { case HOSTS: @@ -166,7 +166,7 @@ public class HostDbProvider extends ContentProvider { case HOST_ID: qb.setTables("hosts"); - qb.appendWhere("_id=" + uri.getPathSegment(1)); + qb.appendWhere("_id=" + uri.getPathSegments().get(1)); break; default: @@ -180,14 +180,14 @@ public class HostDbProvider extends ContentProvider { orderBy = sortOrder; } - Cursor c = qb.query(mDB, projection, selection, selectionArgs, groupBy, - having, orderBy); + Cursor c = qb.query(mDB, projection, selection, selectionArgs, null, + null, orderBy); c.setNotificationUri(getContext().getContentResolver(), uri); return c; } @Override - public int update(ContentURI uri, ContentValues values, String where, + public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { int count; @@ -197,7 +197,7 @@ public class HostDbProvider extends ContentProvider { break; case HOST_ID: - String segment = uri.getPathSegment(1); + String segment = uri.getPathSegments().get(1); count = mDB .update("hosts", values, "_id=" + segment @@ -215,7 +215,7 @@ public class HostDbProvider extends ContentProvider { } static { - URL_MATCHER = new ContentURIParser(ContentURIParser.NO_MATCH); + URL_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); URL_MATCHER.addURI("org.theb.provider.HostDb", "hosts", HOSTS); URL_MATCHER.addURI("org.theb.provider.HostDb", "hosts/#", HOST_ID); diff --git a/src/org/theb/ssh/HostEditor.java b/src/org/theb/ssh/HostEditor.java index 967cf5b..a8a6de7 100644 --- a/src/org/theb/ssh/HostEditor.java +++ b/src/org/theb/ssh/HostEditor.java @@ -23,7 +23,7 @@ import org.theb.provider.HostDb; import android.app.Activity; import android.content.Intent; import android.database.Cursor; -import android.net.ContentURI; +import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -59,15 +59,16 @@ public class HostEditor extends Activity { private Cursor mCursor; private int mState; - private ContentURI mURI; + private Uri mURI; @Override public void onCreate(Bundle savedValues) { super.onCreate(savedValues); + // TODO: update or remove // Have the system blur any windows behind this one. - getWindow().setFlags(WindowManager.LayoutParams.BLUR_BEHIND_FLAG, - WindowManager.LayoutParams.BLUR_BEHIND_FLAG); + //getWindow().setFlags(WindowManager.LayoutParams.BLUR_BEHIND_FLAG, + // WindowManager.LayoutParams.BLUR_BEHIND_FLAG); // Apply a tint to any windows behind this one. Doing a tint this // way is more efficient than using a translucent background. Note diff --git a/src/org/theb/ssh/HostsList.java b/src/org/theb/ssh/HostsList.java index 2634eba..6f30f45 100644 --- a/src/org/theb/ssh/HostsList.java +++ b/src/org/theb/ssh/HostsList.java @@ -23,13 +23,13 @@ import org.theb.provider.HostDb; import android.app.Dialog; import android.app.ListActivity; import android.content.ComponentName; +import android.content.ContentUris; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.graphics.drawable.Drawable; -import android.net.ContentURI; +import android.net.Uri; import android.os.Bundle; -import android.view.KeyEvent; import android.view.Menu; import android.view.SubMenu; import android.view.View; @@ -144,13 +144,13 @@ public class HostsList extends ListActivity { // This is our one standard application action -- inserting a // new host into the list. - menu.add(0, INSERT_ID, R.string.menu_insert).setShortcut( - KeyEvent.KEYCODE_3, 0, KeyEvent.KEYCODE_A); + menu.add(0, INSERT_ID, R.string.menu_insert) + .setShortcut('3', 'a'); // The preferences link allows users to e.g. set the pubkey SubMenu prefs = menu.addSubMenu(0, 0, R.string.menu_preferences); - prefs.add(0, PUBKEY_ID, R.string.menu_pubkey).setShortcut( - KeyEvent.KEYCODE_4, 0, KeyEvent.KEYCODE_P); + prefs.add(0, PUBKEY_ID, R.string.menu_pubkey) + .setShortcut('4', 'p'); // This links to the about dialog for the program. menu.add(0, ABOUT_ID, R.string.menu_about); @@ -180,7 +180,7 @@ public class HostsList extends ListActivity { // found. if (haveItems) { // This is the selected item. - ContentURI uri = getIntent().getData().addId(getSelectionRowID()); + Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId()); // Build menu... always starts with the PICK action... Intent[] specifics = new Intent[1]; @@ -191,17 +191,15 @@ public class HostsList extends ListActivity { Intent intent = new Intent(null, uri); intent.addCategory(Intent.SELECTED_ALTERNATIVE_CATEGORY); menu.addIntentOptions(Menu.SELECTED_ALTERNATIVE, 0, null, specifics, - intent, Menu.NO_SEPARATOR_AFTER, items); + intent, 0, items); // ... and ends with the delete command. menu.add(Menu.SELECTED_ALTERNATIVE, DELETE_ID, R.string.menu_delete) -. - setShortcut(KeyEvent.KEYCODE_2, 0, KeyEvent.KEYCODE_D); - menu.addSeparator(Menu.SELECTED_ALTERNATIVE, 0); + .setShortcut('2', 'd'); // Give a shortcut to the connect action. if (items[0] != null) { - items[0].setShortcut(KeyEvent.KEYCODE_1, 0, KeyEvent.KEYCODE_C); + items[0].setShortcut('1', 'c'); } } else { menu.removeGroup(Menu.SELECTED_ALTERNATIVE); @@ -243,9 +241,10 @@ public class HostsList extends ListActivity { + " " + getResources().getString(R.string.msg_version)); + // TODO: update or remove // Everything looks cooler when you blur the window behind it. - about.getWindow().setFlags(WindowManager.LayoutParams.BLUR_BEHIND_FLAG, - WindowManager.LayoutParams.BLUR_BEHIND_FLAG); + //about.getWindow().setFlags(WindowManager.LayoutParams.BLUR_BEHIND_FLAG, + // WindowManager.LayoutParams.BLUR_BEHIND_FLAG); WindowManager.LayoutParams lp = about.getWindow().getAttributes(); lp.tintBehind = 0x60000820; about.getWindow().setAttributes(lp); @@ -255,7 +254,7 @@ public class HostsList extends ListActivity { @Override protected void onListItemClick(ListView l, View v, int position, long id) { - ContentURI url = getIntent().getData().addId(getSelectionRowID()); + Uri url = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId()); String action = getIntent().getAction(); if (Intent.PICK_ACTION.equals(action) @@ -270,7 +269,7 @@ public class HostsList extends ListActivity { } private final void deleteItem() { - mCursor.moveTo(getSelection()); + mCursor.moveTo(getSelectedItemPosition()); mCursor.deleteRow(); } diff --git a/src/org/theb/ssh/Pubkey.java b/src/org/theb/ssh/Pubkey.java index cf3bd0d..4cfaa9c 100644 --- a/src/org/theb/ssh/Pubkey.java +++ b/src/org/theb/ssh/Pubkey.java @@ -20,7 +20,6 @@ package org.theb.ssh; import java.security.KeyPair; import java.security.KeyPairGenerator; -import java.security.KeyStore; import java.security.PrivateKey; import java.security.PublicKey; import java.security.SecureRandom; diff --git a/src/org/theb/ssh/SecureShell.java b/src/org/theb/ssh/SecureShell.java index 8d4dda6..9269bac 100644 --- a/src/org/theb/ssh/SecureShell.java +++ b/src/org/theb/ssh/SecureShell.java @@ -216,9 +216,13 @@ public class SecureShell extends Activity implements FeedbackUI, ConnectionMonit if (SecureShell.this.isFinishing()) return; - AlertDialog d = AlertDialog.show(SecureShell.this, - "Connection Lost", mDisconnectReason, "Ok", false); - d.show(); +// AlertDialog d = AlertDialog.show(SecureShell.this, +// "Connection Lost", mDisconnectReason, "Ok", false); + new AlertDialog.Builder(SecureShell.this) + .setIcon(R.drawable.icon) + .setTitle(R.string.alert_disconnect_msg) + .setPositiveButton(R.string.button_ok, null) + .show(); // TODO: Return to previous activity if connection fails. } }; diff --git a/src/org/theb/ssh/TouchEntropy.java b/src/org/theb/ssh/TouchEntropy.java index 33ad499..023e531 100644 --- a/src/org/theb/ssh/TouchEntropy.java +++ b/src/org/theb/ssh/TouchEntropy.java @@ -52,7 +52,7 @@ public class TouchEntropy extends Activity { } @Override - public boolean onMotionEvent(MotionEvent event) { + public boolean onTouchEvent(MotionEvent event) { // Only get entropy every 200 milliseconds to ensure the user has moved around. long now = System.currentTimeMillis(); if ((now - mLastTime) < 200) |