diff options
author | Allan Wang <me@allanwang.ca> | 2019-09-22 22:47:07 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-09-22 22:47:07 -0700 |
commit | 142b95f0ae82a849b1e9ef390a2a068b4c792be6 (patch) | |
tree | 10e7cfbca87fdc3ad904d5b0f38e493d088496e1 /app/src/main/kotlin | |
parent | 981d6ffb409a501e6efcf4fe0cbe719e192beee7 (diff) | |
download | frost-142b95f0ae82a849b1e9ef390a2a068b4c792be6.tar.gz frost-142b95f0ae82a849b1e9ef390a2a068b4c792be6.tar.bz2 frost-142b95f0ae82a849b1e9ef390a2a068b4c792be6.zip |
Optimize imports and update changelog
Diffstat (limited to 'app/src/main/kotlin')
23 files changed, 30 insertions, 33 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt index 4cfa46c8..5b3a7315 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -41,7 +41,6 @@ import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.aboutlibraries.entity.License import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.items.AbstractItem import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index 2574d507..798ee4b3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -467,7 +467,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, fun hasRequest(flag: Int) = resultCode and flag > 0 if (requestCode == ACTIVITY_SETTINGS) { - if (resultCode and REQUEST_RESTART_APPLICATION > 0) { //completely restart application + if (resultCode and REQUEST_RESTART_APPLICATION > 0) { // completely restart application L.d { "Restart Application Requested" } val intent = packageManager.getLaunchIntentForPackage(packageName)!! Intent.makeRestartActivityTask(intent.component) @@ -604,7 +604,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, if (!fragmentChannel.isClosedForSend) { fragmentChannel.offer(0) } - } //trigger hook so title is set + } // trigger hook so title is set } fun saveInstanceState(outState: Bundle) { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt index 1549e23e..5da6d970 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -258,7 +258,7 @@ class ImageActivity : KauBaseActivity() { ) { super.onViewPositionChanged(changedView, left, top, dx, dy) with(binding) { - //make sure that we are using the proper axis + // make sure that we are using the proper axis scrollPercent = abs(top.toFloat() / imageContainer.height) scrollToTop = top < 0 val multiplier = max(1f - scrollPercent, 0f) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt index 5983bd30..77a58cf2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -123,7 +123,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On * All fragments are locked in position */ override fun transformPage(page: View, position: Float) { - //only apply to adjacent pages + // only apply to adjacent pages if ((position < 0 && position > -1) || (position > 0 && position < 1)) { val pageWidth = page.width val translateValue = position * -pageWidth diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt index 7312399e..1fbba812 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/FeedSort.kt @@ -29,7 +29,7 @@ enum class FeedSort(@StringRes val textRes: Int, val item: FbItem) { TOP(R.string.top_stories, FbItem.FEED_TOP_STORIES); companion object { - val values = values() //save one instance + val values = values() // save one instance operator fun invoke(index: Int) = values[index] } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt index 2d51b032..a3a4c1a4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt @@ -40,7 +40,7 @@ enum class MainActivityLayout( { Prefs.textColor }); companion object { - val values = values() //save one instance + val values = values() // save one instance operator fun invoke(index: Int) = values[index] } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt index 345aa88e..6c911e9c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt @@ -104,7 +104,7 @@ enum class Theme( get() = iconColorGetter() companion object { - val values = values() //save one instance + val values = values() // save one instance operator fun invoke(index: Int) = values[index] } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt index 2095f8fd..6292f4f0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt @@ -67,7 +67,7 @@ class FbUrlFormatter(url: String) { return url } cleanedUrl = cleanedUrl.replace("&", "&") - if (changed && !cleanedUrl.contains("?")) //ensure we aren't missing '?' + if (changed && !cleanedUrl.contains("?")) // ensure we aren't missing '?' cleanedUrl = cleanedUrl.replaceFirst("&", "?") val qm = cleanedUrl.indexOf("?") if (qm > -1) { @@ -82,7 +82,7 @@ class FbUrlFormatter(url: String) { cleanedUrl = cleanedUrl.replaceFirst( ".facebook.com//", ".facebook.com/" - ) //sometimes we are given a bad url + ) // sometimes we are given a bad url L.v { "Formatted url from $url to $cleanedUrl" } return cleanedUrl } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt index 3705448a..f754b454 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt @@ -136,7 +136,7 @@ private class MessageParserImpl : FrostParserBase<FrostMessages>(true) { val a = element.getElementsByTag("a").first() ?: return null val abbr = element.getElementsByTag("abbr") val epoch = FB_EPOCH_MATCHER.find(abbr.attr("data-store"))[1]?.toLongOrNull() ?: -1L - //fetch id + // fetch id val id = FB_MESSAGE_NOTIF_ID_MATCHER.find(element.id())[1]?.toLongOrNull() ?: System.currentTimeMillis() % FALLBACK_TIME_MOD val snippet = element.select("span.snippet").firstOrNull() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt index f9db0a8f..ab18172f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt @@ -105,13 +105,13 @@ private class NotifParserImpl : FrostParserBase<FrostNotifs>(false) { val a = element.getElementsByTag("a").first() ?: return null val abbr = element.getElementsByTag("abbr") val epoch = FB_EPOCH_MATCHER.find(abbr.attr("data-store"))[1]?.toLongOrNull() ?: -1L - //fetch id + // fetch id val id = FB_NOTIF_ID_MATCHER.find(element.id())[1]?.toLongOrNull() ?: System.currentTimeMillis() % FALLBACK_TIME_MOD val img = element.getInnerImgStyle() val timeString = abbr.text() val content = - a.text().replace("\u00a0", " ").removeSuffix(timeString).trim() //remove + a.text().replace("\u00a0", " ").removeSuffix(timeString).trim() // remove val thumbnail = element.selectFirst("img.thumbnail")?.attr("src") return FrostNotif( id = id, diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt index d73f3eb9..21ba17ae 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt @@ -18,10 +18,8 @@ package com.pitchedapps.frost.fragments import ca.allanwang.kau.adapters.fastAdapter import ca.allanwang.kau.utils.withMainContext -import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.GenericFastAdapter import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.fastadapter.adapters.ModelAdapter import com.pitchedapps.frost.R diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt index 894a220d..b2d328ec 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt @@ -68,7 +68,7 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : } } - //todo see if necessary + // todo see if necessary val DIFF: DiffCallback<NotificationIItem> by lazy(::Diff) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt index 36924551..9a4ec0c1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt @@ -71,7 +71,7 @@ abstract class BaseImageIntroFragment( override fun onPageScrolledImpl(positionOffset: Float) { super.onPageScrolledImpl(positionOffset) val alpha = ((1 - abs(positionOffset)) * 255).toInt() - //apply alpha to all layers except the phone base + // apply alpha to all layers except the phone base (0 until imageDrawable.numberOfLayers).forEach { val d = imageDrawable.getDrawable(it) if (d != phone) d.alpha = alpha diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt index 8a8893e5..7352082d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt @@ -140,7 +140,7 @@ inline fun <reified T : JobService> Context.scheduleJob(id: Int, minutes: Long): .setPeriodic(minutes * 60000) .setExtras(id) .setPersisted(true) - .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) //TODO add options + .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) // TODO add options val result = scheduler.schedule(builder.build()) if (result <= 0) { L.eThrow("${T::class.java.simpleName} scheduler failed") diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt index 2d86f3b9..2dbe6b6b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt @@ -32,6 +32,6 @@ class UpdateReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED) return L.d { "Frost has updated" } - context.scheduleNotifications(Prefs.notificationFreq) //Update notifications + context.scheduleNotifications(Prefs.notificationFreq) // Update notifications } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt index 9fcf2e96..b8a80e8d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -144,7 +144,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { if (it.isBlank()) string(R.string.kau_default) else RingtoneManager.getRingtone(this@getNotificationPrefs, frostUri(it)) ?.getTitle(this@getNotificationPrefs) - ?: "---" //todo figure out why this happens + ?: "---" // todo figure out why this happens } onClick = { val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt index c9e64eb3..0195f168 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt @@ -86,7 +86,7 @@ class AnimatedVectorDelegate( private fun animateImpl(toStart: Boolean) { if ((atStart == toStart)) return L.d { "AVD already at ${if (toStart) "start" else "end"}" } - if (avd == null) return L.d { "AVD null resource" } //no longer using animated vector; do not modify + if (avd == null) return L.d { "AVD null resource" } // no longer using animated vector; do not modify avd?.stop() view.setImageResource(if (toStart) avdEnd else avdStart) animatedVectorListener?.invoke(avd!!, !toStart) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt index f69af40b..edbe7682 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt @@ -25,7 +25,7 @@ import ca.allanwang.kau.kpref.KPref */ object Showcase : KPref() { - //check if this is the first time launching the web overlay; show snackbar if true + // check if this is the first time launching the web overlay; show snackbar if true val firstWebOverlay: Boolean by kprefSingle("first_web_overlay") val intro: Boolean by kprefSingle("intro_pages") diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index c2f28a4b..d725acd9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -242,11 +242,11 @@ fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) @SuppressLint("RestrictedApi") private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = { builder() - //hacky workaround, but it has proper checks and shouldn't crash + // hacky workaround, but it has proper checks and shouldn't crash ((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply { messageView.setTextColor(Prefs.textColor) actionView.setTextColor(Prefs.accentColor) - //only set if previous text colors are set + // only set if previous text colors are set view.setBackgroundColor(Prefs.bgColor.withAlpha(255).colorToForeground(0.1f)) } } @@ -316,10 +316,10 @@ inline val String.isIndirectImageUrl: Boolean */ inline val String?.isIndependent: Boolean get() { - if (this == null || length < 5) return false // ignore short queries - if (this[0] == '#' && !contains('/')) return false // ignore element values - if (startsWith("http") && !isFacebookUrl) return true // ignore non facebook urls - if (dependentSegments.any { contains(it) }) return false // ignore known dependent segments + if (this == null || length < 5) return false // ignore short queries + if (this[0] == '#' && !contains('/')) return false // ignore element values + if (startsWith("http") && !isFacebookUrl) return true // ignore non facebook urls + if (dependentSegments.any { contains(it) }) return false // ignore known dependent segments return true } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt index 7fdd485d..9089d891 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt @@ -34,7 +34,7 @@ fun Context.showWebContextMenu(wc: WebContext) { if (wc.isEmpty) return var title = wc.url ?: string(R.string.menu) title = - title.substring(title.indexOf("m/") + 1) //just so if defaults to 0 in case it's not .com/ + title.substring(title.indexOf("m/") + 1) // just so if defaults to 0 in case it's not .com/ if (title.length > 100) title = title.substring(0, 100) + '\u2026' val menuItems = WebContextType.values @@ -46,7 +46,7 @@ fun Context.showWebContextMenu(wc: WebContext) { menuItems[position].onClick(this@showWebContextMenu, wc) } onDismiss { - //showing the dialog interrupts the touch down event, so we must ensure that the viewpager's swipe is enabled + // showing the dialog interrupts the touch down event, so we must ensure that the viewpager's swipe is enabled (this@showWebContextMenu as? MainActivity)?.viewPager?.enableSwipe = true } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt index 9f2b8a5d..19bf9f69 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt @@ -67,7 +67,7 @@ class BadgedIcon @JvmOverloads constructor( } fun setAllAlpha(alpha: Float) { - //badgeTextView.setTextColor(Prefs.textColor.withAlpha(alpha.toInt())) + // badgeTextView.setTextColor(Prefs.textColor.withAlpha(alpha.toInt())) badge_image.drawable.alpha = alpha.toInt() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 449e98f1..187ab9eb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -78,7 +78,7 @@ class FrostJSI(val web: FrostWebView) { @JavascriptInterface fun contextMenu(url: String?, text: String?) { - //url will be formatted through webcontext + // url will be formatted through webcontext web.post { context.showWebContextMenu(WebContext(url.takeIf { it.isIndependent }, text)) } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt index 857c166d..33a4875f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt @@ -106,7 +106,7 @@ class LoginWebView @JvmOverloads constructor( } override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { - //For now, we will ignore all attempts to launch external apps during login + // For now, we will ignore all attempts to launch external apps during login if (request.url == null || request.url.scheme == "intent" || request.url.scheme == "android-app") return true return super.shouldOverrideUrlLoading(view, request) |