Tootsearchのサービス終了。ほか依存関係の更新やdeprecated警告の対応など
This commit is contained in:
parent
4a0b98cb56
commit
373415874c
|
@ -31,11 +31,11 @@ android {
|
|||
kotlinOptions {
|
||||
jvmTarget = jvm_target
|
||||
freeCompilerArgs += [
|
||||
"-Xopt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
"-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
"-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
// "-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
// "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
// "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
// "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
// "-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,12 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
testImplementation "junit:junit:$junit_version"
|
||||
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
androidTestImplementation 'androidx.test:runner:1.5.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
|
||||
|
||||
api project(':apng')
|
||||
// 'api' に指定した依存関係はこのライブラリの利用者に公開されます
|
||||
// 'implementation' に指定した依存関係はこのライブラリの利用者に公開されません
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ dependencies {
|
|||
|
||||
// targetSdkVersion 31 で androidTest 時に android:exported 云々で怒られる問題の対策
|
||||
// https://github.com/android/android-test/issues/1022
|
||||
androidTestImplementation "androidx.test:core:1.4.0"
|
||||
androidTestImplementation "androidx.test:core:$androidx_test_version"
|
||||
|
||||
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
|
@ -176,7 +176,7 @@ dependencies {
|
|||
kapt 'androidx.annotation:annotation:1.5.0'
|
||||
|
||||
// https://firebase.google.com/support/release-notes/android
|
||||
implementation "com.google.firebase:firebase-messaging:23.1.0"
|
||||
implementation "com.google.firebase:firebase-messaging:23.1.1"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
||||
|
@ -231,7 +231,7 @@ dependencies {
|
|||
|
||||
implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
|
||||
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.18.1'
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.18.2'
|
||||
/*
|
||||
WARNING: [Processor] Library '…\exoplayer-ui-2.12.0.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
|
||||
Example of androidX reference: 'androidx/core/app/NotificationCompat$Builder'
|
||||
|
@ -267,7 +267,7 @@ dependencies {
|
|||
// optional - Test helpers for LiveData
|
||||
testImplementation "androidx.arch.core:core-testing:$arch_version"
|
||||
|
||||
implementation 'androidx.work:work-runtime-ktx:2.8.0-beta01'
|
||||
implementation 'androidx.work:work-runtime-ktx:2.8.0-rc01'
|
||||
|
||||
def roomVersion = "2.4.3"
|
||||
implementation "androidx.room:room-runtime:$roomVersion"
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package com.bumptech.glide.load.resource.gif
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.bumptech.glide.gifdecoder.GifDecoder.TOTAL_ITERATION_COUNT_FOREVER
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import android.view.Gravity
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.gifdecoder.GifDecoder
|
||||
import com.bumptech.glide.gifdecoder.GifDecoder.TOTAL_ITERATION_COUNT_FOREVER
|
||||
import com.bumptech.glide.load.Transformation
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
||||
import com.bumptech.glide.util.Preconditions
|
||||
|
@ -349,10 +348,10 @@ class MyGifDrawable internal constructor(
|
|||
return p
|
||||
}
|
||||
|
||||
override fun getOpacity(): Int {
|
||||
// We can't tell, so default to transparent to be safe.
|
||||
return PixelFormat.TRANSPARENT
|
||||
}
|
||||
// We can't tell, so default to transparent to be safe.
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("deprecated in API level 29.")
|
||||
override fun getOpacity() = PixelFormat.TRANSPARENT
|
||||
|
||||
// See #1087.
|
||||
private fun findCallback(): Callback? {
|
||||
|
|
|
@ -61,16 +61,15 @@ class ActHighlightWordEdit
|
|||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
AlertDialog.Builder(this)
|
||||
.setCancelable(true)
|
||||
.setMessage(R.string.discard_changes)
|
||||
.setPositiveButton(R.string.no, null)
|
||||
.setNegativeButton(R.string.yes) { _, _ -> finish() }
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
backPressed{
|
||||
AlertDialog.Builder(this)
|
||||
.setCancelable(true)
|
||||
.setMessage(R.string.discard_changes)
|
||||
.setPositiveButton(R.string.no, null)
|
||||
.setNegativeButton(R.string.yes) { _, _ -> finish() }
|
||||
.show()
|
||||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
arNotificationSound.register(this)
|
||||
App1.setActivityTheme(this)
|
||||
|
|
|
@ -295,7 +295,7 @@ class ActMain : AppCompatActivity(),
|
|||
val arActText = ActivityResultHandler(log) { r ->
|
||||
when (r.resultCode) {
|
||||
ActText.RESULT_SEARCH_MSP -> searchFromActivityResult(r.data, ColumnType.SEARCH_MSP)
|
||||
ActText.RESULT_SEARCH_TS -> searchFromActivityResult(r.data, ColumnType.SEARCH_TS)
|
||||
// ActText.RESULT_SEARCH_TS -> searchFromActivityResult(r.data, ColumnType.SEARCH_TS)
|
||||
ActText.RESULT_SEARCH_NOTESTOCK -> searchFromActivityResult(
|
||||
r.data,
|
||||
ColumnType.SEARCH_NOTESTOCK
|
||||
|
@ -315,6 +315,7 @@ class ActMain : AppCompatActivity(),
|
|||
// ライフサイクルイベント
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
backPressed { onBackPressedImpl() }
|
||||
log.d("onCreate")
|
||||
super.onCreate(savedInstanceState)
|
||||
refActMain = WeakReference(this)
|
||||
|
@ -617,8 +618,6 @@ class ActMain : AppCompatActivity(),
|
|||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() = onBackPressedImpl()
|
||||
|
||||
override fun onClick(v: View) = onClickImpl(v)
|
||||
|
||||
override fun onMyClickableSpanClicked(viewClicked: View, span: MyClickableSpan) =
|
||||
|
|
|
@ -25,7 +25,7 @@ class ActText : AppCompatActivity() {
|
|||
internal val log = LogCategory("ActText")
|
||||
|
||||
internal const val RESULT_SEARCH_MSP = RESULT_FIRST_USER + 1
|
||||
internal const val RESULT_SEARCH_TS = RESULT_FIRST_USER + 2
|
||||
// internal const val RESULT_SEARCH_TS = RESULT_FIRST_USER + 2
|
||||
internal const val RESULT_SEARCH_NOTESTOCK = RESULT_FIRST_USER + 3
|
||||
|
||||
internal const val EXTRA_TEXT = "text"
|
||||
|
@ -83,7 +83,7 @@ class ActText : AppCompatActivity() {
|
|||
selection,
|
||||
)
|
||||
|
||||
R.id.btnSearchTS -> searchToot(RESULT_SEARCH_TS)
|
||||
// R.id.btnSearchTS -> searchToot(RESULT_SEARCH_TS)
|
||||
|
||||
R.id.btnSearchNotestock -> searchToot(RESULT_SEARCH_NOTESTOCK)
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.view.View
|
|||
import android.widget.TextView
|
||||
import androidx.core.view.GravityCompat
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.action.openColumnList
|
||||
import jp.juggler.subwaytooter.action.openPost
|
||||
|
@ -19,10 +17,11 @@ import jp.juggler.subwaytooter.columnviewholder.ViewHolderHeaderBase
|
|||
import jp.juggler.subwaytooter.columnviewholder.ViewHolderItem
|
||||
import jp.juggler.subwaytooter.dialog.ActionsDialog
|
||||
import jp.juggler.subwaytooter.itemviewholder.ItemViewHolder
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import jp.juggler.subwaytooter.span.MyClickableSpan
|
||||
import jp.juggler.subwaytooter.util.openCustomTab
|
||||
import jp.juggler.util.*
|
||||
import java.util.*
|
||||
|
||||
private val log = LogCategory("ActMainActions")
|
||||
|
||||
|
@ -61,22 +60,24 @@ fun ActMain.onBackPressedImpl() {
|
|||
}
|
||||
|
||||
// カラムが1個以上ある場合は設定に合わせて挙動を変える
|
||||
when (PrefI.ipBackButtonAction(pref)) {
|
||||
when (PrefI.ipBackButtonAction.invoke(pref)) {
|
||||
PrefI.BACK_EXIT_APP -> finish()
|
||||
PrefI.BACK_OPEN_COLUMN_LIST -> openColumnList()
|
||||
PrefI.BACK_CLOSE_COLUMN -> {
|
||||
val closeableColumnList = getClosableColumnList()
|
||||
when (closeableColumnList.size) {
|
||||
0 -> when {
|
||||
PrefB.bpExitAppWhenCloseProtectedColumn(pref) && PrefB.bpDontConfirmBeforeCloseColumn(pref) -> finish()
|
||||
PrefB.bpExitAppWhenCloseProtectedColumn(pref) &&
|
||||
PrefB.bpDontConfirmBeforeCloseColumn.invoke(pref) ->
|
||||
finish()
|
||||
else -> showToast(false, R.string.missing_closeable_column)
|
||||
}
|
||||
1 -> closeColumn(closeableColumnList.first())
|
||||
else -> showToast(false, R.string.cant_close_column_by_back_button_when_multiple_column_shown)
|
||||
else -> showToast(false,
|
||||
R.string.cant_close_column_by_back_button_when_multiple_column_shown)
|
||||
}
|
||||
}
|
||||
// ActAppSetting.BACK_ASK_ALWAYS
|
||||
else -> {
|
||||
else /* PrefI.BACK_ASK_ALWAYS */ -> {
|
||||
val closeableColumnList = getClosableColumnList()
|
||||
val dialog = ActionsDialog()
|
||||
if (closeableColumnList.size == 1) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package jp.juggler.subwaytooter.actmain
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.StateListDrawable
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
|
@ -382,9 +381,9 @@ class SideMenuAdapter(
|
|||
Item(icon = R.drawable.ic_search, title = R.string.mastodon_search_portal) {
|
||||
addColumn(defaultInsertPosition, SavedAccount.na, ColumnType.SEARCH_MSP, "")
|
||||
},
|
||||
Item(icon = R.drawable.ic_search, title = R.string.tootsearch) {
|
||||
addColumn(defaultInsertPosition, SavedAccount.na, ColumnType.SEARCH_TS, "")
|
||||
},
|
||||
// Item(icon = R.drawable.ic_search, title = R.string.tootsearch) {
|
||||
// addColumn(defaultInsertPosition, SavedAccount.na, ColumnType.SEARCH_TS, "")
|
||||
// },
|
||||
Item(icon = R.drawable.ic_search, title = R.string.notestock) {
|
||||
addColumn(defaultInsertPosition, SavedAccount.na, ColumnType.SEARCH_NOTESTOCK, "")
|
||||
},
|
||||
|
|
|
@ -41,6 +41,8 @@ class MediaBackgroundDrawable(
|
|||
paint.colorFilter = colorFilter
|
||||
}
|
||||
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("deprecated in API level 29.")
|
||||
override fun getOpacity() = when (paint.alpha) {
|
||||
255 -> PixelFormat.OPAQUE
|
||||
0 -> PixelFormat.TRANSPARENT
|
||||
|
|
|
@ -13,6 +13,8 @@ class PollPlotDrawable(
|
|||
override fun setAlpha(alpha: Int) {
|
||||
}
|
||||
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("deprecated in API level 29.")
|
||||
override fun getOpacity(): Int = PixelFormat.TRANSLUCENT
|
||||
|
||||
override fun setColorFilter(colorFilter: ColorFilter?) {
|
||||
|
|
|
@ -29,6 +29,8 @@ class PreviewCardBorder : Drawable() {
|
|||
canvas.drawRoundRect(left, top, right, bottom, round, round, paint)
|
||||
}
|
||||
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("deprecated in API level 29.")
|
||||
override fun getOpacity(): Int = PixelFormat.TRANSLUCENT
|
||||
|
||||
override fun setAlpha(alpha: Int) = Unit
|
||||
|
|
|
@ -84,7 +84,7 @@ class PollingWorker2(
|
|||
|
||||
workManager.enqueueUniquePeriodicWork(
|
||||
WORK_NAME,
|
||||
ExistingPeriodicWorkPolicy.REPLACE,
|
||||
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
workRequest
|
||||
).await()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package jp.juggler.subwaytooter.search
|
||||
|
||||
import jp.juggler.subwaytooter.*
|
||||
import jp.juggler.subwaytooter.column.addWithFilterStatus
|
||||
import android.content.Context
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.TootApiClient
|
||||
import jp.juggler.subwaytooter.api.TootApiResult
|
||||
import jp.juggler.subwaytooter.api.TootParser
|
||||
|
@ -10,8 +10,11 @@ import jp.juggler.subwaytooter.api.entity.ServiceType
|
|||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.column.ColumnTask_Loading
|
||||
import jp.juggler.subwaytooter.column.ColumnTask_Refresh
|
||||
import jp.juggler.util.*
|
||||
import okhttp3.Request
|
||||
import jp.juggler.subwaytooter.column.addWithFilterStatus
|
||||
import jp.juggler.util.JsonArray
|
||||
import jp.juggler.util.JsonObject
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.cast
|
||||
|
||||
object TootsearchHelper {
|
||||
|
||||
|
@ -26,21 +29,33 @@ object TootsearchHelper {
|
|||
private fun getNextId(root: JsonObject, oldSize: Int): String? =
|
||||
getHits(root)?.size?.takeIf { it > 0 }?.let { (oldSize + it) }?.toString()
|
||||
|
||||
private suspend fun TootApiClient.search(query: String, from: Int?): TootApiResult? {
|
||||
val result = TootApiResult.makeWithCaption("Tootsearch")
|
||||
if (result.error != null) return result
|
||||
if (!sendRequest(result) {
|
||||
val url = StringBuilder().apply {
|
||||
append("https://tootsearch.chotto.moe/api/v1/search?sort=")
|
||||
append("created_at:desc".encodePercent())
|
||||
append("&q=").append(query.encodePercent())
|
||||
if (from != null) append("&from=").append(from.toString())
|
||||
}.toString()
|
||||
@Suppress(
|
||||
"unused",
|
||||
"RedundantNullableReturnType",
|
||||
"RedundantSuspendModifier",
|
||||
"UNUSED_PARAMETER",
|
||||
)
|
||||
private suspend fun TootApiClient.search(
|
||||
context: Context,
|
||||
query: String,
|
||||
from: Int?,
|
||||
): TootApiResult? {
|
||||
return TootApiResult("Tootsearch discontinued service on 2022/12/25.")
|
||||
|
||||
Request.Builder().url(url).build()
|
||||
}) return result
|
||||
|
||||
return parseJson(result)
|
||||
// val result = TootApiResult.makeWithCaption("Tootsearch")
|
||||
// if (result.error != null) return result
|
||||
// if (!sendRequest(result) {
|
||||
// val url = StringBuilder().apply {
|
||||
// append("https://tootsearch.chotto.moe/api/v1/search?sort=")
|
||||
// append("created_at:desc".encodePercent())
|
||||
// append("&q=").append(query.encodePercent())
|
||||
// if (from != null) append("&from=").append(from.toString())
|
||||
// }.toString()
|
||||
//
|
||||
// Request.Builder().url(url).build()
|
||||
// }) return result
|
||||
//
|
||||
// return parseJson(result)
|
||||
}
|
||||
|
||||
private fun parseList(parser: TootParser, root: JsonObject) =
|
||||
|
@ -66,7 +81,11 @@ object TootsearchHelper {
|
|||
listTmp = java.util.ArrayList()
|
||||
TootApiResult()
|
||||
} else {
|
||||
client.search(column.searchQuery, null)?.also { result ->
|
||||
client.search(
|
||||
context = context,
|
||||
query = column.searchQuery,
|
||||
from = null
|
||||
)?.also { result ->
|
||||
result.jsonObject?.let { root ->
|
||||
column.idOld = EntityId.mayNull(getNextId(root, 0))
|
||||
listTmp = addWithFilterStatus(
|
||||
|
@ -92,7 +111,11 @@ object TootsearchHelper {
|
|||
listTmp = ArrayList()
|
||||
TootApiResult(context.getString(R.string.end_of_list))
|
||||
} else {
|
||||
client.search(q, oldSize)?.also { result ->
|
||||
client.search(
|
||||
context = context,
|
||||
query = q,
|
||||
from = oldSize,
|
||||
)?.also { result ->
|
||||
result.jsonObject?.let { root ->
|
||||
column.idOld = EntityId.mayNull(getNextId(root, oldSize))
|
||||
listTmp = addWithFilterStatus(listTmp, parseList(parser, root))
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
android:title="@string/search_web"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/btnSearchTS"
|
||||
android:title="@string/toot_search_ts"
|
||||
app:showAsAction="never" />
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/btnSearchTS"-->
|
||||
<!-- android:title="@string/toot_search_ts"-->
|
||||
<!-- app:showAsAction="never" />-->
|
||||
|
||||
<item
|
||||
android:id="@+id/btnSearchNotestock"
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
ext.min_sdk_version = 26
|
||||
ext.target_sdk_version = 32
|
||||
ext.compile_sdk_version = 33
|
||||
ext.build_tools_version = "33.0.0"
|
||||
ext.build_tools_version = "33.0.1"
|
||||
|
||||
ext.appcompat_version = "1.5.1"
|
||||
ext.lifecycle_version = "2.5.1"
|
||||
|
@ -24,6 +24,8 @@ buildscript {
|
|||
|
||||
ext.koin_version = '3.1.3'
|
||||
|
||||
ext.androidx_test_version = '1.5.0'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
|
|
@ -26,11 +26,11 @@ android {
|
|||
kotlinOptions {
|
||||
jvmTarget = jvm_target
|
||||
freeCompilerArgs += [
|
||||
"-Xopt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
"-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
"-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
//"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
//"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
//"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ dependencies {
|
|||
|
||||
testImplementation "junit:junit:$junit_version"
|
||||
|
||||
androidTestImplementation "androidx.test:core:1.4.0"
|
||||
androidTestImplementation "androidx.test:core:$androidx_test_version"
|
||||
|
||||
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
|
|
|
@ -132,7 +132,7 @@ class ColorPanelView @JvmOverloads constructor(
|
|||
public override fun onRestoreInstanceState(state: Parcelable) {
|
||||
if (state is Bundle) {
|
||||
color = state.getInt("color")
|
||||
super.onRestoreInstanceState(state.getParcelable("instanceState"))
|
||||
super.onRestoreInstanceState(state.getParcelableCompat("instanceState"))
|
||||
} else {
|
||||
super.onRestoreInstanceState(state)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import kotlin.math.min
|
|||
class ColorPickerView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0
|
||||
defStyle: Int = 0,
|
||||
) : View(context, attrs, defStyle) {
|
||||
|
||||
companion object {
|
||||
|
@ -215,7 +215,6 @@ class ColorPickerView @JvmOverloads constructor(
|
|||
*/
|
||||
var onColorChangedListener: OnColorChangedListener? = null
|
||||
|
||||
|
||||
public override fun onSaveInstanceState(): Parcelable {
|
||||
val state = Bundle()
|
||||
state.putParcelable("instanceState", super.onSaveInstanceState())
|
||||
|
@ -228,19 +227,18 @@ class ColorPickerView @JvmOverloads constructor(
|
|||
return state
|
||||
}
|
||||
|
||||
public override fun onRestoreInstanceState(stateArg: Parcelable) {
|
||||
var state: Parcelable? = stateArg
|
||||
public override fun onRestoreInstanceState(state: Parcelable) {
|
||||
if (state is Bundle) {
|
||||
val bundle = state
|
||||
alpha = bundle.getInt("alpha")
|
||||
hue = bundle.getFloat("hue")
|
||||
sat = bundle.getFloat("sat")
|
||||
bri = bundle.getFloat("val")
|
||||
showAlphaPanel = bundle.getBoolean("show_alpha")
|
||||
alphaSliderText = bundle.getString("alpha_text")
|
||||
state = bundle.getParcelable("instanceState")
|
||||
alpha = state.getInt("alpha")
|
||||
hue = state.getFloat("hue")
|
||||
sat = state.getFloat("sat")
|
||||
bri = state.getFloat("val")
|
||||
showAlphaPanel = state.getBoolean("show_alpha")
|
||||
alphaSliderText = state.getString("alpha_text")
|
||||
super.onRestoreInstanceState(state.getParcelableCompat("instanceState"))
|
||||
} else {
|
||||
super.onRestoreInstanceState(state)
|
||||
}
|
||||
super.onRestoreInstanceState(state)
|
||||
}
|
||||
|
||||
init {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.jrummyapps.android.colorpicker
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
|
||||
inline fun <reified T : Parcelable> Bundle.getParcelableCompat(key: String) =
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
getParcelable(key, T::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
getParcelable(key)
|
||||
}
|
|
@ -16,7 +16,6 @@ android {
|
|||
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
|
@ -29,15 +28,5 @@ android {
|
|||
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm_target
|
||||
freeCompilerArgs += [
|
||||
"-Xopt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
"-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
"-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ android {
|
|||
kotlinOptions {
|
||||
jvmTarget = jvm_target
|
||||
freeCompilerArgs += [
|
||||
"-Xopt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
// "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
// "-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
// "-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
|
@ -56,8 +56,8 @@ dependencies {
|
|||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||
|
||||
testImplementation "junit:junit:$junit_version"
|
||||
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
androidTestImplementation 'androidx.test:runner:1.5.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
|
||||
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_version"
|
||||
|
|
Loading…
Reference in New Issue