improved ui for decrypt/encrypt
This commit is contained in:
parent
e2ce35c85e
commit
cb8216b587
5 changed files with 249 additions and 70 deletions
|
@ -176,6 +176,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
||||||
intent.putExtra("PGP-ID", FileUtils.readFileToString(PasswordRepository.getFile("/.gpg-id")));
|
intent.putExtra("PGP-ID", FileUtils.readFileToString(PasswordRepository.getFile("/.gpg-id")));
|
||||||
intent.putExtra("NAME", item.getName());
|
intent.putExtra("NAME", item.getName());
|
||||||
intent.putExtra("FILE_PATH", item.getFile().getAbsolutePath());
|
intent.putExtra("FILE_PATH", item.getFile().getAbsolutePath());
|
||||||
|
intent.putExtra("Operation", "DECRYPT");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -192,5 +193,17 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
||||||
|
|
||||||
public void createPassword(View v) {
|
public void createPassword(View v) {
|
||||||
System.out.println("Adding file to : " + this.currentDir.getAbsolutePath());
|
System.out.println("Adding file to : " + this.currentDir.getAbsolutePath());
|
||||||
|
this.leftActivity = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(this, PgpHandler.class);
|
||||||
|
intent.putExtra("PGP-ID", FileUtils.readFileToString(PasswordRepository.getFile("/.gpg-id")));
|
||||||
|
intent.putExtra("NAME", "test.gpg");
|
||||||
|
intent.putExtra("FILE_PATH", this.currentDir.getAbsolutePath() + "/test.gpg");
|
||||||
|
intent.putExtra("Operation", "ENCRYPT");
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.zeapo.pwdstore.crypto;
|
package com.zeapo.pwdstore.crypto;
|
||||||
|
|
||||||
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
@ -15,10 +15,12 @@ import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.widget.GridLayout.LayoutParams;
|
||||||
|
|
||||||
import com.zeapo.pwdstore.R;
|
import com.zeapo.pwdstore.R;
|
||||||
import com.zeapo.pwdstore.UserPreference;
|
import com.zeapo.pwdstore.UserPreference;
|
||||||
|
@ -56,10 +58,19 @@ public class PgpHandler extends Activity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_pgp_handler);
|
|
||||||
|
|
||||||
Bundle extra = getIntent().getExtras();
|
Bundle extra = getIntent().getExtras();
|
||||||
|
if (extra.getString("Operation").equals("DECRYPT")) {
|
||||||
|
setContentView(R.layout.decrypt_layout);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME"));
|
((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME"));
|
||||||
|
findViewById(R.id.crypto_show_button).setVisibility(View.VISIBLE);
|
||||||
|
} else if (extra.getString("Operation").equals("ENCRYPT")) {
|
||||||
|
setContentView(R.layout.encrypt_layout);
|
||||||
|
|
||||||
|
((EditText) findViewById(R.id.crypto_password_edit)).setText(extra.getString("NAME"));
|
||||||
|
findViewById(R.id.crypto_password_edit_layout).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
// some persistance
|
// some persistance
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
@ -136,16 +147,16 @@ public class PgpHandler extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
((LinearLayout) findViewById(R.id.crypto_password_show_layout)).setVisibility(View.VISIBLE);
|
LinearLayout container = (LinearLayout) findViewById(R.id.crypto_container);
|
||||||
|
container.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
TextView extraText = (TextView) findViewById(R.id.crypto_extra_show);
|
TextView extraText = (TextView) findViewById(R.id.crypto_extra_show);
|
||||||
|
|
||||||
if (extraText.getText().length() != 0)
|
if (extraText.getText().length() != 0)
|
||||||
((LinearLayout) findViewById(R.id.crypto_extra_show_layout )).setVisibility(View.VISIBLE);
|
((LinearLayout) findViewById(R.id.crypto_extra_show_layout )).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
this.pb = (ProgressBar) findViewById(R.id.pbLoading);
|
this.pb = (ProgressBar) findViewById(R.id.pbLoading);
|
||||||
this.pb.setVisibility(ProgressBar.VISIBLE);
|
|
||||||
this.pb.setMax(SHOW_TIME);
|
this.pb.setMax(SHOW_TIME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -161,10 +172,8 @@ public class PgpHandler extends Activity {
|
||||||
protected void onPostExecute(Boolean b) {
|
protected void onPostExecute(Boolean b) {
|
||||||
//clear password
|
//clear password
|
||||||
((TextView) findViewById(R.id.crypto_password_show)).setText("");
|
((TextView) findViewById(R.id.crypto_password_show)).setText("");
|
||||||
((LinearLayout) findViewById(R.id.crypto_password_show_layout)).setVisibility(View.INVISIBLE);
|
findViewById(R.id.crypto_extra_show_layout).setVisibility(View.INVISIBLE);
|
||||||
((LinearLayout) findViewById(R.id.crypto_extra_show_layout)).setVisibility(View.INVISIBLE);
|
findViewById(R.id.crypto_container).setVisibility(View.INVISIBLE);
|
||||||
// run a background job and once complete
|
|
||||||
this.pb.setVisibility(ProgressBar.INVISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,7 +206,10 @@ public class PgpHandler extends Activity {
|
||||||
try {
|
try {
|
||||||
Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length
|
Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length
|
||||||
+ " str=" + os.toString("UTF-8"));
|
+ " str=" + os.toString("UTF-8"));
|
||||||
|
|
||||||
if (returnToCiphertextField) {
|
if (returnToCiphertextField) {
|
||||||
|
findViewById(R.id.crypto_container).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
String[] passContent = os.toString("UTF-8").split("\n");
|
String[] passContent = os.toString("UTF-8").split("\n");
|
||||||
((TextView) findViewById(R.id.crypto_password_show))
|
((TextView) findViewById(R.id.crypto_password_show))
|
||||||
.setText(passContent[0]);
|
.setText(passContent[0]);
|
||||||
|
|
|
@ -24,73 +24,30 @@
|
||||||
android:id="@+id/crypto_password_file"
|
android:id="@+id/crypto_password_file"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_column="0"/>
|
android:layout_column="0"
|
||||||
|
android:layout_row="0"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
android:id="@+id/crypto_show_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_column="2"
|
|
||||||
android:src="@android:drawable/ic_input_get"
|
android:src="@android:drawable/ic_input_get"
|
||||||
android:background="@android:drawable/screen_background_light_transparent"
|
android:background="@android:drawable/screen_background_light_transparent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:onClick="decrypt"/>
|
android:visibility="invisible"
|
||||||
|
android:onClick="decrypt"
|
||||||
|
android:layout_column="2"
|
||||||
|
android:layout_row="0"/>
|
||||||
|
|
||||||
</GridLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/crypto_password_show_layout"
|
android:id="@+id/crypto_container"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="invisible"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@drawable/rectangle">
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_column="0"
|
||||||
|
android:layout_row="2"
|
||||||
|
android:layout_columnSpan="3" />
|
||||||
|
|
||||||
<GridLayout
|
|
||||||
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:textStyle="bold"
|
|
||||||
android:text="Password: "/>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/crypto_password_show"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:typeface="monospace"
|
|
||||||
android:layout_column="2"/>
|
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/pbLoading"
|
|
||||||
android:visibility="invisible"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
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">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:text="Extra content: "/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/crypto_extra_show"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:typeface="monospace"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
115
app/src/main/res/layout/decrypt_layout.xml
Normal file
115
app/src/main/res/layout/decrypt_layout.xml
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
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"
|
||||||
|
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_marginLeft="8dp"
|
||||||
|
android:layout_column="0"
|
||||||
|
android:layout_row="0"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/crypto_show_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@android:drawable/ic_input_get"
|
||||||
|
android:background="@android:drawable/screen_background_light_transparent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:visibility="invisible"
|
||||||
|
android:onClick="decrypt"
|
||||||
|
android:layout_column="2"
|
||||||
|
android:layout_row="0"/>
|
||||||
|
</GridLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/crypto_container"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/rectangle"
|
||||||
|
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||||
|
android:visibility="invisible">
|
||||||
|
|
||||||
|
<GridLayout
|
||||||
|
android:id="@+id/crypto_password_show_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:text="Password: "
|
||||||
|
android:layout_row="0"
|
||||||
|
android:layout_column="0"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/crypto_password_show"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:typeface="monospace"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:layout_column="2"
|
||||||
|
android:layout_row="0"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/pbLoading"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_row="1"
|
||||||
|
android:layout_column="0"
|
||||||
|
android:layout_columnSpan="3"/>
|
||||||
|
</GridLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/crypto_extra_show_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="invisible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:text="Extra content: "/>
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/crypto_extra_show"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:typeface="monospace"/>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
82
app/src/main/res/layout/encrypt_layout.xml
Normal file
82
app/src/main/res/layout/encrypt_layout.xml
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
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"
|
||||||
|
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_marginLeft="8dp"
|
||||||
|
android:layout_column="0"
|
||||||
|
android:layout_row="0"/>
|
||||||
|
|
||||||
|
</GridLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/crypto_container"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||||
|
android:background="@drawable/rectangle"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/crypto_password_edit_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
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:textStyle="bold"
|
||||||
|
android:text="Password: "/>
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/crypto_password_edit"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:typeface="monospace"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="Extra content: "/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/crypto_edit_show"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="true"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:typeface="monospace"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in a new issue