diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 00000000..0a9757e2 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,33 @@ +name: Android CI + +on: + push: + branches: [ master, develop ] + pull_request: + branches: [ master, develop ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew build + - name: assemble and jacoco + run: ./gradlew assembleDebug jacocoTestReport + - name: Android Emulator Runner + # You may pin to the exact commit or the version. + # uses: ReactiveCircus/android-emulator-runner@e08f702234bdc95883c7fd5c7d2867ccf1a8463b + uses: ReactiveCircus/android-emulator-runner@v2.13.0 + with: + # API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10 + api-level: 25 + script: ./gradlew connectedCheck connectedAndroidTest + - name: Codecov + uses: codecov/codecov-action@v1.0.15 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0b059781..00000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ - -language: android - - -android: - components: - - build-tools-29.0.2 - - android-15 - - android-22 - - android-29 - - tools - - platform-tools - - add-on - - extra - - extra-google-google_play_services - - extra-google-m2repository - - extra-android-m2repository -# Images - - sys-img-armeabi-v7a-android-22 - - sys-img-${ANDROID_ABI}-${ANDROID_TARGET} - -licenses: - - 'android-sdk-preview-license-.+' - - 'android-sdk-license-.+' - - 'google-gdk-license-.+' - -notifications: - email: true - -env: - matrix: - - ANDROID_TARGET=google_apis-25 ANDROID_ABI=armeabi-v7a - - global: - - ADB_INSTALL_TIMEOUT=20 - - - -before_install: - - chmod +x gradlew - - -before_script: - - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a - - emulator -avd test -no-skin -no-audio -no-window & - - android-wait-for-emulator - - adb shell input keyevent 82 & - -script: - - ./gradlew build jacocoTestReport assembleAndroidTest - - ./gradlew build connectedCheck - - ./gradlew connectedAndroidTest - -after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/FishBun/build.gradle b/FishBun/build.gradle index 19a9e1ab..12023458 100644 --- a/FishBun/build.gradle +++ b/FishBun/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'com.hiya.jacoco-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'de.mobilej.unmock' +apply plugin: 'maven-publish' buildscript { repositories { @@ -86,3 +87,11 @@ dependencies { tasks.withType(Javadoc).all { enabled = false } + +install { + repositories.mavenInstaller { + pom.groupId = 'com.sangcomz' + pom.version = gradle.versionName + pom.artifactId = project.name + } +} \ No newline at end of file diff --git a/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt b/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt index 851c9f62..1f942630 100644 --- a/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt +++ b/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt @@ -9,11 +9,13 @@ class PickerIntentDataSourceImpl(private val intent: Intent) : PickerIntentDataS && intent.hasExtra(ARG_ALBUM_ID) && intent.hasExtra(ARG_ALBUM_POSITION) ) - AlbumData( - intent.getLongExtra(ARG_ALBUM_ID, -1), - intent.getStringExtra(ARG_ALBUM_NAME), - intent.getIntExtra(ARG_ALBUM_POSITION, -1) - ) + intent.getStringExtra(ARG_ALBUM_NAME)?.let { + AlbumData( + intent.getLongExtra(ARG_ALBUM_ID, -1), + it, + intent.getIntExtra(ARG_ALBUM_POSITION, -1) + ) + } else null } diff --git a/FishBun/src/main/res/layout/header_item.xml b/FishBun/src/main/res/layout/header_item.xml index de2108dd..88d8a5d2 100644 --- a/FishBun/src/main/res/layout/header_item.xml +++ b/FishBun/src/main/res/layout/header_item.xml @@ -1,5 +1,6 @@ + android:background="#d9d9d9" + android:foreground="?attr/selectableItemBackground" + tools:targetApi="m"> + 专辑 + 相机 + 完成 + 全部完成 + 没有选择图片。 + 所有视图 + 缺少权限。 + 没有专辑。\n拍一张照片吧! + 选择数量达到上限。取消一张照片以继续选择其他照片。 + 加载中… + 照片 + 有点临时错误哦。请过几分钟再试试哦。 + 请至少选择 %d 张图片。 + diff --git a/FishBunDemo/build.gradle b/FishBunDemo/build.gradle index 07002ee0..c5951f5c 100644 --- a/FishBunDemo/build.gradle +++ b/FishBunDemo/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.android.application' -apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' buildscript { repositories { diff --git a/FishBunDemo/src/main/AndroidManifest.xml b/FishBunDemo/src/main/AndroidManifest.xml index 77fedcbf..7c6c0513 100644 --- a/FishBunDemo/src/main/AndroidManifest.xml +++ b/FishBunDemo/src/main/AndroidManifest.xml @@ -6,6 +6,12 @@ + + + + + + - \ No newline at end of file diff --git a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt index b0c2bcf8..f168dca7 100644 --- a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt +++ b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt @@ -14,6 +14,7 @@ import com.sangcomz.fishbun.FishBun import com.sangcomz.fishbun.adapter.image.impl.CoilAdapter import kotlinx.android.synthetic.main.fragment_sub.* import java.util.* +import kotlin.collections.ArrayList /** * A simple [Fragment] subclass. @@ -52,7 +53,7 @@ class SubFragment : Fragment() { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { FishBun.FISHBUN_REQUEST_CODE -> if (resultCode == Activity.RESULT_OK) { - path = data!!.getParcelableArrayListExtra(FishBun.INTENT_PATH) + path = data?.getParcelableArrayListExtra(FishBun.INTENT_PATH) ?: arrayListOf() imageAdapter.changePath(path) } } diff --git a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt index 6aa3590b..9dc88f0b 100644 --- a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt +++ b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt @@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.recyclerview.widget.LinearLayoutManager import com.sangcomz.fishbun.FishBun +import com.sangcomz.fishbun.MimeType import com.sangcomz.fishbun.adapter.image.impl.GlideAdapter import com.sangcomz.fishbun.adapter.image.impl.CoilAdapter import kotlinx.android.synthetic.main.activity_withactivity.* @@ -46,7 +47,7 @@ class WithActivityActivity : AppCompatActivity() { super.onActivityResult(requestCode, resultCode, imageData) if (requestCode == FishBun.FISHBUN_REQUEST_CODE && resultCode == RESULT_OK) { - path = imageData!!.getParcelableArrayListExtra(FishBun.INTENT_PATH) + path = imageData?.getParcelableArrayListExtra(FishBun.INTENT_PATH) ?: arrayListOf() imageAdapter.changePath(path) } } @@ -84,8 +85,8 @@ class WithActivityActivity : AppCompatActivity() { .setSelectedImages(path) .setAlbumSpanCount(2, 3) .setButtonInAlbumActivity(false) - .setCamera(true) - .exceptGif(true) + .hasCameraInPickerPage(true) + .exceptMimeType(arrayListOf(MimeType.GIF)) .setReachLimitAutomaticClose(true) .setHomeAsUpIndicatorDrawable( ContextCompat.getDrawable( @@ -119,8 +120,8 @@ class WithActivityActivity : AppCompatActivity() { .setSelectedImages(path) .setAlbumSpanCount(1, 2) .setButtonInAlbumActivity(true) - .setCamera(false) - .exceptGif(true) + .hasCameraInPickerPage(false) + .exceptMimeType(arrayListOf(MimeType.GIF)) .setReachLimitAutomaticClose(false) .setHomeAsUpIndicatorDrawable( ContextCompat.getDrawable( diff --git a/README.md b/README.md index c50ac058..b8e7699c 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,16 @@ _FishBun_ is a highly customizable image picker for Android. -## What's New in _FishBun_ 1.0.0-alpha03? :tada: +## What's New in _FishBun_ 1.0.0-alpha04? :tada: - Refactoring for rapid development:rocket::rocket::rocket: - Change PickerSpanCount default value (`3`->`4`) -- target SDK 29 support +- target SDK 30 support - In API 29 or higher, the camera can be used only in the total image folder. - Fix Issue(#215) - Change DetailView statusBar color - Removed Picasso and added Coil +- Supprot Chinese ## Customizable Styles @@ -121,15 +122,14 @@ Setting up _FishBun_ requires to add this Gradle configuration: dependencies { // Under the Android Plugin 3.0.0. - compile 'com.sangcomz:FishBun:1.0.0-alpha02' + compile 'com.sangcomz:FishBun:1.0.0-alpha04' - compile 'com.squareup.picasso:picasso:2.71828' compile 'io.coil-kt:coil:0.11.0' or compile 'com.github.bumptech.glide:glide:4.9.0' // Android plugin 3.0.0 or higher. - implementation 'com.sangcomz:FishBun:1.0.0-alpha03' + implementation 'com.sangcomz:FishBun:1.0.0-alpha04' implementation 'io.coil-kt:coil:0.11.0' or @@ -142,6 +142,13 @@ and to allow the following permissions in your `Manifest`: +If your app targets Android 11 with compileSdk/targetSdk >= 30 then you will need to add this to the manifest (outside of the application block) in order to capture pictures with the device camera. [Android documentation here](https://developer.android.com/about/versions/11/privacy/package-visibility): + + + + + + ## How to Use @@ -151,7 +158,7 @@ Use _FishBun_ in an activity: or in a fragment: - FishBun.with(YourFragment).setImageAdapter(new PicassoAdapter()).startAlbum(); + FishBun.with(YourFragment).setImageAdapter(new CoilAdapter()).startAlbum(); and implement `OnActivityResult`: diff --git a/build.gradle b/build.gradle index 3a66bdf3..6ef9233f 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { kotlin_version = '1.3.50' androidx_version = '1.1.0' recyclerview_version = '1.1.0' - material_version = '1.1.0' + material_version = '1.2.1' coil_version = '0.11.0' glide_version = '4.11.0' constraint_version = '1.1.3' diff --git a/settings.gradle b/settings.gradle index 49d29e71..015990c0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,8 @@ include ':FishBunDemo', ':FishBun' -gradle.ext.versionCode = 31 -gradle.ext.versionName = '1.0.0-alpha03' +gradle.ext.versionCode = 32 +gradle.ext.versionName = '1.0.0-alpha04' gradle.ext.set('minSdk', 15) -gradle.ext.set('targetSdk', 29) -gradle.ext.set('compileSdk', 29) +gradle.ext.set('targetSdk', 30) +gradle.ext.set('compileSdk', 30)