aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectOrCaptureImageBottomSheetFragment.java52
-rw-r--r--app/src/main/res/drawable-night/ic_outline_add_a_photo_day_night_24dp.xml9
-rw-r--r--app/src/main/res/drawable-night/ic_outline_select_photo_day_night_24dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_outline_add_a_photo_day_night_24dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_outline_select_photo_day_night_24dp.xml9
-rw-r--r--app/src/main/res/layout/fragment_select_or_capture_image_bottom_sheet.xml53
-rw-r--r--app/src/main/res/layout/fragment_uploaded_images_bottom_sheet.xml2
-rw-r--r--app/src/main/res/values/strings.xml2
10 files changed, 179 insertions, 13 deletions
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 50786e1b..9b80db16 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
@@ -1,12 +1,15 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
+import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -19,6 +22,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
+import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
@@ -34,6 +38,8 @@ import com.libRG.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.Executor;
@@ -50,6 +56,7 @@ 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.bottomsheetfragments.SelectOrCaptureImageBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
@@ -194,7 +201,8 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
adapter = new RedditGallerySubmissionRecyclerViewAdapter(this, mCustomThemeWrapper, new RedditGallerySubmissionRecyclerViewAdapter.ItemClickListener() {
@Override
public void onAddImageClicked() {
-
+ SelectOrCaptureImageBottomSheetFragment fragment = new SelectOrCaptureImageBottomSheetFragment();
+ fragment.show(getSupportFragmentManager(), fragment.getTag());
}
});
imagesRecyclerView.setAdapter(adapter);
@@ -369,6 +377,24 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
titleEditText.setHintTextColor(secondaryTextColor);
}
+ public void selectImage() {
+
+ }
+
+ public void captureImage() {
+ Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ try {
+ captureImageUri = FileProvider.getUriForFile(this, "ml.docilealligator.infinityforreddit.provider",
+ File.createTempFile("temp_img", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
+ pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, captureImageUri);
+ startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
+ } catch (IOException ex) {
+ Snackbar.make(coordinatorLayout, R.string.error_creating_temp_file, Snackbar.LENGTH_SHORT).show();
+ } catch (ActivityNotFoundException e) {
+ Snackbar.make(coordinatorLayout, R.string.no_camera_available, Snackbar.LENGTH_SHORT).show();
+ }
+ }
+
private void displaySubredditIcon() {
if (iconUrl != null && !iconUrl.equals("")) {
mGlide.load(iconUrl)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
index a1b0281c..573617f6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
@@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
@@ -346,16 +347,14 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
captureFab.setOnClickListener(view -> {
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- if (pictureIntent.resolveActivity(getPackageManager()) != null) {
- try {
- imageUri = FileProvider.getUriForFile(this, "ml.docilealligator.infinityforreddit.provider",
- File.createTempFile("temp_img", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
- pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
- startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
- } catch (IOException ex) {
- Snackbar.make(coordinatorLayout, R.string.error_creating_temp_file, Snackbar.LENGTH_SHORT).show();
- }
- } else {
+ try {
+ imageUri = FileProvider.getUriForFile(this, "ml.docilealligator.infinityforreddit.provider",
+ File.createTempFile("temp_img", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
+ pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
+ startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
+ } catch (IOException ex) {
+ Snackbar.make(coordinatorLayout, R.string.error_creating_temp_file, Snackbar.LENGTH_SHORT).show();
+ } catch (ActivityNotFoundException e) {
Snackbar.make(coordinatorLayout, R.string.no_camera_available, Snackbar.LENGTH_SHORT).show();
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectOrCaptureImageBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectOrCaptureImageBottomSheetFragment.java
new file mode 100644
index 00000000..4be9b51f
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectOrCaptureImageBottomSheetFragment.java
@@ -0,0 +1,52 @@
+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 android.widget.TextView;
+
+import androidx.annotation.NonNull;
+
+import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
+
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.activities.PostGalleryActivity;
+
+public class SelectOrCaptureImageBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+
+ private PostGalleryActivity mActivity;
+
+ public SelectOrCaptureImageBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ View rootView = inflater.inflate(R.layout.fragment_select_or_capture_image_bottom_sheet, container, false);
+
+ TextView selectImageTextView = rootView.findViewById(R.id.select_image_text_view_select_or_capture_image_bottom_sheet_fragment);
+ TextView captureImageTextView = rootView.findViewById(R.id.capture_image_text_view_select_or_capture_image_bottom_sheet_fragment);
+
+ selectImageTextView.setOnClickListener(view -> {
+ mActivity.selectImage();
+ dismiss();
+ });
+
+ captureImageTextView.setOnClickListener(view -> {
+ mActivity.captureImage();
+ dismiss();
+ });
+
+ return rootView;
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ mActivity = (PostGalleryActivity) context;
+ }
+} \ No newline at end of file
diff --git a/app/src/main/res/drawable-night/ic_outline_add_a_photo_day_night_24dp.xml b/app/src/main/res/drawable-night/ic_outline_add_a_photo_day_night_24dp.xml
new file mode 100644
index 00000000..57869fc5
--- /dev/null
+++ b/app/src/main/res/drawable-night/ic_outline_add_a_photo_day_night_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M21,6h-3.17L16,4h-6v2h5.12l1.83,2L21,8v12L5,20v-9L3,11v9c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L23,8c0,-1.1 -0.9,-2 -2,-2zM8,14c0,2.76 2.24,5 5,5s5,-2.24 5,-5 -2.24,-5 -5,-5 -5,2.24 -5,5zM13,11c1.65,0 3,1.35 3,3s-1.35,3 -3,3 -3,-1.35 -3,-3 1.35,-3 3,-3zM5,6h3L8,4L5,4L5,1L3,1v3L0,4v2h3v3h2z"/>
+</vector>
diff --git a/app/src/main/res/drawable-night/ic_outline_select_photo_day_night_24dp.xml b/app/src/main/res/drawable-night/ic_outline_select_photo_day_night_24dp.xml
new file mode 100644
index 00000000..136ace9f
--- /dev/null
+++ b/app/src/main/res/drawable-night/ic_outline_select_photo_day_night_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M18,20L4,20L4,6h9L13,4L4,4c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2v-9h-2v9zM10.21,16.83l-1.96,-2.36L5.5,18h11l-3.54,-4.71zM20,4L20,1h-2v3h-3c0.01,0.01 0,2 0,2h3v2.99c0.01,0.01 2,0 2,0L20,6h3L23,4h-3z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_outline_add_a_photo_day_night_24dp.xml b/app/src/main/res/drawable/ic_outline_add_a_photo_day_night_24dp.xml
new file mode 100644
index 00000000..98c1ac80
--- /dev/null
+++ b/app/src/main/res/drawable/ic_outline_add_a_photo_day_night_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M21,6h-3.17L16,4h-6v2h5.12l1.83,2L21,8v12L5,20v-9L3,11v9c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L23,8c0,-1.1 -0.9,-2 -2,-2zM8,14c0,2.76 2.24,5 5,5s5,-2.24 5,-5 -2.24,-5 -5,-5 -5,2.24 -5,5zM13,11c1.65,0 3,1.35 3,3s-1.35,3 -3,3 -3,-1.35 -3,-3 1.35,-3 3,-3zM5,6h3L8,4L5,4L5,1L3,1v3L0,4v2h3v3h2z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_outline_select_photo_day_night_24dp.xml b/app/src/main/res/drawable/ic_outline_select_photo_day_night_24dp.xml
new file mode 100644
index 00000000..9551f621
--- /dev/null
+++ b/app/src/main/res/drawable/ic_outline_select_photo_day_night_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M18,20L4,20L4,6h9L13,4L4,4c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2v-9h-2v9zM10.21,16.83l-1.96,-2.36L5.5,18h11l-3.54,-4.71zM20,4L20,1h-2v3h-3c0.01,0.01 0,2 0,2h3v2.99c0.01,0.01 2,0 2,0L20,6h3L23,4h-3z"/>
+</vector>
diff --git a/app/src/main/res/layout/fragment_select_or_capture_image_bottom_sheet.xml b/app/src/main/res/layout/fragment_select_or_capture_image_bottom_sheet.xml
new file mode 100644
index 00000000..55f60691
--- /dev/null
+++ b/app/src/main/res/layout/fragment_select_or_capture_image_bottom_sheet.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="8dp"
+ android:overScrollMode="never">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/select_image_text_view_select_or_capture_image_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/select_image"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:drawableStart="@drawable/ic_outline_select_photo_day_night_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/capture_image_text_view_select_or_capture_image_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/capture"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:drawableStart="@drawable/ic_outline_add_a_photo_day_night_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/layout/fragment_uploaded_images_bottom_sheet.xml b/app/src/main/res/layout/fragment_uploaded_images_bottom_sheet.xml
index 79b6fa82..f3e96ef5 100644
--- a/app/src/main/res/layout/fragment_uploaded_images_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_uploaded_images_bottom_sheet.xml
@@ -40,7 +40,7 @@
android:layout_margin="16dp"
android:backgroundTint="@color/colorPrimary"
android:textColor="#FFFFFF"
- android:text="@string/upload" />
+ android:text="@string/select_image" />
</LinearLayout>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 58fe7e6b..3742cc52 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1125,7 +1125,7 @@
<string name="reply">Reply</string>
<string name="uploaded_images">Uploaded Images</string>
- <string name="upload">Upload</string>
+ <string name="select_image">Select an Image</string>
<string name="capture">Capture</string>
<string name="uploading_image">Uploading</string>
<string name="upload_image_success">Upload image successfully. Click the image button again to see the uploaded images.</string>