extend-uid: use FAB instead of extra list item
This commit is contained in:
parent
54cc08c291
commit
fd119bda00
|
@ -29,6 +29,7 @@ import android.support.v4.content.Loader;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v4.view.ViewPager.SimpleOnPageChangeListener;
|
import android.support.v4.view.ViewPager.SimpleOnPageChangeListener;
|
||||||
import android.view.ActionMode;
|
import android.view.ActionMode;
|
||||||
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -260,4 +261,5 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
||||||
super.onActionModeFinished(mode);
|
super.onActionModeFinished(mode);
|
||||||
mSlidingTabLayout.setOnPageChangeListener(null);
|
mSlidingTabLayout.setOnPageChangeListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.ViewAnimator;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
@ -64,6 +65,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
||||||
private ListView mUserIds;
|
private ListView mUserIds;
|
||||||
private ListView mUserIdsAddedList;
|
private ListView mUserIdsAddedList;
|
||||||
private View mUserIdsAddedLayout;
|
private View mUserIdsAddedLayout;
|
||||||
|
private ViewAnimator mUserIdAddFabLayout;
|
||||||
|
|
||||||
private UserIdsAdapter mUserIdsAdapter;
|
private UserIdsAdapter mUserIdsAdapter;
|
||||||
private UserIdsAddedAdapter mUserIdsAddedAdapter;
|
private UserIdsAddedAdapter mUserIdsAddedAdapter;
|
||||||
|
@ -88,7 +90,19 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view.findViewById(R.id.view_key_action_add_user_id).setOnClickListener(new View.OnClickListener() {
|
View footer = new View(getActivity());
|
||||||
|
int spacing = (int) android.util.TypedValue.applyDimension(
|
||||||
|
android.util.TypedValue.COMPLEX_UNIT_DIP, 72, getResources().getDisplayMetrics()
|
||||||
|
);
|
||||||
|
android.widget.AbsListView.LayoutParams params = new android.widget.AbsListView.LayoutParams(
|
||||||
|
android.widget.AbsListView.LayoutParams.MATCH_PARENT,
|
||||||
|
spacing
|
||||||
|
);
|
||||||
|
footer.setLayoutParams(params);
|
||||||
|
mUserIdsAddedList.addFooterView(footer, null, false);
|
||||||
|
|
||||||
|
mUserIdAddFabLayout = (ViewAnimator) view.findViewById(R.id.view_key_user_id_fab_layout);
|
||||||
|
view.findViewById(R.id.view_key_user_id_fab).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
addUserId();
|
addUserId();
|
||||||
|
@ -271,7 +285,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
||||||
vEditUserIds.setVisible(mHasSecret);
|
vEditUserIds.setVisible(mHasSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterEditMode() {
|
private void enterEditMode() {
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
activity.startActionMode(new Callback() {
|
activity.startActionMode(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -283,6 +297,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
||||||
new UserIdsAddedAdapter(getActivity(), mEditModeSaveKeyringParcel.mAddUserIds, false);
|
new UserIdsAddedAdapter(getActivity(), mEditModeSaveKeyringParcel.mAddUserIds, false);
|
||||||
mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
|
mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
|
||||||
mUserIdsAddedLayout.setVisibility(View.VISIBLE);
|
mUserIdsAddedLayout.setVisibility(View.VISIBLE);
|
||||||
|
mUserIdAddFabLayout.setDisplayedChild(1);
|
||||||
|
|
||||||
mUserIdsAdapter.setEditMode(mEditModeSaveKeyringParcel);
|
mUserIdsAdapter.setEditMode(mEditModeSaveKeyringParcel);
|
||||||
getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, ViewKeyAdvUserIdsFragment.this);
|
getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, ViewKeyAdvUserIdsFragment.this);
|
||||||
|
@ -309,6 +324,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
||||||
mEditModeSaveKeyringParcel = null;
|
mEditModeSaveKeyringParcel = null;
|
||||||
mUserIdsAdapter.setEditMode(null);
|
mUserIdsAdapter.setEditMode(null);
|
||||||
mUserIdsAddedLayout.setVisibility(View.GONE);
|
mUserIdsAddedLayout.setVisibility(View.GONE);
|
||||||
|
mUserIdAddFabLayout.setDisplayedChild(0);
|
||||||
getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, ViewKeyAdvUserIdsFragment.this);
|
getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, ViewKeyAdvUserIdsFragment.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
6
OpenKeychain/src/main/res/anim/fab_slide_down.xml
Normal file
6
OpenKeychain/src/main/res/anim/fab_slide_down.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromYDelta="0" android:toYDelta="300"
|
||||||
|
android:interpolator="@android:anim/anticipate_interpolator"
|
||||||
|
android:duration="250"
|
||||||
|
/>
|
7
OpenKeychain/src/main/res/anim/fab_slide_in.xml
Normal file
7
OpenKeychain/src/main/res/anim/fab_slide_in.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromYDelta="300" android:toYDelta="0"
|
||||||
|
android:interpolator="@android:anim/overshoot_interpolator"
|
||||||
|
android:duration="250"
|
||||||
|
android:startOffset="100"
|
||||||
|
/>
|
|
@ -1,74 +1,86 @@
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
|
<ScrollView
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:focusable="true"
|
|
||||||
android:focusableInTouchMode="true"
|
|
||||||
android:descendantFocusability="beforeDescendants"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
style="@style/SectionHeader"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:text="@string/section_user_ids"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
|
||||||
android:id="@+id/view_key_user_ids"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginBottom="4dp"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
|
<!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:descendantFocusability="beforeDescendants"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:id="@+id/view_key_user_ids_add_layout"
|
android:paddingLeft="16dp"
|
||||||
android:visibility="gone"
|
android:paddingRight="16dp">
|
||||||
tools:visibility="visible">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dip"
|
|
||||||
android:background="?android:attr/listDivider" />
|
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
|
||||||
android:id="@+id/view_key_user_ids_added"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dip"
|
|
||||||
android:background="?android:attr/listDivider" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/view_key_action_add_user_id"
|
style="@style/SectionHeader"
|
||||||
android:paddingLeft="8dp"
|
android:layout_width="wrap_content"
|
||||||
android:paddingRight="8dp"
|
android:layout_height="0dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/section_user_ids"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||||
|
android:id="@+id/view_key_user_ids"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="0dp"
|
||||||
android:text="@string/edit_key_action_add_identity"
|
android:layout_marginBottom="4dp"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:layout_weight="1" />
|
||||||
android:drawableRight="@drawable/ic_person_add_grey_24dp"
|
|
||||||
android:drawablePadding="8dp"
|
<LinearLayout
|
||||||
android:gravity="center_vertical"
|
android:layout_width="wrap_content"
|
||||||
android:clickable="true"
|
android:layout_height="wrap_content"
|
||||||
style="?android:attr/borderlessButtonStyle" />
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/view_key_user_ids_add_layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||||
|
android:id="@+id/view_key_user_ids_added"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</ScrollView>
|
||||||
|
|
||||||
</ScrollView>
|
<ViewAnimator
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:id="@+id/view_key_user_id_fab_layout"
|
||||||
|
android:inAnimation="@anim/fab_slide_in"
|
||||||
|
android:outAnimation="@anim/fab_slide_down">
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/view_key_user_id_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="24dp"
|
||||||
|
android:src="@drawable/ic_person_add_grey_24dp"
|
||||||
|
android:visibility="invisible"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
</ViewAnimator>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue