mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-16 06:53:01 +00:00
Started working on the bottom sheet for editing profiles
This commit is contained in:
parent
fd3db9854d
commit
61149887ee
8 changed files with 109 additions and 17 deletions
|
@ -0,0 +1,21 @@
|
|||
package me.impy.aegis;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetDialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class EditProfileBottomSheetdialog extends BottomSheetDialogFragment {
|
||||
|
||||
public static EditProfileBottomSheetdialog getInstance() {
|
||||
return new EditProfileBottomSheetdialog();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.bottom_sheet_edit_profile, container, false);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package me.impy.aegis;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.ClipData;
|
||||
import android.os.Handler;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
@ -30,6 +31,7 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
|
|||
private ArrayList<KeyProfile> mKeyProfiles;
|
||||
private Handler uiHandler;
|
||||
private static ItemClickListener itemClickListener;
|
||||
private static LongItemClickListener longItemClickListener;
|
||||
|
||||
public KeyProfileAdapter(ArrayList<KeyProfile> keyProfiles) {
|
||||
mKeyProfiles = keyProfiles;
|
||||
|
@ -101,7 +103,7 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
|
|||
return mKeyProfiles.size();
|
||||
}
|
||||
|
||||
public static class KeyProfileHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public static class KeyProfileHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView profileName;
|
||||
TextView profileCode;
|
||||
TextView profileIssuer;
|
||||
|
@ -118,6 +120,7 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
|
|||
progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
public void setData(KeyProfile profile) {
|
||||
|
@ -167,14 +170,29 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
|
|||
public void onClick(View view) {
|
||||
itemClickListener.onItemClick(getAdapterPosition(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
longItemClickListener.onLongItemClick(getAdapterPosition(), view);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(ItemClickListener clickListener) {
|
||||
KeyProfileAdapter.itemClickListener = clickListener;
|
||||
}
|
||||
|
||||
public void setOnLongItemClickListener(LongItemClickListener clickListener) {
|
||||
KeyProfileAdapter.longItemClickListener = clickListener;
|
||||
}
|
||||
|
||||
public interface ItemClickListener
|
||||
{
|
||||
void onItemClick(int position, View v);
|
||||
}
|
||||
|
||||
public interface LongItemClickListener
|
||||
{
|
||||
void onLongItemClick(int position, View v);
|
||||
}
|
||||
}
|
|
@ -90,6 +90,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
Toast.makeText(context, "Code successfully copied to the clipboard", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
mKeyProfileAdapter.setOnLongItemClickListener((position, v) -> {
|
||||
EditProfileBottomSheetdialog bottomSheetDialog = EditProfileBottomSheetdialog.getInstance();
|
||||
bottomSheetDialog.show(getSupportFragmentManager(), "Custom Bottom Sheet");
|
||||
});
|
||||
|
||||
ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(mKeyProfileAdapter);
|
||||
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
|
||||
touchHelper.attachToRecyclerView(rvKeyProfiles);
|
||||
|
|
|
@ -5,4 +5,5 @@ import android.view.View;
|
|||
public interface ItemClickListener
|
||||
{
|
||||
void onItemClick(int position, View v);
|
||||
void onLongItemClick(int position, View v);
|
||||
}
|
||||
|
|
9
app/src/main/res/drawable/ic_create_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_create_black_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_delete_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_delete_black_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
||||
</vector>
|
|
@ -46,22 +46,6 @@
|
|||
/>
|
||||
</RelativeLayout>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/bottom_sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="350dp"
|
||||
android:clipToPadding="true"
|
||||
android:background="@android:color/holo_orange_light"
|
||||
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/ipsum"
|
||||
android:padding="16dp"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
45
app/src/main/res/layout/bottom_sheet_edit_profile.xml
Normal file
45
app/src/main/res/layout/bottom_sheet_edit_profile.xml
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="126dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:clickable="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:id="@+id/edit_button"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="16dp"
|
||||
android:src="@drawable/ic_create_black_24dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Edit"/>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:id="@+id/delete_button"
|
||||
android:clickable="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="16dp"
|
||||
android:src="@drawable/ic_delete_black_24dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Delete"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
Loading…
Add table
Add a link
Reference in a new issue