From d6e7d2377f9e54103cd89e5b65fd14112eeccd9a Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Sat, 9 Jan 2021 16:19:26 +0100 Subject: [PATCH] Carousel in the PostCreationActivity, change PhotoEditActivity to be more intuitive --- app/build.gradle | 1 + .../postCreation/PostCreationActivity.kt | 117 ++++++++++-- .../photoEdit/EditImageFragment.kt | 30 +-- .../photoEdit/FilterListFragment.kt | 12 +- .../photoEdit/PhotoEditActivity.kt | 179 ++++++------------ .../photoEdit/ThumbnailAdapter.kt | 5 + .../h/pixeldroid/posts/StatusViewHolder.kt | 4 +- .../main/res/drawable/download_file_24dp.xml | 9 + .../main/res/drawable/ic_baseline_edit_24.xml | 5 +- app/src/main/res/drawable/restore_24dp.xml | 9 + .../res/layout/activity_post_creation.xml | 56 +++++- app/src/main/res/menu/edit_photo_menu.xml | 12 +- app/src/main/res/values/strings.xml | 4 +- 13 files changed, 265 insertions(+), 178 deletions(-) create mode 100644 app/src/main/res/drawable/download_file_24dp.xml create mode 100644 app/src/main/res/drawable/restore_24dp.xml diff --git a/app/build.gradle b/app/build.gradle index be16906b..20a46d4b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -157,6 +157,7 @@ dependencies { implementation 'com.github.ligi.tracedroid:lib:3.0' implementation 'com.github.ligi.tracedroid:supportemail:3.0' + implementation 'com.github.ImaginativeShohag:Why-Not-Image-Carousel:v1.1.0' /** * Not in release, so not mentioned in licenses list diff --git a/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt b/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt index 0a0aae17..454cf265 100644 --- a/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt +++ b/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt @@ -1,9 +1,16 @@ package com.h.pixeldroid.postCreation import android.app.Activity +import android.content.ContentResolver +import android.content.ContentValues import android.content.Intent +import android.graphics.Bitmap +import android.media.MediaScannerConnection import android.net.Uri +import android.os.Build import android.os.Bundle +import android.os.Environment +import android.provider.MediaStore import android.provider.OpenableColumns import android.util.Log import android.view.LayoutInflater @@ -12,10 +19,12 @@ import android.view.ViewGroup import android.widget.Button import android.widget.Toast import androidx.core.net.toFile +import androidx.core.net.toUri import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide +import com.google.android.material.snackbar.Snackbar import com.google.android.material.textfield.TextInputLayout import com.h.pixeldroid.utils.BaseActivity import com.h.pixeldroid.MainActivity @@ -33,11 +42,18 @@ import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.activity_post_creation.* import kotlinx.android.synthetic.main.image_album_creation.view.* import okhttp3.MultipartBody +import org.imaginativeworld.whynotimagecarousel.CarouselItem +import org.imaginativeworld.whynotimagecarousel.ImageCarousel import retrofit2.Call import retrofit2.Callback import retrofit2.HttpException import retrofit2.Response +import java.io.File import java.io.IOException +import java.io.OutputStream +import java.text.SimpleDateFormat +import java.util.* +import kotlin.collections.ArrayList private const val TAG = "Post Creation Activity" private const val MORE_PICTURES_REQUEST_CODE = 0xffff @@ -45,9 +61,6 @@ private const val MORE_PICTURES_REQUEST_CODE = 0xffff class PostCreationActivity : BaseActivity() { - private lateinit var recycler : RecyclerView - private lateinit var adapter : PostCreationAdapter - private lateinit var accessToken: String private lateinit var pixelfedAPI: PixelfedAPI @@ -100,10 +113,9 @@ class PostCreationActivity : BaseActivity() { progressList = posts.map { 0 } as ArrayList upload() - adapter = PostCreationAdapter(posts) - recycler = findViewById(R.id.image_grid) - recycler.layoutManager = GridLayoutManager(this, 3) - recycler.adapter = adapter + + val carousel: ImageCarousel = findViewById(R.id.carousel) + carousel.addData(posts.map { CarouselItem(it) }) // get the description and send the post findViewById