-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to re-order sticker packs.
- Loading branch information
1 parent
7d70ea7
commit f7a3bb2
Showing
13 changed files
with
211 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
app/src/main/java/org/thoughtcrime/securesms/stickers/StickerManagementItemTouchHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.thoughtcrime.securesms.stickers; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.ItemTouchHelper; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
public class StickerManagementItemTouchHelper extends ItemTouchHelper.Callback { | ||
|
||
private final Callback callback; | ||
|
||
public StickerManagementItemTouchHelper(Callback callback) { | ||
this.callback = callback; | ||
} | ||
|
||
@Override | ||
public boolean isLongPressDragEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isItemViewSwipeEnabled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { | ||
if (callback.isMovable(viewHolder.getAdapterPosition())) { | ||
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; | ||
return makeMovementFlags(dragFlags, 0); | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) { | ||
return callback.onMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); | ||
} | ||
|
||
@Override | ||
public void clearView(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { | ||
super.clearView(recyclerView, viewHolder); | ||
callback.onMoveCommitted(); | ||
} | ||
|
||
@Override | ||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { | ||
} | ||
|
||
public interface Callback { | ||
/** | ||
* @return True if both the start and end positions are valid, and therefore the move will occur. | ||
*/ | ||
boolean onMove(int start, int end); | ||
void onMoveCommitted(); | ||
boolean isMovable(int position); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/res/drawable-v21/selectable_background_dark.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ripple | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:color="@color/transparent_white_20"> | ||
|
||
<item android:id="@+id/mask"> | ||
<shape> | ||
<solid android:color="@color/transparent_black" /> | ||
</shape> | ||
</item> | ||
|
||
<item> | ||
<shape android:shape="rectangle" > | ||
<solid android:color="@color/core_grey_95"/> | ||
</shape> | ||
</item> | ||
</ripple> |
17 changes: 17 additions & 0 deletions
17
app/src/main/res/drawable-v21/selectable_background_light.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ripple | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:color="@color/transparent_black_20"> | ||
|
||
<item android:id="@+id/mask"> | ||
<shape> | ||
<solid android:color="@color/transparent_black" /> | ||
</shape> | ||
</item> | ||
|
||
<item> | ||
<shape android:shape="rectangle" > | ||
<solid android:color="@color/core_white"/> | ||
</shape> | ||
</item> | ||
</ripple> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.