mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] Remove deprecatd support-ktx methods (https://github.com/mozilla-mobile/fenix/pull/3305)
This commit is contained in:
parent
636c936d79
commit
b563f67ccf
@ -15,6 +15,8 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
|
import androidx.core.net.toUri
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.navigation.fragment.NavHostFragment.findNavController
|
import androidx.navigation.fragment.NavHostFragment.findNavController
|
||||||
@ -52,7 +54,6 @@ import mozilla.components.feature.sitepermissions.SitePermissionsRules
|
|||||||
import mozilla.components.support.base.feature.BackHandler
|
import mozilla.components.support.base.feature.BackHandler
|
||||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||||
import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded
|
import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded
|
||||||
import mozilla.components.support.ktx.kotlin.toUri
|
|
||||||
import org.mozilla.fenix.BrowsingModeManager
|
import org.mozilla.fenix.BrowsingModeManager
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.FenixViewModelProvider
|
import org.mozilla.fenix.FenixViewModelProvider
|
||||||
@ -818,8 +819,9 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Session.copyUrl(context: Context) {
|
private fun Session.copyUrl(context: Context) {
|
||||||
val clipBoard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
context.getSystemService<ClipboardManager>()?.apply {
|
||||||
clipBoard.primaryClip = ClipData.newPlainText(url, url)
|
primaryClip = ClipData.newPlainText(url, url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun subscribeToSession(): Session.Observer {
|
private fun subscribeToSession(): Session.Observer {
|
||||||
|
@ -15,6 +15,7 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
import mozilla.components.concept.sync.DeviceEvent
|
import mozilla.components.concept.sync.DeviceEvent
|
||||||
import mozilla.components.concept.sync.TabData
|
import mozilla.components.concept.sync.TabData
|
||||||
import mozilla.components.support.base.log.logger.Logger
|
import mozilla.components.support.base.log.logger.Logger
|
||||||
@ -95,8 +96,7 @@ class NotificationManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
// Register the channel with the system. Once this is done, we can't change importance or other notification
|
// Register the channel with the system. Once this is done, we can't change importance or other notification
|
||||||
// channel behaviour. We will be able to change 'name' and 'description' if we so choose.
|
// channel behaviour. We will be able to change 'name' and 'description' if we so choose.
|
||||||
val notificationManager: NotificationManager =
|
val notificationManager: NotificationManager = context.getSystemService()!!
|
||||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
||||||
notificationManager.createNotificationChannel(channel)
|
notificationManager.createNotificationChannel(channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
package org.mozilla.fenix.ext
|
package org.mozilla.fenix.ext
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.core.net.toUri
|
||||||
import java.net.MalformedURLException
|
import java.net.MalformedURLException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
|
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
|
||||||
import mozilla.components.support.ktx.kotlin.toUri
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the keys with the values with the map provided.
|
* Replaces the keys with the values with the map provided.
|
||||||
@ -36,7 +36,7 @@ fun String?.getHostFromUrl(): String? = try {
|
|||||||
*/
|
*/
|
||||||
suspend fun String.urlToTrimmedHost(context: Context): String {
|
suspend fun String.urlToTrimmedHost(context: Context): String {
|
||||||
return try {
|
return try {
|
||||||
val host = this.toUri().hostWithoutCommonPrefixes ?: return this
|
val host = toUri().hostWithoutCommonPrefixes ?: return this
|
||||||
context.components.publicSuffixList.stripPublicSuffix(host).await()
|
context.components.publicSuffixList.stripPublicSuffix(host).await()
|
||||||
} catch (e: MalformedURLException) {
|
} catch (e: MalformedURLException) {
|
||||||
this
|
this
|
||||||
|
@ -18,6 +18,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
@ -398,8 +399,9 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler, AccountObserve
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun BookmarkNode.copyUrl(context: Context) {
|
private fun BookmarkNode.copyUrl(context: Context) {
|
||||||
val clipBoard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
context.getSystemService<ClipboardManager>()?.apply {
|
||||||
clipBoard.primaryClip = ClipData.newPlainText(url, url)
|
primaryClip = ClipData.newPlainText(url, url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ReturnCount")
|
@SuppressWarnings("ReturnCount")
|
||||||
|
@ -22,6 +22,10 @@ class ShortcutsSuggestionProvider(
|
|||||||
override val shouldClearSuggestions: Boolean
|
override val shouldClearSuggestions: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
|
|
||||||
|
private val settingsIcon by lazy {
|
||||||
|
context.getDrawable(R.drawable.ic_settings)?.toBitmap()
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun onInputChanged(text: String): List<AwesomeBar.Suggestion> {
|
override suspend fun onInputChanged(text: String): List<AwesomeBar.Suggestion> {
|
||||||
val suggestions = mutableListOf<AwesomeBar.Suggestion>()
|
val suggestions = mutableListOf<AwesomeBar.Suggestion>()
|
||||||
|
|
||||||
@ -42,9 +46,7 @@ class ShortcutsSuggestionProvider(
|
|||||||
suggestions.add(
|
suggestions.add(
|
||||||
AwesomeBar.Suggestion(
|
AwesomeBar.Suggestion(
|
||||||
provider = this,
|
provider = this,
|
||||||
icon = { _, _ ->
|
icon = { _, _ -> settingsIcon },
|
||||||
context.getDrawable(R.drawable.ic_settings)?.toBitmap()
|
|
||||||
},
|
|
||||||
title = context.getString(R.string.search_shortcuts_engine_settings),
|
title = context.getString(R.string.search_shortcuts_engine_settings),
|
||||||
onSuggestionClicked = {
|
onSuggestionClicked = {
|
||||||
selectShortcutEngineSettings()
|
selectShortcutEngineSettings()
|
||||||
|
@ -6,8 +6,8 @@ package org.mozilla.fenix.settings.quicksettings
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.net.toUri
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissions
|
import mozilla.components.feature.sitepermissions.SitePermissions
|
||||||
import mozilla.components.support.ktx.kotlin.toUri
|
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.mvi.ViewState
|
import org.mozilla.fenix.mvi.ViewState
|
||||||
import org.mozilla.fenix.mvi.Change
|
import org.mozilla.fenix.mvi.Change
|
||||||
|
@ -18,6 +18,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.appcompat.app.AppCompatDialogFragment
|
import androidx.appcompat.app.AppCompatDialogFragment
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
|
import androidx.core.net.toUri
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.navigation.fragment.NavHostFragment.findNavController
|
import androidx.navigation.fragment.NavHostFragment.findNavController
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
@ -27,7 +28,6 @@ import kotlinx.coroutines.Job
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissions
|
import mozilla.components.feature.sitepermissions.SitePermissions
|
||||||
import mozilla.components.support.ktx.kotlin.toUri
|
|
||||||
import org.mozilla.fenix.FenixViewModelProvider
|
import org.mozilla.fenix.FenixViewModelProvider
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.IntentReceiverActivity
|
import org.mozilla.fenix.IntentReceiverActivity
|
||||||
|
@ -14,6 +14,7 @@ import android.widget.TextView
|
|||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.net.toUri
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
import io.reactivex.functions.Consumer
|
import io.reactivex.functions.Consumer
|
||||||
@ -21,7 +22,6 @@ import mozilla.components.feature.sitepermissions.SitePermissions
|
|||||||
import mozilla.components.feature.sitepermissions.SitePermissions.Status.BLOCKED
|
import mozilla.components.feature.sitepermissions.SitePermissions.Status.BLOCKED
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissions.Status.NO_DECISION
|
import mozilla.components.feature.sitepermissions.SitePermissions.Status.NO_DECISION
|
||||||
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
|
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
|
||||||
import mozilla.components.support.ktx.kotlin.toUri
|
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.mvi.UIView
|
import org.mozilla.fenix.mvi.UIView
|
||||||
import org.mozilla.fenix.settings.PhoneFeature
|
import org.mozilla.fenix.settings.PhoneFeature
|
||||||
|
Loading…
Reference in New Issue
Block a user