Profile edit remove row buttons
This commit is contained in:
parent
2dcd3c765f
commit
3215960115
|
@ -13,11 +13,14 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.model.AccountField;
|
||||
import org.joinmastodon.android.ui.BetterItemAnimator;
|
||||
import org.joinmastodon.android.ui.OutlineProviders;
|
||||
import org.joinmastodon.android.ui.text.CustomEmojiSpan;
|
||||
import org.joinmastodon.android.ui.utils.SimpleTextWatcher;
|
||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||
|
@ -68,6 +71,8 @@ public class ProfileAboutFragment extends Fragment{
|
|||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState){
|
||||
list=new UsableRecyclerView(getActivity());
|
||||
list.setId(R.id.list);
|
||||
list.setItemAnimator(new BetterItemAnimator());
|
||||
list.setDrawSelectorOnTop(true);
|
||||
list.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
imgLoader=new ListImageLoaderWrapper(getActivity(), list, new RecyclerViewDelegate(list), null);
|
||||
list.setAdapter(adapter=new AboutAdapter());
|
||||
|
@ -76,7 +81,7 @@ public class ProfileAboutFragment extends Fragment{
|
|||
list.setClipToPadding(false);
|
||||
dividerPaint.setStyle(Paint.Style.STROKE);
|
||||
dividerPaint.setStrokeWidth(V.dp(1));
|
||||
dividerPaint.setColor(getResources().getColor(R.color.gray_200));
|
||||
dividerPaint.setColor(getResources().getColor(R.color.gray_200)); // TODO themes
|
||||
list.addItemDecoration(new RecyclerView.ItemDecoration(){
|
||||
@Override
|
||||
public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state){
|
||||
|
@ -85,7 +90,9 @@ public class ProfileAboutFragment extends Fragment{
|
|||
int pos=parent.getChildAdapterPosition(item);
|
||||
int draggedPos=draggedViewHolder==null ? -1 : draggedViewHolder.getAbsoluteAdapterPosition();
|
||||
if(pos<adapter.getItemCount()-1 && pos!=draggedPos && pos!=draggedPos-1){
|
||||
c.drawLine(item.getLeft(), item.getBottom(), item.getRight(), item.getBottom(), dividerPaint);
|
||||
float y=item.getY()+item.getHeight();
|
||||
dividerPaint.setAlpha(Math.round(255*item.getAlpha()));
|
||||
c.drawLine(item.getLeft(), y, item.getRight(), y, dividerPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,6 +235,7 @@ public class ProfileAboutFragment extends Fragment{
|
|||
});
|
||||
title.addTextChangedListener(new SimpleTextWatcher(e->item.name=e.toString()));
|
||||
value.addTextChangedListener(new SimpleTextWatcher(e->item.value=e.toString()));
|
||||
findViewById(R.id.remove_row_btn).setOnClickListener(this::onRemoveRowClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -236,6 +244,16 @@ public class ProfileAboutFragment extends Fragment{
|
|||
title.setText(item.name);
|
||||
value.setText(item.value);
|
||||
}
|
||||
|
||||
private void onRemoveRowClick(View v){
|
||||
int pos=getAbsoluteAdapterPosition();
|
||||
fields.remove(pos);
|
||||
adapter.notifyItemRemoved(pos);
|
||||
for(int i=0;i<list.getChildCount();i++){
|
||||
BaseViewHolder vh=(BaseViewHolder) list.getChildViewHolder(list.getChildAt(i));
|
||||
vh.rebind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class AddRowViewHolder extends BaseViewHolder implements UsableRecyclerView.Clickable{
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.joinmastodon.android.ui;
|
||||
|
||||
import android.graphics.Outline;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
|
||||
public class OutlineProviders{
|
||||
private OutlineProviders(){
|
||||
//no instance
|
||||
}
|
||||
|
||||
public static final ViewOutlineProvider BACKGROUND_WITH_ALPHA=new ViewOutlineProvider(){
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline){
|
||||
view.getBackground().getOutline(outline);
|
||||
outline.setAlpha(view.getAlpha());
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
|
||||
<path android:pathData="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2zm-4.25 9.25C7.336 11.25 7 11.586 7 12c0 0.38 0.282 0.694 0.648 0.743L7.75 12.75h8.5c0.414 0 0.75-0.336 0.75-0.75 0-0.38-0.282-0.694-0.648-0.743L16.25 11.25h-8.5z" android:fillColor="@color/fluent_default_icon_tint"/>
|
||||
</vector>
|
|
@ -210,8 +210,7 @@
|
|||
android:layout_marginTop="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:background="@null"
|
||||
android:padding="0px"
|
||||
android:background="@drawable/edit_text_border"
|
||||
android:inputType="textMultiLine|textCapSentences"
|
||||
android:visibility="gone"
|
||||
tools:text="Founder, CEO and lead developer @Mastodon, Germany." />
|
||||
|
|
|
@ -6,14 +6,26 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?colorBackgroundLight"
|
||||
android:elevation="2dp"
|
||||
android:outlineProvider="background"
|
||||
android:padding="16dp">
|
||||
android:outlineProvider="background">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/remove_row_btn"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_fluent_subtract_circle_24_filled"
|
||||
android:tint="@color/error_500"
|
||||
android:stateListAnimator="@null"
|
||||
android:padding="0px"
|
||||
android:background="@null"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@id/dragger_thingy"
|
||||
android:layout_toEndOf="@id/remove_row_btn"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="@style/m3_label_medium"
|
||||
android:background="@drawable/bg_profile_field_edit_text"
|
||||
android:hint="@string/field_label"
|
||||
|
@ -27,6 +39,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/title"
|
||||
android:layout_toStartOf="@id/dragger_thingy"
|
||||
android:layout_toEndOf="@id/remove_row_btn"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:background="@drawable/bg_profile_field_edit_text"
|
||||
android:hint="@string/field_content"
|
||||
|
@ -38,9 +52,9 @@
|
|||
android:layout_width="56dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="-16dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignBottom="@id/value"
|
||||
android:layout_marginBottom="-16dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_fluent_re_order_dots_vertical_24_regular"/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue