API変更に追従
This commit is contained in:
parent
d83dab789f
commit
27f15c9760
|
@ -146,7 +146,7 @@ dependencies {
|
|||
|
||||
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
||||
|
||||
implementation "androidx.core:core-ktx:1.8.0"
|
||||
implementation "androidx.core:core-ktx:1.9.0"
|
||||
|
||||
def emoji2Version = "1.2.0"
|
||||
implementation "androidx.emoji2:emoji2:$emoji2Version"
|
||||
|
@ -171,7 +171,7 @@ dependencies {
|
|||
kapt 'androidx.annotation:annotation:1.4.0'
|
||||
|
||||
// https://firebase.google.com/support/release-notes/android
|
||||
implementation "com.google.firebase:firebase-messaging:23.0.7"
|
||||
implementation "com.google.firebase:firebase-messaging:23.0.8"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
||||
|
|
|
@ -2,7 +2,6 @@ package jp.juggler.subwaytooter
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.widget.Button
|
||||
|
@ -12,6 +11,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.appcompat.widget.AppCompatButton
|
||||
import jp.juggler.subwaytooter.util.openBrowser
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.getPackageInfoCompat
|
||||
|
||||
class ActAbout : AppCompatActivity() {
|
||||
|
||||
|
@ -79,11 +79,12 @@ class ActAbout : AppCompatActivity() {
|
|||
Styler.fixHorizontalPadding(findViewById(R.id.svContent))
|
||||
|
||||
try {
|
||||
val pInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
val tv = findViewById<TextView>(R.id.tvVersion)
|
||||
tv.text = getString(R.string.version_is, pInfo.versionName)
|
||||
} catch (ex: PackageManager.NameNotFoundException) {
|
||||
log.trace(ex, "getPackageInfo failed.")
|
||||
packageManager.getPackageInfoCompat(packageName)?.let { pInfo ->
|
||||
findViewById<TextView>(R.id.tvVersion)
|
||||
?.text = getString(R.string.version_is, pInfo.versionName)
|
||||
}
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex, "can't get app version.")
|
||||
}
|
||||
|
||||
fun setButton(btnId: Int, caption: String, onClick: () -> Unit) {
|
||||
|
|
|
@ -193,6 +193,11 @@ class ActAccountSetting : AppCompatActivity(),
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
checkNotificationImmediateAll(this, onlySubscription = true)
|
||||
checkNotificationImmediate(this, account.db_id)
|
||||
finish()
|
||||
}
|
||||
|
||||
prPickAvater.register(this)
|
||||
prPickHeader.register(this)
|
||||
|
@ -234,12 +239,7 @@ class ActAccountSetting : AppCompatActivity(),
|
|||
outState.putString(ACTIVITY_STATE, encodedState)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
|
||||
checkNotificationImmediateAll(this, onlySubscription = true)
|
||||
checkNotificationImmediate(this, account.db_id)
|
||||
}
|
||||
|
||||
var density: Float = 1f
|
||||
|
||||
|
|
|
@ -110,6 +110,13 @@ class ActAppSetting : AppCompatActivity(), ColorPickerDialogListener, View.OnCli
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
when {
|
||||
lastQuery != null -> load(lastSection, null)
|
||||
lastSection != null -> load(null, null)
|
||||
else -> finish()
|
||||
}
|
||||
}
|
||||
|
||||
arNoop.register(this)
|
||||
arImportAppData.register(this)
|
||||
|
@ -204,14 +211,6 @@ class ActAppSetting : AppCompatActivity(), ColorPickerDialogListener, View.OnCli
|
|||
restartAllWorker(context = this)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
when {
|
||||
lastQuery != null -> load(lastSection, null)
|
||||
lastSection != null -> load(null, null)
|
||||
else -> super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
when (v.id) {
|
||||
R.id.btnSearchReset -> {
|
||||
|
|
|
@ -5,9 +5,7 @@ import android.net.Uri
|
|||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.FileProvider
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.digestSHA256Hex
|
||||
import jp.juggler.util.showToast
|
||||
import jp.juggler.util.*
|
||||
import okhttp3.internal.toHexString
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
@ -135,26 +133,22 @@ class ActCallback : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
} else if (Intent.ACTION_SEND == action) {
|
||||
var uri: Uri? = src.getParcelableExtra(Intent.EXTRA_STREAM)
|
||||
if (uri == null) {
|
||||
// text/plain
|
||||
return src
|
||||
} else {
|
||||
try {
|
||||
uri = saveToCache(uri)
|
||||
var uri = src.getStreamUriExtra()
|
||||
?: return src // text/plainの場合
|
||||
try {
|
||||
uri = saveToCache(uri)
|
||||
|
||||
val dst = Intent(action)
|
||||
dst.type = type
|
||||
dst.putExtra(Intent.EXTRA_STREAM, uri)
|
||||
copyExtraTexts(dst, src)
|
||||
return dst
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex)
|
||||
}
|
||||
val dst = Intent(action)
|
||||
dst.type = type
|
||||
dst.putExtra(Intent.EXTRA_STREAM, uri)
|
||||
copyExtraTexts(dst, src)
|
||||
return dst
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex)
|
||||
}
|
||||
} else if (Intent.ACTION_SEND_MULTIPLE == action) {
|
||||
val listUri =
|
||||
src.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM) ?: return null
|
||||
val listUri = src.getStreamUriListExtra()
|
||||
?: return null
|
||||
val listDst = ArrayList<Uri>()
|
||||
for (uriOriginal in listUri) {
|
||||
if (uriOriginal != null) {
|
||||
|
|
|
@ -77,11 +77,6 @@ class ActColumnCustomize : AppCompatActivity(), View.OnClickListener, ColorPicke
|
|||
?.firstOrNull()?.uri?.let { updateBackground(it) }
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
makeResult()
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun makeResult() {
|
||||
val data = Intent()
|
||||
data.putExtra(EXTRA_COLUMN_INDEX, columnIndex)
|
||||
|
@ -90,6 +85,10 @@ class ActColumnCustomize : AppCompatActivity(), View.OnClickListener, ColorPicke
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
makeResult()
|
||||
finish()
|
||||
}
|
||||
arColumnBackgroundImage.register(this)
|
||||
App1.setActivityTheme(this)
|
||||
initUI()
|
||||
|
|
|
@ -18,7 +18,6 @@ import jp.juggler.subwaytooter.api.entity.Acct
|
|||
import jp.juggler.subwaytooter.column.ColumnEncoder
|
||||
import jp.juggler.subwaytooter.column.ColumnType
|
||||
import jp.juggler.util.*
|
||||
import java.util.*
|
||||
|
||||
class ActColumnList : AppCompatActivity() {
|
||||
|
||||
|
@ -44,6 +43,10 @@ class ActColumnList : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
makeResult(-1)
|
||||
finish()
|
||||
}
|
||||
App1.setActivityTheme(this)
|
||||
initUI()
|
||||
|
||||
|
@ -64,11 +67,6 @@ class ActColumnList : AppCompatActivity() {
|
|||
AppState.saveColumnList(this, TMP_FILE_COLUMN_LIST, array)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
makeResult(-1)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun initUI() {
|
||||
setContentView(R.layout.act_column_list)
|
||||
App1.initEdgeToEdge(this)
|
||||
|
|
|
@ -2,27 +2,24 @@ package jp.juggler.subwaytooter
|
|||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.woxthebox.draglistview.DragItem
|
||||
import com.woxthebox.draglistview.DragItemAdapter
|
||||
import com.woxthebox.draglistview.DragListView
|
||||
import com.woxthebox.draglistview.swipe.ListSwipeHelper
|
||||
import com.woxthebox.draglistview.swipe.ListSwipeItem
|
||||
import jp.juggler.subwaytooter.api.entity.Acct
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
import jp.juggler.subwaytooter.table.FavMute
|
||||
import jp.juggler.util.*
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.backPressed
|
||||
import jp.juggler.util.attrColor
|
||||
|
||||
class ActFavMute : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
private val log = LogCategory("ActFavMute")
|
||||
}
|
||||
|
||||
|
@ -32,15 +29,14 @@ class ActFavMute : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
App1.setActivityTheme(this)
|
||||
backPressed {
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
initUI()
|
||||
loadData()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(RESULT_OK)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun initUI() {
|
||||
setContentView(R.layout.act_word_list)
|
||||
App1.initEdgeToEdge(this)
|
||||
|
|
|
@ -127,6 +127,17 @@ class ActLanguageFilter : AppCompatActivity(), View.OnClickListener {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
if (equalsLanguageList(column.languageFilter, encodeLanguageList())) {
|
||||
finish()
|
||||
} else {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(R.string.language_filter_quit_waring)
|
||||
.setPositiveButton(R.string.ok) { _, _ -> finish() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
arExport.register(this)
|
||||
arImport.register(this)
|
||||
|
||||
|
@ -158,19 +169,6 @@ class ActLanguageFilter : AppCompatActivity(), View.OnClickListener {
|
|||
outState.putString(STATE_LANGUAGE_LIST, encodeLanguageList().toString())
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (!equalsLanguageList(column.languageFilter, encodeLanguageList())) {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(R.string.language_filter_quit_waring)
|
||||
.setPositiveButton(R.string.ok) { _, _ -> finish() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show()
|
||||
return
|
||||
}
|
||||
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun initUI() {
|
||||
setContentView(R.layout.act_language_filter)
|
||||
App1.initEdgeToEdge(this)
|
||||
|
|
|
@ -13,8 +13,8 @@ import com.woxthebox.draglistview.swipe.ListSwipeHelper
|
|||
import com.woxthebox.draglistview.swipe.ListSwipeItem
|
||||
import jp.juggler.subwaytooter.table.MutedApp
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.backPressed
|
||||
import jp.juggler.util.attrColor
|
||||
import java.util.*
|
||||
|
||||
class ActMutedApp : AppCompatActivity() {
|
||||
|
||||
|
@ -28,16 +28,15 @@ class ActMutedApp : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
App1.setActivityTheme(this)
|
||||
initUI()
|
||||
loadData()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(RESULT_OK)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun initUI() {
|
||||
setContentView(R.layout.act_word_list)
|
||||
App1.initEdgeToEdge(this)
|
||||
|
|
|
@ -13,8 +13,8 @@ import com.woxthebox.draglistview.swipe.ListSwipeHelper
|
|||
import com.woxthebox.draglistview.swipe.ListSwipeItem
|
||||
import jp.juggler.subwaytooter.table.UserRelation
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.backPressed
|
||||
import jp.juggler.util.attrColor
|
||||
import java.util.*
|
||||
|
||||
class ActMutedPseudoAccount : AppCompatActivity() {
|
||||
|
||||
|
@ -27,16 +27,15 @@ class ActMutedPseudoAccount : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
App1.setActivityTheme(this)
|
||||
initUI()
|
||||
loadData()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(RESULT_OK)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun initUI() {
|
||||
setContentView(R.layout.act_word_list)
|
||||
App1.initEdgeToEdge(this)
|
||||
|
|
|
@ -13,8 +13,8 @@ import com.woxthebox.draglistview.swipe.ListSwipeHelper
|
|||
import com.woxthebox.draglistview.swipe.ListSwipeItem
|
||||
import jp.juggler.subwaytooter.table.MutedWord
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.backPressed
|
||||
import jp.juggler.util.attrColor
|
||||
import java.util.*
|
||||
|
||||
class ActMutedWord : AppCompatActivity() {
|
||||
|
||||
|
@ -27,16 +27,15 @@ class ActMutedWord : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
App1.setActivityTheme(this)
|
||||
initUI()
|
||||
loadData()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(RESULT_OK)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun initUI() {
|
||||
setContentView(R.layout.act_word_list)
|
||||
App1.initEdgeToEdge(this)
|
||||
|
|
|
@ -56,13 +56,12 @@ class ActNickname : AppCompatActivity(), View.OnClickListener, ColorPickerDialog
|
|||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(RESULT_OK)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
arNotificationSound.register(this)
|
||||
App1.setActivityTheme(this)
|
||||
|
||||
|
|
|
@ -162,6 +162,12 @@ class ActPost : AppCompatActivity(),
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
backPressed {
|
||||
finish()
|
||||
// 戻るボタンを押したときとonPauseで2回保存することになるが、
|
||||
// 同じ内容はDB上は重複しないはず…
|
||||
saveDraft()
|
||||
}
|
||||
if (isMultiWindowPost) ActMain.refActMain?.get()?.closeList?.add(WeakReference(this))
|
||||
App1.setActivityTheme(this, noActionBar = true)
|
||||
appState = App1.getAppState(this)
|
||||
|
@ -237,12 +243,6 @@ class ActPost : AppCompatActivity(),
|
|||
if (!isPostComplete) saveDraft()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
// 戻るボタンを押したときとonPauseで2回保存することになるが、
|
||||
// 同じ内容はDB上は重複しないはず…
|
||||
saveDraft()
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
refActPost = WeakReference(this)
|
||||
|
|
|
@ -115,7 +115,7 @@ fun ActMain.handleOtherUri(uri: Uri): Boolean {
|
|||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
|
||||
val myName = packageName
|
||||
val resolveInfoList = packageManager.queryIntentActivities(intent, queryFlag)
|
||||
val resolveInfoList = packageManager.queryIntentActivitiesCompat(intent, queryFlag)
|
||||
.filter { myName != it.activityInfo.packageName }
|
||||
|
||||
if (resolveInfoList.isEmpty()) error("resolveInfoList is empty.")
|
||||
|
|
|
@ -97,8 +97,8 @@ class SideMenuAdapter(
|
|||
// メインスレッドでもそれ以外でも動作すること
|
||||
private fun Context.createVersionRow() = SpannableStringBuilder().apply {
|
||||
val currentVersion = try {
|
||||
packageManager.getPackageInfo(packageName, 0).versionName
|
||||
} catch (ignored: PackageManager.NameNotFoundException) {
|
||||
packageManager.getPackageInfoCompat(packageName)!!.versionName
|
||||
} catch (ignored: Throwable) {
|
||||
"??"
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,8 @@ fun ActPost.updateText(
|
|||
accountList.find { it.db_id == accountDbId }?.let { selectAccount(it) }
|
||||
}
|
||||
|
||||
val sharedIntent = intent.getParcelableExtra<Intent>(ActPost.KEY_SHARED_INTENT)
|
||||
val sharedIntent = intent.getIntentExtra(ActPost.KEY_SHARED_INTENT)
|
||||
|
||||
if (sharedIntent != null) {
|
||||
initializeFromSharedIntent(sharedIntent)
|
||||
}
|
||||
|
@ -230,7 +231,7 @@ fun ActPost.initializeFromSharedIntent(sharedIntent: Intent) {
|
|||
}
|
||||
|
||||
Intent.ACTION_SEND -> {
|
||||
val uri = sharedIntent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
|
||||
val uri = sharedIntent.getStreamUriExtra()
|
||||
val type = sharedIntent.type
|
||||
if (uri != null) {
|
||||
addAttachment(uri, type)
|
||||
|
@ -241,8 +242,7 @@ fun ActPost.initializeFromSharedIntent(sharedIntent: Intent) {
|
|||
}
|
||||
|
||||
Intent.ACTION_SEND_MULTIPLE -> {
|
||||
val listUri =
|
||||
sharedIntent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)
|
||||
val listUri = sharedIntent.getStreamUriListExtra()
|
||||
?.filterNotNull()
|
||||
if (listUri?.isNotEmpty() == true) {
|
||||
for (uri in listUri) {
|
||||
|
|
|
@ -23,36 +23,24 @@ private class ErrorFlickListener(
|
|||
val density = cvh.activity.resources.displayMetrics.density
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
||||
return gd.onTouchEvent(event)
|
||||
}
|
||||
override fun onTouch(v: View?, event: MotionEvent?) =
|
||||
event?.let { gd.onTouchEvent(it) } ?: false
|
||||
|
||||
override fun onShowPress(e: MotionEvent?) {
|
||||
}
|
||||
|
||||
override fun onLongPress(e: MotionEvent?) {
|
||||
}
|
||||
|
||||
override fun onSingleTapUp(e: MotionEvent?): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDown(e: MotionEvent?): Boolean {
|
||||
return true
|
||||
}
|
||||
override fun onShowPress(e: MotionEvent) = Unit
|
||||
override fun onLongPress(e: MotionEvent) = Unit
|
||||
override fun onSingleTapUp(e: MotionEvent) = true
|
||||
override fun onDown(e: MotionEvent) = true
|
||||
|
||||
override fun onScroll(
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent?,
|
||||
e1: MotionEvent,
|
||||
e2: MotionEvent,
|
||||
distanceX: Float,
|
||||
distanceY: Float,
|
||||
): Boolean {
|
||||
return true
|
||||
}
|
||||
) = true
|
||||
|
||||
override fun onFling(
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent?,
|
||||
e1: MotionEvent,
|
||||
e2: MotionEvent,
|
||||
velocityX: Float,
|
||||
velocityY: Float,
|
||||
): Boolean {
|
||||
|
@ -83,16 +71,11 @@ private class AdapterItemHeightWorkarea(
|
|||
val adapter: ItemListAdapter,
|
||||
) : Closeable {
|
||||
|
||||
private val itemWidth: Int
|
||||
private val widthSpec: Int
|
||||
private val itemWidth = listView.width - listView.paddingLeft - listView.paddingRight
|
||||
private val widthSpec = View.MeasureSpec.makeMeasureSpec(itemWidth, View.MeasureSpec.EXACTLY)
|
||||
var lastViewType: Int = -1
|
||||
var lastViewHolder: RecyclerView.ViewHolder? = null
|
||||
|
||||
init {
|
||||
this.itemWidth = listView.width - listView.paddingLeft - listView.paddingRight
|
||||
this.widthSpec = View.MeasureSpec.makeMeasureSpec(itemWidth, View.MeasureSpec.EXACTLY)
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
val childViewHolder = lastViewHolder
|
||||
if (childViewHolder != null) {
|
||||
|
|
|
@ -38,10 +38,7 @@ class DlgAppPicker(
|
|||
val list = ArrayList<ListItem>().apply {
|
||||
|
||||
val pm = activity.packageManager
|
||||
val listResolveInfo = pm.queryIntentActivities(
|
||||
intent,
|
||||
PackageManager.MATCH_ALL,
|
||||
)
|
||||
val listResolveInfo = pm.queryIntentActivitiesCompat(intent, PackageManager.MATCH_ALL)
|
||||
|
||||
for (it in listResolveInfo) {
|
||||
if (!filter(it)) continue
|
||||
|
|
|
@ -8,10 +8,7 @@ import jp.juggler.subwaytooter.R
|
|||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.attrColor
|
||||
import jp.juggler.util.showToast
|
||||
import jp.juggler.util.systemService
|
||||
import jp.juggler.util.*
|
||||
|
||||
enum class CustomShareTarget {
|
||||
Translate,
|
||||
|
@ -74,7 +71,7 @@ object CustomShare {
|
|||
}
|
||||
} else {
|
||||
val pm = context.packageManager
|
||||
val ri = pm.resolveActivity(Intent().apply { component = cn }, 0)
|
||||
val ri = pm.resolveActivityCompat(Intent().apply { component = cn })
|
||||
if (ri != null) {
|
||||
try {
|
||||
label = ri.loadLabel(pm)
|
||||
|
@ -192,7 +189,8 @@ fun String.cn(): ComponentName? {
|
|||
|
||||
fun ComponentName.exists(context: Context): Boolean {
|
||||
return try {
|
||||
context.packageManager.resolveActivity(Intent().apply { component = this@exists }, 0)
|
||||
@Suppress("DEPRECATION")
|
||||
context.packageManager.resolveActivityCompat(Intent().apply { component = this@exists })
|
||||
?.activityInfo?.exported ?: false
|
||||
} catch (_: Throwable) {
|
||||
false
|
||||
|
|
|
@ -1,16 +1,53 @@
|
|||
package jp.juggler.util
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.PackageManager.PackageInfoFlags
|
||||
import android.content.pm.PackageManager.ResolveInfoFlags
|
||||
import android.content.pm.ResolveInfo
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
/**
|
||||
* API 33 で Bundle.get() が deprecatedになる。
|
||||
* type safeにするべきだが、過去の使い方にもよるかな…
|
||||
*/
|
||||
fun Bundle.getRaw(key: String) = get(key)
|
||||
private fun Bundle.getRaw(key: String) =
|
||||
@Suppress("DEPRECATION")
|
||||
get(key)
|
||||
|
||||
fun Intent.getUriExtra(key: String) =
|
||||
extras?.getRaw(key) as? Uri
|
||||
|
||||
fun Intent.getStreamUriExtra() =
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
getParcelableExtra(Intent.EXTRA_STREAM, Uri::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
getParcelableExtra(Intent.EXTRA_STREAM) as? Uri?
|
||||
}
|
||||
|
||||
fun Intent.getStreamUriListExtra() =
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
getParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
getParcelableArrayListExtra(Intent.EXTRA_STREAM)
|
||||
}
|
||||
|
||||
fun Intent.getIntentExtra(key: String) =
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
getParcelableExtra(key, Intent::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
getParcelableExtra(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Ringtone pickerの処理結果のUriまたはnull
|
||||
|
@ -18,7 +55,7 @@ fun Bundle.getRaw(key: String) = get(key)
|
|||
fun ActivityResult.decodeRingtonePickerResult() =
|
||||
when {
|
||||
isNotOk -> null
|
||||
else -> data?.extras?.getRaw(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) as? Uri
|
||||
else -> data?.getUriExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +74,6 @@ fun Bundle.int(key: String) =
|
|||
*/
|
||||
fun Bundle.long(key: String) =
|
||||
when (val v = getRaw(key)) {
|
||||
null -> null
|
||||
is Number -> v.toLong()
|
||||
is String -> v.toLongOrNull()
|
||||
else -> null
|
||||
|
@ -52,3 +88,39 @@ fun Intent.int(key: String) = extras?.int(key)
|
|||
* IntentのExtrasからキーを指定してlong値またはnullを得る
|
||||
*/
|
||||
fun Intent.long(key: String) = extras?.long(key)
|
||||
|
||||
fun PackageManager.getPackageInfoCompat(
|
||||
pakageName: String,
|
||||
flags: Int = 0,
|
||||
): PackageInfo? = if (Build.VERSION.SDK_INT >= 33) {
|
||||
getPackageInfo(pakageName, PackageInfoFlags.of(flags.toLong()))
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
getPackageInfo(pakageName, flags)
|
||||
}
|
||||
|
||||
fun PackageManager.queryIntentActivitiesCompat(
|
||||
intent: Intent,
|
||||
queryFlag: Int = 0,
|
||||
): List<ResolveInfo> = if (Build.VERSION.SDK_INT >= 33) {
|
||||
queryIntentActivities(intent, ResolveInfoFlags.of(queryFlag.toLong()))
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
queryIntentActivities(intent, queryFlag)
|
||||
}
|
||||
|
||||
fun PackageManager.resolveActivityCompat(
|
||||
intent: Intent,
|
||||
queryFlag: Int = 0,
|
||||
): ResolveInfo? = if (Build.VERSION.SDK_INT >= 33) {
|
||||
resolveActivity(intent, ResolveInfoFlags.of(queryFlag.toLong()))
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
resolveActivity(intent, queryFlag)
|
||||
}
|
||||
|
||||
fun AppCompatActivity.backPressed(block: () -> Unit) {
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() = block()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ buildscript {
|
|||
|
||||
ext.min_sdk_version = 26
|
||||
ext.target_sdk_version = 32
|
||||
ext.compile_sdk_version = 32
|
||||
ext.compile_sdk_version = 33
|
||||
ext.build_tools_version = "33.0.0"
|
||||
|
||||
ext.appcompat_version = "1.5.0"
|
||||
|
|
Loading…
Reference in New Issue