Skip to content

Commit

Permalink
Merge pull request #248 from sangcomz/release/1.0.0-beta01
Browse files Browse the repository at this point in the history
Release/1.0.0 beta01
  • Loading branch information
sangcomz authored Jan 8, 2022
2 parents f2f89d6 + b2f3960 commit c1aa38a
Show file tree
Hide file tree
Showing 25 changed files with 214 additions and 108 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Build with Gradle
run: ./gradlew build
- name: assemble and jacoco
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release library

on:
push:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Build with Gradle
run: ./gradlew build

- name: Release
run: sh release.sh
32 changes: 16 additions & 16 deletions FishBun/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'com.hiya.jacoco-android'
apply plugin: 'de.mobilej.unmock'

jacoco {
toolVersion = "0.8.7"
}

buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
Expand All @@ -27,8 +30,6 @@ android {
minSdkVersion gradle.minSdk
targetSdkVersion gradle.targetSdk
consumerProguardFile('proguard-rules.pro')
versionCode gradle.versionCode
versionName gradle.versionName
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -53,7 +54,6 @@ android {
}
}

apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'co.riiid.gradle'

apply from: '../publish/release.gradle'
Expand All @@ -64,16 +64,14 @@ unMock {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compileOnly "androidx.appcompat:appcompat:$rootProject.androidx_version"
implementation "androidx.appcompat:appcompat:$rootProject.androidx_version"

compile "androidx.constraintlayout:constraintlayout:$rootProject.constraint_version"
compile "com.google.android.material:material:$rootProject.material_version"
compile "androidx.recyclerview:recyclerview:$rootProject.recyclerview_version"
implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraint_version"
implementation "com.google.android.material:material:$rootProject.material_version"


testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.0.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'org.mockito:mockito-android:3.0.0'

compileOnly "io.coil-kt:coil:$rootProject.coil_version"
Expand All @@ -84,10 +82,12 @@ tasks.withType(Javadoc).all {
enabled = false
}

install {
repositories.mavenInstaller {
pom.groupId = 'com.sangcomz'
pom.version = gradle.versionName
pom.artifactId = project.name
configurations.all{
resolutionStrategy {
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "0.8.7"
}
}
}
}
6 changes: 6 additions & 0 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseProperty.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.sangcomz.fishbun

import android.content.Intent
import android.net.Uri
import androidx.activity.result.ActivityResultLauncher

/**
* Created by sangcomz on 13/05/2017.
Expand All @@ -23,4 +25,8 @@ interface BaseProperty {
fun exceptMimeType(exceptMimeTypeList: List<MimeType>): FishBunCreator

fun startAlbum()

fun startAlbumWithOnActivityResult(requestCode: Int)

fun startAlbumWithActivityResultCallback(activityResultLauncher: ActivityResultLauncher<Intent>)
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ interface CustomizationProperty {

fun setSpecifyFolderList(specifyFolderList: List<String>): FishBunCreator

fun hasCameraInPickerPage(isCamera: Boolean): FishBunCreator
fun hasCameraInPickerPage(hasCamera: Boolean): FishBunCreator
}
12 changes: 12 additions & 0 deletions FishBun/src/main/java/com/sangcomz/fishbun/FishBun.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.sangcomz.fishbun
import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.ActivityResultLauncher
import androidx.fragment.app.Fragment
import com.sangcomz.fishbun.adapter.image.ImageAdapter
import java.lang.ref.WeakReference
Expand All @@ -23,6 +24,7 @@ class FishBun private constructor(activity: Activity?, fragment: Fragment?) {
}

companion object {
@Deprecated("To be deleted along with the startAlbum function")
const val FISHBUN_REQUEST_CODE = 27
const val INTENT_PATH = "intent_path"

Expand All @@ -46,6 +48,16 @@ class FishBun private constructor(activity: Activity?, fragment: Fragment?) {
else -> throw NullPointerException("Activity or Fragment Null")
}
}

fun startWithRegisterForActivityResult(
activityResultLauncher: ActivityResultLauncher<Intent>,
intent: Intent
) {
when {
activity != null || fragment != null -> activityResultLauncher.launch(intent)
else -> throw NullPointerException("Activity or Fragment Null")
}
}
}
}

Expand Down
52 changes: 39 additions & 13 deletions FishBun/src/main/java/com/sangcomz/fishbun/FishBunCreator.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.sangcomz.fishbun

import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable
import android.net.Uri
import androidx.activity.result.ActivityResultLauncher
import com.sangcomz.fishbun.ui.album.ui.AlbumActivity
import com.sangcomz.fishbun.ui.picker.PickerActivity
import kotlin.collections.ArrayList
Expand Down Expand Up @@ -72,7 +74,7 @@ class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton)
fishton.hasCameraInPickerPage = hasCamera
}


@Deprecated("To be deleted along with the startAlbum function")
override fun setRequestCode(requestCode: Int): FishBunCreator = this.apply {
this.requestCode = requestCode
}
Expand Down Expand Up @@ -176,32 +178,56 @@ class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton)
fishton.specifyFolderList = specifyFolderList
}

private fun prepareStartAlbum(context: Context) {
checkNotNull(fishton.imageAdapter)
exceptionHandling()
setDefaultValue(context)
}

@Deprecated("instead startAlbumWithOnActivityResult(requestCode)", ReplaceWith("startAlbumWithOnActivityResult(requestCode)"))
override fun startAlbum() {
val fishBunContext = fishBun.fishBunContext
val context = fishBunContext.getContext()

exceptionHandling()
prepareStartAlbum(context)

fishBunContext.startActivityForResult(getIntent(context), requestCode)
}

override fun startAlbumWithOnActivityResult(requestCode: Int) {
val fishBunContext = fishBun.fishBunContext
val context = fishBunContext.getContext()

prepareStartAlbum(context)

if (fishton.imageAdapter == null) throw NullPointerException("ImageAdapter is Null")
fishBunContext.startActivityForResult(getIntent(context), requestCode)
}

override fun startAlbumWithActivityResultCallback(activityResultLauncher: ActivityResultLauncher<Intent>) {
val fishBunContext = fishBun.fishBunContext
val context = fishBunContext.getContext()

prepareStartAlbum(context)

fishBunContext.startWithRegisterForActivityResult(activityResultLauncher, getIntent(context))
}

private fun getIntent(context: Context): Intent =
if (fishton.isStartInAllView) {
PickerActivity.getPickerActivityIntent(context, 0L, fishton.titleAlbumAllView, 0)
} else {
Intent(context, AlbumActivity::class.java)
}

private fun setDefaultValue(context: Context) {
with(fishton) {
setDefaultMessage(context)
setMenuTextColor()
setDefaultDimen(context)
}

val intent: Intent =
if (fishton.isStartInAllView) {
PickerActivity.getPickerActivityIntent(context, 0L, fishton.titleAlbumAllView, 0)
} else {
Intent(context, AlbumActivity::class.java)
}

fishBunContext.startActivityForResult(intent, requestCode)
}

private fun exceptionHandling() {
//TODO support camera
if (fishton.hasCameraInPickerPage) {
fishton.hasCameraInPickerPage = fishton.specifyFolderList.isEmpty()
}
Expand Down
9 changes: 2 additions & 7 deletions FishBun/src/main/res/layout/detail_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@

<com.sangcomz.fishbun.util.TouchImageView
android:id="@+id/img_detail_image"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:layout_width="match_parent"
Expand Down
7 changes: 1 addition & 6 deletions FishBunDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'

buildscript {
repositories {
jcenter()
mavenCentral()
}
}
Expand Down Expand Up @@ -74,18 +73,14 @@ dependencies {
implementation "androidx.appcompat:appcompat:$rootProject.androidx_version"
implementation "androidx.recyclerview:recyclerview:$rootProject.recyclerview_version"

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-4'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'

implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation "com.github.bumptech.glide:glide:$rootProject.glide_version"
implementation "io.coil-kt:coil:$rootProject.coil_version"
}

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.triplet.gradle:play-publisher:1.2.2'
// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 3 additions & 1 deletion FishBunDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.sangcomz.fishbundemo.WithActivityActivity" />
<activity android:name="com.sangcomz.fishbundemo.MainActivity">
<activity
android:name="com.sangcomz.fishbundemo.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
16 changes: 6 additions & 10 deletions FishBunDemo/src/main/java/com/sangcomz/fishbundemo/ImageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.sangcomz.fishbundemo
import android.content.Context
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import coil.api.load
import coil.size.Scale
import coil.transform.CircleCropTransformation
import coil.transform.RoundedCornersTransformation
import com.sangcomz.fishbundemo.databinding.ItemBinding
import com.squareup.picasso.Picasso
import java.util.*

/**
* Created by sangc on 2015-11-06.
Expand All @@ -26,12 +26,8 @@ class ImageAdapter(

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val imagePath = imagePaths[position]

Picasso.get()
.load(imagePath)
.fit()
.centerCrop()
.into(holder.imageView)

holder.imageView.load(imagePath)

holder.imageView.setOnClickListener { imageController.setImgMain(imagePath) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package com.sangcomz.fishbundemo

import android.net.Uri
import android.widget.ImageView
import com.squareup.picasso.Picasso
import coil.api.load
import coil.size.Scale

/**
* Created by sangc on 2015-11-06.
*/
class ImageController(private val imgMain: ImageView) {

fun setImgMain(path: Uri) {
Picasso.get()
.load(path)
.fit()
.centerCrop()
.into(imgMain)
imgMain.load(path) {
scale(Scale.FILL)
scale(Scale.FIT)
}
}
}
Loading

0 comments on commit c1aa38a

Please sign in to comment.