aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java56
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java163
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java4
-rw-r--r--app/src/main/res/layout/activity_post_gallery.xml199
5 files changed, 427 insertions, 2 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e790b06a..8f4a9b4f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -18,7 +18,8 @@
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
- <uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE"
+ <uses-permission-sdk-23
+ android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
@@ -33,7 +34,9 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="android:label">
- <activity android:name=".activities.RPANActivity"
+ <activity android:name=".activities.PostGalleryActivity"></activity>
+ <activity
+ android:name=".activities.RPANActivity"
android:configChanges="orientation|screenSize|layoutDirection"
android:label="@string/rpan_activity_label"
android:parentActivityName=".activities.MainActivity"
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);
}
diff --git a/app/src/main/res/layout/activity_post_gallery.xml b/app/src/main/res/layout/activity_post_gallery.xml
new file mode 100644
index 00000000..e573b945
--- /dev/null
+++ b/app/src/main/res/layout/activity_post_gallery.xml
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/coordinator_layout_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:application=".PostImageActivity">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/appbar_layout_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?attr/actionBarSize"
+ app:navigationIcon="?attr/homeAsUpIndicator"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
+
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <androidx.core.widget.NestedScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingTop="8dp"
+ android:paddingEnd="16dp"
+ android:paddingBottom="8dp">
+
+ <pl.droidsonroids.gif.GifImageView
+ android:id="@+id/subreddit_icon_gif_image_view_post_gallery_activity"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true" />
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_post_gallery_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:layout_marginStart="32dp"
+ android:layout_marginEnd="16dp"
+ android:layout_toStartOf="@id/rules_button_post_gallery_activity"
+ android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_gallery_activity"
+ android:text="@string/choose_a_subreddit"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/rules_button_post_gallery_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:text="@string/rules"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ </RelativeLayout>
+
+ <View
+ android:id="@+id/divider_1_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="1dp" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_post_gallery_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:padding="4dp"
+ android:text="@string/flair"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_post_gallery_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:padding="4dp"
+ android:text="@string/spoiler"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_custom_text_view_post_gallery_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ </LinearLayout>
+
+ <View
+ android:id="@+id/divider_2_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="1dp" />
+
+ <LinearLayout
+ android:id="@+id/receive_post_reply_notifications_linear_layout_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:paddingBottom="8dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <TextView
+ android:id="@+id/receive_post_reply_notifications_text_view_post_gallery_activity"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="16dp"
+ android:text="@string/receive_post_reply_notifications"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ <com.google.android.material.switchmaterial.SwitchMaterial
+ android:id="@+id/receive_post_reply_notifications_switch_material_post_gallery_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:checked="true" />
+
+ </LinearLayout>
+
+ <View
+ android:id="@+id/divider_3_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="1dp" />
+
+ <EditText
+ android:id="@+id/post_title_edit_text_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#00000000"
+ android:gravity="top"
+ android:hint="@string/post_title_hint"
+ android:inputType="textCapSentences|textMultiLine"
+ android:padding="16dp"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/title_font_18"
+ android:fontFamily="?attr/title_font_family" />
+
+ <View
+ android:id="@+id/divider_4_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="1dp" />
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/images_recycler_view_post_gallery_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ </androidx.core.widget.NestedScrollView>
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file