Skip to content

Fix new UseKtx lint warnings in AGP 8.9.0-alpha09 #3346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package org.mozilla.reference.browser

import android.content.Intent
import android.net.Uri
import androidx.core.net.toUri
import mozilla.components.lib.crash.CrashReporter
import mozilla.components.lib.crash.ui.AbstractCrashListActivity
import org.mozilla.reference.browser.ext.components
Expand All @@ -15,7 +15,7 @@ class CrashListActivity : AbstractCrashListActivity() {

override fun onCrashServiceSelected(url: String) {
val intent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(url)
data = url.toUri()
`package` = packageName
}
startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package org.mozilla.reference.browser

import android.net.Uri
import androidx.core.net.toUri
import androidx.fragment.app.Fragment
import mozilla.components.concept.engine.manifest.WebAppManifest
import mozilla.components.feature.pwa.ext.getWebAppManifest
Expand All @@ -21,7 +21,7 @@ class ExternalAppBrowserActivity : BrowserActivity() {
val scope = when (manifest?.display) {
WebAppManifest.DisplayMode.FULLSCREEN,
WebAppManifest.DisplayMode.STANDALONE,
-> Uri.parse(manifest.scope ?: manifest.startUrl)
-> (manifest.scope ?: manifest.startUrl).toUri()

WebAppManifest.DisplayMode.MINIMAL_UI,
WebAppManifest.DisplayMode.BROWSER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.edit
import androidx.core.net.toUri
import androidx.preference.PreferenceManager
import mozilla.components.concept.sync.Device
import mozilla.components.concept.sync.TabData
Expand Down Expand Up @@ -53,7 +54,7 @@ object NotificationManager {
logger.debug("Showing ${tabs.size} tab(s) received from deviceID=${device?.id}")

tabs.forEach { tab ->
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(tab.url)).apply {
val intent = Intent(Intent.ACTION_VIEW, tab.url.toUri()).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val flags = if (SDK_INT >= Build.VERSION_CODES.S) {
Expand Down Expand Up @@ -123,7 +124,7 @@ object NotificationManager {
val notificationSummary = resources.getString(R.string.datareporting_notification_summary)

val intent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(PRIVACY_NOTICE_URL)
data = PRIVACY_NOTICE_URL.toUri()
setPackage(context.packageName)
}

Expand Down Expand Up @@ -151,10 +152,10 @@ object NotificationManager {
NotificationManagerCompat.from(context)
.notify(DATA_REPORTING_TAG, DATA_REPORTING_NOTIFICATION_ID, notificationBuilder.build())

preferences.edit()
.putLong(PREFS_POLICY_NOTIFIED_TIME, System.currentTimeMillis())
.putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION)
.apply()
preferences.edit {
putLong(PREFS_POLICY_NOTIFIED_TIME, System.currentTimeMillis())
putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION)
}
}

private fun getNotificationChannelId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
package org.mozilla.reference.browser.addons

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.method.LinkMovementMethod
import android.view.View
import android.widget.RatingBar
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import androidx.core.text.HtmlCompat
import mozilla.components.feature.addons.Addon
import mozilla.components.feature.addons.ui.translateDescription
Expand Down Expand Up @@ -66,8 +66,7 @@ class AddonDetailsActivity : AppCompatActivity() {

private fun bindWebsite(addon: Addon) {
findViewById<View>(R.id.home_page_text).setOnClickListener {
val intent =
Intent(Intent.ACTION_VIEW).setData(Uri.parse(addon.homepageUrl))
val intent = Intent(Intent.ACTION_VIEW, addon.homepageUrl.toUri())
startActivity(intent)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
package org.mozilla.reference.browser.addons

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import mozilla.components.feature.addons.Addon
Expand Down Expand Up @@ -86,8 +86,7 @@ class PermissionsDetailsActivity : AppCompatActivity(), View.OnClickListener {
) : RecyclerView.ViewHolder(view)

override fun onClick(v: View?) {
val intent =
Intent(Intent.ACTION_VIEW).setData(Uri.parse(LEARN_MORE_URL))
val intent = Intent(Intent.ACTION_VIEW).setData(LEARN_MORE_URL.toUri())
startActivity(intent)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ package org.mozilla.reference.browser.autofill

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.util.AttributeSet
import android.view.autofill.AutofillManager
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.SwitchCompat
import androidx.core.net.toUri
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import org.mozilla.reference.browser.R
Expand Down Expand Up @@ -45,8 +45,9 @@ class AutofillPreference @JvmOverloads constructor(

@RequiresApi(Build.VERSION_CODES.O)
override fun onClick() {
val intent = Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE)
intent.data = Uri.parse("package:${context.packageName}")
val intent = Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE).apply {
data = "package:${context.packageName}".toUri()
}
context.startActivity(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.mozilla.reference.browser.settings

import android.content.Context
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import org.mozilla.reference.browser.R

Expand All @@ -29,18 +30,16 @@ object Settings {

fun setOverrideAmoUser(context: Context, value: String) {
val key = context.getString(R.string.pref_key_override_amo_user)
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(key, value)
.apply()
PreferenceManager.getDefaultSharedPreferences(context).edit {
putString(key, value)
}
}

fun setOverrideAmoCollection(context: Context, value: String) {
val key = context.getString(R.string.pref_key_override_amo_collection)
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(key, value)
.apply()
PreferenceManager.getDefaultSharedPreferences(context).edit {
putString(key, value)
}
}

fun isAmoCollectionOverrideConfigured(context: Context): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
package org.mozilla.reference.browser.tabs.synced

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.net.toUri
import androidx.fragment.app.Fragment
import mozilla.components.browser.storage.sync.Tab
import mozilla.components.feature.syncedtabs.SyncedTabsFeature
Expand Down Expand Up @@ -49,7 +49,7 @@ class SyncedTabsFragment : Fragment() {
}

private fun handleTabClicked(tab: Tab) {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(tab.active().url))
val browserIntent = Intent(Intent.ACTION_VIEW, tab.active().url.toUri())
requireContext().startActivity(browserIntent)
}
}