improved editing of extra strings

This commit is contained in:
Philipp Crocoll 2016-01-05 12:17:58 +01:00
parent 490fe1cd63
commit 161964bff7
3 changed files with 42 additions and 39 deletions

View File

@ -267,8 +267,9 @@ namespace keepass2android
State.EntryModified = true; State.EntryModified = true;
TextView keyView = (TextView) ees.FindViewById(Resource.Id.title); /*TextView keyView = (TextView) ees.FindViewById(Resource.Id.title);
keyView.RequestFocus(); keyView.RequestFocus();*/
EditAdvancedString(ees.FindViewById(Resource.Id.edit_extra));
}; };
SetAddExtraStringEnabled(); SetAddExtraStringEnabled();
@ -840,17 +841,15 @@ namespace keepass2android
RelativeLayout CreateExtraStringView(KeyValuePair<string, ProtectedString> pair) RelativeLayout CreateExtraStringView(KeyValuePair<string, ProtectedString> pair)
{ {
RelativeLayout ees = (RelativeLayout)LayoutInflater.Inflate(Resource.Layout.entry_edit_section, null); RelativeLayout ees = (RelativeLayout)LayoutInflater.Inflate(Resource.Layout.entry_edit_section, null);
var titleView = ((AutoCompleteTextView)ees.FindViewById(Resource.Id.title)); var titleView = ((TextView)ees.FindViewById(Resource.Id.title));
titleView.Text = pair.Key; titleView.Text = pair.Key;
titleView.TextChanged += (sender, e) => State.EntryModified = true; ((TextView)ees.FindViewById(Resource.Id.value)).Text = pair.Value.ReadString();
titleView.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, Android.Resource.Id.Text1, AdditionalKeys);
((TextView)ees.FindViewById(Resource.Id.value)).Text = pair.Value.ReadString();
((TextView)ees.FindViewById(Resource.Id.value)).TextChanged += (sender, e) => State.EntryModified = true; ((TextView)ees.FindViewById(Resource.Id.value)).TextChanged += (sender, e) => State.EntryModified = true;
((CheckBox)ees.FindViewById(Resource.Id.protection)).Checked = pair.Value.IsProtected; ((CheckBox)ees.FindViewById(Resource.Id.protection)).Checked = pair.Value.IsProtected;
//ees.FindViewById(Resource.Id.edit_extra).Click += (sender, e) => DeleteAdvancedString((View)sender); //ees.FindViewById(Resource.Id.edit_extra).Click += (sender, e) => DeleteAdvancedString((View)sender);
ees.FindViewById(Resource.Id.edit_extra).Click += (sender, e) => EditAdvancedString((View)sender); ees.FindViewById(Resource.Id.edit_extra).Click += (sender, e) => EditAdvancedString(ees);
return ees; return ees;
} }
@ -876,7 +875,11 @@ namespace keepass2android
private void EditAdvancedString(View sender) private void EditAdvancedString(View sender)
{ {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
View dlgView = LayoutInflater.Inflate(Resource.Layout.edit_extra_string_dialog, null); View dlgView = LayoutInflater.Inflate(Resource.Layout.
edit_extra_string_dialog, null);
builder.SetView(dlgView); builder.SetView(dlgView);
builder.SetNegativeButton(Android.Resource.String.Cancel, (o, args) => { }); builder.SetNegativeButton(Android.Resource.String.Cancel, (o, args) => { });
builder.SetPositiveButton(Android.Resource.String.Ok, (o, args) => builder.SetPositiveButton(Android.Resource.String.Ok, (o, args) =>
@ -897,10 +900,14 @@ namespace keepass2android
}; };
//copy values: //copy values:
View ees = (View) sender.Parent; View ees = (View) sender.Parent;
dlgView.FindViewById<EditText>(Resource.Id.title).Text = ees.FindViewById<EditText>(Resource.Id.title).Text; dlgView.FindViewById<TextView>(Resource.Id.title).Text = ees.FindViewById<TextView>(Resource.Id.title).Text;
dlgView.FindViewById<EditText>(Resource.Id.value).Text = ees.FindViewById<EditText>(Resource.Id.value).Text; dlgView.FindViewById<EditText>(Resource.Id.value).Text = ees.FindViewById<EditText>(Resource.Id.value).Text;
dlgView.FindViewById<CheckBox>(Resource.Id.protection).Checked = ees.FindViewById<CheckBox>(Resource.Id.protection).Checked; dlgView.FindViewById<CheckBox>(Resource.Id.protection).Checked = ees.FindViewById<CheckBox>(Resource.Id.protection).Checked;
var titleView = ((AutoCompleteTextView)dlgView.FindViewById(Resource.Id.title));
titleView.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, Android.Resource.Id.Text1, AdditionalKeys);
dialog.Show(); dialog.Show();
} }

View File

@ -2,13 +2,16 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout 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">
<EditText
<AutoCompleteTextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true" android:singleLine="true"
android:inputType="text" android:inputType="text"
android:hint="@string/field_name" /> android:hint="@string/field_name"
android:dropDownWidth="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<EditText <EditText
android:id="@+id/value" android:id="@+id/value"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View File

@ -14,35 +14,28 @@
android:gravity="center" android:gravity="center"
android:layout_marginRight="0dip" android:layout_marginRight="0dip"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
/> />
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toLeftOf="@id/edit_extra"> android:layout_toLeftOf="@id/edit_extra">
<AutoCompleteTextView
android:id="@+id/title" <TextView
android:singleLine="true" android:id="@+id/title"
android:inputType="text" android:layout_width="wrap_content"
android:hint="@string/field_name" android:layout_height="wrap_content"
style="@style/TextAppearance_EditEntry_Value" android:layout_marginRight="0dip"
android:layout_width="0dip" style="@style/EntryFieldHeader" />
android:layout_height="wrap_content"
android:layout_weight="0.4" <EditText
android:gravity="top|left" android:id="@+id/value"
android:layout_marginRight="0dip" android:hint="@string/field_value"
android:layout_marginLeft="0dip" android:inputType="textMultiLine"
android:dropDownWidth="match_parent" style="@style/EntryEditSingleLine_EditText"
/> android:layout_marginRight="0dip" />
<EditText
android:id="@+id/value"
android:hint="@string/field_value"
android:inputType="textMultiLine"
style="@style/TextAppearance_EditEntry_Value"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:gravity="top|left"
android:layout_marginRight="0dip" />
<CheckBox <CheckBox
android:id="@+id/protection" android:id="@+id/protection"
android:layout_width="0dip" android:layout_width="0dip"