UI enhancements. Custom views refactored.

This commit is contained in:
Brian Pellin
2009-02-16 23:43:14 -06:00
parent e7165d9be2
commit 325f663fea
12 changed files with 123 additions and 89 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.keepass" package="com.android.keepass"
android:versionCode="5" android:versionName="0.1.4"> android:versionCode="6" android:versionName="0.1.5">
<application android:label="@string/app_name" android:icon="@drawable/keepass_icon"> <application android:label="@string/app_name" android:icon="@drawable/keepass_icon">
<activity android:name=".KeePass" <activity android:name=".KeePass"
android:label="@string/app_name"> android:label="@string/app_name">

View File

@@ -1,6 +1,7 @@
KeePassDroid (0.2.0) KeePassDroid (0.1.5)
* Improve file selection * Improve file selection
* UI enhancements
KeePassDroid (0.1.4) KeePassDroid (0.1.4)

View File

@@ -17,6 +17,8 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>. along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
--> -->
<TextView android:id="@+id/text1" xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/entry_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:textSize="30sp"/>

View File

@@ -31,16 +31,18 @@
<EditText android:id="@+id/file_filename" <EditText android:id="@+id/file_filename"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true"/> android:singleLine="true"
android:text="/sdcard/keepass/keepass.kdb"/>
<Button android:id="@+id/file_button" <Button android:id="@+id/file_button"
android:text="Open" android:text="Open"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content"/> android:layout_width="wrap_content"
android:width="100sp"/>
<ImageView <ImageView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:scaleType="fitXY" android:scaleType="fitXY"
android:tint="#0000dd" android:tint="@color/blue_highlight"
android:src="@android:drawable/divider_horizontal_dark"/> android:src="@android:drawable/divider_horizontal_dark"/>
<TextView android:id="@+id/file_listtop" <TextView android:id="@+id/file_listtop"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View File

@@ -0,0 +1,37 @@
<?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/>.
-->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/group_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textColor="@color/blue_highlight"/>
<View/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue_highlight"
android:text="@string/group"/>
</TableRow>
</TableLayout>

View File

@@ -19,10 +19,25 @@
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/group_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="@string/current_group_root"
android:textStyle="bold"
android:layout_weight="0"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:tint="@color/blue_highlight"
android:src="@android:drawable/divider_horizontal_dark"/>
<ListView android:id="@android:id/list" <ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView android:id="@android:id/empty" <TextView android:id="@android:id/empty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -26,4 +26,9 @@
<string name="entry_and_or">Enter a password and/or a key file to unlock your database:</string> <string name="entry_and_or">Enter a password and/or a key file to unlock your database:</string>
<string name="entry_keyfile">Key file (optional):</string> <string name="entry_keyfile">Key file (optional):</string>
<color name="blue_highlight">#0000dd</color>
<string name="group">Group</string>
<string name="current_group">Current Group: </string>
<string name="root">Root</string>
<string name="current_group_root">Current Group: Root</string>
</resources> </resources>

View File

@@ -32,6 +32,7 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
public class GroupActivity extends ListActivity { public class GroupActivity extends ListActivity {
@@ -58,15 +59,15 @@ public class GroupActivity extends ListActivity {
protected void onListItemClick(ListView l, View v, int position, long id) { protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id); super.onListItemClick(l, v, position, id);
int size = mGroup.childGroups.size(); int size = mGroup.childGroups.size();
PwItemView iv;
if (position < size ) { if (position < size ) {
PwGroup group = (PwGroup) mGroup.childGroups.elementAt(position); PwGroup group = (PwGroup) mGroup.childGroups.elementAt(position);
iv = new PwGroupView(this, group); PwGroupView gv = new PwGroupView(this, group);
gv.onClick();
} else { } else {
PwEntry entry = (PwEntry) mGroup.childEntries.elementAt(position - size); PwEntry entry = (PwEntry) mGroup.childEntries.elementAt(position - size);
iv = new PwEntryView(this, entry); PwEntryView pe = new PwEntryView(this, entry);
pe.onClick();
} }
iv.onClick();
} }
@Override @Override
@@ -86,11 +87,23 @@ public class GroupActivity extends ListActivity {
} }
assert(mGroup != null); assert(mGroup != null);
setGroupTitle();
setListAdapter(new PwListAdapter(this, mGroup)); setListAdapter(new PwListAdapter(this, mGroup));
getListView().setTextFilterEnabled(true); getListView().setTextFilterEnabled(true);
} }
private void setGroupTitle() {
if ( mGroup != null ) {
String name = mGroup.name;
if ( name != null && name.length() > 0 ) {
TextView tv = (TextView) findViewById(R.id.group_header);
tv.setText(getText(R.string.current_group) + " " + name);
}
}
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);

