Skip to content

Commit

Permalink
Merge branch 'release/v0.11.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
sangcomz committed Mar 22, 2020
2 parents 89b8b0a + fe69d02 commit 3a537c9
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 117 deletions.
25 changes: 0 additions & 25 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseFragment.java

This file was deleted.

12 changes: 0 additions & 12 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseParams.java

This file was deleted.

33 changes: 26 additions & 7 deletions FishBun/src/main/java/com/sangcomz/fishbun/FishBun.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.sangcomz.fishbun

import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import com.sangcomz.fishbun.adapter.image.ImageAdapter
import java.lang.ref.WeakReference

class FishBun private constructor(context: Activity?) {
class FishBun private constructor(activity: Activity?, fragment: Fragment?) {

private val _context: WeakReference<Activity?> = WeakReference(context)
private val _activity: WeakReference<Activity?> = WeakReference(activity)
private val _fragment: WeakReference<Fragment?> = WeakReference(fragment)

val context: Activity?
get() = _context.get()
val fishBunContext: FishBunContext get() = FishBunContext()

fun setImageAdapter(imageAdapter: ImageAdapter): FishBunCreator {
val fishton = Fishton.getInstance().apply {
Expand All @@ -22,9 +24,26 @@ class FishBun private constructor(context: Activity?) {

companion object {
@JvmStatic
fun with(activity: Activity) = FishBun(activity)
fun with(activity: Activity) = FishBun(activity, null)

@JvmStatic
fun with(fragment: Fragment) = FishBun(fragment.activity)
fun with(fragment: Fragment) = FishBun(null, fragment)
}
}

inner class FishBunContext {
private val activity = _activity.get()
private val fragment = _fragment.get()
fun getContext(): Context =
activity ?: fragment?.context ?: throw NullPointerException("Activity or Fragment Null")

fun startActivityForResult(intent: Intent, requestCode: Int) {
when {
activity != null -> activity.startActivityForResult(intent, requestCode)
fragment != null -> fragment.startActivityForResult(intent, requestCode)
else -> throw NullPointerException("Activity or Fragment Null")
}
}
}
}


81 changes: 51 additions & 30 deletions FishBun/src/main/java/com/sangcomz/fishbun/FishBunCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import java.util.*
/**
* Created by sangcomz on 17/05/2017.
*/
class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton) : BaseProperty, CustomizationProperty {
class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton) : BaseProperty,
CustomizationProperty {
private var requestCode = 27

override fun setSelectedImages(selectedImages: ArrayList<Uri>): FishBunCreator = this.apply {
Expand Down Expand Up @@ -48,12 +49,17 @@ class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton)
fishton.colorActionBar = actionbarColor
}

override fun setActionBarColor(actionbarColor: Int, statusBarColor: Int): FishBunCreator = this.apply {
fishton.colorActionBar = actionbarColor
fishton.colorStatusBar = statusBarColor
}
override fun setActionBarColor(actionbarColor: Int, statusBarColor: Int): FishBunCreator =
this.apply {
fishton.colorActionBar = actionbarColor
fishton.colorStatusBar = statusBarColor
}

override fun setActionBarColor(actionbarColor: Int, statusBarColor: Int, isStatusBarLight: Boolean): FishBunCreator = this.apply {
override fun setActionBarColor(
actionbarColor: Int,
statusBarColor: Int,
isStatusBarLight: Boolean
): FishBunCreator = this.apply {
fishton.colorActionBar = actionbarColor
fishton.colorStatusBar = statusBarColor
fishton.isStatusBarLight = isStatusBarLight
Expand All @@ -79,18 +85,23 @@ class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton)
fishton.isButton = isButton
}

override fun setReachLimitAutomaticClose(isAutomaticClose: Boolean): FishBunCreator = this.apply {
fishton.isAutomaticClose = isAutomaticClose
}
override fun setReachLimitAutomaticClose(isAutomaticClose: Boolean): FishBunCreator =
this.apply {
fishton.isAutomaticClose = isAutomaticClose
}

override fun setAlbumSpanCount(portraitSpanCount: Int, landscapeSpanCount: Int): FishBunCreator = this.apply {
override fun setAlbumSpanCount(
portraitSpanCount: Int,
landscapeSpanCount: Int
): FishBunCreator = this.apply {
fishton.albumPortraitSpanCount = portraitSpanCount
fishton.albumLandscapeSpanCount = landscapeSpanCount
}

override fun setAlbumSpanCountOnlyLandscape(landscapeSpanCount: Int): FishBunCreator = this.apply {
fishton.albumLandscapeSpanCount = landscapeSpanCount
}
override fun setAlbumSpanCountOnlyLandscape(landscapeSpanCount: Int): FishBunCreator =
this.apply {
fishton.albumLandscapeSpanCount = landscapeSpanCount
}

override fun setAlbumSpanCountOnlPortrait(portraitSpanCount: Int): FishBunCreator = this.apply {
fishton.albumPortraitSpanCount = portraitSpanCount
Expand Down Expand Up @@ -152,23 +163,33 @@ class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton)
fishton.isStartInAllView = isStartInAllView
}

override fun startAlbum() =
fishBun.context?.let { context ->
with(fishton) {
setDefaultMessage(context)
setMenuTextColor()
setDefaultDimen(context)
}
val intent: Intent =
if (fishton.isStartInAllView) {
Intent(context, PickerActivity::class.java).apply {
putExtra(Define.BUNDLE_NAME.ALBUM.name, Album(0, fishton.titleAlbumAllView, null, 0))
putExtra(Define.BUNDLE_NAME.POSITION.name, 0)
}
} else {
Intent(context, AlbumActivity::class.java)

override fun startAlbum() {
val fishBunContext = fishBun.fishBunContext
val context = fishBunContext.getContext()

if (fishton.imageAdapter == null) throw NullPointerException("ImageAdapter is Null")

with(fishton) {
setDefaultMessage(context)
setMenuTextColor()
setDefaultDimen(context)
}

val intent: Intent =
if (fishton.isStartInAllView) {
Intent(context, PickerActivity::class.java).apply {
putExtra(
Define.BUNDLE_NAME.ALBUM.name,
Album(0, fishton.titleAlbumAllView, null, 0)
)
putExtra(Define.BUNDLE_NAME.POSITION.name, 0)
}
context.startActivityForResult(intent, requestCode)
} ?: throw NullPointerException("Activity or Fragment Null")
} else {
Intent(context, AlbumActivity::class.java)
}

fishBunContext.startActivityForResult(intent, requestCode)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.sangcomz.fishbun.adapter.image.impl

import android.net.Uri
import android.widget.ImageView

import com.bumptech.glide.Glide
import com.bumptech.glide.load.DecodeFormat
import com.bumptech.glide.request.RequestOptions
import com.sangcomz.fishbun.adapter.image.ImageAdapter

Expand All @@ -13,20 +13,25 @@ import com.sangcomz.fishbun.adapter.image.ImageAdapter

class GlideAdapter : ImageAdapter {
override fun loadImage(target: ImageView, loadUrl: Uri) {
val options = RequestOptions().centerCrop()
val options = RequestOptions().apply {
centerCrop()
format(DecodeFormat.PREFER_RGB_565)
}
Glide
.with(target.context)
.load(loadUrl)
.apply(options)
.into(target)
.with(target.context)
.load(loadUrl)
.apply(options)
.override(target.width, target.height)
.thumbnail(0.25f)
.into(target)
}

override fun loadDetailImage(target: ImageView, loadUrl: Uri) {
val options = RequestOptions().centerInside()
Glide
.with(target.context)
.load(loadUrl)
.apply(options)
.into(target)
.with(target.context)
.load(loadUrl)
.apply(options)
.into(target)
}
}
3 changes: 1 addition & 2 deletions FishBunDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$rootProject.androidx_version"
implementation "androidx.recyclerview:recyclerview:$rootProject.recyclerview_version"

debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-4'

implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "com.squareup.picasso:picasso:$rootProject.picasso_version"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.sangcomz.fishbundemo

import android.app.Application
import com.squareup.leakcanary.LeakCanary

class CommonApplication : Application() {

override fun onCreate() {
super.onCreate()
LeakCanary.install(this)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.sangcomz.fishbundemo

import android.content.Intent
import android.os.Bundle
import androidx.annotation.Nullable
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_withfragment.*

Expand All @@ -17,12 +15,4 @@ class WithFragmentActivity : AppCompatActivity() {
subFragment = SubFragment.newInstance()
supportFragmentManager.beginTransaction().add(area_container.id, subFragment).commit()
}

/**
* Send onActivityResult method to SubFragment
*/
override fun onActivityResult(requestCode: Int, resultCode: Int, @Nullable data: Intent?) {
subFragment.onActivityResult(requestCode, resultCode, data)
}

}
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ _FishBun_ is a highly customizable image picker for Android.
<img src="/pic/fishbuns.png">


## What's New in _FishBun_ 0.11.2? :tada:
## What's New in _FishBun_ 0.11.3? :tada:

- 🔧 Fix to respond to onActivityResult in fragment
- 🔧 Fix glide requestOptions
- 🐥🆙 Update LeakCanary

- added some guide for reporting issue[#176](https://github.com/sangcomz/FishBun/pull/176)
- Java to Kotlin[#174](https://github.com/sangcomz/FishBun/pull/174), [#175](https://github.com/sangcomz/FishBun/pull/175), [#179](https://github.com/sangcomz/FishBun/pull/179), [#185](https://github.com/sangcomz/FishBun/pull/185), [#187](https://github.com/sangcomz/FishBun/pull/187)
- fix README.md for App used[#180](https://github.com/sangcomz/FishBun/pull/180)
- Runtime permission for camera [#116](https://github.com/sangcomz/FishBun/issue/116)
- Implement Instrument test code [#186](https://github.com/sangcomz/FishBun/pull/186)
- Fix bug, when Image displays in wrong orientation [#184](https://github.com/sangcomz/FishBun/pull/184)


## Customizable Styles
Expand Down Expand Up @@ -125,7 +123,7 @@ Setting up _FishBun_ requires to add this Gradle configuration:
compile 'com.github.bumptech.glide:glide:4.9.0'
// Android plugin 3.0.0 or higher.
implementation 'com.sangcomz:FishBun:0.11.2'
implementation 'com.sangcomz:FishBun:0.11.3'
implementation 'com.squareup.picasso:picasso:2.5.2'
or
Expand Down Expand Up @@ -206,7 +204,7 @@ Running on Android M, _FishBun_ checks if it has proper permission for you befor

| Project Name | Result Screen |
|:---------:|---|
| Pandaz <p style="float:left;"> <a href="https://play.google.com/store/apps/details?id=com.pwdr.panda"> <img HEIGHT="40" WIDTH="135" alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/apps/en-play-badge.png" /></a></p> | <img src="/pic/pandaz_result.gif"> |
| Pandaz(unavailable now) <p style="float:left;"> | <img src="/pic/pandaz_result.gif"> |
| Multi photo resize compress crop in batch PicTools <p style="float:left;"> <a href="https://play.google.com/store/apps/details?id=omkar.tenkale.pictoolsandroid&hl=en_US"> <img HEIGHT="40" WIDTH="135" alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/apps/en-play-badge.png" /></a></p> | <img src="/pic/multi_photo_result.gif"> |


Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
ext {
kotlin_version = '1.3.50'
androidx_version = '1.0.0'
recyclerview_version = '1.0.0'
recyclerview_version = '1.1.0'
material_version = '1.0.0'
picasso_version = '2.5.2'
glide_version = '4.9.0'
Expand All @@ -16,7 +16,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
9 changes: 3 additions & 6 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,9 @@ if (project.rootProject.file('local.properties').isFile()) {
tagName = version
targetCommitish = 'master'
body = """## Release Note
* added some guide for reporting issue[#176](https://github.com/sangcomz/FishBun/pull/176)
* Java to Kotlin[#174](https://github.com/sangcomz/FishBun/pull/174), [#175](https://github.com/sangcomz/FishBun/pull/175), [#179](https://github.com/sangcomz/FishBun/pull/179), [#185](https://github.com/sangcomz/FishBun/pull/185), [#187](https://github.com/sangcomz/FishBun/pull/187)
* fix README.md for App used[#180](https://github.com/sangcomz/FishBun/pull/180)
* Runtime permission for camera [#116](https://github.com/sangcomz/FishBun/issue/116)
* Implement Instrument test code [#186](https://github.com/sangcomz/FishBun/pull/186)
* Fix bug, when Image displays in wrong orientation [#184](https://github.com/sangcomz/FishBun/pull/184)
* Fix to respond to onActivityResult in fragment
* Update LeakCanary
* Fix glide requestOptions
"""
name = version
}
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include ':FishBunDemo', ':FishBun'

gradle.ext.versionCode = 27
gradle.ext.versionName = '0.11.2'
gradle.ext.versionCode = 28
gradle.ext.versionName = '0.11.3'

gradle.ext.set('minSdk', 15)
gradle.ext.set('targetSdk', 28)
Expand Down

0 comments on commit 3a537c9

Please sign in to comment.