Skip to content

Commit

Permalink
Show GiphyGifInfoBottomSheetFragment before the Giphy gif selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
Docile-Alligator committed Sep 25, 2024
1 parent cfe1781 commit e5b35e1
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.AccountChooserBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.GiphyGifInfoBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UploadedImagesBottomSheetFragment;
import ml.docilealligator.infinityforreddit.comment.Comment;
import ml.docilealligator.infinityforreddit.comment.SendComment;
Expand Down Expand Up @@ -313,7 +314,8 @@ public void onUploadImage() {

@Override
public void onSelectGiphyGif() {
GiphyDialogFragment.Companion.newInstance().show(getSupportFragmentManager(), "giphy_dialog");
GiphyGifInfoBottomSheetFragment fragment = new GiphyGifInfoBottomSheetFragment();
fragment.show(getSupportFragmentManager(), fragment.getTag());
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.giphy.sdk.ui.views.GiphyDialogFragment;

import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.databinding.FragmentGiphyGifInfoBottomSheetBinding;

public class GiphyGifInfoBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {

private BaseActivity activity;

public GiphyGifInfoBottomSheetFragment() {
// Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
FragmentGiphyGifInfoBottomSheetBinding binding = FragmentGiphyGifInfoBottomSheetBinding.inflate(inflater, container, false);

binding.selectGiphyGifButtonUploadedImagesBottomSheetFragment.setOnClickListener(view -> {
GiphyDialogFragment.Companion.newInstance().show(activity.getSupportFragmentManager(), "giphy_dialog");
dismiss();
});

return binding.getRoot();
}

public void onAttach(@NonNull Context context) {
super.onAttach(context);
this.activity = (BaseActivity) context;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions app/src/main/res/layout/fragment_giphy_gif_info_bottom_sheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".bottomsheetfragments.GiphyGifInfoBottomSheetFragment">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp"
android:src="@drawable/powered_by_giphy" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/select_giphy_gif_explanation"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
android:textColor="?attr/secondaryTextColor" />

<com.google.android.material.button.MaterialButton
android:id="@+id/select_giphy_gif_button_uploaded_images_bottom_sheet_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="16dp"
android:backgroundTint="@color/colorPrimary"
android:textColor="#FFFFFF"
android:text="@string/select_giphy_gif" />

</LinearLayout>

</ScrollView>
19 changes: 15 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1255,11 +1255,11 @@
<string name="uploaded_images">Uploaded Images</string>
<string name="uploaded_images_explanation">This is an experimental feature, and here are some things you need to know:\n
1. Uploaded images will not be shown in the text editor, and instead, a piece of text will be inserted as a block,
with a format similar to ![](XXXXX). XXXXX is the image id, and it should not be modified. To add a caption for
your image, simply type between the brackets. Example: ![This is a caption](XXXXX). Note that the caption will be treated
as plain text.\n
with a format similar to ![](XXXXX). XXXXX is the image id, and it should not be modified. To add a caption for
your image, simply type between the brackets. Example: ![This is a caption](XXXXX). Note that the caption will be treated
as plain text.\n
2. To write a superscript, please use ^(), and put the texts inside the parentheses, instead of only
using a single ^. For simplicity, click the superscript option in the formatting tools to insert a superscript.\n
using a single ^. For simplicity, click the superscript option in the formatting tools to insert a superscript.\n
3. This feature converts your markdown to rich text format and some formatting may be lost in the process.\n
4. Uploaded images may not be shown on the preview screen.\n
5. You cannot edit a submitted post with embedded images in it.\n
Expand All @@ -1271,6 +1271,17 @@
<string name="upload_image_success">Upload image successfully. Click the image button again to see the uploaded images.</string>
<string name="get_image_bitmap_failed">Unable to get the bitmap of the image</string>
<string name="upload_image_failed">Unable to upload the image</string>
<string name="select_giphy_gif">Select a Giphy GIF</string>
<string name="select_giphy_gif_explanation">This is an experimental feature, and here are some things you need to know:\n
1. Giphy gifs will not be shown in the text editor, and instead, a piece of text will be inserted as a block,
with a format similar to ![gif](XXXXX). XXXXX is the Giphy gif id, and it should not be modified.\n
2. You can only insert one Giphy gif per comment.\n
3. To write a superscript, please use ^(), and put the texts inside the parentheses, instead of only
using a single ^. For simplicity, click the superscript option in the formatting tools to insert a superscript.\n
4. This feature converts your markdown to rich text format and some formatting may be lost in the process.\n
5. Giphy gifs may not be shown on the preview screen.\n
6. Please do not change your account using the account chooser on the editing screen. You should switch
your account in the navigation drawer on the main screen.</string>

<string name="search_comments">Search Comments</string>

Expand Down

0 comments on commit e5b35e1

Please sign in to comment.