View File

@@ -22,27 +22,30 @@ package com.android.keepass;
import org.phoneid.keepassj2me.PwEntry; import org.phoneid.keepassj2me.PwEntry;
import android.app.Activity; import android.app.Activity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
public class PwEntryView extends PwItemView { public class PwEntryView extends LinearLayout {
private Activity mAct; private Activity mAct;
private PwEntry mPw; private PwEntry mPw;
public PwEntryView(Activity act, PwEntry pw) { public PwEntryView(Activity act, PwEntry pw) {
super(act, pw.title); super(act);
mAct = act; mAct = act;
mPw = pw; mPw = pw;
View ev = View.inflate(mAct, R.layout.entry_list_entry, null);
TextView tv = (TextView) ev.findViewById(R.id.entry_text);
tv.setText(mPw.title);
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
addView(ev, lp);
} }
public void setEntry(PwEntry pw) {
super.setTitle(pw.title);
mPw = pw;
}
@Override
void onClick() { void onClick() {
EntryActivity.Launch(mAct, mPw); EntryActivity.Launch(mAct, mPw);

View File

@@ -22,30 +22,33 @@ package com.android.keepass;
import org.phoneid.keepassj2me.PwGroup; import org.phoneid.keepassj2me.PwGroup;
import android.app.Activity; import android.app.Activity;
import android.graphics.Color; import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
public class PwGroupView extends PwItemView {
public class PwGroupView extends LinearLayout {
private PwGroup mPw; private PwGroup mPw;
private Activity mAct; private Activity mAct;
public PwGroupView(Activity act, PwGroup pw) { public PwGroupView(Activity act, PwGroup pw) {
super(act, pw.name); super(act);
mAct = act; mAct = act;
mPw = pw; mPw = pw;
getTextView().setTextColor(Color.BLUE); View gv = View.inflate(act, R.layout.group_list_entry, null);
TextView tv = (TextView) gv.findViewById(R.id.group_text);
tv.setText(pw.name);
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
addView(gv, lp);
} }
public void setGroup(PwGroup pw) {
super.setTitle(pw.name);
mPw = pw;
}
@Override
void onClick() { void onClick() {
GroupActivity.Launch(mAct, mPw); GroupActivity.Launch(mAct, mPw);
} }

View File

@@ -1,48 +0,0 @@
/*
* 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/>.
*
*/
package com.android.keepass;
import android.content.Context;
import android.util.TypedValue;
import android.widget.LinearLayout;
import android.widget.TextView;
abstract public class PwItemView extends LinearLayout {
private TextView mTitle;
PwItemView(Context context, String title) {
super(context);
mTitle = new TextView(context);
mTitle.setText(title);
mTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
protected void setTitle(String title) {
mTitle.setText(title);
}
protected TextView getTextView() {
return mTitle;
}
abstract void onClick();
}

View File

@@ -83,25 +83,26 @@ public class PwListAdapter extends BaseAdapter {
private View createGroupView(int position, View convertView) { private View createGroupView(int position, View convertView) {
PwGroupView gv; PwGroupView gv;
if (convertView == null || ! (convertView instanceof PwGroupView)) { //if (convertView == null || ! (convertView instanceof PwGroupView)) {
PwGroup group = (PwGroup) mGroup.childGroups.elementAt(position); PwGroup group = (PwGroup) mGroup.childGroups.elementAt(position);
gv = new PwGroupView(mAct, group); gv = new PwGroupView(mAct, group);
/*
} else { } else {
gv = (PwGroupView) convertView; gv = (PwGroupView) convertView;
gv.setGroup((PwGroup) mGroup.childGroups.elementAt(position)); gv.setGroup((PwGroup) mGroup.childGroups.elementAt(position));
} }
*/
return gv; return gv;
} }
private PwEntryView createEntryView(int position, View convertView) { private PwEntryView createEntryView(int position, View convertView) {
PwEntryView ev; PwEntryView ev;
if (convertView == null || ! (convertView instanceof PwEntryView) ) { // if (convertView == null || ! (convertView instanceof PwEntryView) ) {
ev = new PwEntryView(mAct, filteredEntries.elementAt(position)); ev = new PwEntryView(mAct, filteredEntries.elementAt(position));
} else { // } else {
ev = (PwEntryView) convertView; // ev = (PwEntryView) convertView;
ev.setEntry(filteredEntries.elementAt(position)); // ev.setEntry(filteredEntries.elementAt(position));
} // }
return ev; return ev;
} }