mirror of
https://github.com/fcitx5-android/fcitx5-android.git
synced 2026-08-02 04:44:35 +08:00
Migrate off deprecated androidx.core.os.bundleOf
This commit is contained in:
parent
134880d267
commit
306fdaef77
@ -23,7 +23,6 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
@ -60,7 +59,7 @@ class CropImageActivity : AppCompatActivity() {
|
||||
const val CROP_RESULT = "crop_result"
|
||||
}
|
||||
|
||||
sealed class CropOption() : Parcelable {
|
||||
sealed class CropOption : Parcelable {
|
||||
abstract val width: Int
|
||||
abstract val height: Int
|
||||
|
||||
@ -247,7 +246,7 @@ class CropImageActivity : AppCompatActivity() {
|
||||
file = tempOutFile,
|
||||
srcUri = sourceImageUri
|
||||
)
|
||||
setResult(RESULT_OK, Intent().putExtras(bundleOf(CROP_RESULT to success)))
|
||||
setResult(RESULT_OK, Intent().putExtra(CROP_RESULT, success))
|
||||
} catch (e: Exception) {
|
||||
tempOutFile.delete()
|
||||
Timber.e("Exception when cropping image: ${e.stackTraceToString()}")
|
||||
|
||||
@ -9,7 +9,6 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import org.fcitx.fcitx5.android.core.Key
|
||||
@ -156,7 +155,10 @@ class ListFragment : Fragment() {
|
||||
|
||||
override fun onDestroy() {
|
||||
val items = Array(ui.entries.size) { RawConfig("$it", ui.entries[it]!!.toString()) }
|
||||
parentFragmentManager.setFragmentResult(descriptor.name, bundleOf(descriptor.name to items))
|
||||
parentFragmentManager.setFragmentResult(
|
||||
descriptor.name,
|
||||
Bundle().apply { putParcelableArray(descriptor.name, items) }
|
||||
)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
package org.fcitx.fcitx5.android.ui.main.settings
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
@ -151,7 +151,9 @@ class QuickPhraseEditFragment : ProgressFragment(), OnItemChangedListener<QuickP
|
||||
quickPhrase.saveData(QuickPhraseData(ui.entries))
|
||||
launch(Dispatchers.Main) {
|
||||
// tell parent that we need to reload
|
||||
parentFragmentManager.setFragmentResult(RESULT, bundleOf(RESULT to quickPhrase))
|
||||
parentFragmentManager.setFragmentResult(
|
||||
RESULT,
|
||||
Bundle().apply { putParcelable(RESULT, quickPhrase) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@ import android.widget.Button
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
@ -54,12 +53,12 @@ class SetupActivity : FragmentActivity() {
|
||||
}
|
||||
prevButton = binding.prevButton.apply {
|
||||
text = getString(R.string.prev)
|
||||
setOnClickListener { viewPager.currentItem = viewPager.currentItem - 1 }
|
||||
setOnClickListener { viewPager.currentItem -= 1 }
|
||||
}
|
||||
nextButton = binding.nextButton.apply {
|
||||
setOnClickListener {
|
||||
if (viewPager.currentItem != SetupPage.entries.size - 1)
|
||||
viewPager.currentItem = viewPager.currentItem + 1
|
||||
viewPager.currentItem += 1
|
||||
else finish()
|
||||
}
|
||||
}
|
||||
@ -143,7 +142,9 @@ class SetupActivity : FragmentActivity() {
|
||||
|
||||
override fun createFragment(position: Int): Fragment =
|
||||
SetupFragment().apply {
|
||||
arguments = bundleOf(SetupFragment.PAGE to SetupPage.valueOf(position))
|
||||
arguments = Bundle().apply {
|
||||
putSerializable(SetupFragment.PAGE, SetupPage.valueOf(position))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* SPDX-FileCopyrightText: Copyright 2024 Fcitx5 for Android Contributors
|
||||
* SPDX-FileCopyrightText: Copyright 2024-2026 Fcitx5 for Android Contributors
|
||||
*/
|
||||
|
||||
package org.fcitx.fcitx5.android.utils
|
||||
@ -9,8 +9,13 @@ import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import android.provider.OpenableColumns
|
||||
|
||||
fun ContentResolver.queryFileName(uri: Uri): String? = query(uri, null, null, null, null)?.use {
|
||||
val index = it.getColumnIndex(OpenableColumns.DISPLAY_NAME)
|
||||
it.moveToFirst()
|
||||
it.getString(index)
|
||||
}
|
||||
/**
|
||||
* Query file display name for uri
|
||||
*
|
||||
* ref: [androidx.documentfile](https://github.com/androidx/androidx/blob/8e30346c2bb3b53a3bd45e9a56f3344d98f2356f/documentfile/documentfile/src/main/java/androidx/documentfile/provider/DocumentsContractApi19.java#L150)
|
||||
* @see android.provider.DocumentsContract.Document#COLUMN_DISPLAY_NAME
|
||||
*/
|
||||
fun ContentResolver.queryFileName(uri: Uri): String? =
|
||||
query(uri, arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null)?.use {
|
||||
if (it.moveToFirst() && !it.isNull(0)) it.getString(0) else null
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user