aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeapo <mohamed@zenadi.com>2014-08-02 17:52:08 +0100
committerZeapo <mohamed@zenadi.com>2014-08-02 17:52:08 +0100
commit280e662fc3f6df01088a1a615540289fc61db9cb (patch)
tree7d0caef572be03c58b798bbefe9f39e732387dee
parentc19191a3d5c625df1f1c6bf233be8f7a6411a0e1 (diff)
added temp (10sec) password visibility and extra content
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java9
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java91
-rw-r--r--app/src/main/res/layout/activity_pgp_handler.xml108
-rw-r--r--app/src/main/res/layout/activity_pwdstore.xml40
-rw-r--r--app/src/main/res/layout/password_row_layout.xml2
5 files changed, 188 insertions, 62 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index f525d6d7..79f1fc2d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -3,12 +3,16 @@ package com.zeapo.pwdstore;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
+import android.content.Context;
import android.content.Intent;
+import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.view.WindowManager;
+import android.widget.PopupWindow;
import com.zeapo.pwdstore.crypto.PgpHandler;
import com.zeapo.pwdstore.utils.PasswordItem;
@@ -25,6 +29,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
private Stack<Integer> scrollPositions;
/** if we leave the activity to do something, do not add any other fragment */
private boolean leftActivity = false;
+ private File currentDir;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -148,6 +153,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
}
this.leftActivity = false;
+ this.currentDir = localDir;
}
/** Stack the positions the different fragments were at */
@@ -184,4 +190,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
}
}
+ public void createPassword(View v) {
+ System.out.println("Adding file to : " + this.currentDir.getAbsolutePath());
+ }
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
index 0132c4cd..c7504e69 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
@@ -5,17 +5,23 @@ import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
+import android.graphics.Typeface;
+import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.zeapo.pwdstore.R;
+import com.zeapo.pwdstore.UserPreference;
import org.apache.commons.io.FileUtils;
import org.openintents.openpgp.OpenPgpError;
@@ -52,31 +58,24 @@ public class PgpHandler extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pgp_handler);
- // Setup action buttons
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
-
Bundle extra = getIntent().getExtras();
- ((TextView) findViewById(R.id.crypto_handler_name)).setText(extra.getString("NAME"));
+ ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME"));
// some persistance
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
String providerPackageName = settings.getString("openpgp_provider_list", "");
String accountName = settings.getString("openpgp_account_name", "");
- if (accountName.isEmpty()) {
- ((TextView) findViewById(R.id.crypto_account_name)).setText("No account selected");
- }
-
if (TextUtils.isEmpty(providerPackageName)) {
Toast.makeText(this, "No OpenPGP Provider selected!", Toast.LENGTH_LONG).show();
- finish();
- } else {
- // bind to service
- mServiceConnection = new OpenPgpServiceConnection(
- PgpHandler.this, providerPackageName);
- mServiceConnection.bindToService();
+ Intent intent = new Intent(this, UserPreference.class);
+ startActivity(intent);
+
}
+ // bind to service
+ mServiceConnection = new OpenPgpServiceConnection(
+ PgpHandler.this, providerPackageName);
+ mServiceConnection.bindToService();
}
@@ -130,6 +129,52 @@ public class PgpHandler extends Activity {
});
}
+ public class DelayShow extends AsyncTask<Void, Integer, Boolean> {
+ int count = 0;
+ final int SHOW_TIME = 10;
+ ProgressBar pb;
+
+ @Override
+ protected void onPreExecute() {
+ ((LinearLayout) findViewById(R.id.crypto_password_show_layout)).setVisibility(View.VISIBLE);
+ TextView extraText = (TextView) findViewById(R.id.crypto_extra_show);
+
+ if (extraText.getText().length() != 0)
+ ((LinearLayout) findViewById(R.id.crypto_extra_show_layout)).setVisibility(View.VISIBLE);
+
+ this.pb = (ProgressBar) findViewById(R.id.pbLoading);
+ this.pb.setVisibility(ProgressBar.VISIBLE);
+ this.pb.setMax(SHOW_TIME);
+
+ }
+
+ @Override
+ protected Boolean doInBackground(Void... params) {
+ while (this.count < SHOW_TIME) {
+ SystemClock.sleep(1000); this.count++;
+ publishProgress(this.count);
+ }
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean b) {
+ //clear password
+ ((TextView) findViewById(R.id.crypto_password_show)).setText("");
+ ((LinearLayout) findViewById(R.id.crypto_password_show_layout)).setVisibility(View.INVISIBLE);
+ ((LinearLayout) findViewById(R.id.crypto_extra_show_layout)).setVisibility(View.INVISIBLE);
+ // run a background job and once complete
+ this.pb.setVisibility(ProgressBar.INVISIBLE);
+ }
+
+
+ @Override
+ protected void onProgressUpdate(Integer... values) {
+ this.pb.setProgress(values[0]);
+ }
+
+ }
+
private class MyCallback implements OpenPgpApi.IOpenPgpCallback {
boolean returnToCiphertextField;
ByteArrayOutputStream os;
@@ -152,11 +197,19 @@ public class PgpHandler extends Activity {
try {
Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length
+ " str=" + os.toString("UTF-8"));
- showToast(os.toString("UTF-8"));
if (returnToCiphertextField) {
-// mCiphertext.setText(os.toString("UTF-8"));
+ String[] passContent = os.toString("UTF-8").split("\n");
+ ((TextView) findViewById(R.id.crypto_password_show))
+ .setText(passContent[0]);
+
+ String extraContent = os.toString("UTF-8").replaceFirst(".*\n","");
+ if (extraContent.length() != 0) {
+ ((TextView) findViewById(R.id.crypto_extra_show))
+ .setText(extraContent);
+ }
+ new DelayShow().execute();
} else {
-// mMessage.setText(os.toString("UTF-8"));
+ showToast(os.toString());
}
} catch (UnsupportedEncodingException e) {
Log.e(Constants.TAG, "UnsupportedEncodingException", e);
@@ -216,7 +269,7 @@ public class PgpHandler extends Activity {
ByteArrayOutputStream os = new ByteArrayOutputStream();
OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
- api.executeApiAsync(data, is, os, new MyCallback(false, os, REQUEST_CODE_DECRYPT_AND_VERIFY));
+ api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_DECRYPT_AND_VERIFY));
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/app/src/main/res/layout/activity_pgp_handler.xml b/app/src/main/res/layout/activity_pgp_handler.xml
index 5095b32c..4fe6c529 100644
--- a/app/src/main/res/layout/activity_pgp_handler.xml
+++ b/app/src/main/res/layout/activity_pgp_handler.xml
@@ -1,4 +1,4 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -6,58 +6,90 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
- tools:context="com.zeapo.pwdstore.crypto.PgpHandler">
+ tools:context="com.zeapo.pwdstore.crypto.PgpHandler"
+ android:orientation="vertical"
+ android:background="#eee">
+
+ <GridLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/rectangle"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@android:color/holo_orange_dark"
+ android:text="Large Text"
+ android:id="@+id/crypto_password_file"
+ android:layout_gravity="center_vertical"
+ android:layout_column="0"/>
+
+ <ImageButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_column="2"
+ android:src="@android:drawable/ic_input_get"
+ android:background="@android:drawable/screen_background_light_transparent"
+ android:layout_gravity="center_vertical"
+ android:onClick="decrypt"/>
+
+ </GridLayout>
<LinearLayout
+ android:id="@+id/crypto_password_show_layout"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="wrap_content"
+ android:visibility="invisible"
+ android:orientation="vertical"
+ android:background="@drawable/rectangle">
<GridLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:text="Large Text"
- android:id="@+id/crypto_account_name"
- android:layout_row="0"
- android:layout_column="0" />
-
- <Button
- android:layout_width="wrap_content"
+ android:textStyle="bold"
+ android:text="Password: "/>
+ <TextView
+ android:id="@+id/crypto_password_show"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="Change account"
- android:id="@+id/button"
- android:layout_row="0"
- android:layout_column="2" />
+ android:typeface="monospace"
+ android:layout_column="2"/>
</GridLayout>
- <View
- android:layout_width="fill_parent"
- android:layout_marginBottom="4dp"
- android:layout_height="1dp"
- android:background="@android:color/darker_gray"/>
-
- <TextView
+ <ProgressBar
+ android:id="@+id/pbLoading"
+ android:visibility="invisible"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="New Text"
- android:id="@+id/crypto_handler_name"/>
+ android:layout_height="2dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ style="?android:attr/progressBarStyleHorizontal"/>
+ </LinearLayout>
+ <LinearLayout
+ android:id="@+id/crypto_extra_show_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/rectangle"
+ android:orientation="vertical"
+ android:visibility="invisible">
- <Button
- android:layout_width="match_parent"
+ <TextView
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Select Key-id"
- android:onClick="getKeyID"/>
+ android:textStyle="bold"
+ android:text="Extra content: "/>
- <Button
+ <TextView
+ android:id="@+id/crypto_extra_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="Show password"
- android:onClick="decrypt"/>
- </LinearLayout>
-</RelativeLayout>
+ android:typeface="monospace"/>
+
+ </LinearLayout>
+</LinearLayout>
diff --git a/app/src/main/res/layout/activity_pwdstore.xml b/app/src/main/res/layout/activity_pwdstore.xml
index 0060cb78..66c5dedb 100644
--- a/app/src/main/res/layout/activity_pwdstore.xml
+++ b/app/src/main/res/layout/activity_pwdstore.xml
@@ -1,4 +1,4 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -7,12 +7,42 @@
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:background="#eee"
- tools:context=".pwdstore">
+ tools:context=".pwdstore"
+ android:orientation="vertical">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"></LinearLayout>
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_row="0"></LinearLayout>
-</RelativeLayout>
+ <GridLayout
+ android:id="@+id/bottom_layout"
+ android:orientation="horizontal"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_row="2">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@android:color/holo_orange_dark"
+ android:layout_gravity="center_vertical"
+ android:text="Large Text"
+ android:id="@+id/crypto_password_file"
+ android:background="#fff"
+ android:layout_marginBottom="@dimen/activity_vertical_margin"/>
+
+ <ImageButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@android:drawable/ic_input_add"
+ android:background="@drawable/rectangle"
+ android:layout_gravity="center_vertical"
+ android:onClick="createPassword"
+ android:layout_column="2"/>
+
+ </GridLayout>
+
+</GridLayout>
diff --git a/app/src/main/res/layout/password_row_layout.xml b/app/src/main/res/layout/password_row_layout.xml
index 85f576e8..f8d656fd 100644
--- a/app/src/main/res/layout/password_row_layout.xml
+++ b/app/src/main/res/layout/password_row_layout.xml
@@ -13,11 +13,13 @@
android:layout_height="wrap_content"
android:padding="8dp"
android:textStyle="bold"
+ android:layout_gravity="center_vertical"
/>
<TextView
android:id="@+id/label"
android:text="FILE_NAME"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
android:padding="8dp"/>
</GridLayout>