Remove support for linear gif flow.
This commit is contained in:
parent
a844a6b6c1
commit
86f2cf0ac4
8 changed files with 11 additions and 177 deletions
|
@ -57,7 +57,7 @@ public class GiphyMp4Fragment extends Fragment {
|
|||
List<GiphyMp4PlayerHolder> holders = injectVideoViews(frameLayout);
|
||||
GiphyMp4AdapterPlaybackControllerCallback callback = new GiphyMp4AdapterPlaybackControllerCallback(holders);
|
||||
|
||||
recycler.setLayoutManager(getLayoutManager(TextSecurePreferences.isGifSearchInGridLayout(getContext())));
|
||||
recycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
|
||||
recycler.setAdapter(adapter);
|
||||
recycler.setItemAnimator(null);
|
||||
|
||||
|
@ -66,21 +66,6 @@ public class GiphyMp4Fragment extends Fragment {
|
|||
viewModel.getImages().observe(getViewLifecycleOwner(), adapter::submitList);
|
||||
|
||||
viewModel.getPagingController().observe(getViewLifecycleOwner(), adapter::setPagingController);
|
||||
viewModel.isGridMode().observe(getViewLifecycleOwner(), isGridLayout -> updateGridLayout(recycler, isGridLayout));
|
||||
}
|
||||
|
||||
private void updateGridLayout(@NonNull RecyclerView recyclerView, boolean isGridLayout) {
|
||||
RecyclerView.LayoutManager oldLayoutManager = recyclerView.getLayoutManager();
|
||||
RecyclerView.LayoutManager newLayoutManager = getLayoutManager(isGridLayout);
|
||||
|
||||
if (oldLayoutManager == null || !Objects.equals(oldLayoutManager.getClass(), newLayoutManager.getClass())) {
|
||||
recyclerView.setLayoutManager(newLayoutManager);
|
||||
}
|
||||
}
|
||||
|
||||
private RecyclerView.LayoutManager getLayoutManager(boolean gridLayout) {
|
||||
return gridLayout ? new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
|
||||
: new LinearLayoutManager(requireContext());
|
||||
}
|
||||
|
||||
private List<GiphyMp4PlayerHolder> injectVideoViews(@NonNull ViewGroup viewGroup) {
|
||||
|
|
|
@ -33,7 +33,6 @@ public final class GiphyMp4ViewModel extends ViewModel {
|
|||
private final LiveData<List<GiphyImage>> images;
|
||||
private final LiveData<PagingController> pagingController;
|
||||
private final SingleLiveEvent<GiphyMp4SaveResult> saveResultEvents;
|
||||
private final MutableLiveData<Boolean> isGridMode;
|
||||
private final boolean isForMms;
|
||||
|
||||
private String query;
|
||||
|
@ -43,7 +42,6 @@ public final class GiphyMp4ViewModel extends ViewModel {
|
|||
this.repository = new GiphyMp4Repository();
|
||||
this.pagedData = new DefaultValueLiveData<>(getGiphyImagePagedData(null));
|
||||
this.saveResultEvents = new SingleLiveEvent<>();
|
||||
this.isGridMode = new MutableLiveData<>();
|
||||
this.pagingController = Transformations.map(pagedData, PagedData::getController);
|
||||
this.images = Transformations.switchMap(pagedData, pagedData -> Transformations.map(pagedData.getData(),
|
||||
data -> Stream.of(data)
|
||||
|
@ -62,10 +60,6 @@ public final class GiphyMp4ViewModel extends ViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateLayout(boolean isGridMode) {
|
||||
this.isGridMode.setValue(isGridMode);
|
||||
}
|
||||
|
||||
public void saveToBlob(@NonNull GiphyImage giphyImage) {
|
||||
saveResultEvents.postValue(new GiphyMp4SaveResult.InProgress());
|
||||
repository.saveToBlob(giphyImage, isForMms, saveResultEvents::postValue);
|
||||
|
@ -83,10 +77,6 @@ public final class GiphyMp4ViewModel extends ViewModel {
|
|||
return pagingController;
|
||||
}
|
||||
|
||||
public @NonNull LiveData<Boolean> isGridMode() {
|
||||
return isGridMode;
|
||||
}
|
||||
|
||||
private PagedData<GiphyImage> getGiphyImagePagedData(@Nullable String query) {
|
||||
return PagedData.create(new GiphyMp4PagedDataSource(query),
|
||||
new PagingConfig.Builder().setPageSize(20)
|
||||
|
|
|
@ -41,8 +41,7 @@ import java.io.IOException;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class GiphyActivity extends PassphraseRequiredActivity
|
||||
implements GiphyActivityToolbar.OnLayoutChangedListener,
|
||||
GiphyActivityToolbar.OnFilterChangedListener,
|
||||
implements GiphyActivityToolbar.OnFilterChangedListener,
|
||||
GiphyAdapter.OnItemClickListener
|
||||
{
|
||||
|
||||
|
@ -89,8 +88,6 @@ public class GiphyActivity extends PassphraseRequiredActivity
|
|||
|
||||
GiphyActivityToolbar toolbar = findViewById(R.id.giphy_toolbar);
|
||||
toolbar.setOnFilterChangedListener(this);
|
||||
toolbar.setOnLayoutChangedListener(this);
|
||||
toolbar.setPersistence(GiphyActivityToolbarTextSecurePreferencesPersistence.fromContext(this));
|
||||
|
||||
final int conversationColor = getConversationColor();
|
||||
toolbar.setBackgroundColor(conversationColor);
|
||||
|
@ -160,12 +157,6 @@ public class GiphyActivity extends PassphraseRequiredActivity
|
|||
this.stickerFragment.setSearchString(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanged(boolean gridLayout) {
|
||||
giphyMp4ViewModel.updateLayout(gridLayout);
|
||||
stickerFragment.setLayoutManager(gridLayout);
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Override
|
||||
public void onClick(final GiphyAdapter.GiphyViewHolder viewHolder) {
|
||||
|
|
|
@ -27,16 +27,11 @@ import org.thoughtcrime.securesms.components.AnimatingToggle;
|
|||
public class GiphyActivityToolbar extends Toolbar {
|
||||
|
||||
@Nullable private OnFilterChangedListener filterListener;
|
||||
@Nullable private OnLayoutChangedListener layoutListener;
|
||||
|
||||
private EditText searchText;
|
||||
private AnimatingToggle toggle;
|
||||
private ImageView action;
|
||||
private ImageView clearToggle;
|
||||
private LinearLayout toggleContainer;
|
||||
private View listLayoutToggle;
|
||||
private View gridLayoutToggle;
|
||||
private Persistence persistence;
|
||||
|
||||
public GiphyActivityToolbar(Context context) {
|
||||
this(context, null);
|
||||
|
@ -52,13 +47,8 @@ public class GiphyActivityToolbar extends Toolbar {
|
|||
|
||||
this.action = findViewById(R.id.action_icon);
|
||||
this.searchText = findViewById(R.id.search_view);
|
||||
this.toggle = findViewById(R.id.button_toggle);
|
||||
this.clearToggle = findViewById(R.id.search_clear);
|
||||
this.toggleContainer = findViewById(R.id.toggle_container);
|
||||
this.listLayoutToggle = findViewById(R.id.view_stream);
|
||||
this.gridLayoutToggle = findViewById(R.id.view_grid);
|
||||
|
||||
setupGridLayoutToggles();
|
||||
|
||||
this.clearToggle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -106,29 +96,6 @@ public class GiphyActivityToolbar extends Toolbar {
|
|||
expandTapArea(this, action);
|
||||
}
|
||||
|
||||
public void setPersistence(@NonNull Persistence persistence) {
|
||||
this.persistence = persistence;
|
||||
displayTogglingView(persistence.getGridSelected() ? listLayoutToggle : gridLayoutToggle);
|
||||
}
|
||||
|
||||
private void setupGridLayoutToggles() {
|
||||
setUpGridToggle(listLayoutToggle, gridLayoutToggle, false);
|
||||
setUpGridToggle(gridLayoutToggle, listLayoutToggle, true);
|
||||
displayTogglingView(gridLayoutToggle);
|
||||
}
|
||||
|
||||
private void setUpGridToggle(View gridToggle, View otherToggle, boolean gridLayout) {
|
||||
gridToggle.setOnClickListener(v -> {
|
||||
displayTogglingView(otherToggle);
|
||||
if (layoutListener != null) {
|
||||
layoutListener.onLayoutChanged(gridLayout);
|
||||
}
|
||||
if (persistence != null) {
|
||||
persistence.setGridSelected(gridLayout);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavigationIcon(int resId) {
|
||||
action.setImageResource(resId);
|
||||
|
@ -139,10 +106,6 @@ public class GiphyActivityToolbar extends Toolbar {
|
|||
notifyListener();
|
||||
}
|
||||
|
||||
public void setOnLayoutChangedListener(@Nullable OnLayoutChangedListener layoutListener) {
|
||||
this.layoutListener = layoutListener;
|
||||
}
|
||||
|
||||
public void setOnFilterChangedListener(@Nullable OnFilterChangedListener filterListener) {
|
||||
this.filterListener = filterListener;
|
||||
}
|
||||
|
@ -151,27 +114,19 @@ public class GiphyActivityToolbar extends Toolbar {
|
|||
if (filterListener != null) filterListener.onFilterChanged(searchText.getText().toString());
|
||||
}
|
||||
|
||||
private void displayTogglingView(View view) {
|
||||
toggle.display(view);
|
||||
expandTapArea(toggleContainer, view);
|
||||
}
|
||||
|
||||
private void expandTapArea(final View container, final View child) {
|
||||
final int padding = getResources().getDimensionPixelSize(R.dimen.contact_selection_actions_tap_area);
|
||||
|
||||
container.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Rect rect = new Rect();
|
||||
child.getHitRect(rect);
|
||||
container.post(() -> {
|
||||
Rect rect = new Rect();
|
||||
child.getHitRect(rect);
|
||||
|
||||
rect.top -= padding;
|
||||
rect.left -= padding;
|
||||
rect.right += padding;
|
||||
rect.bottom += padding;
|
||||
rect.top -= padding;
|
||||
rect.left -= padding;
|
||||
rect.right += padding;
|
||||
rect.bottom += padding;
|
||||
|
||||
container.setTouchDelegate(new TouchDelegate(rect, child));
|
||||
}
|
||||
container.setTouchDelegate(new TouchDelegate(rect, child));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -192,13 +147,4 @@ public class GiphyActivityToolbar extends Toolbar {
|
|||
public interface OnFilterChangedListener {
|
||||
void onFilterChanged(String filter);
|
||||
}
|
||||
|
||||
public interface OnLayoutChangedListener {
|
||||
void onLayoutChanged(boolean gridLayout);
|
||||
}
|
||||
|
||||
public interface Persistence {
|
||||
boolean getGridSelected();
|
||||
void setGridSelected(boolean isGridSelected);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package org.thoughtcrime.securesms.giph.ui;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
class GiphyActivityToolbarTextSecurePreferencesPersistence implements GiphyActivityToolbar.Persistence {
|
||||
|
||||
static GiphyActivityToolbar.Persistence fromContext(Context context) {
|
||||
return new GiphyActivityToolbarTextSecurePreferencesPersistence(context.getApplicationContext());
|
||||
}
|
||||
|
||||
private final Context context;
|
||||
|
||||
private GiphyActivityToolbarTextSecurePreferencesPersistence(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGridSelected() {
|
||||
return TextSecurePreferences.isGifSearchInGridLayout(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGridSelected(boolean isGridSelected) {
|
||||
TextSecurePreferences.setIsGifSearchInGridLayout(context, isGridSelected);
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ public abstract class GiphyFragment extends LoggingFragment implements LoaderMan
|
|||
this.giphyAdapter = new GiphyAdapter(getActivity(), GlideApp.with(this), new LinkedList<>());
|
||||
this.giphyAdapter.setListener(this);
|
||||
|
||||
setLayoutManager(TextSecurePreferences.isGifSearchInGridLayout(getContext()));
|
||||
this.recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
|
||||
this.recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||
this.recyclerView.setAdapter(giphyAdapter);
|
||||
this.recyclerView.addOnScrollListener(new GiphyScrollListener());
|
||||
|
@ -83,15 +83,6 @@ public abstract class GiphyFragment extends LoggingFragment implements LoaderMan
|
|||
this.giphyAdapter.setImages(new LinkedList<GiphyImage>());
|
||||
}
|
||||
|
||||
public void setLayoutManager(boolean gridLayout) {
|
||||
recyclerView.setLayoutManager(getLayoutManager(gridLayout));
|
||||
}
|
||||
|
||||
private RecyclerView.LayoutManager getLayoutManager(boolean gridLayout) {
|
||||
return gridLayout ? new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
|
||||
: new LinearLayoutManager(getActivity());
|
||||
}
|
||||
|
||||
public void setClickListener(GiphyAdapter.OnItemClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
|
|
@ -502,14 +502,6 @@ public class TextSecurePreferences {
|
|||
return getBooleanPreference(context, LINK_PREVIEWS, true);
|
||||
}
|
||||
|
||||
public static boolean isGifSearchInGridLayout(Context context) {
|
||||
return getBooleanPreference(context, GIF_GRID_LAYOUT, false);
|
||||
}
|
||||
|
||||
public static void setIsGifSearchInGridLayout(Context context, boolean isGrid) {
|
||||
setBooleanPreference(context, GIF_GRID_LAYOUT, isGrid);
|
||||
}
|
||||
|
||||
public static int getNotificationPriority(Context context) {
|
||||
return Integer.valueOf(getStringPreference(context, NOTIFICATION_PRIORITY_PREF, String.valueOf(NotificationCompat.PRIORITY_HIGH)));
|
||||
}
|
||||
|
|
|
@ -52,39 +52,6 @@
|
|||
android:tint="@color/signal_text_toolbar_subtitle"
|
||||
app:srcCompat="@drawable/ic_x" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.AnimatingToggle
|
||||
android:id="@+id/button_toggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView android:id="@+id/view_grid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:visibility="visible"
|
||||
android:focusable="true"
|
||||
android:background="@drawable/circle_touch_highlight_background"
|
||||
app:srcCompat="@drawable/ic_dashboard_24" />
|
||||
|
||||
<ImageView android:id="@+id/view_stream"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="@drawable/circle_touch_highlight_background"
|
||||
app:srcCompat="@drawable/ic_view_stream_24" />
|
||||
|
||||
</org.thoughtcrime.securesms.components.AnimatingToggle>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Add table
Reference in a new issue