Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew :FishBun:build
- name: assemble and jacoco
run: ./gradlew assembleDebug jacocoTestReport
run: ./gradlew :FishBun:assembleDebug :FishBun: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
with:
# API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10
api-level: 29
script: ./gradlew connectedCheck connectedAndroidTest
api-level: 36
script: ./gradlew :FishBun:connectedCheck :FishBun:connectedAndroidTest
- name: Codecov
uses: codecov/codecov-action@v1.0.15
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/checkout@v2

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

- name: Build with Gradle
run: ./gradlew build
Expand Down
20 changes: 10 additions & 10 deletions FishBun/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.hiya.jacoco-android'
apply plugin: 'jacoco'
apply plugin: 'de.mobilej.unmock'

jacoco {
Expand All @@ -17,30 +17,29 @@ buildscript {

dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.hiya:jacoco-android:0.2'
classpath 'co.riiid:gradle-github-plugin:0.4.2'
}
}


android {
namespace 'com.sangcomz.fishbun'
compileSdkVersion gradle.compileSdk
compileSdkVersion gradle.ext.compileSdk

defaultConfig {
minSdkVersion gradle.minSdk
targetSdkVersion gradle.targetSdk
minSdkVersion gradle.ext.minSdk
targetSdkVersion gradle.ext.targetSdk
consumerProguardFile('proguard-rules.pro')
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
debug {
testCoverageEnabled true
enableUnitTestCoverage true
enableAndroidTestCoverage true
}
}


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -49,10 +48,10 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

lintOptions {
lint {
abortOnError false
}

}

apply plugin: "io.github.sabujak-sabujak"
Expand All @@ -69,6 +68,7 @@ dependencies {

implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraint_version"
implementation "com.google.android.material:material:$rootProject.material_version"
implementation "androidx.activity:activity-ktx:$rootProject.activity_version"

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.0.0'
Expand Down
45 changes: 43 additions & 2 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.sangcomz.fishbun

import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.Window
import androidx.activity.SystemBarStyle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.sangcomz.fishbun.permission.PermissionCheck
import com.sangcomz.fishbun.util.CameraUtil

Expand All @@ -13,12 +19,47 @@ abstract class BaseActivity : AppCompatActivity() {
protected val permissionCheck: PermissionCheck by lazy { PermissionCheck(this) }

override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
if (Fishton.enableEdgeToEdge) {
val isLight =
if (Fishton.isStatusBarLight) SystemBarStyle.dark(Color.BLACK)
else SystemBarStyle.auto(
Color.TRANSPARENT,
Color.TRANSPARENT
)
enableEdgeToEdge(
statusBarStyle = isLight

)
}

window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
super.onCreate(savedInstanceState)
}

override fun setContentView(layoutResID: Int) {
super.setContentView(layoutResID)

if (Fishton.enableEdgeToEdge) {
setupNavigationBarInsets(findViewById(android.R.id.content))
}
}

fun setupStatusBarInsets(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
val statusBars = insets.getInsets(WindowInsetsCompat.Type.statusBars())
v.setPadding(0, statusBars.top, 0, 0)
insets
}
}

fun setupNavigationBarInsets(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
val navigationBars = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
v.setPadding(navigationBars.left, 0, navigationBars.right, navigationBars.bottom)
insets
}
}

companion object {
const val PERMISSION_STORAGE = 28
const val PERMISSION_CAMERA = 29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ interface CustomizationProperty {
fun setSpecifyFolderList(specifyFolderList: List<String>): FishBunCreator

fun hasCameraInPickerPage(hasCamera: Boolean): FishBunCreator

fun enableEdgeToEdge(enable: Boolean): FishBunCreator
}
4 changes: 4 additions & 0 deletions FishBun/src/main/java/com/sangcomz/fishbun/FishBunCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class FishBunCreator(private val fishBun: FishBun, private val fishton: Fishton)
fishton.hasCameraInPickerPage = hasCamera
}

override fun enableEdgeToEdge(enable: Boolean): FishBunCreator = this.apply {
fishton.enableEdgeToEdge = enable
}

