Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
Update AndroidX dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo authored and mergify[bot] committed Jun 23, 2021
1 parent a543621 commit 3684b00
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 49 deletions.
25 changes: 12 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,18 @@ configurations {
}

dependencies {
implementation "androidx.appcompat:appcompat:$support_libraries_version"
implementation "androidx.browser:browser:$support_libraries_version"
implementation "androidx.core:core-ktx:1.1.0"
implementation "com.google.android.material:material:$support_libraries_version"
implementation "androidx.cardview:cardview:$support_libraries_version"
implementation "androidx.recyclerview:recyclerview:$support_libraries_version"
implementation "androidx.legacy:legacy-support-v4:$support_libraries_version"
implementation "androidx.preference:preference:$support_libraries_version"
implementation 'io.sentry:sentry-android:1.7.21'
implementation Dependencies.androidx_appcompat
implementation Dependencies.androidx_browser
implementation Dependencies.androidx_cardview
implementation Dependencies.androidx_core_ktx
implementation Dependencies.androidx_lifecycle_extensions
implementation Dependencies.androidx_palette
implementation Dependencies.androidx_preferences
implementation Dependencies.androidx_recyclerview

implementation Dependencies.google_material

implementation "androidx.lifecycle:lifecycle-extensions:$architecture_components_version"
implementation 'io.sentry:sentry-android:1.7.21'

compileOnly 'net.jcip:jcip-annotations:1.0'
implementation("com.google.code.findbugs:jsr305:3.0.2")
Expand Down Expand Up @@ -198,8 +199,6 @@ dependencies {
focusImplementation 'com.adjust.sdk:adjust-android:4.11.4'
focusImplementation 'com.android.installreferrer:installreferrer:1.1' // Required by Adjust

implementation "androidx.palette:palette:$support_libraries_version"

jnaForTest "net.java.dev.jna:jna:${jna_version}@jar"
testImplementation files(configurations.jnaForTest.copyRecursive().files)
testImplementation "org.mozilla.telemetry:glean-forUnitTests:${project.ext.glean_version}"
Expand All @@ -211,7 +210,7 @@ dependencies {
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.3.1"
testImplementation "org.robolectric:robolectric:4.4" // required to support api level 28
testImplementation "org.mockito:mockito-core:3.11.0"
testImplementation "androidx.arch.core:core-testing:${architecture_components_version}"
testImplementation Dependencies.androidx_arch_core_testing

androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version", {
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class AddToHomescreenDialogFragment : DialogFragment() {
return builder.create()
}

@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/4958
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val dialog = dialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class BrowserFragment :
customTabId = tab.id,
fragmentManager = parentFragmentManager,
onNeedToRequestPermissions = { permissions ->
@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/4959
requestPermissions(permissions, REQUEST_CODE_PROMPT_PERMISSIONS)
}
), this, view)
Expand All @@ -233,6 +234,7 @@ class BrowserFragment :
DownloadService::class
),
onNeedToRequestPermissions = { permissions ->
@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/4959
requestPermissions(permissions, REQUEST_CODE_DOWNLOAD_PERMISSIONS)
},
onDownloadStopped = { state, _, status ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class UrlInputFragment :
}
}

@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/4958
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class SearchSuggestionsFragment : Fragment(), CoroutineScope {
super.onPause()
}

@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/4958
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class GeneralSettingsFragment : BaseSettingsFragment(),
super.onResume()

val preference =
findPreference(getString(R.string.pref_key_default_browser)) as DefaultBrowserPreference
preference.update()
findPreference(getString(R.string.pref_key_default_browser)) as? DefaultBrowserPreference
preference?.update()

preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)

Expand All @@ -63,8 +63,8 @@ class GeneralSettingsFragment : BaseSettingsFragment(),
InstalledSearchEnginesSettingsFragment.languageChanged = true

val languagePreference =
findPreference(getString(R.string.pref_key_locale)) as ListPreference
val value = languagePreference.value
findPreference(getString(R.string.pref_key_locale)) as? ListPreference
val value = languagePreference?.value

