mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Activity for editing entries is built, except for hooking up the Save button.
This commit is contained in:
@@ -15,5 +15,6 @@
|
|||||||
<meta-data android:name="com.a0soft.gphone.aTrackDog.webURL" android:value="http://keepassdroid.com" />
|
<meta-data android:name="com.a0soft.gphone.aTrackDog.webURL" android:value="http://keepassdroid.com" />
|
||||||
<service android:name=".services.TimeoutService"></service>
|
<service android:name=".services.TimeoutService"></service>
|
||||||
<activity android:name=".LockingActivity"></activity>
|
<activity android:name=".LockingActivity"></activity>
|
||||||
|
<activity android:name=".EntryEditActivity"></activity>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
99
res/layout/entry_edit.xml
Normal file
99
res/layout/entry_edit.xml
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2009 Brian Pellin.
|
||||||
|
|
||||||
|
This file is part of KeePassDroid.
|
||||||
|
|
||||||
|
KeePassDroid is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
KeePassDroid is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/entry_scrollview"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
<RelativeLayout android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
<!-- Title -->
|
||||||
|
<TextView android:id="@+id/entry_title_label"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/entry_title" />
|
||||||
|
<EditText android:id="@+id/entry_title"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_title_label"/>
|
||||||
|
<!-- Username -->
|
||||||
|
<TextView android:id="@+id/entry_user_name_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_title"
|
||||||
|
android:text="@string/entry_user_name" />
|
||||||
|
<EditText android:id="@+id/entry_user_name"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_user_name_label"/>
|
||||||
|
<!-- URL -->
|
||||||
|
<TextView android:id="@+id/entry_url_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_user_name"
|
||||||
|
android:text="@string/entry_url" />
|
||||||
|
<EditText android:id="@+id/entry_url"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_url_label"/>
|
||||||
|
<!-- Password -->
|
||||||
|
<TextView android:id="@+id/entry_password_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_url"
|
||||||
|
android:text="@string/entry_password" />
|
||||||
|
<EditText android:id="@+id/entry_password"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:password="true"
|
||||||
|
android:layout_below="@id/entry_password_label"/>
|
||||||
|
<!-- Confirm Password -->
|
||||||
|
<TextView android:id="@+id/entry_confpassword_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_password"
|
||||||
|
android:text="@string/entry_confpassword" />
|
||||||
|
<EditText android:id="@+id/entry_confpassword"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:password="true"
|
||||||
|
android:layout_below="@id/entry_confpassword_label"/>
|
||||||
|
<!-- Comment -->
|
||||||
|
<TextView android:id="@+id/entry_comment_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_confpassword"
|
||||||
|
android:text="@string/entry_comment" />
|
||||||
|
<EditText android:id="@+id/entry_comment"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_comment_label"/>
|
||||||
|
<Button android:id="@+id/entry_save"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_comment"
|
||||||
|
android:text="@string/entry_save"/>
|
||||||
|
<Button android:id="@+id/entry_cancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/entry_comment"
|
||||||
|
android:layout_toRightOf="@id/entry_save"
|
||||||
|
android:text="@string/entry_cancel"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
</ScrollView>
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
<TextView android:id="@+id/entry_password"
|
<TextView android:id="@+id/entry_password"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:password="true"
|
||||||
android:layout_alignLeft="@id/entry_title"
|
android:layout_alignLeft="@id/entry_title"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignTop="@id/entry_password_label"/>
|
android:layout_alignTop="@id/entry_password_label"/>
|
||||||
@@ -123,6 +124,12 @@
|
|||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:layout_alignTop="@id/entry_comment_label"/>
|
android:layout_alignTop="@id/entry_comment_label"/>
|
||||||
|
<Button android:id="@+id/entry_edit"
|
||||||
|
android:text="Edit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentTop="true"/>
|
||||||
<!--
|
<!--
|
||||||
<ScrollView android:layout_width="wrap_content"
|
<ScrollView android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|||||||
@@ -41,4 +41,7 @@
|
|||||||
<string name="entry_created">Created: </string>
|
<string name="entry_created">Created: </string>
|
||||||
<string name="entry_modified">Modified: </string>
|
<string name="entry_modified">Modified: </string>
|
||||||
<string name="entry_accessed">Accessed: </string>
|
<string name="entry_accessed">Accessed: </string>
|
||||||
|
<string name="entry_save">Save</string>
|
||||||
|
<string name="entry_cancel">Cancel</string>
|
||||||
|
<string name="entry_confpassword">Confirm password:</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -32,10 +32,12 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
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.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class EntryActivity extends LockingActivity {
|
public class EntryActivity extends LockingActivity {
|
||||||
@@ -59,7 +61,7 @@ public class EntryActivity extends LockingActivity {
|
|||||||
|
|
||||||
private PwEntry mEntry;
|
private PwEntry mEntry;
|
||||||
private Timer mTimer = new Timer();
|
private Timer mTimer = new Timer();
|
||||||
private boolean showPassword = true;
|
private boolean mShowPassword = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -76,15 +78,25 @@ public class EntryActivity extends LockingActivity {
|
|||||||
// Update last access time.
|
// Update last access time.
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
mEntry.tLastAccess = cal.getTime();
|
mEntry.tLastAccess = cal.getTime();
|
||||||
|
|
||||||
fillData();
|
fillData();
|
||||||
|
|
||||||
|
Button edit = (Button) findViewById(R.id.entry_edit);
|
||||||
|
edit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
EntryEditActivity.Launch(EntryActivity.this, mEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillData() {
|
private void fillData() {
|
||||||
populateText(R.id.entry_title, mEntry.title);
|
populateText(R.id.entry_title, mEntry.title);
|
||||||
populateText(R.id.entry_user_name, mEntry.username);
|
populateText(R.id.entry_user_name, mEntry.username);
|
||||||
populateText(R.id.entry_url, mEntry.url);
|
populateText(R.id.entry_url, mEntry.url);
|
||||||
populateText(R.id.entry_password, getString(R.string.MaskedPassword));
|
populateText(R.id.entry_password, new String(mEntry.getPassword()));
|
||||||
|
setPasswordStyle();
|
||||||
|
|
||||||
DateFormat df = DateFormat.getInstance();
|
DateFormat df = DateFormat.getInstance();
|
||||||
populateText(R.id.entry_created, df.format(mEntry.tCreation));
|
populateText(R.id.entry_created, df.format(mEntry.tCreation));
|
||||||
@@ -119,20 +131,30 @@ public class EntryActivity extends LockingActivity {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setPasswordStyle() {
|
||||||
|
TextView password = (TextView) findViewById(R.id.entry_password);
|
||||||
|
|
||||||
|
if ( mShowPassword ) {
|
||||||
|
password.setTransformationMethod(null);
|
||||||
|
} else {
|
||||||
|
password.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch ( item.getItemId() ) {
|
switch ( item.getItemId() ) {
|
||||||
case MENU_PASS:
|
case MENU_PASS:
|
||||||
if ( showPassword ) {
|
if ( mShowPassword ) {
|
||||||
populateText(R.id.entry_password, new String(mEntry.getPassword()));
|
|
||||||
item.setTitle(R.string.menu_hide_password);
|
item.setTitle(R.string.menu_hide_password);
|
||||||
showPassword = false;
|
mShowPassword = false;
|
||||||
} else {
|
} else {
|
||||||
populateText(R.id.entry_password, getString(R.string.MaskedPassword));
|
|
||||||
item.setTitle(R.string.menu_show_password);
|
item.setTitle(R.string.menu_show_password);
|
||||||
showPassword = true;
|
mShowPassword = true;
|
||||||
}
|
}
|
||||||
|
setPasswordStyle();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MENU_GOTO_URL:
|
case MENU_GOTO_URL:
|
||||||
|
|||||||
157
src/com/android/keepass/EntryEditActivity.java
Normal file
157
src/com/android/keepass/EntryEditActivity.java
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 Brian Pellin.
|
||||||
|
*
|
||||||
|
* This file is part of KeePassDroid.
|
||||||
|
*
|
||||||
|
* KeePassDroid is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* KeePassDroid is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.android.keepass;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.phoneid.keepassj2me.PwEntry;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
|
import android.text.method.ScrollingMovementMethod;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class EntryEditActivity extends LockingActivity {
|
||||||
|
public static final String KEY_ENTRY = "entry";
|
||||||
|
|
||||||
|
private static final int MENU_PASS = Menu.FIRST;
|
||||||
|
|
||||||
|
private PwEntry mEntry;
|
||||||
|
private boolean mShowPassword = false;
|
||||||
|
|
||||||
|
public static void Launch(Activity act, PwEntry pw) {
|
||||||
|
Intent i = new Intent(act, EntryEditActivity.class);
|
||||||
|
|
||||||
|
i.putExtra(KEY_ENTRY, pw.uuid);
|
||||||
|
act.startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.entry_edit);
|
||||||
|
|
||||||
|
Intent i = getIntent();
|
||||||
|
UUID uuid = UUID.nameUUIDFromBytes(i.getByteArrayExtra(KEY_ENTRY));
|
||||||
|
assert(uuid != null);
|
||||||
|
|
||||||
|
mEntry = Database.gEntries.get(uuid).get();
|
||||||
|
|
||||||
|
View scrollView = findViewById(R.id.entry_scrollview);
|
||||||
|
scrollView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
||||||
|
|
||||||
|
|
||||||
|
fillData();
|
||||||
|
|
||||||
|
Button save = (Button) findViewById(R.id.entry_save);
|
||||||
|
save.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Button cancel = (Button) findViewById(R.id.entry_cancel);
|
||||||
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
|
menu.add(0, MENU_PASS, 0, R.string.menu_show_password);
|
||||||
|
menu.findItem(MENU_PASS).setIcon(android.R.drawable.ic_menu_view);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch ( item.getItemId() ) {
|
||||||
|
case MENU_PASS:
|
||||||
|
if ( mShowPassword ) {
|
||||||
|
item.setTitle(R.string.menu_hide_password);
|
||||||
|
mShowPassword = false;
|
||||||
|
} else {
|
||||||
|
item.setTitle(R.string.menu_show_password);
|
||||||
|
mShowPassword = true;
|
||||||
|
}
|
||||||
|
setPasswordStyle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPasswordStyle() {
|
||||||
|
TextView password = (TextView) findViewById(R.id.entry_password);
|
||||||
|
TextView confpassword = (TextView) findViewById(R.id.entry_confpassword);
|
||||||
|
|
||||||
|
if ( mShowPassword ) {
|
||||||
|
password.setTransformationMethod(null);
|
||||||
|
confpassword.setTransformationMethod(null);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PasswordTransformationMethod ptm = PasswordTransformationMethod.getInstance();
|
||||||
|
password.setTransformationMethod(ptm);
|
||||||
|
confpassword.setTransformationMethod(ptm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillData() {
|
||||||
|
populateText(R.id.entry_title, mEntry.title);
|
||||||
|
populateText(R.id.entry_user_name, mEntry.username);
|
||||||
|
populateText(R.id.entry_url, mEntry.url);
|
||||||
|
|
||||||
|
String password = new String(mEntry.getPassword());
|
||||||
|
populateText(R.id.entry_password, password);
|
||||||
|
populateText(R.id.entry_confpassword, password);
|
||||||
|
setPasswordStyle();
|
||||||
|
|
||||||
|
populateText(R.id.entry_comment, mEntry.additional);
|
||||||
|
TextView comment = (TextView)findViewById(R.id.entry_comment);
|
||||||
|
comment.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
||||||
|
comment.setMovementMethod(new ScrollingMovementMethod());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateText(int viewId, String text) {
|
||||||
|
TextView tv = (TextView) findViewById(viewId);
|
||||||
|
tv.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user