diff options
author | Allan Wang <me@allanwang.ca> | 2019-06-13 18:56:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-13 18:56:33 -0700 |
commit | c7c983d2658510302c03abc398a6398c6fb484a8 (patch) | |
tree | 70abfabf3473a061cdb863fdfc1d8bb0e25d2a80 /app/src/main/kotlin | |
parent | ace51697528fc05bad88eddf4dea6fe52ca008ba (diff) | |
parent | b39774a9a1103809b0eb54ef1cd2b695ad8ce8b3 (diff) | |
download | frost-c7c983d2658510302c03abc398a6398c6fb484a8.tar.gz frost-c7c983d2658510302c03abc398a6398c6fb484a8.tar.bz2 frost-c7c983d2658510302c03abc398a6398c6fb484a8.zip |
Merge pull request #1442 from AllanWang/kau-update
KAU Update
Diffstat (limited to 'app/src/main/kotlin')
25 files changed, 64 insertions, 48 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt index cc1ae466..cf8acdd3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt @@ -28,7 +28,7 @@ import ca.allanwang.kau.utils.buildIsLollipopAndUp import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.startActivity import ca.allanwang.kau.utils.string -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.activities.LoginActivity import com.pitchedapps.frost.activities.MainActivity import com.pitchedapps.frost.activities.SelectorActivity 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 3c5f71c2..56125303 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -40,10 +40,10 @@ import ca.allanwang.kau.utils.withMinAlpha import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.aboutlibraries.entity.License -import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import com.mikepenz.community_material_typeface_library.CommunityMaterial import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.items.AbstractItem -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.mikepenz.iconics.typeface.IIcon import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R 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 ea062cf7..b2946852 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -60,7 +60,7 @@ import co.zsmb.materialdrawerkt.draweritems.profile.profileSetting import com.afollestad.materialdialogs.checkbox.checkBoxPrompt import com.google.android.material.appbar.AppBarLayout import com.google.android.material.tabs.TabLayout -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.materialdrawer.AccountHeader diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt index 0ad0204f..a1b41830 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt @@ -25,7 +25,7 @@ import ca.allanwang.kau.internal.KauBaseActivity import ca.allanwang.kau.utils.launchMain import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.visible -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.injectors.JsActions 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 de553376..814ce778 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -42,7 +42,7 @@ import ca.allanwang.kau.utils.withMinAlpha import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.google.android.material.floatingactionbutton.FloatingActionButton -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.mikepenz.iconics.typeface.IIcon import com.pitchedapps.frost.R import com.pitchedapps.frost.facebook.FB_IMAGE_ID_MATCHER @@ -121,7 +121,7 @@ class ImageActivity : KauBaseActivity() { private val cookie: String? by lazy { intent.getStringExtra(ARG_COOKIE) } - val imageUrl: String by lazy { intent.getStringExtra(ARG_IMAGE_URL).trim('"') } + val imageUrl: String by lazy { intent.getStringExtra(ARG_IMAGE_URL)?.trim('"') ?: "" } private lateinit var trueImageUrl: Deferred<String> @@ -146,7 +146,9 @@ class ImageActivity : KauBaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - intent?.extras ?: return finish() + if (imageUrl.isEmpty()) { + return finish() + } L.i { "Displaying image" } trueImageUrl = async(Dispatchers.IO) { val result = if (!imageUrl.isIndirectImageUrl) imageUrl 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 e1d03314..1e106765 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -41,7 +41,7 @@ import ca.allanwang.kau.utils.postDelayed import ca.allanwang.kau.utils.scaleXY import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.statusBarColor -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.intro.BaseIntroFragment import com.pitchedapps.frost.intro.IntroAccountFragment diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt index e78da3be..3007933c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt @@ -37,8 +37,8 @@ import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.tint import ca.allanwang.kau.utils.withSceneTransitionAnimation import com.afollestad.materialdialogs.list.listItems -import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.community_material_typeface_library.CommunityMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.enums.Support import com.pitchedapps.frost.settings.getAppearancePrefs diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt index c6bcbb6a..6ad7d3f2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt @@ -32,7 +32,7 @@ import ca.allanwang.kau.utils.withAlpha import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter import com.mikepenz.fastadapter_extensions.drag.ItemTouchCallback import com.mikepenz.fastadapter_extensions.drag.SimpleDragCallback -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.db.GenericDao import com.pitchedapps.frost.db.TAB_COUNT diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt index ff31b56b..5b2d01d4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -47,8 +47,8 @@ import ca.allanwang.kau.utils.toast import ca.allanwang.kau.utils.withAlpha import ca.allanwang.kau.utils.withMainContext import com.google.android.material.snackbar.BaseTransientBottomBar -import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.community_material_typeface_library.CommunityMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.contracts.ActivityContract import com.pitchedapps.frost.contracts.FileChooserContract @@ -163,13 +163,16 @@ open class WebOverlayActivityBase(private val forceDesktopAgent: Boolean) : Base val content: FrostContentWeb by bindView(R.id.frost_content_web) val web: FrostWebView get() = content.coreView - val coordinator: CoordinatorLayout by bindView(R.id.overlay_main_content) + private val coordinator: CoordinatorLayout by bindView(R.id.overlay_main_content) private inline val urlTest: String? get() = intent.getStringExtra(ARG_URL) ?: intent.dataString + /** + * Nonnull variant; verify by checking [urlTest] + */ override val baseUrl: String - get() = (intent.getStringExtra(ARG_URL) ?: intent.dataString).formattedFbUrl + get() = urlTest!!.formattedFbUrl override val baseEnum: FbItem? = null diff --git a/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt b/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt index f128edcf..6bb50ccd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt @@ -209,9 +209,9 @@ class OfflineWebsite( delete() } baseDir.listFiles { file -> file != zip } - .forEach { it.zip() } + ?.forEach { it.zip() } assetDir.listFiles() - .forEach { it.zip("assets/${it.name}") } + ?.forEach { it.zip("assets/${it.name}") } assetDir.delete() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt index 16952e49..82e15111 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt @@ -17,10 +17,10 @@ package com.pitchedapps.frost.facebook import androidx.annotation.StringRes -import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.community_material_typeface_library.CommunityMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.mikepenz.iconics.typeface.IIcon -import com.mikepenz.iconics.typeface.library.materialdesigniconic.MaterialDesignIconic +import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic import com.pitchedapps.frost.R import com.pitchedapps.frost.fragments.BaseFragment import com.pitchedapps.frost.fragments.MenuFragment diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt index 0000195c..55fbcd40 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt @@ -82,7 +82,7 @@ abstract class BaseFragment : Fragment(), CoroutineScope, FragmentContract, Dyna override val coroutineContext: CoroutineContext get() = ContextHelper.dispatcher + job - override val baseUrl: String by lazy { arguments!!.getString(ARG_URL) } + override val baseUrl: String by lazy { arguments!!.getString(ARG_URL)!! } override val baseEnum: FbItem by lazy { FbItem[arguments]!! } override val position: Int by lazy { arguments!!.getInt(ARG_POSITION) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt index c81c780b..72367eaa 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt @@ -17,7 +17,7 @@ package com.pitchedapps.frost.fragments import android.webkit.WebView -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.contracts.MainFabContract import com.pitchedapps.frost.facebook.FbItem 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 bddf42b2..1fd8c76e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt @@ -27,7 +27,7 @@ import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.tint import ca.allanwang.kau.utils.visible import ca.allanwang.kau.utils.withAlpha -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.launchTabCustomizerActivity diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index 4b0e1a82..0b1deb4e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -170,7 +170,7 @@ enum class NotificationType( val ringtone = ringtone() notifs.forEachIndexed { i, notif -> // Ring at most twice - notif.withAlert(i < 2, ringtone).notify(context) + notif.withAlert(context, i < 2, ringtone).notify(context) } return notifs.size } @@ -302,8 +302,8 @@ data class FrostNotification( val notif: NotificationCompat.Builder ) { - fun withAlert(enable: Boolean, ringtone: String): FrostNotification { - notif.setFrostAlert(enable, ringtone) + fun withAlert(context: Context, enable: Boolean, ringtone: String): FrostNotification { + notif.setFrostAlert(context, enable, ringtone) return this } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt index a8ecb27d..0d707dae 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt @@ -82,7 +82,7 @@ private const val ARG_1 = "frost_request_arg_1" private const val ARG_2 = "frost_request_arg_2" private const val ARG_3 = "frost_request_arg_3" -private fun BaseBundle.getCookie() = getString(ARG_COOKIE) +private fun BaseBundle.getCookie(): String = getString(ARG_COOKIE)!! private fun BaseBundle.putCookie(cookie: String) = putString(ARG_COOKIE, cookie) /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt index 0eee5558..1d983f14 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt @@ -132,7 +132,7 @@ class NotificationService : BaseJobService() { private fun generalNotification(id: Int, textRes: Int, withDefaults: Boolean) { val notifBuilder = frostNotification(NOTIF_CHANNEL_GENERAL) - .setFrostAlert(withDefaults, Prefs.notificationRingtone) + .setFrostAlert(this, withDefaults, Prefs.notificationRingtone) .setContentTitle(string(R.string.frost_name)) .setContentText(string(textRes)) NotificationManagerCompat.from(this).notify(id, notifBuilder.build()) 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 bba2a9a1..7327d098 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt @@ -24,7 +24,6 @@ import android.app.job.JobScheduler import android.app.job.JobService import android.content.ComponentName import android.content.Context -import android.net.Uri import android.os.Build import android.os.PersistableBundle import androidx.annotation.RequiresApi @@ -34,6 +33,7 @@ import ca.allanwang.kau.utils.string import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.frostUri /** * Created by Allan Wang on 07/04/18. @@ -85,7 +85,7 @@ fun Context.frostNotification(id: String) = * Delegates to channels if Android O and up * Otherwise uses our provided preferences */ -fun NotificationCompat.Builder.setFrostAlert(enable: Boolean, ringtone: String): NotificationCompat.Builder { +fun NotificationCompat.Builder.setFrostAlert(context: Context, enable: Boolean, ringtone: String): NotificationCompat.Builder { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { setGroupAlertBehavior( if (enable) NotificationCompat.GROUP_ALERT_CHILDREN @@ -97,7 +97,7 @@ fun NotificationCompat.Builder.setFrostAlert(enable: Boolean, ringtone: String): var defaults = 0 if (Prefs.notificationVibrate) defaults = defaults or Notification.DEFAULT_VIBRATE if (Prefs.notificationSound) { - if (ringtone.isNotBlank()) setSound(Uri.parse(ringtone)) + if (ringtone.isNotBlank()) setSound(context.frostUri(ringtone)) else defaults = defaults or Notification.DEFAULT_SOUND } if (Prefs.notificationLights) defaults = defaults or Notification.DEFAULT_LIGHTS diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt index f7cf3ee3..c764244b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt @@ -44,7 +44,6 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { item.pref = index shouldRestartMain() } - } } } 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 777b4edd..40ff071e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -19,7 +19,6 @@ package com.pitchedapps.frost.settings import android.annotation.SuppressLint import android.content.Intent import android.media.RingtoneManager -import android.net.Uri import android.os.Build import android.provider.Settings import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder @@ -39,6 +38,7 @@ import com.pitchedapps.frost.services.fetchNotifications import com.pitchedapps.frost.services.scheduleNotifications import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.frostSnackbar +import com.pitchedapps.frost.utils.frostUri import com.pitchedapps.frost.views.Keywords import kotlinx.coroutines.launch @@ -136,7 +136,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { enabler = Prefs::notificationSound textGetter = { if (it.isBlank()) string(R.string.kau_default) - else RingtoneManager.getRingtone(this@getNotificationPrefs, Uri.parse(it)) + else RingtoneManager.getRingtone(this@getNotificationPrefs, frostUri(it)) ?.getTitle(this@getNotificationPrefs) ?: "---" //todo figure out why this happens } @@ -146,8 +146,12 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false) putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true) putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION) - if (item.pref.isNotBlank()) - putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(item.pref)) + if (item.pref.isNotBlank()) { + putExtra( + RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, + frostUri(item.pref) + ) + } } startActivityForResult(intent, code) } 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 a6a9e721..8ad0d432 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -34,11 +34,9 @@ import ca.allanwang.kau.email.EmailBuilder import ca.allanwang.kau.email.sendEmail import ca.allanwang.kau.mediapicker.createMediaFile import ca.allanwang.kau.mediapicker.createPrivateMediaFile -import ca.allanwang.kau.utils.adjustAlpha import ca.allanwang.kau.utils.colorToForeground import ca.allanwang.kau.utils.darken import ca.allanwang.kau.utils.isColorDark -import ca.allanwang.kau.utils.lighten import ca.allanwang.kau.utils.navigationBarColor import ca.allanwang.kau.utils.snackbar import ca.allanwang.kau.utils.startActivity @@ -47,9 +45,7 @@ import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.with import ca.allanwang.kau.utils.withAlpha -import ca.allanwang.kau.utils.withMinAlpha import ca.allanwang.kau.xml.showChangelog -import com.afollestad.materialdialogs.MaterialDialog import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.SnackbarContentLayout import com.pitchedapps.frost.BuildConfig @@ -351,6 +347,18 @@ fun Context.frostUriFromFile(file: File): Uri = file ) +/** + * Gets uri from our own resolver if it's a file, or return the parsed uri otherwise + */ +fun Context.frostUri(entry: String): Uri { + val uri = Uri.parse(entry) + val path = uri.path + if (uri.scheme == "file" && path != null) { + return frostUriFromFile(File(path)) + } + return uri +} + inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit) = sendFrostEmail(string(subjectId), builder) @@ -389,7 +397,7 @@ fun File.createFreshFile(): Boolean { if (!delete()) return false } else { val parent = parentFile - if (!parent.exists() && !parent.mkdirs()) + if (parent != null && !parent.exists() && !parent.mkdirs()) return false } return createNewFile() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt index 98909e0a..0269b1a9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt @@ -31,7 +31,7 @@ import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.target.Target -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.db.CookieEntity import com.pitchedapps.frost.facebook.profilePictureUrl diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt index 6ee34a2b..b3912bab 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt @@ -97,7 +97,7 @@ class FrostVideoView @JvmOverloads constructor( if (!isPlaying) showControls() else viewerContract.onControlsHidden() } - } + }.start() } else { hideControls() val (scale, tX, tY) = mapBounds() @@ -108,7 +108,7 @@ class FrostVideoView @JvmOverloads constructor( withAnimator(origScale, scale) { scaleXY = it } withAnimator(origX, tX) { translationX = it } withAnimator(origY, tY) { translationY = it } - } + }.start() } } @@ -231,7 +231,7 @@ class FrostVideoView @JvmOverloads constructor( duration = FAST_ANIMATION_DURATION withAnimator(alpha, 0f) { alpha = it } withEndAction { onFinishedListener() } - } + }.start() else onFinishedListener() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt index 6593a8df..4d88ad3d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt @@ -38,7 +38,7 @@ import ca.allanwang.kau.utils.setMenuIcons import ca.allanwang.kau.utils.visible import ca.allanwang.kau.utils.withMinAlpha import com.devbrackets.android.exomedia.listener.VideoControlsVisibilityListener -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.db.FrostDatabase import com.pitchedapps.frost.db.currentCookie diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt index 0d596086..e63fcc21 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt @@ -34,7 +34,7 @@ import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter import com.mikepenz.fastadapter.items.AbstractItem import com.mikepenz.fastadapter.listeners.ClickEventHook -import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.mikepenz.iconics.typeface.IIcon import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.Prefs |