From 5034778a7dac9ae1f776cb3baa8123143cd9e50b Mon Sep 17 00:00:00 2001 From: kosyak Date: Mon, 12 Aug 2024 10:19:51 +0200 Subject: [PATCH] get rid of jcenter --- build.gradle | 3 +- .../medialib/activities/EditActivity.kt | 3 +- .../medialib/activities/FilterPack.java | 336 ++++++++++++++++++ .../medialib/activities/NamedFilter.java | 25 ++ .../medialib/models/FilterItem.kt | 3 +- src/main/res/values/strings.xml | 18 + 6 files changed, 383 insertions(+), 5 deletions(-) create mode 100644 src/main/java/eu/siacs/conversations/medialib/activities/FilterPack.java create mode 100644 src/main/java/eu/siacs/conversations/medialib/activities/NamedFilter.java diff --git a/build.gradle b/build.gradle index df89b38c2..a53710f0f 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,6 @@ repositories { google() mavenCentral() maven { url='https://jitpack.io'} - jcenter() } configurations { @@ -77,7 +76,7 @@ dependencies { implementation "androidx.recyclerview:recyclerview:1.2.1" implementation 'com.github.bumptech.glide:glide:4.15.1' // https://mvnrepository.com/artifact/info.androidhive/imagefilters - implementation 'info.androidhive:imagefilters:1.0.7' + implementation 'com.github.zomato:androidphotofilters:1.0.2' implementation 'com.github.chrisbanes:PhotoView:2.3.0' //implementation 'com.splitwise:tokenautocomplete:3.0.2' diff --git a/src/main/java/eu/siacs/conversations/medialib/activities/EditActivity.kt b/src/main/java/eu/siacs/conversations/medialib/activities/EditActivity.kt index 31d63a408..b333318ee 100644 --- a/src/main/java/eu/siacs/conversations/medialib/activities/EditActivity.kt +++ b/src/main/java/eu/siacs/conversations/medialib/activities/EditActivity.kt @@ -25,7 +25,6 @@ import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.Target import com.canhub.cropper.CropImageView import com.leinardi.android.speeddial.UiUtils.getPrimaryColor -import com.zomato.photofilters.FilterPack import com.zomato.photofilters.imageprocessors.Filter import eu.siacs.conversations.R import eu.siacs.conversations.databinding.ActivityEditBinding @@ -526,7 +525,7 @@ class EditActivity : AppCompatActivity(), CropImageView.OnCropImageCompleteListe val filterThumbnailsManager = FilterThumbnailsManager() filterThumbnailsManager.clearThumbs() - val noFilter = Filter(getString(R.string.none)) + val noFilter = NamedFilter(getString(R.string.none)) filterThumbnailsManager.addThumb(FilterItem(bitmap, noFilter)) FilterPack.getFilterPack(this).forEach { diff --git a/src/main/java/eu/siacs/conversations/medialib/activities/FilterPack.java b/src/main/java/eu/siacs/conversations/medialib/activities/FilterPack.java new file mode 100644 index 000000000..6bc850792 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/medialib/activities/FilterPack.java @@ -0,0 +1,336 @@ +package eu.siacs.conversations.medialib.activities; + +import android.content.Context; + +import com.zomato.photofilters.geometry.Point; +import com.zomato.photofilters.imageprocessors.Filter; +import com.zomato.photofilters.imageprocessors.subfilters.BrightnessSubFilter; +import com.zomato.photofilters.imageprocessors.subfilters.ColorOverlaySubFilter; +import com.zomato.photofilters.imageprocessors.subfilters.ContrastSubFilter; +import com.zomato.photofilters.imageprocessors.subfilters.SaturationSubFilter; +import com.zomato.photofilters.imageprocessors.subfilters.ToneCurveSubFilter; +import com.zomato.photofilters.imageprocessors.subfilters.VignetteSubFilter; + +import java.util.ArrayList; +import java.util.List; + +import eu.siacs.conversations.R; + +public final class FilterPack { + + private FilterPack() { + } + + public static List getFilterPack(Context context) { + List filters = new ArrayList<>(); + filters.add(getAweStruckVibeFilter(context)); + filters.add(getClarendon(context)); + filters.add(getOldManFilter(context)); + filters.add(getMarsFilter(context)); + filters.add(getRiseFilter(context)); + filters.add(getAprilFilter(context)); + filters.add(getAmazonFilter(context)); + filters.add(getStarLitFilter(context)); + filters.add(getNightWhisperFilter(context)); + filters.add(getLimeStutterFilter(context)); + filters.add(getHaanFilter(context)); + filters.add(getBlueMessFilter(context)); + filters.add(getAdeleFilter(context)); + filters.add(getCruzFilter(context)); + filters.add(getMetropolis(context)); + filters.add(getAudreyFilter(context)); + return filters; + } + + public static NamedFilter getStarLitFilter(Context context) { + Point[] rgbKnots; + rgbKnots = new Point[8]; + rgbKnots[0] = new Point(0, 0); + rgbKnots[1] = new Point(34, 6); + rgbKnots[2] = new Point(69, 23); + rgbKnots[3] = new Point(100, 58); + rgbKnots[4] = new Point(150, 154); + rgbKnots[5] = new Point(176, 196); + rgbKnots[6] = new Point(207, 233); + rgbKnots[7] = new Point(255, 255); + NamedFilter filter = new NamedFilter(); + filter.setName(context.getString(R.string.starlit)); + filter.addSubFilter(new ToneCurveSubFilter(rgbKnots, null, null, null)); + return filter; + } + + public static NamedFilter getBlueMessFilter(Context context) { + Point[] redKnots; + redKnots = new Point[8]; + redKnots[0] = new Point(0, 0); + redKnots[1] = new Point(86, 34); + redKnots[2] = new Point(117, 41); + redKnots[3] = new Point(146, 80); + redKnots[4] = new Point(170, 151); + redKnots[5] = new Point(200, 214); + redKnots[6] = new Point(225, 242); + redKnots[7] = new Point(255, 255); + NamedFilter filter = new NamedFilter(); + filter.setName(context.getString(R.string.bluemess)); + filter.addSubFilter(new ToneCurveSubFilter(null, redKnots, null, null)); + filter.addSubFilter(new BrightnessSubFilter(30)); + filter.addSubFilter(new ContrastSubFilter(1f)); + return filter; + } + + public static NamedFilter getAweStruckVibeFilter(Context context) { + Point[] rgbKnots; + Point[] redKnots; + Point[] greenKnots; + Point[] blueKnots; + + rgbKnots = new Point[5]; + rgbKnots[0] = new Point(0, 0); + rgbKnots[1] = new Point(80, 43); + rgbKnots[2] = new Point(149, 102); + rgbKnots[3] = new Point(201, 173); + rgbKnots[4] = new Point(255, 255); + + redKnots = new Point[5]; + redKnots[0] = new Point(0, 0); + redKnots[1] = new Point(125, 147); + redKnots[2] = new Point(177, 199); + redKnots[3] = new Point(213, 228); + redKnots[4] = new Point(255, 255); + + + greenKnots = new Point[6]; + greenKnots[0] = new Point(0, 0); + greenKnots[1] = new Point(57, 76); + greenKnots[2] = new Point(103, 130); + greenKnots[3] = new Point(167, 192); + greenKnots[4] = new Point(211, 229); + greenKnots[5] = new Point(255, 255); + + + blueKnots = new Point[7]; + blueKnots[0] = new Point(0, 0); + blueKnots[1] = new Point(38, 62); + blueKnots[2] = new Point(75, 112); + blueKnots[3] = new Point(116, 158); + blueKnots[4] = new Point(171, 204); + blueKnots[5] = new Point(212, 233); + blueKnots[6] = new Point(255, 255); + + NamedFilter filter = new NamedFilter(); + filter.setName(context.getString(R.string.struck)); + filter.addSubFilter(new ToneCurveSubFilter(rgbKnots, redKnots, greenKnots, blueKnots)); + return filter; + } + + public static NamedFilter getLimeStutterFilter(Context context) { + Point[] blueKnots; + blueKnots = new Point[3]; + blueKnots[0] = new Point(0, 0); + blueKnots[1] = new Point(165, 114); + blueKnots[2] = new Point(255, 255); + NamedFilter filter = new NamedFilter(); + filter.setName(context.getString(R.string.lime)); + filter.addSubFilter(new ToneCurveSubFilter(null, null, null, blueKnots)); + return filter; + } + + public static NamedFilter getNightWhisperFilter(Context context) { + Point[] rgbKnots; + Point[] redKnots; + Point[] greenKnots; + Point[] blueKnots; + + rgbKnots = new Point[3]; + rgbKnots[0] = new Point(0, 0); + rgbKnots[1] = new Point(174, 109); + rgbKnots[2] = new Point(255, 255); + + redKnots = new Point[4]; + redKnots[0] = new Point(0, 0); + redKnots[1] = new Point(70, 114); + redKnots[2] = new Point(157, 145); + redKnots[3] = new Point(255, 255); + + greenKnots = new Point[3]; + greenKnots[0] = new Point(0, 0); + greenKnots[1] = new Point(109, 138); + greenKnots[2] = new Point(255, 255); + + blueKnots = new Point[3]; + blueKnots[0] = new Point(0, 0); + blueKnots[1] = new Point(113, 152); + blueKnots[2] = new Point(255, 255); + + NamedFilter filter = new NamedFilter(); + filter.setName(context.getString(R.string.whisper)); + filter.addSubFilter(new ContrastSubFilter(1.5f)); + filter.addSubFilter(new ToneCurveSubFilter(rgbKnots, redKnots, greenKnots, blueKnots)); + return filter; + } + + public static NamedFilter getAmazonFilter(Context context) { + Point[] blueKnots; + blueKnots = new Point[6]; + blueKnots[0] = new Point(0, 0); + blueKnots[1] = new Point(11, 40); + blueKnots[2] = new Point(36, 99); + blueKnots[3] = new Point(86, 151); + blueKnots[4] = new Point(167, 209); + blueKnots[5] = new Point(255, 255); + NamedFilter filter = new NamedFilter(context.getString(R.string.amazon)); + filter.addSubFilter(new ContrastSubFilter(1.2f)); + filter.addSubFilter(new ToneCurveSubFilter(null, null, null, blueKnots)); + return filter; + } + + public static NamedFilter getAdeleFilter(Context context) { + NamedFilter filter = new NamedFilter(context.getString(R.string.adele)); + filter.addSubFilter(new SaturationSubFilter(-100f)); + return filter; + } + + public static NamedFilter getCruzFilter(Context context) { + NamedFilter filter = new NamedFilter(context.getString(R.string.cruz)); + filter.addSubFilter(new SaturationSubFilter(-100f)); + filter.addSubFilter(new ContrastSubFilter(1.3f)); + filter.addSubFilter(new BrightnessSubFilter(20)); + return filter; + } + + public static NamedFilter getMetropolis(Context context) { + NamedFilter filter = new NamedFilter(context.getString(R.string.metropolis)); + filter.addSubFilter(new SaturationSubFilter(-1f)); + filter.addSubFilter(new ContrastSubFilter(1.7f)); + filter.addSubFilter(new BrightnessSubFilter(70)); + return filter; + } + + public static NamedFilter getAudreyFilter(Context context) { + NamedFilter filter = new NamedFilter(context.getString(R.string.audrey)); + + Point[] redKnots; + redKnots = new Point[3]; + redKnots[0] = new Point(0, 0); + redKnots[1] = new Point(124, 138); + redKnots[2] = new Point(255, 255); + + filter.addSubFilter(new SaturationSubFilter(-100f)); + filter.addSubFilter(new ContrastSubFilter(1.3f)); + filter.addSubFilter(new BrightnessSubFilter(20)); + filter.addSubFilter(new ToneCurveSubFilter(null, redKnots, null, null)); + return filter; + } + + public static NamedFilter getRiseFilter(Context context) { + Point[] blueKnots; + Point[] redKnots; + + blueKnots = new Point[4]; + blueKnots[0] = new Point(0, 0); + blueKnots[1] = new Point(39, 70); + blueKnots[2] = new Point(150, 200); + blueKnots[3] = new Point(255, 255); + + redKnots = new Point[4]; + redKnots[0] = new Point(0, 0); + redKnots[1] = new Point(45, 64); + redKnots[2] = new Point(170, 190); + redKnots[3] = new Point(255, 255); + + NamedFilter filter = new NamedFilter(context.getString(R.string.rise)); + filter.addSubFilter(new ContrastSubFilter(1.9f)); + filter.addSubFilter(new BrightnessSubFilter(60)); + filter.addSubFilter(new VignetteSubFilter(context, 200)); + filter.addSubFilter(new ToneCurveSubFilter(null, redKnots, null, blueKnots)); + return filter; + } + + public static NamedFilter getMarsFilter(Context context) { + NamedFilter filter = new NamedFilter(context.getString(R.string.mars)); + filter.addSubFilter(new ContrastSubFilter(1.5f)); + filter.addSubFilter(new BrightnessSubFilter(10)); + return filter; + } + + public static NamedFilter getAprilFilter(Context context) { + Point[] blueKnots; + Point[] redKnots; + + blueKnots = new Point[4]; + blueKnots[0] = new Point(0, 0); + blueKnots[1] = new Point(39, 70); + blueKnots[2] = new Point(150, 200); + blueKnots[3] = new Point(255, 255); + + redKnots = new Point[4]; + redKnots[0] = new Point(0, 0); + redKnots[1] = new Point(45, 64); + redKnots[2] = new Point(170, 190); + redKnots[3] = new Point(255, 255); + + NamedFilter filter = new NamedFilter(context.getString(R.string.april)); + filter.addSubFilter(new ContrastSubFilter(1.5f)); + filter.addSubFilter(new BrightnessSubFilter(5)); + filter.addSubFilter(new VignetteSubFilter(context, 150)); + filter.addSubFilter(new ToneCurveSubFilter(null, redKnots, null, blueKnots)); + return filter; + } + + public static NamedFilter getHaanFilter(Context context) { + Point[] greenKnots; + greenKnots = new Point[3]; + greenKnots[0] = new Point(0, 0); + greenKnots[1] = new Point(113, 142); + greenKnots[2] = new Point(255, 255); + + NamedFilter filter = new NamedFilter(context.getString(R.string.haan)); + filter.addSubFilter(new ContrastSubFilter(1.3f)); + filter.addSubFilter(new BrightnessSubFilter(60)); + filter.addSubFilter(new VignetteSubFilter(context, 200)); + filter.addSubFilter(new ToneCurveSubFilter(null, null, greenKnots, null)); + return filter; + } + + public static NamedFilter getOldManFilter(Context context) { + NamedFilter filter = new NamedFilter(context.getString(R.string.oldman)); + filter.addSubFilter(new BrightnessSubFilter(30)); + filter.addSubFilter(new SaturationSubFilter(0.8f)); + filter.addSubFilter(new ContrastSubFilter(1.3f)); + filter.addSubFilter(new VignetteSubFilter(context, 100)); + filter.addSubFilter(new ColorOverlaySubFilter(100, .2f, .2f, .1f)); + return filter; + } + + public static NamedFilter getClarendon(Context context) { + Point[] redKnots; + Point[] greenKnots; + Point[] blueKnots; + + redKnots = new Point[4]; + redKnots[0] = new Point(0, 0); + redKnots[1] = new Point(56, 68); + redKnots[2] = new Point(196, 206); + redKnots[3] = new Point(255, 255); + + + greenKnots = new Point[4]; + greenKnots[0] = new Point(0, 0); + greenKnots[1] = new Point(46, 77); + greenKnots[2] = new Point(160, 200); + greenKnots[3] = new Point(255, 255); + + + blueKnots = new Point[4]; + blueKnots[0] = new Point(0, 0); + blueKnots[1] = new Point(33, 86); + blueKnots[2] = new Point(126, 220); + blueKnots[3] = new Point(255, 255); + + NamedFilter filter = new NamedFilter(context.getString(R.string.clarendon)); + filter.addSubFilter(new ContrastSubFilter(1.5f)); + filter.addSubFilter(new BrightnessSubFilter(-10)); + filter.addSubFilter(new ToneCurveSubFilter(null, redKnots, greenKnots, blueKnots)); + return filter; + } +} \ No newline at end of file diff --git a/src/main/java/eu/siacs/conversations/medialib/activities/NamedFilter.java b/src/main/java/eu/siacs/conversations/medialib/activities/NamedFilter.java new file mode 100644 index 000000000..df66c2fd2 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/medialib/activities/NamedFilter.java @@ -0,0 +1,25 @@ +package eu.siacs.conversations.medialib.activities; + +import com.zomato.photofilters.imageprocessors.Filter; + +public class NamedFilter extends Filter { + + private String name; + + public NamedFilter() { + } + + public NamedFilter(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + +} diff --git a/src/main/java/eu/siacs/conversations/medialib/models/FilterItem.kt b/src/main/java/eu/siacs/conversations/medialib/models/FilterItem.kt index 7da94fca8..71e41d3a4 100644 --- a/src/main/java/eu/siacs/conversations/medialib/models/FilterItem.kt +++ b/src/main/java/eu/siacs/conversations/medialib/models/FilterItem.kt @@ -2,5 +2,6 @@ package eu.siacs.conversations.medialib.models import android.graphics.Bitmap import com.zomato.photofilters.imageprocessors.Filter +import eu.siacs.conversations.medialib.activities.NamedFilter -data class FilterItem(var bitmap: Bitmap, val filter: Filter) +data class FilterItem(var bitmap: Bitmap, val filter: NamedFilter) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 91879e43e..a6c021455 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1107,4 +1107,22 @@ Oval Rounded Square Square + + + Clarendon + OldMan + Haan + April + Mars + Rise + Audrey + Metropolis + Cruz + Adele + Amazon + Starlit + BlueMess + Struck + Whisper + Lime