mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
show a list of thumbnails at the editor, for applying filters
This commit is contained in:
parent
85e105819c
commit
dbaacd596e
8 changed files with 113 additions and 4 deletions
|
@ -57,6 +57,7 @@ dependencies {
|
||||||
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.2'
|
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.2'
|
||||||
implementation 'com.google.vr:sdk-panowidget:1.150.0'
|
implementation 'com.google.vr:sdk-panowidget:1.150.0'
|
||||||
implementation 'org.apache.sanselan:sanselan:0.97-incubator'
|
implementation 'org.apache.sanselan:sanselan:0.97-incubator'
|
||||||
|
implementation 'info.androidhive:imagefilters:1.0.7'
|
||||||
|
|
||||||
kapt "android.arch.persistence.room:compiler:1.1.1"
|
kapt "android.arch.persistence.room:compiler:1.1.1"
|
||||||
implementation "android.arch.persistence.room:runtime:1.1.1"
|
implementation "android.arch.persistence.room:runtime:1.1.1"
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
android:label="@string/app_launcher_name"
|
android:label="@string/app_launcher_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher"
|
android:roundIcon="@mipmap/ic_launcher"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme"
|
||||||
|
tools:replace="android:label">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.SplashActivity"
|
android:name=".activities.SplashActivity"
|
||||||
|
|
|
@ -11,24 +11,35 @@ import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||||
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
|
import com.simplemobiletools.gallery.adapters.FiltersAdapter
|
||||||
import com.simplemobiletools.gallery.dialogs.ResizeDialog
|
import com.simplemobiletools.gallery.dialogs.ResizeDialog
|
||||||
import com.simplemobiletools.gallery.dialogs.SaveAsDialog
|
import com.simplemobiletools.gallery.dialogs.SaveAsDialog
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.extensions.openEditor
|
import com.simplemobiletools.gallery.extensions.openEditor
|
||||||
|
import com.simplemobiletools.gallery.models.FilterItem
|
||||||
import com.theartofdev.edmodo.cropper.CropImageView
|
import com.theartofdev.edmodo.cropper.CropImageView
|
||||||
|
import com.zomato.photofilters.FilterPack
|
||||||
import kotlinx.android.synthetic.main.activity_edit.*
|
import kotlinx.android.synthetic.main.activity_edit.*
|
||||||
import kotlinx.android.synthetic.main.bottom_actions_aspect_ratio.*
|
import kotlinx.android.synthetic.main.bottom_actions_aspect_ratio.*
|
||||||
|
import kotlinx.android.synthetic.main.bottom_editor_actions_filter.*
|
||||||
import kotlinx.android.synthetic.main.bottom_editor_crop_rotate_actions.*
|
import kotlinx.android.synthetic.main.bottom_editor_crop_rotate_actions.*
|
||||||
import kotlinx.android.synthetic.main.bottom_editor_primary_actions.*
|
import kotlinx.android.synthetic.main.bottom_editor_primary_actions.*
|
||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
||||||
|
companion object {
|
||||||
|
init {
|
||||||
|
System.loadLibrary("NativeImageProcessor")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val ASPECT_X = "aspectX"
|
private val ASPECT_X = "aspectX"
|
||||||
private val ASPECT_Y = "aspectY"
|
private val ASPECT_Y = "aspectY"
|
||||||
private val CROP = "crop"
|
private val CROP = "crop"
|
||||||
|
@ -237,9 +248,27 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
bottom_editor_filter_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_FILTER)
|
bottom_editor_filter_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_FILTER)
|
||||||
bottom_editor_crop_rotate_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE)
|
bottom_editor_crop_rotate_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE)
|
||||||
|
|
||||||
|
if (currPrimaryAction == PRIMARY_ACTION_FILTER) {
|
||||||
|
Thread {
|
||||||
|
val size = resources.getDimension(R.dimen.bottom_filters_thumbnail_height).toInt()
|
||||||
|
val bitmap = Glide.with(this).asBitmap().load(uri).submit(size, size).get()
|
||||||
|
runOnUiThread {
|
||||||
|
val filterItems = FilterPack.getFilterPack(this).map { FilterItem(bitmap, it) } as ArrayList<FilterItem>
|
||||||
|
|
||||||
|
val adapter = FiltersAdapter(filterItems) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bottom_actions_filter_list.adapter = adapter
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
|
|
||||||
if (currPrimaryAction != PRIMARY_ACTION_CROP_ROTATE) {
|
if (currPrimaryAction != PRIMARY_ACTION_CROP_ROTATE) {
|
||||||
bottom_aspect_ratios.beGone()
|
bottom_aspect_ratios.beGone()
|
||||||
currCropRotateAction = CROP_ROTATE_NONE
|
currCropRotateAction = CROP_ROTATE_NONE
|
||||||
|
updateCropRotateActionButtons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.simplemobiletools.gallery.adapters
|
||||||
|
|
||||||
|
import android.support.v7.widget.RecyclerView
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.simplemobiletools.gallery.R
|
||||||
|
import com.simplemobiletools.gallery.models.FilterItem
|
||||||
|
import kotlinx.android.synthetic.main.editor_filter_item.view.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class FiltersAdapter(val filterItems: ArrayList<FilterItem>, val itemClick: (FilterItem) -> Unit) : RecyclerView.Adapter<FiltersAdapter.ViewHolder>() {
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
holder.bindView(filterItems[position], itemClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.editor_filter_item, parent, false)
|
||||||
|
return ViewHolder(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = filterItems.size
|
||||||
|
|
||||||
|
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
fun bindView(filterItem: FilterItem, itemClick: (FilterItem) -> Unit): View {
|
||||||
|
itemView.apply {
|
||||||
|
editor_filter_item_label.text = filterItem.filter.name
|
||||||
|
editor_filter_item_thumbnail.setImageBitmap(filterItem.bitmap)
|
||||||
|
|
||||||
|
setOnClickListener {
|
||||||
|
itemClick.invoke(filterItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return itemView
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.simplemobiletools.gallery.models
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import com.zomato.photofilters.imageprocessors.Filter
|
||||||
|
|
||||||
|
data class FilterItem(val bitmap: Bitmap, val filter: Filter)
|
|
@ -1,15 +1,18 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/bottom_actions_filter_wrapper"
|
android:id="@+id/bottom_actions_filter_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/bottom_actions_height"
|
android:layout_height="@dimen/bottom_filters_height"
|
||||||
android:paddingTop="@dimen/medium_margin">
|
android:paddingTop="@dimen/medium_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/bottom_actions_filter_list"
|
android:id="@+id/bottom_actions_filter_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/bottom_actions_height"
|
android:layout_height="@dimen/bottom_filters_height"
|
||||||
android:orientation="horizontal"/>
|
android:background="@color/crop_image_view_background"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
29
app/src/main/res/layout/editor_filter_item.xml
Normal file
29
app/src/main/res/layout/editor_filter_item.xml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/editor_filter_item_holder"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/tiny_margin"
|
||||||
|
android:paddingRight="@dimen/tiny_margin"
|
||||||
|
android:paddingTop="@dimen/tiny_margin">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/editor_filter_item_thumbnail"
|
||||||
|
android:layout_width="@dimen/bottom_filters_thumbnail_height"
|
||||||
|
android:layout_height="@dimen/bottom_filters_thumbnail_height"
|
||||||
|
android:layout_above="@+id/editor_filter_item_label"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/editor_filter_item_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="@dimen/smaller_text_size"
|
||||||
|
tools:text="Filter"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -11,4 +11,6 @@
|
||||||
<dimen name="instant_change_bar_width">30dp</dimen>
|
<dimen name="instant_change_bar_width">30dp</dimen>
|
||||||
<dimen name="list_view_folder_thumbnail_size">72dp</dimen>
|
<dimen name="list_view_folder_thumbnail_size">72dp</dimen>
|
||||||
<dimen name="bottom_actions_height">64dp</dimen>
|
<dimen name="bottom_actions_height">64dp</dimen>
|
||||||
|
<dimen name="bottom_filters_thumbnail_height">76dp</dimen>
|
||||||
|
<dimen name="bottom_filters_height">90dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue