Permalink
Browse files

add some fulture

  • Loading branch information...
1 parent fc04fcc commit 545aa7824bd3d487d1a66eaca5a1db479241f0ef aisk committed Dec 29, 2011
Showing with 255 additions and 31 deletions.
  1. BIN bin/SaltPass-debug-unaligned.apk
  2. BIN bin/SaltPass-debug.apk
  3. BIN bin/SaltPass.ap_
  4. +13 −1 bin/SaltPass.ap_.d
  5. +1 −1 bin/build.prop
  6. BIN bin/classes.dex
  7. BIN bin/classes/aisk/saltpass/DBAdapter$saltDBOpenHelper.class
  8. BIN bin/classes/aisk/saltpass/DBAdapter.class
  9. BIN bin/classes/aisk/saltpass/IntEditTextPreference.class
  10. BIN bin/classes/aisk/saltpass/Main$1$1.class
  11. BIN bin/classes/aisk/saltpass/Main$1.class
  12. BIN bin/classes/aisk/saltpass/Main$2$1$1.class
  13. BIN bin/classes/aisk/saltpass/Main$2$1.class
  14. BIN bin/classes/aisk/saltpass/Main$2.class
  15. BIN bin/classes/aisk/saltpass/Main$3.class
  16. BIN bin/classes/aisk/saltpass/Main.class
  17. BIN bin/classes/aisk/saltpass/R$drawable.class
  18. BIN bin/classes/aisk/saltpass/R$id.class
  19. BIN bin/classes/aisk/saltpass/R$layout.class
  20. BIN bin/classes/aisk/saltpass/R$menu.class
  21. BIN bin/classes/aisk/saltpass/R$string.class
  22. BIN bin/classes/aisk/saltpass/R$xml.class
  23. BIN bin/classes/aisk/saltpass/R.class
  24. BIN bin/classes/aisk/saltpass/Utils.class
  25. BIN bin/res/drawable-hdpi/addsite.png
  26. BIN bin/res/drawable-hdpi/setting.png
  27. BIN bin/res/drawable-ldpi/addsite.png
  28. BIN bin/res/drawable-ldpi/setting.png
  29. BIN bin/res/drawable-mdpi/addsite.png
  30. BIN bin/res/drawable-mdpi/setting.png
  31. +7 −1 gen/R.java.d
  32. +5 −3 gen/aisk/saltpass/R.java
  33. BIN res/drawable-hdpi/addsite.png
  34. BIN res/drawable-hdpi/setting.png
  35. BIN res/drawable-ldpi/addsite.png
  36. BIN res/drawable-ldpi/setting.png
  37. BIN res/drawable-mdpi/addsite.png
  38. BIN res/drawable-mdpi/setting.png
  39. +16 −0 res/layout/input_dialog.xml
  40. +17 −14 res/menu/menu.xml
  41. +22 −3 res/xml/settings.xml
  42. +5 −2 src/aisk/saltpass/DBAdapter.java
  43. +30 −0 src/aisk/saltpass/IntEditTextPreference.java
  44. +104 −6 src/aisk/saltpass/Main.java
  45. +35 −0 src/aisk/saltpass/Utils.java
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -2,12 +2,24 @@
: /home/aisk/Projects/saltpass/res/menu/menu.xml \
/home/aisk/Projects/saltpass/res/values/strings.xml \
/home/aisk/Projects/saltpass/res/drawable-hdpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/res/drawable-hdpi/setting.png \
+/home/aisk/Projects/saltpass/res/drawable-hdpi/addsite.png \
/home/aisk/Projects/saltpass/res/drawable-mdpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/res/drawable-mdpi/setting.png \
+/home/aisk/Projects/saltpass/res/drawable-mdpi/addsite.png \
+/home/aisk/Projects/saltpass/res/layout/input_dialog.xml \
/home/aisk/Projects/saltpass/res/layout/main.xml \
-/home/aisk/Projects/saltpass/res/layout/addsite_dialog.xml \
/home/aisk/Projects/saltpass/res/drawable-ldpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/res/drawable-ldpi/setting.png \
+/home/aisk/Projects/saltpass/res/drawable-ldpi/addsite.png \
/home/aisk/Projects/saltpass/res/xml/settings.xml \
/home/aisk/Projects/saltpass/bin/res/drawable-hdpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/bin/res/drawable-hdpi/setting.png \
+/home/aisk/Projects/saltpass/bin/res/drawable-hdpi/addsite.png \
/home/aisk/Projects/saltpass/bin/res/drawable-mdpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/bin/res/drawable-mdpi/setting.png \
+/home/aisk/Projects/saltpass/bin/res/drawable-mdpi/addsite.png \
/home/aisk/Projects/saltpass/bin/res/drawable-ldpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/bin/res/drawable-ldpi/setting.png \
+/home/aisk/Projects/saltpass/bin/res/drawable-ldpi/addsite.png \
/home/aisk/Projects/saltpass/AndroidManifest.xml \
View
@@ -1,5 +1,5 @@
#Last build type
-#Wed, 28 Dec 2011 18:59:55 +0800
+#Thu, 29 Dec 2011 22:31:13 +0800
build.last.target=debug
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -2,9 +2,15 @@
: /home/aisk/Projects/saltpass/res/menu/menu.xml \
/home/aisk/Projects/saltpass/res/values/strings.xml \
/home/aisk/Projects/saltpass/res/drawable-hdpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/res/drawable-hdpi/setting.png \
+/home/aisk/Projects/saltpass/res/drawable-hdpi/addsite.png \
/home/aisk/Projects/saltpass/res/drawable-mdpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/res/drawable-mdpi/setting.png \
+/home/aisk/Projects/saltpass/res/drawable-mdpi/addsite.png \
+/home/aisk/Projects/saltpass/res/layout/input_dialog.xml \
/home/aisk/Projects/saltpass/res/layout/main.xml \
-/home/aisk/Projects/saltpass/res/layout/addsite_dialog.xml \
/home/aisk/Projects/saltpass/res/drawable-ldpi/ic_launcher.png \
+/home/aisk/Projects/saltpass/res/drawable-ldpi/setting.png \
+/home/aisk/Projects/saltpass/res/drawable-ldpi/addsite.png \
/home/aisk/Projects/saltpass/res/xml/settings.xml \
/home/aisk/Projects/saltpass/AndroidManifest.xml \
View
@@ -11,18 +11,20 @@
public static final class attr {
}
public static final class drawable {
- public static final int ic_launcher=0x7f020000;
+ public static final int addsite=0x7f020000;
+ public static final int ic_launcher=0x7f020001;
+ public static final int setting=0x7f020002;
}
public static final class id {
- public static final int addsite_message=0x7f070000;
+ public static final int input_edit=0x7f070000;
public static final int menuAdd=0x7f070002;
public static final int menuExit=0x7f070005;
public static final int menuSetting=0x7f070003;
public static final int meunAbout=0x7f070004;
public static final int siteListView=0x7f070001;
}
public static final class layout {
- public static final int addsite_dialog=0x7f030000;
+ public static final int input_dialog=0x7f030000;
public static final int main=0x7f030001;
}
public static final class menu {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+ <EditText
+ android:id="@+id/input_edit"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:layout_marginLeft="20dip"
+ android:layout_marginRight="20dip"
+ android:scrollHorizontally="true"
+ android:capitalize="none"
+ android:gravity="fill_horizontal" />
+</LinearLayout>
View
@@ -1,16 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
- <menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:title="Add Site"
- android:id="@+id/menuAdd">
- </item>
- <item android:title="Setting"
- android:id="@+id/menuSetting"
- android:showAsAction="ifRoom|withText" >
- </item>
- <item android:title="About"
- android:id="@+id/meunAbout" >
- </item>
- <item android:title="Exit"
- android:id="@+id/menuExit">
- </item>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:title="Add Site"
+ android:id="@+id/menuAdd"
+ android:icon="@drawable/addsite"
+ android:showAsAction="ifRoom">
+ </item>
+ <item android:title="Setting"
+ android:id="@+id/menuSetting"
+ android:icon="@drawable/setting"
+ android:showAsAction="ifRoom" >
+ </item>
+ <item android:title="About"
+ android:id="@+id/meunAbout" >
+ </item>
+ <item android:title="Exit"
+ android:id="@+id/menuExit">
+ </item>
</menu>
View
@@ -3,12 +3,31 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
- android:title="Salt Setting">
+ android:title="Salt Settings">
<EditTextPreference
android:title="Secret Salt Key"
- android:key="SALT_STRING"
+ android:key="SALT_STRING"
android:summary="A salt key to protect your password"/>
-
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:title="Password Settings">
+
+ <EditTextPreference
+ android:title="Salted password length"
+ android:key="SALTED_COUNT"
+ android:defaultValue="100"
+ android:inputType="number"
+ android:summary="Limit of the salted password,any word will be omitted which is over it"/>
+
+ <EditTextPreference
+ android:title="Salted password offset"
+ android:key="SALTED_OFFSET"
+ android:defaultValue="0"
+ android:inputType="number"
+ android:summary="Offset of the salted password"/>
+
</PreferenceCategory>
</PreferenceScreen>
@@ -37,10 +37,13 @@ public long insertSite(String siteName) {
return db.insert(DATABASE_TABLE, null, siteValue);
}
+ public boolean deleteSite(long id) {
+ return db.delete(DATABASE_TABLE, "_id=" + id, null) > 0;
+ }
+
public Cursor getAllSitesCursor() {
//WTF.....
- Cursor cursor = db.query(DATABASE_TABLE, null, null, null, null, null, null);
- return cursor;
+ return db.query(DATABASE_TABLE, null, null, null, null, null, null);
}
public void close() {
@@ -0,0 +1,30 @@
+package aisk.saltpass;
+
+import android.content.Context;
+import android.preference.EditTextPreference;
+import android.util.AttributeSet;
+
+public class IntEditTextPreference extends EditTextPreference {
+
+ public IntEditTextPreference(Context context) {
+ super(context);
+ }
+
+ public IntEditTextPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public IntEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected String getPersistedString(String defaultReturnValue) {
+ return String.valueOf(getPersistedInt(-1));
+ }
+
+ @Override
+ protected boolean persistString(String value) {
+ return persistInt(Integer.valueOf(value));
+ }
+}
View
@@ -7,26 +7,45 @@
import android.app.AlertDialog;
import android.os.Bundle;
import android.content.Intent;
+import android.content.DialogInterface;
+import android.content.ClipData;
+import android.content.SharedPreferences;
import android.widget.SimpleCursorAdapter;
import android.widget.ListView;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemLongClickListener;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.EditText;
+import android.widget.Toast;
+import android.widget.TextView;
+import android.view.View;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;
+import android.text.InputType;
+import android.text.ClipboardManager;
+import android.preference.PreferenceManager;
import android.database.Cursor;
+import android.util.Log;
+
public class Main extends Activity
{
private DBAdapter dbAdapter;
private SimpleCursorAdapter adapter;
private ListView siteListView;
private Cursor siteCursor;
+ private ClipboardManager clipboard;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
siteListView = (ListView)findViewById(R.id.siteListView);
-
+ clipboard = (ClipboardManager)this.getSystemService(CLIPBOARD_SERVICE);
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Main.this);
+
dbAdapter = new DBAdapter(this);
dbAdapter.open();
siteCursor = dbAdapter.getAllSitesCursor();
@@ -37,19 +56,92 @@ public void onCreate(Bundle savedInstanceState) {
new String[] {dbAdapter.KEY_SITE},
new int[] {android.R.id.text1});
siteListView.setAdapter(adapter);
+
+ siteListView.setOnItemLongClickListener(new OnItemLongClickListener(){
+ @Override
+ public boolean onItemLongClick(AdapterView parent, View view, int position, final long id) {
+ Log.d("Long Click:", String.valueOf(id));
+ AlertDialog dialog = new AlertDialog.Builder(Main.this)
+ .setTitle("Would you want delete this site salt?")
+ .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int btn) {
+ boolean result = dbAdapter.deleteSite(id);
+ siteCursor.requery();
+ adapter.notifyDataSetChanged();
+ String msg = result ? "Done" : "Failed";
+ Toast.makeText(Main.this, msg, Toast.LENGTH_SHORT).show();
+ }
+ })
+ .setNegativeButton("Cancel", null)
+ .create();
+ dialog.show();
+ return true;
+ }
+ });
+
+ siteListView.setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView parent, final View view, int position, long id) {
+ LayoutInflater factory = LayoutInflater.from(Main.this);
+ final View addSiteDialog = factory.inflate(R.layout.input_dialog, null);
+ final EditText edit = (EditText)addSiteDialog.findViewById(R.id.input_edit);
+ edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+ AlertDialog inputDialog = new AlertDialog.Builder(Main.this)
+ .setTitle("Input your password")
+ .setView(addSiteDialog)
+ .setPositiveButton("Salt it!", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int btn) {
+ String pswd = edit.getText().toString();
+ String salt = prefs.getString("SALT_STRING", "");
+ int count = Integer.valueOf(prefs.getString("SALTED_COUNT", "100"));
+ int offset = Integer.valueOf(prefs.getString("SALTED_OFFSET", "0"));
+ String pass = salt + ((TextView)view).getText().toString() + pswd;
+ final String saltedPass = Utils.limitCut(Utils.shaConvert(pass, "sha1"),
+ count, offset);
+ AlertDialog resultDialog = new AlertDialog.Builder(Main.this)
+ .setTitle("Salted password")
+ .setMessage(saltedPass)
+ .setPositiveButton("Copy", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int btn) {
+ clipboard.setText(saltedPass);
+ }
+ })
+ .setNegativeButton("Done", null)
+ .create();
+ resultDialog.show();
+ }
+ })
+ .setNegativeButton("Cancel", null)
+ .create();
+ inputDialog.show();
+ }
+ });
}
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch (item.getItemId()) {
case (R.id.menuAdd):
- Dialog dialog = new Dialog(this);
- dialog.setContentView(R.layout.addsite_dialog);
+ LayoutInflater factory = LayoutInflater.from(this);
+ final View addSiteDialog = factory.inflate(R.layout.input_dialog, null);
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setTitle("Add new site salt")
+ .setView(addSiteDialog)
+ .setPositiveButton("ADD", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int btn) {
+ EditText edit = (EditText)addSiteDialog.findViewById(R.id.input_edit);
+ dbAdapter.insertSite(edit.getText().toString());
+ siteCursor.requery();
+ adapter.notifyDataSetChanged();
+ }
+ })
+ .setNegativeButton("Cancel", null)
+ .create();
dialog.show();
- dbAdapter.insertSite("微博");
- siteCursor.requery();
- adapter.notifyDataSetChanged();
break;
case (R.id.menuExit):
Main.this.finish();
@@ -76,4 +168,10 @@ public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ dbAdapter.close();
+ }
}
@@ -0,0 +1,35 @@
+package aisk.saltpass;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class Utils {
+
+ public static String shaConvert(String s, String type) {
+ try {
+ MessageDigest digest = java.security.MessageDigest.getInstance(type);
+ digest.update(s.getBytes());
+ byte messageDigest[] = digest.digest();
+
+ StringBuffer hexString = new StringBuffer();
+ for (int i=0; i<messageDigest.length; i++)
+ hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
+ return hexString.toString();
+ } catch (NoSuchAlgorithmException e) {
+ return "";
+ }
+ }
+
+ public static String limitCut(String s, int count, int offset) {
+ if (s.length() > (offset + count)) {
+ return s.substring(offset, offset + count);
+ }
+ else if (s.length() > offset) {
+ return s.substring(offset, s.length());
+ }
+ else {
+ return("");
+ }
+ }
+
+}

0 comments on commit 545aa78

Please sign in to comment.