fix layouts for search results / share url results

fix crash in empty group view
This commit is contained in:
Philipp Crocoll
2015-09-17 06:01:45 +02:00
parent 7527560ba0
commit 60faa9cfab
7 changed files with 159 additions and 158 deletions

View File

@@ -97,7 +97,7 @@ namespace keepass2android
{ {
get { return App.Kp2a.GetDb().CanWrite && ((this.Group.ParentGroup != null) || App.Kp2a.GetDb().DatabaseFormat.CanHaveEntriesInRootGroup); } get { return App.Kp2a.GetDb().CanWrite && ((this.Group.ParentGroup != null) || App.Kp2a.GetDb().DatabaseFormat.CanHaveEntriesInRootGroup); }
} }
/* /*TODO
public override bool OnCreateOptionsMenu(IMenu menu) public override bool OnCreateOptionsMenu(IMenu menu)
{ {
// Inflate the menu; this adds items to the action bar if it is present. // Inflate the menu; this adds items to the action bar if it is present.

View File

@@ -84,18 +84,32 @@ namespace keepass2android
public void SetNormalButtonVisibility(bool showAddGroup, bool showAddEntry) public void SetNormalButtonVisibility(bool showAddGroup, bool showAddEntry)
{ {
FindViewById(Resource.Id.bottom_bar).Visibility = ViewStates.Gone; //check for null in the following because the "empty" layouts may not have all views
FindViewById(Resource.Id.divider2).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone; if (FindViewById(Resource.Id.bottom_bar) != null)
FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone; FindViewById(Resource.Id.bottom_bar).Visibility = BottomBarAlwaysVisible ? ViewStates.Visible : ViewStates.Gone;
FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabAddNew).Visibility = (showAddGroup || showAddEntry) ? ViewStates.Visible : ViewStates.Gone; if (FindViewById(Resource.Id.divider2) != null)
FindViewById(Resource.Id.divider2).Visibility = BottomBarAlwaysVisible ? ViewStates.Visible : ViewStates.Gone;
if (FindViewById(Resource.Id.fabCancelAddNew) != null)
{
FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabAddNew).Visibility = (showAddGroup || showAddEntry) ? ViewStates.Visible : ViewStates.Gone;
}
} }
public virtual bool BottomBarAlwaysVisible
{
get { return false; }
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{ {
base.OnActivityResult(requestCode, resultCode, data); base.OnActivityResult(requestCode, resultCode, data);
@@ -216,28 +230,36 @@ namespace keepass2android
_prefs = PreferenceManager.GetDefaultSharedPreferences(this); _prefs = PreferenceManager.GetDefaultSharedPreferences(this);
SetContentView(Resource.Layout.group); SetContentView(ContentResourceId);
FindViewById(Resource.Id.fabAddNew).Click += (sender, args) => if (FindViewById(Resource.Id.fabCancelAddNew) != null)
{ {
FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible; FindViewById(Resource.Id.fabAddNew).Click += (sender, args) =>
FindViewById(Resource.Id.fabAddNewGroup).Visibility = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone; {
FindViewById(Resource.Id.fabAddNewEntry).Visibility = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible;
FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewGroup).Visibility = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone;
}; FindViewById(Resource.Id.fabAddNewEntry).Visibility = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone;
FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Gone;
};
FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) => FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) =>
{ {
FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Visible; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Visible;
}; };
}
if (FindViewById(Resource.Id.cancel_insert_element) != null)
FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements(); {
FindViewById(Resource.Id.insert_element).Click += (sender, args) => InsertElements(); FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements();
FindViewById(Resource.Id.insert_element).Click += (sender, args) => InsertElements();
}
SetResult(KeePass.ExitNormal); SetResult(KeePass.ExitNormal);
@@ -245,6 +267,11 @@ namespace keepass2android
} }
protected virtual int ContentResourceId
{
get { return Resource.Layout.group; }
}
private void InsertElements() private void InsertElements()
{ {
MoveElementsTask moveElementsTask = (MoveElementsTask)AppTask; MoveElementsTask moveElementsTask = (MoveElementsTask)AppTask;
@@ -313,7 +340,6 @@ namespace keepass2android
cursor.MoveToPosition(position); cursor.MoveToPosition(position);
string entryIdAsHexString = cursor.GetString(cursor.GetColumnIndexOrThrow(SearchManager.SuggestColumnIntentDataId)); string entryIdAsHexString = cursor.GetString(cursor.GetColumnIndexOrThrow(SearchManager.SuggestColumnIntentDataId));
EntryActivity.Launch(_activity, App.Kp2a.GetDb().Entries[new PwUuid(MemUtil.HexStringToByteArray(entryIdAsHexString))],-1,_activity.AppTask); EntryActivity.Launch(_activity, App.Kp2a.GetDb().Entries[new PwUuid(MemUtil.HexStringToByteArray(entryIdAsHexString))],-1,_activity.AppTask);
((SearchView) _searchItem.ActionView).Iconified = true;
return true; return true;
} }

View File

@@ -27,5 +27,6 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@android:id/list" android:layout_below="@android:id/list"
android:layout_margin="12dp"
android:text="@string/no_results"/> android:text="@string/no_results"/>
</RelativeLayout> </RelativeLayout>

View File

@@ -1,65 +1,49 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent"
<LinearLayout android:background="#fff">
android:id="@+id/top" <LinearLayout
android:layout_width="match_parent" android:id="@+id/top"
android:layout_height="0dp" android:layout_width="match_parent"
android:orientation="horizontal" /> android:layout_height="0dp"
<LinearLayout android:orientation="horizontal" />
android:id="@+id/bottom_bar" <LinearLayout
android:layout_width="match_parent" android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:baselineAligned="false">
<Button
android:id="@+id/select_other_entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:text="@string/select_other_entry"
android:divider="?android:attr/dividerVertical" style="@style/BottomBarButton" />
android:showDividers="middle" <Button
android:layout_alignParentBottom="true" android:id="@+id/add_url_entry"
android:dividerPadding="12dp" android:layout_width="wrap_content"
android:baselineAligned="false">
<FrameLayout
android:id="@+id/select_other_entry"
style="?android:attr/actionButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/select_other_entry" />
</FrameLayout>
<FrameLayout
android:id="@+id/add_url_entry"
style="?android:attr/actionButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/add_url_entry" />
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_above="@id/bottom_bar"
android:background="#b8b8b8" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@id/divider2" android:text="@string/add_url_entry"
style="@style/BottomBarButton" />
</LinearLayout>
<View
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_above="@id/bottom_bar"
android:background="#b8b8b8" />
<fragment
android:name="keepass2android.GroupListFragment"
android:id="@+id/list_fragment"
android:layout_above="@id/divider2"
android:layout_below="@id/top" android:layout_below="@id/top"
android:paddingRight="8dp"
android:paddingLeft="8dp" /> android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout> </RelativeLayout>

View File

@@ -1,72 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent"
<LinearLayout android:background="#fff">
android:id="@+id/top" <LinearLayout
android:layout_width="match_parent" android:id="@+id/top"
android:layout_height="0dp" android:layout_width="match_parent"
android:orientation="horizontal" /> android:layout_height="0dp"
<LinearLayout android:orientation="horizontal" />
android:id="@+id/bottom_bar" <RelativeLayout
android:layout_width="match_parent" android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:baselineAligned="false">
<Button
android:id="@+id/select_other_entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_alignParentLeft="true"
android:divider="?android:attr/dividerVertical" android:text="@string/select_other_entry"
android:showDividers="middle" style="@style/BottomBarButton" />
android:layout_alignParentBottom="true" <Button
android:dividerPadding="12dp" android:id="@+id/add_url_entry"
android:baselineAligned="false"> android:layout_width="wrap_content"
<FrameLayout
android:id="@+id/select_other_entry"
style="?android:attr/actionButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/select_other_entry" />
</FrameLayout>
<FrameLayout
android:id="@+id/add_url_entry"
style="?android:attr/actionButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/add_url_entry" />
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_above="@id/bottom_bar"
android:background="#b8b8b8" />
<TextView
android:id="@+id/no_results"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="12dp" android:layout_alignParentRight="true"
android:layout_below="@id/top" android:text="@string/add_url_entry"
android:text="@string/no_results" /> style="@style/BottomBarButton" />
<ListView </RelativeLayout>
android:id="@android:id/list" <View
android:layout_width="fill_parent" android:id="@+id/divider2"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_above="@id/divider2" android:layout_height="1dp"
android:layout_below="@id/no_results" android:layout_above="@id/bottom_bar"
android:paddingRight="8dp" android:background="#b8b8b8" />
android:paddingLeft="8dp" />
</RelativeLayout> <TextView
android:id="@+id/no_results"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:layout_below="@id/top"
android:text="@string/no_results" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/divider2"
android:layout_below="@id/no_results"
android:paddingRight="8dp"
android:paddingLeft="8dp" />
</RelativeLayout>

View File

@@ -122,11 +122,7 @@ namespace keepass2android
{ {
//TODO //TODO
SetContentView(Resource.Layout.searchurlresults_empty); SetContentView(Resource.Layout.searchurlresults_empty);
} else }
{
//TODO
SetContentView(Resource.Layout.searchurlresults);
}
SetGroupTitle(); SetGroupTitle();
@@ -163,5 +159,15 @@ namespace keepass2android
StartActivity(i); StartActivity(i);
return true; return true;
} }
public override bool BottomBarAlwaysVisible
{
get { return true; }
}
protected override int ContentResourceId
{
get { return Resource.Layout.searchurlresults; }
}
}} }}

View File

@@ -46,7 +46,6 @@ namespace keepass2android.search
SetResult(KeePass.ExitNormal); SetResult(KeePass.ExitNormal);
ProcessIntent(Intent); ProcessIntent(Intent);
//TODO RegisterForContextMenu(ListView);
} }
protected override bool AddEntryEnabled protected override bool AddEntryEnabled