move linked ids into identities card
This commit is contained in:
parent
2e65e63b96
commit
d050c1d03c
|
@ -42,7 +42,6 @@ import org.sufficientlysecure.keychain.ui.keyview.presenter.SystemContactPresent
|
|||
import org.sufficientlysecure.keychain.ui.keyview.presenter.ViewKeyMvpView;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.view.IdentitiesCardView;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.view.KeyHealthView;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.view.LinkedIdentitiesCardView;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.view.SystemContactCardView;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
|
@ -61,9 +60,7 @@ public class ViewKeyFragment extends LoaderFragment implements LinkedIdsFragMvpV
|
|||
|
||||
private IdentitiesCardView mIdentitiesCardView;
|
||||
private IdentitiesPresenter mIdentitiesPresenter;
|
||||
|
||||
LinkedIdentitiesCardView mLinkedIdsCard;
|
||||
LinkedIdentitiesPresenter mLinkedIdentitiesPresenter;
|
||||
private LinkedIdentitiesPresenter mLinkedIdentitiesPresenter;
|
||||
|
||||
SystemContactCardView mSystemContactCard;
|
||||
SystemContactPresenter mSystemContactPresenter;
|
||||
|
@ -92,7 +89,6 @@ public class ViewKeyFragment extends LoaderFragment implements LinkedIdsFragMvpV
|
|||
View view = inflater.inflate(R.layout.view_key_fragment, getContainer());
|
||||
|
||||
mIdentitiesCardView = (IdentitiesCardView) view.findViewById(R.id.card_identities);
|
||||
mLinkedIdsCard = (LinkedIdentitiesCardView) view.findViewById(R.id.card_linked_ids);
|
||||
|
||||
mSystemContactCard = (SystemContactCardView) view.findViewById(R.id.linked_system_contact_card);
|
||||
mKeyStatusHealth = (KeyHealthView) view.findViewById(R.id.key_status_health);
|
||||
|
@ -107,16 +103,13 @@ public class ViewKeyFragment extends LoaderFragment implements LinkedIdsFragMvpV
|
|||
long masterKeyId = getArguments().getLong(ARG_MASTER_KEY_ID);
|
||||
mIsSecret = getArguments().getBoolean(ARG_IS_SECRET);
|
||||
|
||||
// initialize loaders, which will take care of auto-refresh on change
|
||||
// initCardButtonsVisibility(mIsSecret);
|
||||
|
||||
mIdentitiesPresenter = new IdentitiesPresenter(
|
||||
getContext(), mIdentitiesCardView, this, LOADER_ID_USER_IDS, masterKeyId, mIsSecret);
|
||||
mIdentitiesPresenter.startLoader(getLoaderManager());
|
||||
|
||||
if (Preferences.getPreferences(getActivity()).getExperimentalEnableLinkedIdentities()) {
|
||||
mLinkedIdentitiesPresenter = new LinkedIdentitiesPresenter(
|
||||
getContext(), mLinkedIdsCard, this, LOADER_ID_LINKED_IDS, masterKeyId, mIsSecret);
|
||||
getContext(), mIdentitiesCardView, this, LOADER_ID_LINKED_IDS, masterKeyId, mIsSecret);
|
||||
mLinkedIdentitiesPresenter.startLoader(getLoaderManager());
|
||||
}
|
||||
|
||||
|
@ -154,20 +147,6 @@ public class ViewKeyFragment extends LoaderFragment implements LinkedIdsFragMvpV
|
|||
}
|
||||
}
|
||||
|
||||
private void initCardButtonsVisibility(boolean isSecret) {
|
||||
LinearLayout buttonsUserIdsLayout =
|
||||
(LinearLayout) getActivity().findViewById(R.id.view_key_card_user_ids_buttons);
|
||||
LinearLayout buttonsLinkedIdsLayout =
|
||||
(LinearLayout) getActivity().findViewById(R.id.view_key_card_linked_ids_buttons);
|
||||
if (isSecret) {
|
||||
buttonsUserIdsLayout.setVisibility(View.VISIBLE);
|
||||
buttonsLinkedIdsLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
buttonsUserIdsLayout.setVisibility(View.GONE);
|
||||
buttonsLinkedIdsLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidForData(boolean isSecret) {
|
||||
return isSecret == mIsSecret;
|
||||
}
|
||||
|
|
|
@ -87,19 +87,14 @@ public class LinkedIdentitiesPresenter implements LoaderCallbacks<Cursor> {
|
|||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
linkedIdsAdapter.swapCursor(data);
|
||||
|
||||
boolean hasLinkedIdentities = linkedIdsAdapter.getCount() > 0;
|
||||
if (isSecret) {
|
||||
view.showCard(true);
|
||||
view.showEmptyView(!hasLinkedIdentities);
|
||||
} else {
|
||||
view.showCard(hasLinkedIdentities);
|
||||
view.showEmptyView(false);
|
||||
}
|
||||
boolean anyDataShown = data.getCount() > 0;
|
||||
view.setShowLinkedIdDivider(anyDataShown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader loader) {
|
||||
linkedIdsAdapter.swapCursor(null);
|
||||
view.setShowLinkedIdDivider(false);
|
||||
}
|
||||
|
||||
private void showLinkedId(final int position) {
|
||||
|
@ -118,8 +113,7 @@ public class LinkedIdentitiesPresenter implements LoaderCallbacks<Cursor> {
|
|||
void setSystemContactClickListener(LinkedIdsClickListener linkedIdsClickListener);
|
||||
void setLinkedIdsAdapter(LinkedIdsAdapter linkedIdsAdapter);
|
||||
|
||||
void showCard(boolean visible);
|
||||
void showEmptyView(boolean visible);
|
||||
void setShowLinkedIdDivider(boolean show);
|
||||
}
|
||||
|
||||
public interface LinkedIdsFragMvpView {
|
||||
|
|
|
@ -27,18 +27,22 @@ import android.widget.AdapterView;
|
|||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.IdentitiesPresenter.IdentitiesCardListener;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.IdentitiesPresenter.IdentitiesMvpView;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.LinkedIdentitiesPresenter.LinkedIdsClickListener;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.LinkedIdentitiesPresenter.LinkedIdsMvpView;
|
||||
|
||||
|
||||
public class IdentitiesCardView extends CardView implements IdentitiesMvpView {
|
||||
private ListView vUserIds;
|
||||
private TextView vLinkedIdsEmpty;
|
||||
public class IdentitiesCardView extends CardView implements IdentitiesMvpView, LinkedIdsMvpView {
|
||||
private final ListView vLinkedIds;
|
||||
private final ListView vUserIds;
|
||||
private final View vLinkedIdsDivider;
|
||||
|
||||
private LinkedIdsClickListener linkedIdsClickListener;
|
||||
private IdentitiesCardListener identitiesCardListener;
|
||||
|
||||
public IdentitiesCardView(Context context, AttributeSet attrs) {
|
||||
|
@ -67,6 +71,28 @@ public class IdentitiesCardView extends CardView implements IdentitiesMvpView {
|
|||
}
|
||||
});
|
||||
|
||||
vLinkedIds = (ListView) view.findViewById(R.id.view_key_linked_ids);
|
||||
Button linkedIdsAddButton = (Button) view.findViewById(R.id.view_key_card_linked_ids_add);
|
||||
|
||||
linkedIdsAddButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (linkedIdsClickListener != null) {
|
||||
linkedIdsClickListener.onClickAddIdentity();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vLinkedIds.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (linkedIdsClickListener != null) {
|
||||
linkedIdsClickListener.onLinkedIdItemClick(position);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vLinkedIdsDivider = view.findViewById(R.id.view_key_lid_divider);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,4 +109,19 @@ public class IdentitiesCardView extends CardView implements IdentitiesMvpView {
|
|||
public void setEditIdentitiesButtonVisible(boolean show) {
|
||||
findViewById(R.id.view_key_card_user_ids_buttons).setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemContactClickListener(LinkedIdsClickListener linkedIdsClickListener) {
|
||||
this.linkedIdsClickListener = linkedIdsClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLinkedIdsAdapter(LinkedIdsAdapter linkedIdsAdapter) {
|
||||
vLinkedIds.setAdapter(linkedIdsAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowLinkedIdDivider(boolean show) {
|
||||
vLinkedIdsDivider.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2017 Vincent Breitmoser <v.breitmoser@mugenguild.com>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.ui.keyview.view;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.LinkedIdentitiesPresenter.LinkedIdsClickListener;
|
||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.LinkedIdentitiesPresenter.LinkedIdsMvpView;
|
||||
|
||||
|
||||
public class LinkedIdentitiesCardView extends CardView implements LinkedIdsMvpView {
|
||||
private ListView vLinkedIds;
|
||||
private TextView vLinkedIdsEmpty;
|
||||
|
||||
private LinkedIdsClickListener linkedIdsClickListener;
|
||||
|
||||
public LinkedIdentitiesCardView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.linked_identities_card, this, true);
|
||||
|
||||
vLinkedIds = (ListView) view.findViewById(R.id.view_key_linked_ids);
|
||||
vLinkedIdsEmpty = (TextView) view.findViewById(R.id.view_key_linked_ids_empty);
|
||||
Button linkedIdsAddButton = (Button) view.findViewById(R.id.view_key_card_linked_ids_add);
|
||||
|
||||
linkedIdsAddButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (linkedIdsClickListener != null) {
|
||||
linkedIdsClickListener.onClickAddIdentity();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vLinkedIds.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (linkedIdsClickListener != null) {
|
||||
linkedIdsClickListener.onLinkedIdItemClick(position);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemContactClickListener(LinkedIdsClickListener linkedIdsClickListener) {
|
||||
this.linkedIdsClickListener = linkedIdsClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLinkedIdsAdapter(LinkedIdsAdapter linkedIdsAdapter) {
|
||||
vLinkedIds.setAdapter(linkedIdsAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCard(boolean visible) {
|
||||
setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEmptyView(boolean visible) {
|
||||
vLinkedIdsEmpty.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
@ -11,23 +12,47 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/section_user_ids" />
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/view_key_linked_ids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:id="@+id/view_key_lid_divider"
|
||||
android:background="?android:attr/listDivider"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
/>
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/view_key_user_ids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_key_card_user_ids_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|start"
|
||||
android:orientation="vertical">
|
||||
android:gravity="right|end"
|
||||
android:orientation="horizontal"
|
||||
style="?buttonBarStyle">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
<Button
|
||||
android:id="@+id/view_key_card_linked_ids_add"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/menu_linked_add_identity"
|
||||
android:textColor="@color/card_view_button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/view_key_card_user_ids_edit"
|
||||
|
@ -36,6 +61,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/key_view_action_edit"
|
||||
android:textColor="@color/card_view_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,50 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/CardViewHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/section_linked_identities" />
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/view_key_linked_ids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_key_linked_ids_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/linked_empty" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_key_card_linked_ids_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|start"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/view_key_card_linked_ids_add"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/menu_linked_add_identity"
|
||||
android:textColor="@color/card_view_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -40,18 +40,6 @@
|
|||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.keyview.view.LinkedIdentitiesCardView
|
||||
android:id="@+id/card_linked_ids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"
|
||||
card_view:cardBackgroundColor="?attr/colorCardViewBackground"
|
||||
card_view:cardCornerRadius="4dp"
|
||||
card_view:cardElevation="2dp"
|
||||
card_view:cardUseCompatPadding="true"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.keyview.view.IdentitiesCardView
|
||||
android:id="@+id/card_identities"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in a new issue