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;
TextView keyView = (TextView) ees.FindViewById(Resource.Id.title);
keyView.RequestFocus();
/*TextView keyView = (TextView) ees.FindViewById(Resource.Id.title);
keyView.RequestFocus();*/
EditAdvancedString(ees.FindViewById(Resource.Id.edit_extra));
};
SetAddExtraStringEnabled();
@ -840,17 +841,15 @@ namespace keepass2android
RelativeLayout CreateExtraStringView(KeyValuePair<string, ProtectedString> pair)
{
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.TextChanged += (sender, e) => State.EntryModified = true;
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)).Text = pair.Value.ReadString();
((TextView)ees.FindViewById(Resource.Id.value)).TextChanged += (sender, e) => State.EntryModified = true;
((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) => EditAdvancedString((View)sender);
ees.FindViewById(Resource.Id.edit_extra).Click += (sender, e) => EditAdvancedString(ees);
return ees;
}
@ -876,7 +875,11 @@ namespace keepass2android
private void EditAdvancedString(View sender)
{
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.SetNegativeButton(Android.Resource.String.Cancel, (o, args) => { });
builder.SetPositiveButton(Android.Resource.String.Ok, (o, args) =>
@ -897,10 +900,14 @@ namespace keepass2android
};
//copy values:
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<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();
}

View File

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

View File

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