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); }
}
/*
/*TODO
public override bool OnCreateOptionsMenu(IMenu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.

View File

@ -84,15 +84,29 @@ namespace keepass2android
public void SetNormalButtonVisibility(bool showAddGroup, bool showAddEntry)
{
FindViewById(Resource.Id.bottom_bar).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.divider2).Visibility = ViewStates.Gone;
//check for null in the following because the "empty" layouts may not have all views
if (FindViewById(Resource.Id.bottom_bar) != null)
FindViewById(Resource.Id.bottom_bar).Visibility = BottomBarAlwaysVisible ? 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; }
}
@ -216,8 +230,10 @@ namespace keepass2android
_prefs = PreferenceManager.GetDefaultSharedPreferences(this);
SetContentView(Resource.Layout.group);
SetContentView(ContentResourceId);
if (FindViewById(Resource.Id.fabCancelAddNew) != null)
{
FindViewById(Resource.Id.fabAddNew).Click += (sender, args) =>
{
FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible;
@ -235,9 +251,15 @@ namespace keepass2android
};
}
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();
}
SetResult(KeePass.ExitNormal);
@ -245,6 +267,11 @@ namespace keepass2android
}
protected virtual int ContentResourceId
{
get { return Resource.Layout.group; }
}
private void InsertElements()
{
MoveElementsTask moveElementsTask = (MoveElementsTask)AppTask;
@ -313,7 +340,6 @@ namespace keepass2android
cursor.MoveToPosition(position);
string entryIdAsHexString = cursor.GetString(cursor.GetColumnIndexOrThrow(SearchManager.SuggestColumnIntentDataId));
EntryActivity.Launch(_activity, App.Kp2a.GetDb().Entries[new PwUuid(MemUtil.HexStringToByteArray(entryIdAsHexString))],-1,_activity.AppTask);
((SearchView) _searchItem.ActionView).Iconified = true;
return true;
}

View File

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

View File

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<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_height="fill_parent">
android:layout_height="fill_parent"
android:background="#fff">
<LinearLayout
android:id="@+id/top"
android:layout_width="match_parent"
@ -11,55 +14,36 @@
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:attr/dividerVertical"
android:showDividers="middle"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:dividerPadding="12dp"
android:baselineAligned="false">
<FrameLayout
<Button
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:text="@string/select_other_entry"
style="@style/BottomBarButton" />
<Button
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>
android:text="@string/add_url_entry"
style="@style/BottomBarButton" />
</LinearLayout>
<View
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_height="1dp"
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"
<fragment
android:name="keepass2android.GroupListFragment"
android:id="@+id/list_fragment"
android:layout_above="@id/divider2"
android:layout_below="@id/top"
android:paddingRight="8dp"
android:paddingLeft="8dp" />
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

View File

@ -1,59 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<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_height="fill_parent">
android:layout_height="fill_parent"
android:background="#fff">
<LinearLayout
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal" />
<LinearLayout
<RelativeLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:attr/dividerVertical"
android:showDividers="middle"
android:layout_alignParentBottom="true"
android:dividerPadding="12dp"
android:baselineAligned="false">
<FrameLayout
<Button
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:layout_alignParentLeft="true"
android:text="@string/select_other_entry"
style="@style/BottomBarButton" />
<Button
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>
android:layout_alignParentRight="true"
android:text="@string/add_url_entry"
style="@style/BottomBarButton" />
</RelativeLayout>
<View
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_height="1dp"
android:layout_above="@id/bottom_bar"
android:background="#b8b8b8" />
<TextView
android:id="@+id/no_results"
android:layout_width="fill_parent"
@ -61,6 +45,7 @@
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"

View File

@ -122,10 +122,6 @@ namespace keepass2android
{
//TODO
SetContentView(Resource.Layout.searchurlresults_empty);
} else
{
//TODO
SetContentView(Resource.Layout.searchurlresults);
}
SetGroupTitle();
@ -163,5 +159,15 @@ namespace keepass2android
StartActivity(i);
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);
ProcessIntent(Intent);
//TODO RegisterForContextMenu(ListView);
}
protected override bool AddEntryEnabled