Discover the linter's formatter

Adam Novak 2 years ago
parent e0c02f8b25
commit b11ff2a8bb

@ -98,6 +98,12 @@ Developers are especially welcome, wanted, and needed.
We encourage you to participate in this open source project. We love Pull Requests, Bug Reports, ideas, (security) code reviews or any other kind of positive contribution.
### How to Appease the Linter
If you are getting errors form `./gradelw ktlint`, try running `./gradlew
ktlintFormat` to let `ktlint` decide how to lay out your code, instead of just
yelling at you that you can't read its mind.
### 🙅 How to skip CI checks for PRs 🙅
If you want to skip Github CI checks in a PR, please add the following to the PR title exactly: `[skip ci]`.

@ -107,15 +107,18 @@ class PagedAddonCollectionProvider(
if (cachedAddons != null) {
return cachedAddons
} else {
return getAllPages(listOf(
serverURL,
API_VERSION,
"accounts/account",
collectionAccount,
"collections",
collectionName,
"addons"
).joinToString("/"), readTimeoutInSeconds ?: DEFAULT_READ_TIMEOUT_IN_SECONDS).also {
return getAllPages(
listOf(
serverURL,
API_VERSION,
"accounts/account",
collectionAccount,
"collections",
collectionName,
"addons"
).joinToString("/"),
readTimeoutInSeconds ?: DEFAULT_READ_TIMEOUT_IN_SECONDS
).also {
// Cache the JSON object before we parse out the addons
if (maxCacheAgeInMinutes > 0) {
writeToDiskCache(it.toString())
@ -147,26 +150,26 @@ class PagedAddonCollectionProvider(
readTimeout = Pair(readTimeoutInSeconds, TimeUnit.SECONDS)
)
)
.use { response ->
if (!response.isSuccess) {
val errorMessage = "Failed to fetch addon collection. Status code: ${response.status}"
logger.error(errorMessage)
throw IOException(errorMessage)
}
.use { response ->
if (!response.isSuccess) {
val errorMessage = "Failed to fetch addon collection. Status code: ${response.status}"
logger.error(errorMessage)
throw IOException(errorMessage)
}
val currentResponse = try {
JSONObject(response.body.string(Charsets.UTF_8))
} catch (e: JSONException) {
throw IOException(e)
}
if (compiledResponse == null) {
compiledResponse = currentResponse
} else {
// Write the addons into the first response
compiledResponse!!.getJSONArray("results").concat(currentResponse.getJSONArray("results"))
val currentResponse = try {
JSONObject(response.body.string(Charsets.UTF_8))
} catch (e: JSONException) {
throw IOException(e)
}
if (compiledResponse == null) {
compiledResponse = currentResponse
} else {
// Write the addons into the first response
compiledResponse!!.getJSONArray("results").concat(currentResponse.getJSONArray("results"))
}
nextURL = if (currentResponse.isNull("next")) null else currentResponse.getString("next")
}
nextURL = if (currentResponse.isNull("next")) null else currentResponse.getString("next")
}
}
return compiledResponse!!
}
@ -181,7 +184,7 @@ class PagedAddonCollectionProvider(
var bitmap: Bitmap? = null
if (addon.iconUrl != "") {
client.fetch(
Request(url = addon.iconUrl.sanitizeURL())
Request(url = addon.iconUrl.sanitizeURL())
).use { response ->
if (response.isSuccess) {
response.body.useStream {
@ -306,9 +309,11 @@ internal fun JSONObject.getCurrentVersion(): String {
}
internal fun JSONObject.getDownload(): JSONObject? {
return (getJSONObject("current_version")
.optJSONArray("files")
?.getJSONObject(0))
return (
getJSONObject("current_version")
.optJSONArray("files")
?.getJSONObject(0)
)
}
internal fun JSONObject.getDownloadId(): String {

@ -154,7 +154,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
null,
false
)
val binding = MozacFeatureAddonsFragmentDialogAddonInstalledBinding.bind(rootView)
rootView.findViewById<TextView>(R.id.title).text =

@ -41,7 +41,6 @@ import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.ext.runIfFragmentIsAttached
import org.mozilla.fenix.theme.ThemeManager
import java.util.Locale
import java.lang.ref.WeakReference
import java.util.concurrent.CancellationException
@ -257,7 +256,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
private fun hasExistingAddonInstallationDialogFragment(): Boolean {
return parentFragmentManager.findFragmentByTag(INSTALLATION_DIALOG_FRAGMENT_TAG)
as? PagedAddonInstallationDialogFragment != null
as? PagedAddonInstallationDialogFragment != null
}
@VisibleForTesting

@ -114,9 +114,11 @@ class BrowserToolbarView(
display.urlFormatter =
if (settings.shouldStripUrl) {
url -> URLStringUtils.toDisplayUrl(url)
url ->
URLStringUtils.toDisplayUrl(url)
} else {
url -> url
url ->
url
}
display.colors = display.colors.copy(

@ -115,7 +115,8 @@ class TopSheetBehavior<V : View?>
if (mViewRef != null && mViewRef!!.get() != null) {
mMinOffset =
(-mViewRef!!.get()!!.height).coerceAtLeast(
-(mViewRef!!.get()!!.height - mPeekHeight))
-(mViewRef!!.get()!!.height - mPeekHeight)
)
}
}
@ -175,7 +176,8 @@ class TopSheetBehavior<V : View?>
super.onSaveInstanceState(
parent,
child!!
), mState
),
mState
)
}
@ -283,7 +285,7 @@ class TopSheetBehavior<V : View?>
mTouchingScrollingChild = true
}
mIgnoreEvents = mActivePointerId == MotionEvent.INVALID_POINTER_ID &&
!parent.isPointInChildBounds(child, initialX, mInitialY)
!parent.isPointInChildBounds(child, initialX, mInitialY)
}
}
if (!mIgnoreEvents && mViewDragHelper!!.shouldInterceptTouchEvent(event)) {
@ -294,12 +296,12 @@ class TopSheetBehavior<V : View?>
// happening over the scrolling content as nested scrolling logic handles that case.
val scroll = mNestedScrollingChildRef!!.get()
return action == MotionEvent.ACTION_MOVE && scroll != null &&
!mIgnoreEvents && mState != STATE_DRAGGING &&
!parent.isPointInChildBounds(
scroll,
event.x.toInt(),
event.y.toInt()
) && abs(mInitialY - event.y) > mViewDragHelper!!.touchSlop
!mIgnoreEvents && mState != STATE_DRAGGING &&
!parent.isPointInChildBounds(
scroll,
event.x.toInt(),
event.y.toInt()
) && abs(mInitialY - event.y) > mViewDragHelper!!.touchSlop
}
override fun onTouchEvent(
@ -328,7 +330,8 @@ class TopSheetBehavior<V : View?>
// The ViewDragHelper tries to capture only the top-most View. We have to explicitly tell it
// to capture the top sheet in case it is not captured and the touch slop is passed.
if (action == MotionEvent.ACTION_MOVE && !mIgnoreEvents &&
abs(mInitialY - event.y) > mViewDragHelper!!.touchSlop) {
abs(mInitialY - event.y) > mViewDragHelper!!.touchSlop
) {
mViewDragHelper!!.captureChildView(
child,
event.getPointerId(event.actionIndex)
@ -449,11 +452,13 @@ class TopSheetBehavior<V : View?>
velocityY: Float
): Boolean {
return target === mNestedScrollingChildRef!!.get() &&
(mState != STATE_EXPANDED ||
super.onNestedPreFling(
coordinatorLayout, child!!, target,
velocityX, velocityY
))
(
mState != STATE_EXPANDED ||
super.onNestedPreFling(
coordinatorLayout, child!!, target,
velocityX, velocityY
)
)
}
/**
@ -482,7 +487,7 @@ class TopSheetBehavior<V : View?>
if (mViewRef == null) {
// The view is not laid out yet; modify mState and let onLayoutChild handle it later
val stateCondition = state == STATE_COLLAPSED || state == STATE_EXPANDED ||
isHideable && state == STATE_HIDDEN
isHideable && state == STATE_HIDDEN
if (stateCondition) {
mState = state
}

@ -27,7 +27,8 @@ open class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
}
if (preference.key == preference.context.getString(R.string.pref_key_addons_custom_account) ||
preference.key == preference.context.getString(R.string.pref_key_addons_custom_collection)) {
preference.key == preference.context.getString(R.string.pref_key_addons_custom_collection)
) {
preference.context.components.updateAddonManager()
}
}

Loading…
Cancel
Save