diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-07-15 12:20:55 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-07-15 12:20:55 +0000 |
commit | c5e82955bc9e6928ab66c18d4b31be5298681b26 (patch) | |
tree | f09e55bbd89eb1e904dee8300997f4464dbec28b /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | c30dcf415dcf23cc6b93a908ae4b6c8d8b999533 (diff) | |
download | infinity-for-reddit-c5e82955bc9e6928ab66c18d4b31be5298681b26.tar infinity-for-reddit-c5e82955bc9e6928ab66c18d4b31be5298681b26.tar.gz infinity-for-reddit-c5e82955bc9e6928ab66c18d4b31be5298681b26.tar.bz2 infinity-for-reddit-c5e82955bc9e6928ab66c18d4b31be5298681b26.tar.lz infinity-for-reddit-c5e82955bc9e6928ab66c18d4b31be5298681b26.tar.xz infinity-for-reddit-c5e82955bc9e6928ab66c18d4b31be5298681b26.tar.zst infinity-for-reddit-c5e82955bc9e6928ab66c18d4b31be5298681b26.zip |
Start adding submitting gallery posts support.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
3 files changed, 223 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java new file mode 100644 index 00000000..aec9f66c --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java @@ -0,0 +1,56 @@ +package ml.docilealligator.infinityforreddit; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class RedditGalleryPayload { + @SerializedName("sr") + public String subredditName; + @SerializedName("submit_type") + public String submitType; + @SerializedName("api_type") + public String apiType = "json"; + @SerializedName("show_error_list") + public boolean showErrorList = true; + public String title; + @SerializedName("spoiler") + public boolean isSpoiler; + @SerializedName("nsfw") + public boolean isNSFW; + public String kind = "self"; + @SerializedName("original_content") + public boolean originalContent = false; + @SerializedName("post_to_twitter") + public boolean postToTwitter = false; + public boolean sendReplies; + @SerializedName("validate_on_submit") + public boolean validateOnSubmit = true; + public List<Item> items; + + public RedditGalleryPayload(String subredditName, String submitType, String kind, String title, + boolean isSpoiler, boolean isNSFW, boolean sendReplies, List<Item> items) { + this.subredditName = subredditName; + this.submitType = submitType; + this.title = title; + this.isSpoiler = isSpoiler; + this.isNSFW = isNSFW; + this.kind = kind; + this.sendReplies = sendReplies; + this.items = items; + } + + public class Item { + public String caption; + @SerializedName("outbound_url") + public String outboundUrl; + @SerializedName("media_id") + public String mediaId; + + public Item(String caption, String outboundUrl, String mediaId) { + this.caption = caption; + this.outboundUrl = outboundUrl; + this.mediaId = mediaId; + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java new file mode 100644 index 00000000..c70957f6 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -0,0 +1,163 @@ +package ml.docilealligator.infinityforreddit.activities; + +import android.content.SharedPreferences; +import android.content.res.Resources; +import android.net.Uri; +import android.os.Bundle; +import android.view.Menu; +import android.view.View; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.appcompat.widget.Toolbar; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.recyclerview.widget.RecyclerView; + +import com.bumptech.glide.RequestManager; +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.button.MaterialButton; +import com.google.android.material.snackbar.Snackbar; +import com.google.android.material.switchmaterial.SwitchMaterial; +import com.libRG.CustomTextView; + +import java.util.concurrent.Executor; + +import javax.inject.Inject; +import javax.inject.Named; + +import butterknife.BindView; +import ml.docilealligator.infinityforreddit.Flair; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; +import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment; +import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import pl.droidsonroids.gif.GifImageView; +import retrofit2.Retrofit; + +public class PostGalleryActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback { + + static final String EXTRA_SUBREDDIT_NAME = "ESN"; + + private static final String SUBREDDIT_NAME_STATE = "SNS"; + private static final String SUBREDDIT_ICON_STATE = "SIS"; + private static final String SUBREDDIT_SELECTED_STATE = "SSS"; + private static final String SUBREDDIT_IS_USER_STATE = "SIUS"; + private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS"; + private static final String IS_POSTING_STATE = "IPS"; + 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 int SUBREDDIT_SELECTION_REQUEST_CODE = 0; + private static final int PICK_IMAGE_REQUEST_CODE = 1; + private static final int CAPTURE_IMAGE_REQUEST_CODE = 2; + + @BindView(R.id.coordinator_layout_post_gallery_activity) + CoordinatorLayout coordinatorLayout; + @BindView(R.id.appbar_layout_post_gallery_activity) + AppBarLayout appBarLayout; + @BindView(R.id.toolbar_post_gallery_activity) + Toolbar toolbar; + @BindView(R.id.subreddit_icon_gif_image_view_post_gallery_activity) + GifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_post_gallery_activity) + TextView subredditNameTextView; + @BindView(R.id.rules_button_post_gallery_activity) + MaterialButton rulesButton; + @BindView(R.id.divider_1_post_gallery_activity) + View divider1; + @BindView(R.id.flair_custom_text_view_post_gallery_activity) + CustomTextView flairTextView; + @BindView(R.id.spoiler_custom_text_view_post_gallery_activity) + CustomTextView spoilerTextView; + @BindView(R.id.nsfw_custom_text_view_post_gallery_activity) + CustomTextView nsfwTextView; + @BindView(R.id.divider_2_post_gallery_activity) + View divider2; + @BindView(R.id.receive_post_reply_notifications_linear_layout_post_gallery_activity) + LinearLayout receivePostReplyNotificationsLinearLayout; + @BindView(R.id.receive_post_reply_notifications_text_view_post_gallery_activity) + TextView receivePostReplyNotificationsTextView; + @BindView(R.id.receive_post_reply_notifications_switch_material_post_gallery_activity) + SwitchMaterial receivePostReplyNotificationsSwitchMaterial; + @BindView(R.id.divider_3_post_gallery_activity) + View divider3; + @BindView(R.id.post_title_edit_text_post_gallery_activity) + EditText titleEditText; + @BindView(R.id.divider_4_post_gallery_activity) + View divider4; + @BindView(R.id.images_recycler_view_post_gallery_activity) + RecyclerView imagesRecyclerView; + @Inject + @Named("no_oauth") + Retrofit mRetrofit; + @Inject + @Named("oauth") + Retrofit mOauthRetrofit; + @Inject + @Named("upload_media") + Retrofit mUploadMediaRetrofit; + @Inject + RedditDataRoomDatabase mRedditDataRoomDatabase; + @Inject + @Named("default") + SharedPreferences mSharedPreferences; + @Inject + @Named("current_account") + SharedPreferences mCurrentAccountSharedPreferences; + @Inject + CustomThemeWrapper mCustomThemeWrapper; + @Inject + Executor mExecutor; + private String mAccessToken; + private String mAccountName; + private String iconUrl; + private String subredditName; + private boolean subredditSelected = false; + private boolean subredditIsUser; + private boolean loadSubredditIconSuccessful = true; + private boolean isPosting; + private Uri imageUri; + private int primaryTextColor; + private int flairBackgroundColor; + private int flairTextColor; + private int spoilerBackgroundColor; + private int spoilerTextColor; + private int nsfwBackgroundColor; + private int nsfwTextColor; + private Flair flair; + private boolean isSpoiler = false; + private boolean isNSFW = false; + private Resources resources; + private Menu mMemu; + private RequestManager mGlide; + private FlairBottomSheetFragment flairSelectionBottomSheetFragment; + private Snackbar mPostingSnackbar; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_post_gallery); + } + + @Override + protected SharedPreferences getDefaultSharedPreferences() { + return null; + } + + @Override + protected CustomThemeWrapper getCustomThemeWrapper() { + return null; + } + + @Override + protected void applyCustomTheme() { + + } + + @Override + public void flairSelected(Flair flair) { + + } +}
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java index 5269da5f..36fa1d39 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -5,6 +5,7 @@ import java.util.Map; import okhttp3.MultipartBody; import okhttp3.RequestBody; import retrofit2.Call; +import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.FieldMap; import retrofit2.http.FormUrlEncoded; @@ -356,4 +357,7 @@ public interface RedditAPI { @GET("/api/subreddit_autocomplete_v2?typeahead_active=true&include_profiles=false&raw_json=1") Call<String> subredditAutocomplete(@HeaderMap Map<String ,String> headers, @Query("query") String query, @Query("include_over_18") boolean nsfw); + + @POST("/api/submit_gallery_post.json?resubmit=true&raw_json=1") + Call<String> submitGalleryPost(@HeaderMap Map<String, String> headers, @Body String body); } |