Skip to content

Commit e5b35e1

Browse files
Show GiphyGifInfoBottomSheetFragment before the Giphy gif selector.
1 parent cfe1781 commit e5b35e1

File tree

6 files changed

+102
-5
lines changed

6 files changed

+102
-5
lines changed

app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter;
5858
import ml.docilealligator.infinityforreddit.bottomsheetfragments.AccountChooserBottomSheetFragment;
5959
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
60+
import ml.docilealligator.infinityforreddit.bottomsheetfragments.GiphyGifInfoBottomSheetFragment;
6061
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UploadedImagesBottomSheetFragment;
6162
import ml.docilealligator.infinityforreddit.comment.Comment;
6263
import ml.docilealligator.infinityforreddit.comment.SendComment;
@@ -313,7 +314,8 @@ public void onUploadImage() {
313314

314315
@Override
315316
public void onSelectGiphyGif() {
316-
GiphyDialogFragment.Companion.newInstance().show(getSupportFragmentManager(), "giphy_dialog");
317+
GiphyGifInfoBottomSheetFragment fragment = new GiphyGifInfoBottomSheetFragment();
318+
fragment.show(getSupportFragmentManager(), fragment.getTag());
317319
}
318320
});
319321

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package ml.docilealligator.infinityforreddit.bottomsheetfragments;
2+
3+
import android.content.Context;
4+
import android.os.Bundle;
5+
import android.view.LayoutInflater;
6+
import android.view.View;
7+
import android.view.ViewGroup;
8+
9+
import androidx.annotation.NonNull;
10+
11+
import com.giphy.sdk.ui.views.GiphyDialogFragment;
12+
13+
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
14+
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
15+
import ml.docilealligator.infinityforreddit.databinding.FragmentGiphyGifInfoBottomSheetBinding;
16+
17+
public class GiphyGifInfoBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
18+
19+
private BaseActivity activity;
20+
21+
public GiphyGifInfoBottomSheetFragment() {
22+
// Required empty public constructor
23+
}
24+
25+
@Override
26+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
27+
Bundle savedInstanceState) {
28+
FragmentGiphyGifInfoBottomSheetBinding binding = FragmentGiphyGifInfoBottomSheetBinding.inflate(inflater, container, false);
29+
30+
binding.selectGiphyGifButtonUploadedImagesBottomSheetFragment.setOnClickListener(view -> {
31+
GiphyDialogFragment.Companion.newInstance().show(activity.getSupportFragmentManager(), "giphy_dialog");
32+
dismiss();
33+
});
34+
35+
return binding.getRoot();
36+
}
37+
38+
public void onAttach(@NonNull Context context) {
39+
super.onAttach(context);
40+
this.activity = (BaseActivity) context;
41+
}
42+
}
74.1 KB
Loading
74.1 KB
Loading
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
tools:context=".bottomsheetfragments.GiphyGifInfoBottomSheetFragment">
7+
8+
<LinearLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:orientation="vertical">
12+
13+
<pl.droidsonroids.gif.GifImageView
14+
android:layout_width="match_parent"
15+
android:layout_height="wrap_content"
16+
android:gravity="center"
17+
android:padding="16dp"
18+
android:src="@drawable/powered_by_giphy" />
19+
20+
<TextView
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:paddingStart="16dp"
24+
android:paddingEnd="16dp"
25+
android:text="@string/select_giphy_gif_explanation"
26+
android:fontFamily="?attr/font_family"
27+
android:textSize="?attr/font_default"
28+
android:textColor="?attr/secondaryTextColor" />
29+
30+
<com.google.android.material.button.MaterialButton
31+
android:id="@+id/select_giphy_gif_button_uploaded_images_bottom_sheet_fragment"
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:layout_gravity="center_horizontal"
35+
android:layout_margin="16dp"
36+
android:backgroundTint="@color/colorPrimary"
37+
android:textColor="#FFFFFF"
38+
android:text="@string/select_giphy_gif" />
39+
40+
</LinearLayout>
41+
42+
</ScrollView>

app/src/main/res/values/strings.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,11 +1255,11 @@
12551255
<string name="uploaded_images">Uploaded Images</string>
12561256
<string name="uploaded_images_explanation">This is an experimental feature, and here are some things you need to know:\n
12571257
1. Uploaded images will not be shown in the text editor, and instead, a piece of text will be inserted as a block,
1258-
with a format similar to ![](XXXXX). XXXXX is the image id, and it should not be modified. To add a caption for
1259-
your image, simply type between the brackets. Example: ![This is a caption](XXXXX). Note that the caption will be treated
1260-
as plain text.\n
1258+
with a format similar to ![](XXXXX). XXXXX is the image id, and it should not be modified. To add a caption for
1259+
your image, simply type between the brackets. Example: ![This is a caption](XXXXX). Note that the caption will be treated
1260+
as plain text.\n
12611261
2. To write a superscript, please use ^(), and put the texts inside the parentheses, instead of only
1262-
using a single ^. For simplicity, click the superscript option in the formatting tools to insert a superscript.\n
1262+
using a single ^. For simplicity, click the superscript option in the formatting tools to insert a superscript.\n
12631263
3. This feature converts your markdown to rich text format and some formatting may be lost in the process.\n
12641264
4. Uploaded images may not be shown on the preview screen.\n
12651265
5. You cannot edit a submitted post with embedded images in it.\n
@@ -1271,6 +1271,17 @@
12711271
<string name="upload_image_success">Upload image successfully. Click the image button again to see the uploaded images.</string>
12721272
<string name="get_image_bitmap_failed">Unable to get the bitmap of the image</string>
12731273
<string name="upload_image_failed">Unable to upload the image</string>
1274+
<string name="select_giphy_gif">Select a Giphy GIF</string>
1275+
<string name="select_giphy_gif_explanation">This is an experimental feature, and here are some things you need to know:\n
1276+
1. Giphy gifs will not be shown in the text editor, and instead, a piece of text will be inserted as a block,
1277+
with a format similar to ![gif](XXXXX). XXXXX is the Giphy gif id, and it should not be modified.\n
1278+
2. You can only insert one Giphy gif per comment.\n
1279+
3. To write a superscript, please use ^(), and put the texts inside the parentheses, instead of only
1280+
using a single ^. For simplicity, click the superscript option in the formatting tools to insert a superscript.\n
1281+
4. This feature converts your markdown to rich text format and some formatting may be lost in the process.\n
1282+
5. Giphy gifs may not be shown on the preview screen.\n
1283+
6. Please do not change your account using the account chooser on the editing screen. You should switch
1284+
your account in the navigation drawer on the main screen.</string>
12741285

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

0 commit comments

Comments
 (0)