mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix issue #56 - Overlap with undo action
This commit is contained in:
parent
918c32dade
commit
f0c36819b7
2 changed files with 20 additions and 55 deletions
|
@ -19,7 +19,6 @@ import static app.fedilab.android.helper.PinnedTimelineHelper.sortMenuItem;
|
||||||
import static app.fedilab.android.helper.PinnedTimelineHelper.sortPositionAsc;
|
import static app.fedilab.android.helper.PinnedTimelineHelper.sortPositionAsc;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -28,7 +27,6 @@ import android.text.InputFilter;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
@ -43,6 +41,8 @@ import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -346,21 +346,22 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUndo(PinnedTimeline pinnedTimeline, int position) {
|
public void onUndo(PinnedTimeline pinnedTimeline, int position) {
|
||||||
binding.undoContainer.setVisibility(View.VISIBLE);
|
|
||||||
|
String text = "";
|
||||||
switch (pinnedTimeline.type) {
|
switch (pinnedTimeline.type) {
|
||||||
case TAG:
|
case TAG:
|
||||||
binding.undoMessage.setText(R.string.reorder_tag_removed);
|
text = getString(R.string.reorder_tag_removed);
|
||||||
break;
|
break;
|
||||||
case REMOTE:
|
case REMOTE:
|
||||||
binding.undoMessage.setText(R.string.reorder_instance_removed);
|
text = getString(R.string.reorder_instance_removed);
|
||||||
break;
|
break;
|
||||||
case LIST:
|
case LIST:
|
||||||
binding.undoMessage.setText(R.string.reorder_list_deleted);
|
text = getString(R.string.reorder_list_deleted);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
binding.undoAction.setPaintFlags(binding.undoAction.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
||||||
|
|
||||||
Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
binding.undoContainer.setVisibility(View.GONE);
|
|
||||||
//change position of pinned that are after the removed item
|
//change position of pinned that are after the removed item
|
||||||
for (int i = pinnedTimeline.position + 1; i < pinned.pinnedTimelines.size(); i++) {
|
for (int i = pinnedTimeline.position + 1; i < pinned.pinnedTimelines.size(); i++) {
|
||||||
pinned.pinnedTimelines.get(i).position -= 1;
|
pinned.pinnedTimelines.get(i).position -= 1;
|
||||||
|
@ -376,12 +377,16 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
||||||
};
|
};
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
handler.postDelayed(runnable, 4000);
|
handler.postDelayed(runnable, 4000);
|
||||||
binding.undoAction.setOnClickListener(v -> {
|
Snackbar.make(binding.getRoot(), text, 4000)
|
||||||
pinned.pinnedTimelines.add(position, pinnedTimeline);
|
.setAction(getString(R.string.undo), view -> {
|
||||||
reorderTabAdapter.notifyItemInserted(position);
|
pinned.pinnedTimelines.add(position, pinnedTimeline);
|
||||||
binding.undoContainer.setVisibility(View.GONE);
|
reorderTabAdapter.notifyItemInserted(position);
|
||||||
handler.removeCallbacks(runnable);
|
handler.removeCallbacks(runnable);
|
||||||
});
|
})
|
||||||
|
.setTextColor(ThemeHelper.getAttColor(ReorderTimelinesActivity.this, R.attr.mTextColor))
|
||||||
|
.setActionTextColor(ContextCompat.getColor(ReorderTimelinesActivity.this, R.color.cyanea_accent_reference))
|
||||||
|
.setBackgroundTint(ContextCompat.getColor(ReorderTimelinesActivity.this, R.color.cyanea_primary_dark_reference))
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginStart="@dimen/fab_margin"
|
android:layout_marginStart="@dimen/fab_margin"
|
||||||
android:layout_marginEnd="@dimen/fab_margin"
|
android:layout_marginEnd="@dimen/fab_margin"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -72,46 +72,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:scrollbars="none" />
|
android:scrollbars="none" />
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/undo_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:layout_marginBottom="0dp"
|
|
||||||
android:background="@color/cyanea_primary_reference"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/undo_message"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:paddingLeft="20dp"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:paddingRight="20dp"
|
|
||||||
android:paddingBottom="5dp"
|
|
||||||
android:textColor="@color/cyanea_accent_dark_reference"
|
|
||||||
android:textSize="14sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/undo_action"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
android:paddingLeft="20dp"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:paddingRight="20dp"
|
|
||||||
android:paddingBottom="5dp"
|
|
||||||
android:text="@string/undo"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="@color/cyanea_accent_dark_reference"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
</RelativeLayout>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue