diff --git a/README.md b/README.md index a6e0716..55b3848 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ This is an Android library which can be used to apply different Filters/Effects ### Change Log ``` -1.1.0 - Added ability to save video once you apply a FILTER (not EFFECT), Updated Sample app with a detailed example, +1.1.0 - Added ability to save video once you apply a FILTER (not EFFECT), Updated Sample app with a detailed example, (Available on Jcenter) +1.1.1 - Updated Dependencies & Published the videffects to MavenCentral. All future versions from now onwards will be distributed via MavenCentral. ``` ## Supported Effects @@ -48,7 +49,7 @@ The following list of effects are currently avaialble and can be applied using V - Add the following code to your project's `build.gradle` file ```sh repositories { - jcenter() + mavenCentral() } ``` @@ -57,7 +58,7 @@ The following list of effects are currently avaialble and can be applied using V ```sh dependencies { // Gradle path for VidEffects - implementation "com.sherazkhilji.videffects:videffects:1.1.0" + implementation "com.github.krazykira:videffects:1.1.1" } ``` @@ -155,7 +156,7 @@ Developed by License ======= - Copyright 2020 Sheraz Ahmed Khilji + Copyright 2022 Sheraz Ahmed Khilji Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/app/build.gradle b/app/build.gradle index 2abef9b..4484c20 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,8 +2,12 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' +buildscript { + repositories { + mavenCentral() + } +} android { compileSdkVersion 29 buildToolsVersion "29.0.3" @@ -22,12 +26,14 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } + buildFeatures { + viewBinding true + } } dependencies { implementation project(":videffects") -// implementation "com.sherazkhilji.videffects:videffects:1.1.0" - implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.core:core-ktx:1.2.0' - implementation 'com.google.android.material:material:1.1.0' +// implementation "com.github.krazykira:videffects:1.1.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.google.android.material:material:1.4.0' } \ No newline at end of file diff --git a/app/src/main/java/com/videffects/sample/view/AssetsGalleryActivity.kt b/app/src/main/java/com/videffects/sample/view/AssetsGalleryActivity.kt index cb63816..2a16940 100644 --- a/app/src/main/java/com/videffects/sample/view/AssetsGalleryActivity.kt +++ b/app/src/main/java/com/videffects/sample/view/AssetsGalleryActivity.kt @@ -12,24 +12,26 @@ import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.ItemDecoration -import com.sherazkhilji.sample.R +import com.sherazkhilji.sample.databinding.ActivityGalleryBinding import com.videffects.sample.model.AssetsGalleryModel import com.videffects.sample.model.screenHeight import com.videffects.sample.model.screenWidth import com.videffects.sample.model.toPx -import kotlinx.android.synthetic.main.activity_gallery.* class AssetsGalleryActivity : AppCompatActivity() { + private lateinit var binding: ActivityGalleryBinding + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_gallery) - recyclerView.layoutManager = GridLayoutManager(this, SPAN_COUNT) - recyclerView.adapter = PreviewAdapter(AssetsGalleryModel(this)) - recyclerView.addItemDecoration(SpacesItemDecoration()) + binding = ActivityGalleryBinding.inflate(layoutInflater) + setContentView(binding.root) + binding.recyclerView.layoutManager = GridLayoutManager(this, SPAN_COUNT) + binding.recyclerView.adapter = PreviewAdapter(AssetsGalleryModel(this)) + binding.recyclerView.addItemDecoration(SpacesItemDecoration()) - buttonSamplePlayer.setOnClickListener { + binding.buttonSamplePlayer.setOnClickListener { startActivity(Intent(this, SamplePlayerActivity::class.java)) } } diff --git a/app/src/main/java/com/videffects/sample/view/VideoActivity.kt b/app/src/main/java/com/videffects/sample/view/VideoActivity.kt index 23dfd0c..5926834 100644 --- a/app/src/main/java/com/videffects/sample/view/VideoActivity.kt +++ b/app/src/main/java/com/videffects/sample/view/VideoActivity.kt @@ -4,7 +4,6 @@ import android.Manifest import android.content.Context import android.content.Intent import android.content.pm.PackageManager -import android.content.res.AssetFileDescriptor import android.media.MediaPlayer import android.os.Build import android.os.Bundle @@ -17,12 +16,12 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import com.sherazkhilji.sample.R +import com.sherazkhilji.sample.databinding.ActivityVideoBinding import com.sherazkhilji.videffects.filter.NoEffectFilter import com.sherazkhilji.videffects.interfaces.Filter import com.sherazkhilji.videffects.interfaces.ShaderInterface import com.videffects.sample.controller.VideoController import com.videffects.sample.model.resizeView -import kotlinx.android.synthetic.main.activity_video.* class VideoActivity : AppCompatActivity() { @@ -33,31 +32,35 @@ class VideoActivity : AppCompatActivity() { const val ASSET_NAME = "name" fun startActivity(ctx: Context, assetName: String) { - ctx.startActivity(Intent(ctx, VideoActivity::class.java) - .putExtra(ASSET_NAME, assetName)) + ctx.startActivity( + Intent(ctx, VideoActivity::class.java) + .putExtra(ASSET_NAME, assetName) + ) } } private var videoController: VideoController? = null + private lateinit var binding: ActivityVideoBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_video) + binding = ActivityVideoBinding.inflate(layoutInflater) + setContentView(binding.root) val filename = intent.getStringExtra(ASSET_NAME) - ?: throw RuntimeException("Asset name is null") + ?: throw RuntimeException("Asset name is null") videoController = VideoController(this, filename) - progress.setOnClickListener { } + binding.progress.setOnClickListener { } } fun setupVideoSurfaceView(mediaPlayer: MediaPlayer, width: Double, height: Double) { - videoSurfaceView.resizeView(width, height) - videoSurfaceView.init(mediaPlayer, NoEffectFilter()) + binding.videoSurfaceView.resizeView(width, height) + binding.videoSurfaceView.init(mediaPlayer, NoEffectFilter()) } fun setupSeekBar(onSeekBarChangeListener: SeekBar.OnSeekBarChangeListener) { - intensitySeekBar.max = 100 - intensitySeekBar.isEnabled = false - intensitySeekBar.setOnSeekBarChangeListener(onSeekBarChangeListener) + binding.intensitySeekBar.max = 100 + binding.intensitySeekBar.isEnabled = false + binding.intensitySeekBar.setOnSeekBarChangeListener(onSeekBarChangeListener) } override fun onCreateOptionsMenu(menu: Menu?): Boolean { @@ -91,9 +94,9 @@ class VideoActivity : AppCompatActivity() { } override fun onRequestPermissionsResult( - requestCode: Int, - permissions: Array, - grantResults: IntArray + requestCode: Int, + permissions: Array, + grantResults: IntArray ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -104,13 +107,13 @@ class VideoActivity : AppCompatActivity() { override fun onResume() { super.onResume() - videoSurfaceView.onResume() + binding.videoSurfaceView.onResume() } override fun onPause() { super.onPause() videoController?.onPause() - videoSurfaceView.onPause() + binding.videoSurfaceView.onPause() } override fun onDestroy() { @@ -120,39 +123,43 @@ class VideoActivity : AppCompatActivity() { } private fun requestStoragePermissions() { - ActivityCompat.requestPermissions(this, - arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), - WRITE_EXTERNAL_STORAGE) + ActivityCompat.requestPermissions( + this, + arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), + WRITE_EXTERNAL_STORAGE + ) } private fun isStoragePermissionNotGranted(): Boolean { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M - || Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + || Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q + ) { return true } - val result = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) + val result = + ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) return result != PackageManager.PERMISSION_GRANTED } fun onSelectShader(shader: ShaderInterface) { - videoSurfaceView.setShader(shader) - intensitySeekBar.isEnabled = false - intensitySeekBar.progress = 100 + binding.videoSurfaceView.setShader(shader) + binding.intensitySeekBar.isEnabled = false + binding.intensitySeekBar.progress = 100 } fun onSelectFilter(filter: Filter) { - videoSurfaceView.setFilter(filter) - intensitySeekBar.isEnabled = true - intensitySeekBar.progress = 0 + binding.videoSurfaceView.setFilter(filter) + binding.intensitySeekBar.isEnabled = true + binding.intensitySeekBar.progress = 0 } fun onStartSavingVideo() { - progress.visibility = View.VISIBLE + binding.progress.visibility = View.VISIBLE } fun onFinishSavingVideo(msg: String) { runOnUiThread { - progress.visibility = View.GONE + binding.progress.visibility = View.GONE Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() } } diff --git a/build.gradle b/build.gradle index d81b3a8..ae0c41d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,25 +1,20 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.6.10' repositories { - jcenter() google() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.2' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1" + classpath 'com.android.tools.build:gradle:7.0.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } -plugins { - id "com.jfrog.bintray" version "1.7.3" -} allprojects { repositories { - jcenter() google() + mavenCentral() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5111743..e2fc71f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip diff --git a/videffects/build.gradle b/videffects/build.gradle index ad8b03c..ef85c3e 100644 --- a/videffects/build.gradle +++ b/videffects/build.gradle @@ -1,51 +1,18 @@ apply plugin: 'com.android.library' -apply plugin: 'maven' +apply plugin: 'maven-publish' +apply plugin: 'signing' /** - In order to push the library to Bintray we need to execute the - following gradle commands in the given sequence. - - ./gradlew assemble // To generate build folder - ./gradlew createPom // To create POM file for maven. if that creates a new file then dont add it to git - ./gradlew bintrayUpload // To upload library to bintray - */ -ext { - bintrayRepo = 'maven' - bintrayName = 'VidEffects' - - publishedGroupId = 'com.sherazkhilji.videffects' - libraryName = 'VidEffects' - artifact = 'videffects' - - libraryDescription = 'It is an Android library uses OpenGL Shaders to apply effects on Videos at Runtime.' - - siteUrl = 'https://github.com/krazykira/VidEffects' - gitUrl = 'https://github.com/krazykira/VidEffects.git' - - versionCode = 3 - libraryVersion = '1.1.0' - - developerId = 'krazykira' - developerName = 'Sheraz Ahmed Khilji' - developerEmail = 'sherazkhilji@gmail.com' - - licenseName = 'The Apache Software License, Version 2.0' - licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - allLicenses = ["Apache-2.0"] -} -/** - * This is needed because we want to complie this as android library so that we can test it before publishing + * This is needed because we want to compile this as android library so that we can test it before publishing */ android { - compileSdkVersion 29 - buildToolsVersion "29.0.3" + compileSdkVersion 30 + buildToolsVersion "30.0.3" defaultConfig { minSdkVersion 21 - targetSdkVersion 29 - versionCode versionCode - versionName libraryVersion + targetSdkVersion 30 } buildTypes { @@ -57,47 +24,75 @@ android { } dependencies { - implementation 'androidx.annotation:annotation:1.1.0' + implementation 'androidx.annotation:annotation:1.3.0' } -/** - Run this code to create pom-default.xml file in build directory - */ -task createPom doLast { - pom { - project { -// All of these values are defined in the ext block - packaging 'aar' - groupId publishedGroupId - artifactId artifact - version libraryVersion - - inceptionYear new Date() - licenses { - license { - name licenseName - url licenseUrl - distribution 'repo' +// Because the components are created only during the afterEvaluate phase, you must +// configure your publications using the afterEvaluate() lifecycle method. +afterEvaluate { + publishing { + publications { + // Creates a Maven publication called "release". + releaseLibrary(MavenPublication) { + // Applies the component for the release build variant. + from components.release + + // You can then customize attributes of the publication as shown below. + groupId = 'com.github.krazykira' + artifactId = 'videffects' + version = '1.1.1' + pom { + name = 'VidEffects' + description = 'It is an Android library uses OpenGL Shaders to apply effects on Videos at Runtime.' + url = 'https://github.com/krazykira/VidEffects' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'krazykira' + name = 'Sheraz Ahmed Khilji' + email = 'sherazkhilji@gmail.com' + } + } + scm { + connection = 'scm:git:git://github.com/krazykira/VidEffects.git' + developerConnection = 'scm:git:ssh://github.com/krazykira/VidEffects.git' + url = 'github.com/krazykira/VidEffects/' + } } - } - developers { - developer { - id developerId - name developerName - email developerEmail + repositories { + mavenCentral { + // Url for Staging Snapshot Deployment +// url "https://oss.sonatype.org/content/repositories/snapshots/" + + // Url for Live/Release artifact Deployment + url "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username "$osshUsername" + password "$osshPassword" + } + } } } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - - } } - }.writeTo("build/poms/pom-default.xml").writeTo("pom.xml") + } +/** + * Steps for publishing the artifact + * 1. For publishing. You need to have the public gpg key and gradle.properties. + * 2. Once you have them available then you need to run ./gradlew publishReleaseLibraryPublicationToMavenRepoRepository + * 3. Once the gradle task completes goto https://oss.sonatype.org/index.html#stagingRepositories and login with your credentials. + * 4. After logging in, go to Staging repositories section and you will see the recently uploaded releasable artifact there. + * 5. Select the artifact, then click close button. A few validations will run and if all of them pass then release button is enabled. + * 6. Click the release button and the artifact will be released. + */ + signing { + sign publishing.publications.releaseLibrary + } } -// Place it at the end of the file -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' +