@Deprecated("To be deleted along with the startAlbum function")
override fun setRequestCode(requestCode: Int): FishBunCreator = this.apply {
this.requestCode = requestCode
Expand Down
5 changes: 5 additions & 0 deletions FishBun/src/main/java/com/sangcomz/fishbun/Fishton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import com.sangcomz.fishbun.adapter.image.ImageAdapter
import com.sangcomz.fishbun.util.getDimension
import java.util.ArrayList
Expand Down Expand Up @@ -62,6 +63,8 @@ object Fishton {

var isStartInAllView: Boolean = false

var enableEdgeToEdge: Boolean = false

init {
initValue()
}
Expand Down Expand Up @@ -108,6 +111,8 @@ object Fishton {

colorSelectCircleStroke = Color.parseColor("#c1ffffff")
isStartInAllView = false

enableEdgeToEdge = Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM
}

fun setDefaultMessage(context: Context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.sangcomz.fishbun.adapter.image.impl

import android.graphics.Matrix
import android.net.Uri
import android.widget.ImageView
import coil.api.load
import coil.request.LoadRequestBuilder
import coil.load
import coil.size.Scale

import com.sangcomz.fishbun.adapter.image.ImageAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.view.MenuItem
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.widget.Toolbar
import androidx.constraintlayout.widget.Group
import androidx.recyclerview.widget.GridLayoutManager
Expand Down Expand Up @@ -98,13 +99,15 @@ class AlbumActivity : BaseActivity(),
override fun setToolBar(albumViewData: AlbumViewData) {
val toolbar = findViewById<Toolbar>(R.id.toolbar_album_bar)

if (Fishton.enableEdgeToEdge) {
setupStatusBarInsets(toolbar)
}

txtAlbumMessage?.setText(R.string.msg_loading_image)
setSupportActionBar(toolbar)
toolbar.setBackgroundColor(albumViewData.colorActionBar)
toolbar.setTitleTextColor(albumViewData.colorActionBarTitle)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
this.setStatusBarColor(albumViewData.colorStatusBar)
}
this.setStatusBarColor(albumViewData.colorStatusBar)

supportActionBar?.let {
it.title = albumViewData.titleActionBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class DetailImageActivity : BaseActivity(), DetailImageContract.View, OnPageChan
Unit

private fun initView() {
setupStatusBarInsets(findViewById(R.id.root))

vpDetailPager = findViewById(R.id.vp_detail_pager)
btnDetailCount = findViewById(R.id.btn_detail_count)
btnDetailBack = findViewById(R.id.btn_detail_back)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class PickerActivity : BaseActivity(),
}
}
}

ENTER_DETAIL_REQUEST_CODE -> {
if (resultCode == Activity.RESULT_OK) {
pickerPresenter.onDetailImageActivityResult()
Expand Down Expand Up @@ -159,6 +160,7 @@ class PickerActivity : BaseActivity(),
}
}
}

PERMISSION_CAMERA -> {
if (grantResults.isNotEmpty()) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Expand Down Expand Up @@ -229,9 +231,11 @@ class PickerActivity : BaseActivity(),
R.id.action_done -> {
pickerPresenter.onClickMenuDone()
}

R.id.action_all_done -> {
pickerPresenter.onClickMenuAllDone()
}

android.R.id.home -> {
pickerPresenter.transImageFinish()
}
Expand All @@ -258,6 +262,11 @@ class PickerActivity : BaseActivity(),

override fun initToolBar(pickerViewData: PickerViewData) {
val toolbar = findViewById<Toolbar>(R.id.toolbar_picker_bar)

if (Fishton.enableEdgeToEdge) {
setupStatusBarInsets(toolbar)
}

setSupportActionBar(toolbar)
toolbar.setBackgroundColor(pickerViewData.colorActionBar)
toolbar.setTitleTextColor(pickerViewData.colorActionBarTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.util.TypedValue
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.VisibleForTesting

import com.sangcomz.fishbun.R

/**
Expand Down Expand Up @@ -106,7 +105,7 @@ class RadioWithTextButton @JvmOverloads constructor(

private fun fetchAccentColor(): Int {
val typedValue = TypedValue()
val a = context.obtainStyledAttributes(typedValue.data, intArrayOf(R.attr.colorAccent))
val a = context.obtainStyledAttributes(typedValue.data, intArrayOf(androidx.appcompat.R.attr.colorAccent))
val color = a.getColor(0, 0)
a.recycle()
return color
Expand Down
Loading
Loading