val localeManager = LocaleManager.getInstance()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ class InstalledSearchEnginesSettingsFragment : BaseSettingsFragment() {
preferenceScreen?.removeAll()
addPreferencesFromResource(R.xml.search_engine_settings)

val pref = preferenceScreen.findPreference(resources.getString(R.string.pref_key_radio_search_engine_list))
(pref as RadioSearchEngineListPreference).refetchSearchEngines()
val pref: RadioSearchEngineListPreference? = preferenceScreen.findPreference(
resources.getString(R.string.pref_key_radio_search_engine_list)
)
pref?.refetchSearchEngines()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class ManualAddSearchEngineSettingsFragment : BaseSettingsFragment() {
val searchQuery = requireView().findViewById<EditText>(R.id.edit_search_string).text.toString()

val pref = findManualAddSearchEnginePreference(R.string.pref_key_manual_add_search_engine)
val engineValid = pref.validateEngineNameAndShowError(engineName)
val searchValid = pref.validateSearchQueryAndShowError(searchQuery)
val engineValid = pref?.validateEngineNameAndShowError(engineName) ?: false
val searchValid = pref?.validateSearchQueryAndShowError(searchQuery) ?: false
val isPartialSuccess = engineValid && searchValid

if (isPartialSuccess) {
Expand Down Expand Up @@ -138,12 +138,12 @@ class ManualAddSearchEngineSettingsFragment : BaseSettingsFragment() {
view?.alpha = DISABLED_ALPHA
// Delay showing the loading indicator to prevent it flashing on the screen
handler.postDelayed({
pref.setProgressViewShown(isValidating)
pref?.setProgressViewShown(isValidating)
}, LOADING_INDICATOR_DELAY)
} else {
view?.alpha = 1f
handler.removeCallbacksAndMessages(null)
pref.setProgressViewShown(isValidating)
pref?.setProgressViewShown(isValidating)
}

// Disable text entry until done validating
Expand All @@ -164,8 +164,8 @@ class ManualAddSearchEngineSettingsFragment : BaseSettingsFragment() {
}
}

private fun findManualAddSearchEnginePreference(id: Int): ManualAddSearchEnginePreference {
return findPreference(getString(id)) as ManualAddSearchEnginePreference
private fun findManualAddSearchEnginePreference(id: Int): ManualAddSearchEnginePreference? {
return findPreference(getString(id)) as? ManualAddSearchEnginePreference
}

companion object {
Expand Down Expand Up @@ -264,7 +264,7 @@ class ManualAddSearchEngineSettingsFragment : BaseSettingsFragment() {

private fun showServerError(that: ManualAddSearchEngineSettingsFragment) {
val pref = that.findManualAddSearchEnginePreference(R.string.pref_key_manual_add_search_engine)
pref.setSearchQueryErrorText(that.getString(R.string.error_hostLookup_title))
pref?.setSearchQueryErrorText(that.getString(R.string.error_hostLookup_title))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class PrivacySecuritySettingsFragment : BaseSettingsFragment(),
override fun onCreatePreferences(p0: Bundle?, p1: String?) {
addPreferencesFromResource(R.xml.privacy_security_settings)

val biometricPreference = findPreference(getString(R.string.pref_key_biometric))
val biometricPreference: SwitchPreferenceCompat? = findPreference(getString(R.string.pref_key_biometric))
val appName = getString(R.string.app_name)
biometricPreference.summary =
biometricPreference?.summary =
getString(R.string.preference_security_biometric_summary, appName)

// Remove the biometric toggle if the software or hardware do not support it
Expand All @@ -36,9 +36,9 @@ class PrivacySecuritySettingsFragment : BaseSettingsFragment(),
}

val cookiesPreference =
findPreference(getString(R.string.pref_key_performance_enable_cookies)) as CookiesPreference
findPreference(getString(R.string.pref_key_performance_enable_cookies)) as? CookiesPreference

cookiesPreference.updateSummary()
cookiesPreference?.updateSummary()
}

override fun onResume() {
Expand All @@ -65,26 +65,26 @@ class PrivacySecuritySettingsFragment : BaseSettingsFragment(),

private fun updateBiometricsToggleAvailability() {
val switch = preferenceScreen.findPreference(resources.getString(R.string.pref_key_biometric))
as SwitchPreferenceCompat
as? SwitchPreferenceCompat

if (!Biometrics.hasFingerprintHardware(requireContext())) {
switch.isChecked = false
switch.isEnabled = false
switch?.isChecked = false
switch?.isEnabled = false
preferenceManager.sharedPreferences
.edit()
.putBoolean(resources.getString(R.string.pref_key_biometric), false)
.apply()
} else {
switch.isEnabled = true
switch?.isEnabled = true
}
}

private fun updateExceptionSettingAvailability() {
val exceptionsPreference = findPreference(getString(R.string.pref_key_screen_exceptions))
exceptionsPreference.isEnabled = false
val exceptionsPreference: Preference? = findPreference(getString(R.string.pref_key_screen_exceptions))
exceptionsPreference?.isEnabled = false

requireComponents.trackingProtectionUseCases.fetchExceptions.invoke { exceptions ->
exceptionsPreference.isEnabled = exceptions.isNotEmpty()
exceptionsPreference?.isEnabled = exceptions.isNotEmpty()
}
}

Expand All @@ -107,7 +107,7 @@ class PrivacySecuritySettingsFragment : BaseSettingsFragment(),

private fun updateStealthToggleAvailability() {
val switch =
preferenceScreen.findPreference(resources.getString(R.string.pref_key_secure)) as SwitchPreferenceCompat
preferenceScreen.findPreference(resources.getString(R.string.pref_key_secure)) as? SwitchPreferenceCompat
if (preferenceManager.sharedPreferences
.getBoolean(
resources.getString(R.string.pref_key_biometric),
Expand All @@ -120,11 +120,11 @@ class PrivacySecuritySettingsFragment : BaseSettingsFragment(),
true
).apply()
// Disable the stealth switch
switch.isChecked = true
switch.isEnabled = false
switch?.isChecked = true
switch?.isEnabled = false
} else {
// Enable the stealth switch
switch.isEnabled = true
switch?.isEnabled = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,21 @@ class RemoveSearchEnginesSettingsFragment : BaseSettingsFragment() {
view?.post {
val pref = preferenceScreen
.findPreference(resources.getString(R.string.pref_key_multiselect_search_engine_list))
as MultiselectSearchEngineListPreference
as? MultiselectSearchEngineListPreference

menu.findItem(R.id.menu_delete_items)?.let {
ViewUtils.setMenuItemEnabled(it, pref.atLeastOneEngineChecked())
ViewUtils.setMenuItemEnabled(it, pref!!.atLeastOneEngineChecked())
}
}
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.menu_delete_items -> {
val pref = preferenceScreen
val pref: MultiselectSearchEngineListPreference? = preferenceScreen
.findPreference(resources.getString(R.string.pref_key_multiselect_search_engine_list))

val enginesToRemove =
(pref as MultiselectSearchEngineListPreference).checkedEngineIds
val enginesToRemove = pref!!.checkedEngineIds
TelemetryWrapper.removeSearchEnginesEvent(enginesToRemove.size)

requireComponents.store.state.search.searchEngines.filter { searchEngine ->
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.architecture_components_version = '2.1.0'
ext.support_libraries_version = '1.0.0'
ext.espresso_version = '3.1.0-alpha4'
ext.kotlin_version = '1.4.30'
ext.coroutines_version = '1.4.2'
Expand Down
37 changes: 37 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

object Versions {
object AndroidX {
const val annotation = "1.1.0"
const val appcompat = "1.3.0"
const val arch = "2.1.0"
const val browser = "1.3.0"
const val core = "1.3.2"
const val cardview = "1.0.0"
const val recyclerview = "1.2.0"
const val palette = "1.0.0"
const val preferences = "1.1.1"
const val lifecycle = "2.2.0"
}

object Google {
const val material = "1.2.1"
}
}

object Dependencies {
const val androidx_annotation = "androidx.annotation:annotation:${Versions.AndroidX.annotation}"
const val androidx_arch_core_testing = "androidx.arch.core:core-testing:${Versions.AndroidX.arch}"
const val androidx_appcompat = "androidx.appcompat:appcompat:${Versions.AndroidX.appcompat}"
const val androidx_browser = "androidx.browser:browser:${Versions.AndroidX.browser}"
const val androidx_cardview = "androidx.cardview:cardview:${Versions.AndroidX.cardview}"
const val androidx_core_ktx = "androidx.core:core-ktx:${Versions.AndroidX.core}"
const val androidx_palette = "androidx.palette:palette-ktx:${Versions.AndroidX.palette}"
const val androidx_preferences = "androidx.preference:preference-ktx:${Versions.AndroidX.preferences}"
const val androidx_recyclerview = "androidx.recyclerview:recyclerview:${Versions.AndroidX.recyclerview}"
const val androidx_lifecycle_extensions = "androidx.lifecycle:lifecycle-extensions:${Versions.AndroidX.lifecycle}"

const val google_material = "com.google.android.material:material:${Versions.Google.material}"
}
2 changes: 1 addition & 1 deletion service-telemetry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
implementation "org.mozilla.components:support-base:${AndroidComponents.VERSION}"
implementation "org.mozilla.components:concept-fetch:${AndroidComponents.VERSION}"

implementation "androidx.annotation:annotation:$support_libraries_version"
implementation Dependencies.androidx_annotation

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

Expand Down

0 comments on commit 3684b00

Please sign in to comment.