diff options
19 files changed, 179 insertions, 43 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8f4a9b4f..8b704d6f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,7 +34,11 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:replace="android:label"> - <activity android:name=".activities.PostGalleryActivity"></activity> + <activity android:name=".activities.PostGalleryActivity" + android:label="@string/post_gallery_activity_label" + android:parentActivityName=".activities.MainActivity" + android:theme="@style/AppTheme.NoActionBar" + android:windowSoftInputMode="adjustResize" /> <activity android:name=".activities.RPANActivity" android:configChanges="orientation|screenSize|layoutDirection" diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java index aec9f66c..94fcb822 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java @@ -1,5 +1,8 @@ package ml.docilealligator.infinityforreddit; +import android.os.Parcel; +import android.os.Parcelable; + import com.google.gson.annotations.SerializedName; import java.util.List; @@ -40,7 +43,7 @@ public class RedditGalleryPayload { this.items = items; } - public class Item { + public static class Item implements Parcelable { public String caption; @SerializedName("outbound_url") public String outboundUrl; @@ -52,5 +55,35 @@ public class RedditGalleryPayload { this.outboundUrl = outboundUrl; this.mediaId = mediaId; } + + protected Item(Parcel in) { + caption = in.readString(); + outboundUrl = in.readString(); + mediaId = in.readString(); + } + + public static final Creator<Item> CREATOR = new Creator<Item>() { + @Override + public Item createFromParcel(Parcel in) { + return new Item(in); + } + + @Override + public Item[] newArray(int size) { + return new Item[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel parcel, int i) { + parcel.writeString(caption); + parcel.writeString(outboundUrl); + parcel.writeString(mediaId); + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 4a2c945a..3b62cd49 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -1216,6 +1216,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb case PostTypeBottomSheetFragment.TYPE_VIDEO: intent = new Intent(MainActivity.this, PostVideoActivity.class); startActivity(intent); + break; + case PostTypeBottomSheetFragment.TYPE_GALLERY: + intent = new Intent(MainActivity.this, PostGalleryActivity.class); + startActivity(intent); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java index dd340e68..50786e1b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -34,6 +34,7 @@ import com.libRG.CustomTextView; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; +import java.util.ArrayList; import java.util.concurrent.Executor; import javax.inject.Inject; @@ -46,6 +47,7 @@ import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; +import ml.docilealligator.infinityforreddit.adapters.RedditGallerySubmissionRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon; import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; @@ -68,6 +70,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee private static final String FLAIR_STATE = "FS"; private static final String IS_SPOILER_STATE = "ISS"; private static final String IS_NSFW_STATE = "INS"; + private static final String REDDIT_GALLERY_IMAGE_INFO_STATE = "RGIIS"; private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0; private static final int PICK_IMAGE_REQUEST_CODE = 1; @@ -130,6 +133,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee CustomThemeWrapper mCustomThemeWrapper; @Inject Executor mExecutor; + private ArrayList<RedditGallerySubmissionRecyclerViewAdapter.RedditGalleryImageInfo> redditGalleryImageInfoList; private String mAccessToken; private String mAccountName; private String iconUrl; @@ -153,6 +157,8 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee private RequestManager mGlide; private FlairBottomSheetFragment flairSelectionBottomSheetFragment; private Snackbar mPostingSnackbar; + private RedditGallerySubmissionRecyclerViewAdapter adapter; + private Uri captureImageUri; @Override protected void onCreate(Bundle savedInstanceState) { @@ -185,6 +191,14 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); + adapter = new RedditGallerySubmissionRecyclerViewAdapter(this, mCustomThemeWrapper, new RedditGallerySubmissionRecyclerViewAdapter.ItemClickListener() { + @Override + public void onAddImageClicked() { + + } + }); + imagesRecyclerView.setAdapter(adapter); + if (savedInstanceState != null) { subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE); iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE); @@ -195,11 +209,8 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee flair = savedInstanceState.getParcelable(FLAIR_STATE); isSpoiler = savedInstanceState.getBoolean(IS_SPOILER_STATE); isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE); - - if (savedInstanceState.getString(IMAGE_URI_STATE) != null) { - imageUri = Uri.parse(savedInstanceState.getString(IMAGE_URI_STATE)); - loadImage(); - } + redditGalleryImageInfoList = savedInstanceState.getParcelableArrayList(REDDIT_GALLERY_IMAGE_INFO_STATE); + adapter.setRedditGalleryImageInfoList(redditGalleryImageInfoList); if (subredditName != null) { subredditNameTextView.setTextColor(primaryTextColor); @@ -247,11 +258,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(iconGifImageView); } - - imageUri = getIntent().getData(); - if (imageUri != null) { - loadImage(); - } } iconGifImageView.setOnClickListener(view -> { @@ -415,7 +421,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail); return true; } else { - if (!titleEditText.getText().toString().equals("") || imageUri != null) { + if (!titleEditText.getText().toString().equals("") || redditGalleryImageInfoList != null) { promptAlertDialog(R.string.discard, R.string.discard_detail); return true; } @@ -433,7 +439,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee return true; } - if (imageUri == null) { + if (redditGalleryImageInfoList == null) { Snackbar.make(coordinatorLayout, R.string.select_an_image, Snackbar.LENGTH_SHORT).show(); return true; } @@ -453,7 +459,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee } Intent intent = new Intent(this, SubmitPostService.class); - intent.setData(imageUri); intent.putExtra(SubmitPostService.EXTRA_ACCESS_TOKEN, mAccessToken); intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName); intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString()); @@ -461,13 +466,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler); intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW); intent.putExtra(SubmitPostService.EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, receivePostReplyNotificationsSwitchMaterial.isChecked()); - String mimeType = getContentResolver().getType(imageUri); - if (mimeType != null && mimeType.contains("gif")) { - intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_VIDEO); - } else { - intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_IMAGE); - } - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); ContextCompat.startForegroundService(this, intent); @@ -482,7 +480,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee if (isPosting) { promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail); } else { - if (!titleEditText.getText().toString().equals("") || imageUri != null) { + if (!titleEditText.getText().toString().equals("") || redditGalleryImageInfoList != null) { promptAlertDialog(R.string.discard, R.string.discard_detail); } else { finish(); @@ -502,6 +500,8 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee outState.putParcelable(FLAIR_STATE, flair); outState.putBoolean(IS_SPOILER_STATE, isSpoiler); outState.putBoolean(IS_NSFW_STATE, isNSFW); + redditGalleryImageInfoList = adapter.getRedditGalleryImageInfoList(); + outState.putParcelableArrayList(REDDIT_GALLERY_IMAGE_INFO_STATE, redditGalleryImageInfoList); } @Override @@ -531,12 +531,11 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee return; } - imageUri = data.getData(); - loadImage(); + adapter.addImage(data.getData().toString()); } } else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) { if (resultCode == RESULT_OK) { - loadImage(); + adapter.addImage(captureImageUri.toString()); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index 7098b86a..15c004a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -724,6 +724,10 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect case PostTypeBottomSheetFragment.TYPE_VIDEO: intent = new Intent(this, PostVideoActivity.class); startActivity(intent); + break; + case PostTypeBottomSheetFragment.TYPE_GALLERY: + intent = new Intent(this, PostGalleryActivity.class); + startActivity(intent); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index bed746c4..8486318d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -1228,6 +1228,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp intent = new Intent(this, PostVideoActivity.class); intent.putExtra(PostVideoActivity.EXTRA_SUBREDDIT_NAME, subredditName); startActivity(intent); + break; + case PostTypeBottomSheetFragment.TYPE_GALLERY: + intent = new Intent(this, PostGalleryActivity.class); + intent.putExtra(PostVideoActivity.EXTRA_SUBREDDIT_NAME, subredditName); + startActivity(intent); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index c1ef9ea2..5432c074 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -1386,6 +1386,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele case PostTypeBottomSheetFragment.TYPE_VIDEO: intent = new Intent(this, PostVideoActivity.class); startActivity(intent); + break; + case PostTypeBottomSheetFragment.TYPE_GALLERY: + intent = new Intent(this, PostGalleryActivity.class); + startActivity(intent); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 323e22c6..43f6fcbe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -766,7 +766,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler break; case Post.GALLERY_TYPE: ((PostDetailNoPreviewViewHolder) holder).mTypeTextView.setText(R.string.gallery); - ((PostDetailNoPreviewViewHolder) holder).mNoPreviewPostTypeImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostDetailNoPreviewViewHolder) holder).mNoPreviewPostTypeImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); break; } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index c55b7533..ee3896de 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -776,7 +776,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else if (post.getPostType() == Post.LINK_TYPE) { ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_link); } else if (post.getPostType() == Post.GALLERY_TYPE) { - ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } } else if (mDataSavingMode && mOnlyDisablePreviewInVideoAndGifPosts && (post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE)) { ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE); @@ -808,7 +808,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else if (post.getPostType() == Post.LINK_TYPE) { ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_link); } else if (post.getPostType() == Post.GALLERY_TYPE) { - ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } } } @@ -901,7 +901,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else if (post.getPostType() == Post.LINK_TYPE) { ((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link); } else if (post.getPostType() == Post.GALLERY_TYPE) { - ((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } } else if (mDataSavingMode && mOnlyDisablePreviewInVideoAndGifPosts && (post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE)) { ((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE); @@ -935,7 +935,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else if (post.getPostType() == Post.LINK_TYPE) { ((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link); } else if (post.getPostType() == Post.GALLERY_TYPE) { - ((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } } } @@ -1170,7 +1170,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostCompactBaseViewHolder) holder).relativeLayout.setVisibility(View.VISIBLE); if (post.getPostType() == Post.GALLERY_TYPE && post.getPreviews() != null && post.getPreviews().isEmpty()) { ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE); - ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } ArrayList<Post.Preview> previews = post.getPreviews(); if (previews != null && !previews.isEmpty()) { @@ -1259,7 +1259,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.gallery); if (mDataSavingMode && mDisableImagePreview) { ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE); - ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } break; case Post.TEXT_TYPE: @@ -1329,7 +1329,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else if (post.getPostType() == Post.LINK_TYPE) { ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link); } else if (post.getPostType() == Post.GALLERY_TYPE) { - ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp); } @@ -1424,7 +1424,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE); - ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(mActivity.getDrawable(R.drawable.ic_gallery_24dp)); + ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(mActivity.getDrawable(R.drawable.ic_gallery_reverse_color_24dp)); Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { @@ -1441,7 +1441,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView loadImage(holder, post, preview); } else { ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE); - ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp); + ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_reverse_color_24dp); } break; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java index c80a8113..a03d28ec 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java @@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit.adapters; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; +import android.os.Parcel; +import android.os.Parcelable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -21,7 +23,7 @@ import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; import com.google.android.material.floatingactionbutton.FloatingActionButton; -import java.util.List; +import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; @@ -35,7 +37,7 @@ public class RedditGallerySubmissionRecyclerViewAdapter extends RecyclerView.Ada private static final int VIEW_TYPE_IMAGE = 1; private static final int VIEW_TYPE_ADD_IMAGE = 2; - private List<RedditGalleryImageInfo> redditGalleryImageInfoList; + private ArrayList<RedditGalleryImageInfo> redditGalleryImageInfoList; private CustomThemeWrapper customThemeWrapper; private ItemClickListener itemClickListener; private RequestManager glide; @@ -109,10 +111,20 @@ public class RedditGallerySubmissionRecyclerViewAdapter extends RecyclerView.Ada } } - public List<RedditGalleryImageInfo> getRedditGalleryImageInfoList() { + public ArrayList<RedditGalleryImageInfo> getRedditGalleryImageInfoList() { return redditGalleryImageInfoList; } + public void setRedditGalleryImageInfoList(ArrayList<RedditGalleryImageInfo> redditGalleryImageInfoList) { + this.redditGalleryImageInfoList = redditGalleryImageInfoList; + notifyDataSetChanged(); + } + + public void addImage(String imageUrl) { + redditGalleryImageInfoList.add(new RedditGalleryImageInfo(imageUrl)); + notifyItemInserted(redditGalleryImageInfoList.size() - 1); + } + class ImageViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.aspect_ratio_gif_image_view_item_reddit_gallery_submission_image) AspectRatioGifImageView imageView; @@ -147,13 +159,41 @@ public class RedditGallerySubmissionRecyclerViewAdapter extends RecyclerView.Ada } } - public static class RedditGalleryImageInfo { + public static class RedditGalleryImageInfo implements Parcelable { public String imageUrlString; public RedditGalleryPayload.Item payload; public RedditGalleryImageInfo(String imageUrlString) { this.imageUrlString = imageUrlString; } + + protected RedditGalleryImageInfo(Parcel in) { + imageUrlString = in.readString(); + payload = in.readParcelable(RedditGalleryPayload.Item.class.getClassLoader()); + } + + public static final Creator<RedditGalleryImageInfo> CREATOR = new Creator<RedditGalleryImageInfo>() { + @Override + public RedditGalleryImageInfo createFromParcel(Parcel in) { + return new RedditGalleryImageInfo(in); + } + + @Override + public RedditGalleryImageInfo[] newArray(int size) { + return new RedditGalleryImageInfo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel parcel, int i) { + parcel.writeString(imageUrlString); + parcel.writeParcelable(payload, i); + } } public interface ItemClickListener { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java index 64b604ab..046c512b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java @@ -30,6 +30,7 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen public static final int TYPE_LINK = 1; public static final int TYPE_IMAGE = 2; public static final int TYPE_VIDEO = 3; + public static final int TYPE_GALLERY = 4; @BindView(R.id.text_type_linear_layout_post_type_bottom_sheet_fragment) TextView textTypeTextView; @BindView(R.id.link_type_linear_layout_post_type_bottom_sheet_fragment) @@ -38,6 +39,8 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen TextView imageTypeTextView; @BindView(R.id.video_type_linear_layout_post_type_bottom_sheet_fragment) TextView videoTypeTextView; + @BindView(R.id.gallery_type_linear_layout_post_type_bottom_sheet_fragment) + TextView galleryTypeTextView; private Activity activity; public PostTypeBottomSheetFragment() { @@ -75,6 +78,11 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen dismiss(); }); + galleryTypeTextView.setOnClickListener(view -> { + ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_GALLERY); + dismiss(); + }); + return rootView; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java index 4d21ef12..b883b02c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java @@ -57,6 +57,7 @@ public class SubmitPostService extends Service { public static final String EXTRA_SUBREDDIT_NAME = "ESN"; public static final String EXTRA_TITLE = "ET"; public static final String EXTRA_CONTENT = "EC"; + public static final String EXTRA_REDDIT_GALLERY_PAYLOAD = "ERGP"; public static final String EXTRA_KIND = "EK"; public static final String EXTRA_FLAIR = "EF"; public static final String EXTRA_IS_SPOILER = "EIS"; @@ -67,6 +68,7 @@ public class SubmitPostService extends Service { public static final int EXTRA_POST_TYPE_IMAGE = 1; public static final int EXTRA_POST_TYPE_VIDEO = 2; public static final int EXTRA_POST_TYPE_CROSSPOST = 3; + private static final String EXTRA_MEDIA_URI = "EU"; @Inject @Named("oauth") diff --git a/app/src/main/res/drawable-night/ic_gallery_24dp.xml b/app/src/main/res/drawable-night/ic_gallery_24dp.xml index 74716ba7..d54dba10 100644 --- a/app/src/main/res/drawable-night/ic_gallery_24dp.xml +++ b/app/src/main/res/drawable-night/ic_gallery_24dp.xml @@ -1,4 +1,4 @@ -<vector android:height="24dp" android:tint="#000000" +<vector android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> <path android:fillColor="@android:color/white" android:pathData="M20,4v12L8,16L8,4h12m0,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM11.5,11.67l1.69,2.26 2.48,-3.1L19,15L9,15zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/> diff --git a/app/src/main/res/drawable-night/ic_gallery_reverse_color_24dp.xml b/app/src/main/res/drawable-night/ic_gallery_reverse_color_24dp.xml new file mode 100644 index 00000000..74716ba7 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_gallery_reverse_color_24dp.xml @@ -0,0 +1,5 @@ +<vector android:height="24dp" android:tint="#000000" + android:viewportHeight="24" android:viewportWidth="24" + android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M20,4v12L8,16L8,4h12m0,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM11.5,11.67l1.69,2.26 2.48,-3.1L19,15L9,15zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_gallery_24dp.xml b/app/src/main/res/drawable/ic_gallery_24dp.xml index d54dba10..74716ba7 100644 --- a/app/src/main/res/drawable/ic_gallery_24dp.xml +++ b/app/src/main/res/drawable/ic_gallery_24dp.xml @@ -1,4 +1,4 @@ -<vector android:height="24dp" android:tint="#FFFFFF" +<vector android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> <path android:fillColor="@android:color/white" android:pathData="M20,4v12L8,16L8,4h12m0,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM11.5,11.67l1.69,2.26 2.48,-3.1L19,15L9,15zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/> diff --git a/app/src/main/res/drawable/ic_gallery_reverse_color_24dp.xml b/app/src/main/res/drawable/ic_gallery_reverse_color_24dp.xml new file mode 100644 index 00000000..d54dba10 --- /dev/null +++ b/app/src/main/res/drawable/ic_gallery_reverse_color_24dp.xml @@ -0,0 +1,5 @@ +<vector android:height="24dp" android:tint="#FFFFFF" + android:viewportHeight="24" android:viewportWidth="24" + android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M20,4v12L8,16L8,4h12m0,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM11.5,11.67l1.69,2.26 2.48,-3.1L19,15L9,15zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/> +</vector> diff --git a/app/src/main/res/layout/activity_post_gallery.xml b/app/src/main/res/layout/activity_post_gallery.xml index e573b945..5cf045cb 100644 --- a/app/src/main/res/layout/activity_post_gallery.xml +++ b/app/src/main/res/layout/activity_post_gallery.xml @@ -190,7 +190,9 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/images_recycler_view_post_gallery_activity" android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" + app:spanCount="2" /> </LinearLayout> diff --git a/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml index e89e36a2..7138d814 100644 --- a/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml @@ -86,6 +86,25 @@ android:focusable="true" android:background="?attr/selectableItemBackground" /> + <TextView + android:id="@+id/gallery_type_linear_layout_post_type_bottom_sheet_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="32dp" + android:paddingEnd="32dp" + android:text="@string/bottom_sheet_post_gallery" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + android:drawableStart="@drawable/ic_gallery_24dp" + android:drawablePadding="48dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" /> + </LinearLayout> </androidx.core.widget.NestedScrollView>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8fafbd53..58fe7e6b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,6 +40,7 @@ <string name="search_users_result_activity_label">Users</string> <string name="multireddit_selection_activity_label">Select a Multireddit</string> <string name="rpan_activity_label">RPAN</string> + <string name="post_gallery_activity_label">Gallery Post</string> <string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string> @@ -218,6 +219,7 @@ <string name="bottom_sheet_post_link">Link</string> <string name="bottom_sheet_post_image">Image</string> <string name="bottom_sheet_post_video">Video</string> + <string name="bottom_sheet_post_gallery">Gallery</string> <string name="post_type_gif">Gif</string> <string name="post_type_gallery">Gallery</string> |