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.SimpleOnPageChangeListener;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -260,4 +261,5 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||
super.onActionModeFinished(mode);
|
||||
mSlidingTabLayout.setOnPageChangeListener(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
@ -64,6 +65,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
|||
private ListView mUserIds;
|
||||
private ListView mUserIdsAddedList;
|
||||
private View mUserIdsAddedLayout;
|
||||
private ViewAnimator mUserIdAddFabLayout;
|
||||
|
||||
private UserIdsAdapter mUserIdsAdapter;
|
||||
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
|
||||
public void onClick(View v) {
|
||||
addUserId();
|
||||
|
@ -271,7 +285,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
|||
vEditUserIds.setVisible(mHasSecret);
|
||||
}
|
||||
|
||||
public void enterEditMode() {
|
||||
private void enterEditMode() {
|
||||
FragmentActivity activity = getActivity();
|
||||
activity.startActionMode(new Callback() {
|
||||
@Override
|
||||
|
@ -283,6 +297,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
|||
new UserIdsAddedAdapter(getActivity(), mEditModeSaveKeyringParcel.mAddUserIds, false);
|
||||
mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
|
||||
mUserIdsAddedLayout.setVisibility(View.VISIBLE);
|
||||
mUserIdAddFabLayout.setDisplayedChild(1);
|
||||
|
||||
mUserIdsAdapter.setEditMode(mEditModeSaveKeyringParcel);
|
||||
getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, ViewKeyAdvUserIdsFragment.this);
|
||||
|
@ -309,6 +324,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
|||
mEditModeSaveKeyringParcel = null;
|
||||
mUserIdsAdapter.setEditMode(null);
|
||||
mUserIdsAddedLayout.setVisibility(View.GONE);
|
||||
mUserIdAddFabLayout.setDisplayedChild(0);
|
||||
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_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
|
||||
<LinearLayout
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
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" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_key_action_add_user_id"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
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="match_parent"
|
||||
android:text="@string/edit_key_action_add_identity"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:drawableRight="@drawable/ic_person_add_grey_24dp"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
style="?android:attr/borderlessButtonStyle" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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>
|
||||
</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