aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.idea/codeStyles/Project.xml25
-rw-r--r--.idea/encodings.xml4
-rw-r--r--.idea/kotlinScripting.xml6
-rw-r--r--app/build.gradle119
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt26
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt17
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt13
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt33
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt27
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt16
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt33
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt40
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt19
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt6
-rw-r--r--app/src/main/play/en-US/whatsnew10
-rw-r--r--app/src/main/res/values-fr-rFR/strings.xml2
-rw-r--r--app/src/main/res/values-pt-rBR/strings.xml2
-rw-r--r--app/src/main/res/values/dimens.xml2
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/values/styles.xml4
-rw-r--r--app/src/main/res/xml/frost_changelog.xml2
-rw-r--r--build.gradle32
-rw-r--r--buildSrc/.gitignore2
-rw-r--r--buildSrc/build.gradle.kts24
-rw-r--r--buildSrc/src/main/kotlin/Versions.kt37
-rw-r--r--docs/Changelog.md1
-rw-r--r--gradle.properties52
-rw-r--r--gradle/wrapper/gradle-wrapper.properties4
-rw-r--r--settings.gradle1
-rw-r--r--settings.gradle.kts3
38 files changed, 321 insertions, 287 deletions
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 0290b2f8..be6976dc 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -13,31 +13,6 @@
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
- <Objective-C-extensions>
- <file>
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
- </file>
- <class>
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
- <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
- </class>
- <extensions>
- <pair source="cpp" header="h" fileNamingConvention="NONE" />
- <pair source="c" header="h" fileNamingConvention="NONE" />
- </extensions>
- </Objective-C-extensions>
<XML>
<option name="XML_KEEP_LINE_BREAKS" value="false" />
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 00000000..15a15b21
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project> \ No newline at end of file
diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml
new file mode 100644
index 00000000..a6fe551d
--- /dev/null
+++ b/.idea/kotlinScripting.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="KotlinScriptingSettings">
+ <option name="isAutoReloadEnabled" value="true" />
+ </component>
+</project> \ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 4d1ec15e..2348e053 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -10,8 +10,8 @@ apply from: '../spotless.gradle'
group = APP_GROUP
android {
- compileSdkVersion kau.targetSdk
- buildToolsVersion kau.buildTools
+ compileSdkVersion kau.Versions.targetSdk
+ buildToolsVersion kau.Versions.buildTools
androidGitVersion {
codeFormat = 'MMNNPPXX'
@@ -20,9 +20,9 @@ android {
}
defaultConfig {
- applicationId "${project.APP_GROUP}." + project.APP_ID.toLowerCase(Locale.CANADA)
- minSdkVersion kau.minSdk
- targetSdkVersion kau.targetSdk
+ applicationId "${project.APP_GROUP}.${project.APP_ID.toLowerCase(Locale.CANADA)}"
+ minSdkVersion kau.Versions.minSdk
+ targetSdkVersion kau.Versions.targetSdk
versionCode androidGitVersion.code()
versionName androidGitVersion.name()
multiDexEnabled true
@@ -139,6 +139,7 @@ android {
}
packagingOptions {
+ pickFirst 'META-INF/core_release.kotlin_module'
pickFirst 'META-INF/library_release.kotlin_module'
}
@@ -175,96 +176,96 @@ repositories {
dependencies {
implementation 'androidx.exifinterface:exifinterface:1.0.0'
- androidTestImplementation kauDependency.kotlinTest
- androidTestImplementation kauDependency.espresso
- androidTestImplementation kauDependency.testRules
- androidTestImplementation kauDependency.testRunner
- androidTestImplementation "org.jetbrains.kotlin:kotlin-reflect:${KOTLIN}"
+ androidTestImplementation kau.Dependencies.kotlinTest
+ androidTestImplementation kau.Dependencies.espresso
+ androidTestImplementation kau.Dependencies.testRules
+ androidTestImplementation kau.Dependencies.testRunner
+ androidTestImplementation kau.Dependencies.kotlinReflect
- testImplementation kauDependency.kotlinTest
- testImplementation "org.jetbrains.kotlin:kotlin-reflect:${KOTLIN}"
- testImplementation kauDependency.junit
+ testImplementation kau.Dependencies.kotlinTest
+ testImplementation kau.Dependencies.kotlinReflect
+ testImplementation kau.Dependencies.junit
- implementation "org.jetbrains.kotlin:kotlin-stdlib:${KOTLIN}"
+ implementation kau.Dependencies.kotlin
//noinspection GradleDependency
- implementation "ca.allanwang.kau:adapter:$KAU"
+ implementation "ca.allanwang.kau:adapter:${KAU}"
//noinspection GradleDependency
- implementation "ca.allanwang.kau:about:$KAU"
+ implementation "ca.allanwang.kau:about:${KAU}"
//noinspection GradleDependency
- implementation "ca.allanwang.kau:colorpicker:$KAU"
+ implementation "ca.allanwang.kau:colorpicker:${KAU}"
//noinspection GradleDependency
- implementation "ca.allanwang.kau:mediapicker:$KAU"
+ implementation "ca.allanwang.kau:mediapicker:${KAU}"
//noinspection GradleDependency
- implementation "ca.allanwang.kau:kpref-activity:$KAU"
+ implementation "ca.allanwang.kau:kpref-activity:${KAU}"
//noinspection GradleDependency
- implementation "ca.allanwang.kau:searchview:$KAU"
+ implementation "ca.allanwang.kau:searchview:${KAU}"
//noinspection GradleDependency
- implementation "ca.allanwang.kau:core:$KAU"
+ implementation "ca.allanwang.kau:core:${KAU}"
//noinspection GradleDependency
- implementation "ca.allanwang.kau:core-ui:$KAU"
+ implementation "ca.allanwang.kau:core-ui:${KAU}"
- implementation "androidx.core:core-ktx:${KTX}"
+ implementation "androidx.core:core-ktx:${Versions.ktx}"
- implementation "androidx.biometric:biometric:${ANDX_BIOMETRIC}"
+ implementation "androidx.biometric:biometric:${Versions.andxBiometric}"
- implementation "org.koin:koin-android:${KOIN}"
- testImplementation "org.koin:koin-test:${KOIN}"
- androidTestImplementation "org.koin:koin-test:${KOIN}"
+ implementation "org.koin:koin-android:${Versions.koin}"
+ testImplementation "org.koin:koin-test:${Versions.koin}"
+ androidTestImplementation "org.koin:koin-test:${Versions.koin}"
-// androidTestImplementation "io.mockk:mockk:${MOCKK}"
+// androidTestImplementation "io.mockk:mockk:${Versions.mockk}"
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${kau.coroutines}"
+ implementation kau.Dependencies.coroutines
- implementation "org.apache.commons:commons-text:${COMMONS_TEXT}"
+ implementation "org.apache.commons:commons-text:${Versions.apacheCommonsText}"
- implementation "com.devbrackets.android:exomedia:${EXOMEDIA}"
+ implementation "com.devbrackets.android:exomedia:${Versions.exoMedia}"
- implementation "com.mikepenz:fastadapter-extensions:${kau.fastAdapter}@aar"
+ implementation kau.Dependencies.fastAdapter("extensions")
//noinspection GradleDependency
- implementation "com.github.bumptech.glide:okhttp3-integration:${kau.glide}"
+ implementation kau.Dependencies.glide
//noinspection GradleDependency
- kapt "com.github.bumptech.glide:compiler:${kau.glide}"
+ kapt kau.Dependencies.glideKapt
- implementation "com.fasterxml.jackson.core:jackson-databind:${JACKSON}"
+ implementation "com.fasterxml.jackson.core:jackson-databind:${Versions.jackson}"
//noinspection GradleDependency
- releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${LEAK_CANARY}"
+ releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${Versions.leakCanary}"
//noinspection GradleDependency
- releaseTestImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${LEAK_CANARY}"
+ releaseTestImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${Versions.leakCanary}"
//noinspection GradleDependency
- debugImplementation "com.squareup.leakcanary:leakcanary-android:${LEAK_CANARY}"
-// testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${LEAK_CANARY}"
+ debugImplementation "com.squareup.leakcanary:leakcanary-android:${Versions.leakCanary}"
+// testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${Versions.leakCanary}"
- implementation "com.github.Raizlabs.DBFlow:dbflow:${DBFLOW}"
- implementation "com.github.Raizlabs.DBFlow:dbflow-core:${DBFLOW}"
- kapt "com.github.Raizlabs.DBFlow:dbflow-processor:${DBFLOW}"
- implementation "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:${DBFLOW}"
+ implementation "com.github.Raizlabs.DBFlow:dbflow:${Versions.dbflow}"
+ implementation "com.github.Raizlabs.DBFlow:dbflow-core:${Versions.dbflow}"
+ kapt "com.github.Raizlabs.DBFlow:dbflow-processor:${Versions.dbflow}"
+ implementation "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:${Versions.dbflow}"
//Icons
- implementation "com.mikepenz:material-design-iconic-typeface:${kau.iconicsMaterial}@aar"
- implementation "com.mikepenz:community-material-typeface:${kau.iconicsCommunity}@aar"
+ implementation kau.Dependencies.iconicsMaterial
+ implementation kau.Dependencies.iconicsCommunity
- implementation "org.jsoup:jsoup:${JSOUP}"
+ implementation "org.jsoup:jsoup:${Versions.jsoup}"
- implementation "com.squareup.okhttp3:okhttp:${OKHTTP}"
- implementation "com.squareup.okhttp3:logging-interceptor:${OKHTTP}"
- testImplementation "com.squareup.okhttp3:mockwebserver:${OKHTTP}"
- androidTestImplementation "com.squareup.okhttp3:mockwebserver:${OKHTTP}"
+ implementation "com.squareup.okhttp3:okhttp:${Versions.okhttp}"
+ implementation "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp}"
+ testImplementation "com.squareup.okhttp3:mockwebserver:${Versions.okhttp}"
+ androidTestImplementation "com.squareup.okhttp3:mockwebserver:${Versions.okhttp}"
- implementation "co.zsmb:materialdrawer-kt:${MATERIAL_DRAWER_KT}"
+ implementation "co.zsmb:materialdrawer-kt:${Versions.materialDrawerKt}"
- implementation "com.bugsnag:bugsnag-android:${BUGSNAG}"
+ implementation kau.Dependencies.bugsnag
- implementation "com.davemorrissey.labs:subsampling-scale-image-view:${SCALE_IMAGE_VIEW}"
+ implementation "com.davemorrissey.labs:subsampling-scale-image-view:${Versions.scaleImageView}"
- implementation "com.sothree.slidinguppanel:library:${SLIDING_PANEL}"
+ implementation "com.sothree.slidinguppanel:library:${Versions.slidingPanel}"
- implementation "androidx.room:room-coroutines:${ROOM}"
- implementation "androidx.room:room-runtime:${ROOM}"
- kapt "androidx.room:room-compiler:${ROOM}"
- testImplementation "androidx.room:room-testing:${ROOM}"
+ implementation "androidx.room:room-ktx:${Versions.room}"
+ implementation "androidx.room:room-runtime:${Versions.room}"
+ kapt "androidx.room:room-compiler:${Versions.room}"
+ testImplementation "androidx.room:room-testing:${Versions.room}"
}
@@ -289,7 +290,7 @@ configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'org.jetbrains.kotlin' && requested.name in kotlinResolutions) {
- details.useVersion KOTLIN
+ details.useVersion kau.Versions.kotlin
}
}
}
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 49d5f8bf..b2946852 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -40,6 +40,7 @@ import ca.allanwang.kau.searchview.SearchViewHolder
import ca.allanwang.kau.searchview.bindSearchView
import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.fadeScaleTransition
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.restart
import ca.allanwang.kau.utils.setIcon
import ca.allanwang.kau.utils.setMenuIcons
@@ -56,6 +57,7 @@ import co.zsmb.materialdrawerkt.draweritems.badgeable.secondaryItem
import co.zsmb.materialdrawerkt.draweritems.divider
import co.zsmb.materialdrawerkt.draweritems.profile.profile
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.google_material_typeface_library.GoogleMaterial
@@ -99,7 +101,6 @@ import com.pitchedapps.frost.utils.frostNavigationBar
import com.pitchedapps.frost.utils.launchLogin
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.launchWebOverlay
-import com.pitchedapps.frost.utils.materialDialogThemed
import com.pitchedapps.frost.utils.setFrostColors
import com.pitchedapps.frost.views.BadgedIcon
import com.pitchedapps.frost.views.FrostVideoViewer
@@ -293,21 +294,21 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
FbCookie.reset()
launchLogin(cookies(), true)
} else {
- materialDialogThemed {
+ materialDialog {
title(R.string.kau_logout)
- content(
+ message(
+ text =
String.format(
string(R.string.kau_logout_confirm_as_x),
currentCookie.name ?: Prefs.userId.toString()
)
)
- positiveText(R.string.kau_yes)
- negativeText(R.string.kau_no)
- onPositive { _, _ ->
+ positiveButton(R.string.kau_yes) {
this@BaseMainActivity.launch {
FbCookie.logout(this@BaseMainActivity)
}
}
+ negativeButton(R.string.kau_no)
}
}
}
@@ -518,13 +519,14 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
if (currentFragment.onBackPressed()) return true
if (Prefs.exitConfirmation) {
- materialDialogThemed {
+ materialDialog {
title(R.string.kau_exit)
- content(R.string.kau_exit_confirmation)
- positiveText(R.string.kau_yes)
- negativeText(R.string.kau_no)
- onPositive { _, _ -> finish() }
- checkBoxPromptRes(R.string.kau_do_not_show_again, false) { _, b -> Prefs.exitConfirmation = !b }
+ message(R.string.kau_exit_confirmation)
+ positiveButton(R.string.kau_yes) { finish() }
+ negativeButton(R.string.kau_no)
+ checkBoxPrompt(R.string.kau_do_not_show_again, isCheckedDefault = false) {
+ Prefs.exitConfirmation = !it
+ }
}
return true
}
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 b94acb63..814ce778 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -33,6 +33,7 @@ import ca.allanwang.kau.utils.copyFromInputStream
import ca.allanwang.kau.utils.fadeOut
import ca.allanwang.kau.utils.isHidden
import ca.allanwang.kau.utils.isVisible
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.scaleXY
import ca.allanwang.kau.utils.setIcon
import ca.allanwang.kau.utils.tint
@@ -58,7 +59,6 @@ import com.pitchedapps.frost.utils.frostSnackbar
import com.pitchedapps.frost.utils.frostUriFromFile
import com.pitchedapps.frost.utils.isIndirectImageUrl
import com.pitchedapps.frost.utils.logFrostEvent
-import com.pitchedapps.frost.utils.materialDialogThemed
import com.pitchedapps.frost.utils.sendFrostEmail
import com.pitchedapps.frost.utils.setFrostColors
import com.sothree.slidinguppanel.SlidingUpPanelLayout
@@ -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
@@ -297,18 +299,17 @@ internal enum class FabStates(
val err =
activity.errorRef?.takeIf { it !is FileNotFoundException && it.message != "Image failed to decode using JPEG decoder" }
?: return
- activity.materialDialogThemed {
+ activity.materialDialog {
title(R.string.kau_error)
- content(R.string.bad_image_overlay)
- positiveText(R.string.kau_yes)
- onPositive { _, _ ->
+ message(R.string.bad_image_overlay)
+ positiveButton(R.string.kau_yes) {
activity.sendFrostEmail(R.string.debug_image_link_subject) {
addItem("Url", activity.imageUrl)
addItem("Type", err.javaClass.name)
addItem("Message", err.message ?: "Null")
}
}
- negativeText(R.string.kau_no)
+ negativeButton(R.string.kau_no)
}
}
},
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 bc20aa2d..3007933c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
@@ -29,12 +29,14 @@ import ca.allanwang.kau.kpref.activity.KPrefActivity
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
import ca.allanwang.kau.ui.views.RippleCanvas
import ca.allanwang.kau.utils.finishSlideOut
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.setMenuIcons
import ca.allanwang.kau.utils.startActivityForResult
import ca.allanwang.kau.utils.startLink
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.community_material_typeface_library.CommunityMaterial
import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.pitchedapps.frost.R
@@ -55,7 +57,6 @@ import com.pitchedapps.frost.utils.frostChangelog
import com.pitchedapps.frost.utils.frostNavigationBar
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.loadAssets
-import com.pitchedapps.frost.utils.materialDialogThemed
import com.pitchedapps.frost.utils.setFrostTheme
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.launch
@@ -235,10 +236,11 @@ class SettingsActivity : KPrefActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
- R.id.action_email -> materialDialogThemed {
+ R.id.action_email -> materialDialog {
title(R.string.subject)
- items(Support.values().map { string(it.title) })
- itemsCallback { _, _, which, _ -> Support.values()[which].sendEmail(this@SettingsActivity) }
+ listItems(items = Support.values().map { string(it.title) }) { _, index, _ ->
+ Support.values()[index].sendEmail(this@SettingsActivity)
+ }
}
R.id.action_changelog -> frostChangelog()
else -> return super.onOptionsItemSelected(item)
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 ec4ff9dd..5b2d01d4 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -36,6 +36,7 @@ import ca.allanwang.kau.utils.copyToClipboard
import ca.allanwang.kau.utils.darken
import ca.allanwang.kau.utils.dpToPx
import ca.allanwang.kau.utils.finishSlideOut
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.navigationBarColor
import ca.allanwang.kau.utils.setMenuIcons
import ca.allanwang.kau.utils.shareText
@@ -69,7 +70,6 @@ import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.Showcase
import com.pitchedapps.frost.utils.frostSnackbar
-import com.pitchedapps.frost.utils.materialDialogThemed
import com.pitchedapps.frost.utils.setFrostColors
import com.pitchedapps.frost.views.FrostContentWeb
import com.pitchedapps.frost.views.FrostVideoViewer
@@ -109,9 +109,9 @@ class FrostWebActivity : WebOverlayActivityBase(false) {
refreshReceiver.receive()
refreshReceiver.cancel()
withMainContext {
- materialDialogThemed {
+ materialDialog {
title(R.string.invalid_share_url)
- content(R.string.invalid_share_url_desc)
+ message(R.string.invalid_share_url_desc)
}
}
}
@@ -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/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/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/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
index a6437123..718b2dbb 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
@@ -20,7 +20,9 @@ import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
import ca.allanwang.kau.kpref.activity.items.KPrefColorPicker
import ca.allanwang.kau.kpref.activity.items.KPrefSeekbar
import ca.allanwang.kau.ui.views.RippleCanvas
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.string
+import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.SettingsActivity
import com.pitchedapps.frost.enums.MainActivityLayout
@@ -33,7 +35,6 @@ import com.pitchedapps.frost.utils.frostEvent
import com.pitchedapps.frost.utils.frostNavigationBar
import com.pitchedapps.frost.utils.frostSnackbar
import com.pitchedapps.frost.utils.launchTabCustomizerActivity
-import com.pitchedapps.frost.utils.materialDialogThemed
import com.pitchedapps.frost.utils.setFrostTheme
import com.pitchedapps.frost.views.KPrefTextSeekbar
@@ -46,20 +47,21 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
text(R.string.theme, Prefs::theme, { Prefs.theme = it }) {
onClick = {
- materialDialogThemed {
+ materialDialog {
title(R.string.theme)
- items(Theme.values().map { string(it.textRes) })
- itemsCallbackSingleChoice(item.pref) { _, _, which, _ ->
- if (item.pref != which) {
- item.pref = which
+ listItemsSingleChoice(
+ items = Theme.values().map { string(it.textRes) },
+ initialSelection = item.pref
+ ) { _, index, _ ->
+ if (item.pref != index) {
+ item.pref = index
shouldRestartMain()
reload()
setFrostTheme(true)
themeExterior()
invalidateOptionsMenu()
- frostEvent("Theme", "Count" to Theme(which).name)
+ frostEvent("Theme", "Count" to Theme(index).name)
}
- true
}
}
}
@@ -134,16 +136,17 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
text(R.string.main_activity_layout, Prefs::mainActivityLayoutType, { Prefs.mainActivityLayoutType = it }) {
textGetter = { string(Prefs.mainActivityLayout.titleRes) }
onClick = {
- materialDialogThemed {
+ materialDialog {
title(R.string.main_activity_layout_desc)
- items(MainActivityLayout.values.map { string(it.titleRes) })
- itemsCallbackSingleChoice(item.pref) { _, _, which, _ ->
- if (item.pref != which) {
- item.pref = which
+ listItemsSingleChoice(
+ items = MainActivityLayout.values.map { string(it.titleRes) },
+ initialSelection = item.pref
+ ) { _, index, _ ->
+ if (item.pref != index) {
+ item.pref = index
shouldRestartMain()
- frostEvent("Main Layout", "Type" to MainActivityLayout(which).name)
+ frostEvent("Main Layout", "Type" to MainActivityLayout(index).name)
}
- true
}
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
index 1ee06464..ea50a57b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
@@ -24,6 +24,8 @@ import ca.allanwang.kau.utils.startActivityForResult
import ca.allanwang.kau.utils.string
import ca.allanwang.kau.utils.toast
import ca.allanwang.kau.utils.withMainContext
+import com.afollestad.materialdialogs.callbacks.onDismiss
+import com.afollestad.materialdialogs.list.listItems
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.DebugActivity
import com.pitchedapps.frost.activities.SettingsActivity
@@ -68,20 +70,18 @@ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = {
val parsers = arrayOf(NotifParser, MessageParser, SearchParser)
materialDialog {
- items(parsers.map { string(it.nameRes) })
- itemsCallback { dialog, _, position, _ ->
+ listItems(items = parsers.map { string(it.nameRes) }) { dialog, position, _ ->
dialog.dismiss()
val parser = parsers[position]
var attempt: Job? = null
val loading = materialDialog {
- content(parser.nameRes)
- progress(true, 100)
- negativeText(R.string.kau_cancel)
- onNegative { dialog, _ ->
+ message(parser.nameRes)
+ // TODO change dialog? No more progress view
+ negativeButton(R.string.kau_cancel) {
attempt?.cancel()
- dialog.dismiss()
+ it.dismiss()
}
- canceledOnTouchOutside(false)
+ cancelOnTouchOutside(false)
}
attempt = launch(Dispatchers.IO) {
@@ -122,18 +122,17 @@ fun SettingsActivity.sendDebug(url: String, html: String?) {
val md = materialDialog {
title(R.string.parsing_data)
- progress(false, 100)
- negativeText(R.string.kau_cancel)
- onNegative { dialog, _ -> dialog.dismiss() }
- canceledOnTouchOutside(false)
- dismissListener { job.cancel() }
+ // TODO remove dialog? No progress ui
+ negativeButton(R.string.kau_cancel) { it.dismiss() }
+ cancelOnTouchOutside(false)
+ onDismiss { job.cancel() }
}
val progressChannel = Channel<Int>(10)
launchMain {
for (p in progressChannel) {
- md.setProgress(p)
+// md.setProgress(p)
}
}
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 baf68634..c764244b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
@@ -17,13 +17,14 @@
package com.pitchedapps.frost.settings
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.string
+import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.SettingsActivity
import com.pitchedapps.frost.enums.FeedSort
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.REQUEST_REFRESH
-import com.pitchedapps.frost.utils.materialDialogThemed
/**
* Created by Allan Wang on 2017-06-29.
@@ -33,15 +34,16 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
text(R.string.newsfeed_sort, Prefs::feedSort, { Prefs.feedSort = it }) {
descRes = R.string.newsfeed_sort_desc
onClick = {
- materialDialogThemed {
+ materialDialog {
title(R.string.newsfeed_sort)
- items(FeedSort.values().map { string(it.textRes) })
- itemsCallbackSingleChoice(item.pref) { _, _, which, _ ->
- if (item.pref != which) {
- item.pref = which
+ listItemsSingleChoice(
+ items = FeedSort.values().map { string(it.textRes) },
+ initialSelection = item.pref
+ ) { _, index, _ ->
+ if (item.pref != index) {
+ item.pref = index
shouldRestartMain()
}
- true
}
}
}
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 c58710b5..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,13 +19,16 @@ 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
import ca.allanwang.kau.kpref.activity.items.KPrefText
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.minuteToText
import ca.allanwang.kau.utils.string
+import com.afollestad.materialdialogs.callbacks.onDismiss
+import com.afollestad.materialdialogs.customview.customView
+import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.SettingsActivity
@@ -35,7 +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.materialDialogThemed
+import com.pitchedapps.frost.utils.frostUri
import com.pitchedapps.frost.views.Keywords
import kotlinx.coroutines.launch
@@ -49,13 +52,11 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
val options = longArrayOf(15, 30, 60, 120, 180, 300, 1440, 2880)
val texts = options.map { if (it <= 0) string(R.string.no_notifications) else minuteToText(it) }
onClick = {
- materialDialogThemed {
+ materialDialog {
title(R.string.notification_frequency)
- items(texts)
- itemsCallbackSingleChoice(options.indexOf(item.pref)) { _, _, which, _ ->
- item.pref = options[which]
+ listItemsSingleChoice(items = texts, initialSelection = options.indexOf(item.pref)) { _, index, _ ->
+ item.pref = options[index]
scheduleNotifications(item.pref)
- true
}
}
}
@@ -72,11 +73,11 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.notification_keywords_desc
onClick = {
val keywordView = Keywords(this@getNotificationPrefs)
- materialDialogThemed {
+ materialDialog {
title(R.string.notification_keywords)
- customView(keywordView, false)
- dismissListener { keywordView.save() }
- positiveText(R.string.kau_done)
+ customView(view = keywordView)
+ positiveButton(R.string.kau_done)
+ onDismiss { keywordView.save() }
}
}
}
@@ -135,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
}
@@ -145,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/Downloader.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
index 50863e10..b0012b0d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
@@ -25,6 +25,7 @@ import android.webkit.URLUtil
import ca.allanwang.kau.permissions.PERMISSION_WRITE_EXTERNAL_STORAGE
import ca.allanwang.kau.permissions.kauRequestPermissions
import ca.allanwang.kau.utils.isAppEnabled
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.showAppInfo
import ca.allanwang.kau.utils.string
import ca.allanwang.kau.utils.toast
@@ -64,12 +65,13 @@ fun Context.frostDownload(
return L.e { "Invalid download $uri" }
}
if (!isAppEnabled(DOWNLOAD_MANAGER_PACKAGE)) {
- materialDialogThemed {
+ materialDialog {
title(R.string.no_download_manager)
- content(R.string.no_download_manager_desc)
- positiveText(R.string.kau_yes)
- onPositive { _, _ -> showAppInfo(DOWNLOAD_MANAGER_PACKAGE) }
- negativeText(R.string.kau_no)
+ message(R.string.no_download_manager_desc)
+ positiveButton(R.string.kau_yes) {
+ showAppInfo(DOWNLOAD_MANAGER_PACKAGE)
+ }
+ negativeButton(R.string.kau_no)
}
return
}
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 557980af..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
@@ -167,24 +163,6 @@ fun WebOverlayActivity.url(): String {
return intent.getStringExtra(ARG_URL) ?: FbItem.FEED.url
}
-fun Context.materialDialogThemed(action: MaterialDialog.Builder.() -> Unit): MaterialDialog {
- val builder = MaterialDialog.Builder(this).theme()
- builder.action()
- return builder.show()
-}
-
-fun MaterialDialog.Builder.theme(): MaterialDialog.Builder {
- val dimmerTextColor = Prefs.textColor.adjustAlpha(0.8f)
- titleColor(Prefs.textColor)
- contentColor(dimmerTextColor)
- widgetColor(dimmerTextColor)
- backgroundColor(Prefs.bgColor.lighten(0.1f).withMinAlpha(200))
- positiveColor(Prefs.textColor)
- negativeColor(Prefs.textColor)
- neutralColor(Prefs.textColor)
- return this
-}
-
fun Activity.setFrostTheme(forceTransparent: Boolean = false) {
val isTransparent =
(Color.alpha(Prefs.bgColor) != 255) || (Color.alpha(Prefs.headerColor) != 255) || forceTransparent
@@ -360,9 +338,7 @@ val dependentSegments = arrayOf(
inline val String?.isExplicitIntent
get() = this != null && (startsWith("intent://") || startsWith("market://"))
-fun Context.frostChangelog() = showChangelog(R.xml.frost_changelog, Prefs.textColor) {
- theme()
-}
+fun Context.frostChangelog() = showChangelog(R.xml.frost_changelog)
fun Context.frostUriFromFile(file: File): Uri =
FileProvider.getUriForFile(
@@ -371,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)
@@ -409,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/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
index fbaa4574..0a3be830 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
@@ -18,8 +18,11 @@ package com.pitchedapps.frost.utils
import android.content.Context
import ca.allanwang.kau.utils.copyToClipboard
+import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.shareText
import ca.allanwang.kau.utils.string
+import com.afollestad.materialdialogs.callbacks.onDismiss
+import com.afollestad.materialdialogs.list.listItems
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.MainActivity
import com.pitchedapps.frost.facebook.formattedFbUrl
@@ -36,13 +39,12 @@ fun Context.showWebContextMenu(wc: WebContext) {
val menuItems = WebContextType.values
.filter { it.constraint(wc) }
- materialDialogThemed {
- title(title)
- items(menuItems.map { string(it.textId) })
- itemsCallback { _, _, position, _ ->
+ materialDialog {
+ title(text = title)
+ listItems(items = menuItems.map { string(it.textId) }) { _, position, _ ->
menuItems[position].onClick(this@showWebContextMenu, wc)
}
- dismissListener {
+ onDismiss {
//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
}
@@ -66,11 +68,10 @@ enum class WebContextType(
COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc -> c.copyToClipboard(wc.text) }),
SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc -> c.shareText(wc.url) }),
DEBUG_LINK(R.string.debug_link, { it.hasUrl }, { c, wc ->
- c.materialDialogThemed {
+ c.materialDialog {
title(R.string.debug_link)
- content(R.string.debug_link_desc)
- positiveText(R.string.kau_ok)
- onPositive { _, _ ->
+ message(R.string.debug_link_desc)
+ positiveButton(R.string.kau_ok) {
c.sendFrostEmail(R.string.debug_link_subject) {
message = c.string(R.string.debug_link_content)
addItem("Unformatted url", wc.unformattedUrl!!)
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/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew
index 9f440f8b..009f4196 100644
--- a/app/src/main/play/en-US/whatsnew
+++ b/app/src/main/play/en-US/whatsnew
@@ -1 +1,9 @@
-A full changelog is available in the app, or at https://github.com/AllanWang/Frost-for-Facebook/blob/dev/docs/Changelog.md. \ No newline at end of file
+v2.3.0
+
+* Converted internals of Facebook data storage; auto migration will only work from 2.2.x to 2.3.x
+* Added notification widget
+* Update theme
+* Update translations
+* Add fingerprint unlock screen
+* Fix messenger redirect
+* Lots of internal updates \ No newline at end of file
diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml
index 7f9b4233..9c752040 100644
--- a/app/src/main/res/values-fr-rFR/strings.xml
+++ b/app/src/main/res/values-fr-rFR/strings.xml
@@ -56,7 +56,7 @@
The first element is the day, and the second element is the time
-->
- <string name="time_template">%1s à %2s</string>
+ <string name="time_template">%1$s à %2$s</string>
<string name="disclaimer">Clause de non-responsabilité</string>
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 10ae1056..86f0bd4a 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -57,7 +57,7 @@
The first element is the day, and the second element is the time
-->
- <string name="time_template">%1s às %2s</string>
+ <string name="time_template">%1$s às %2$s</string>
<string name="disclaimer">Aviso Legal</string>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 847e74cb..1f66683d 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -11,4 +11,6 @@
<dimen name="badge_icon_size">20dp</dimen>
<dimen name="toolbar_icon_size">24dp</dimen>
+
+ <dimen name="dialog_corner_radius">8dp</dimen>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 29d00a6f..c2660c6a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -74,7 +74,7 @@
The first element is the day, and the second element is the time
-->
- <string name="time_template">%1s at %2s</string>
+ <string name="time_template">%1$s at %2$s</string>
<string name="disclaimer">Disclaimer</string>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 0faa00ab..7816533b 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -7,6 +7,8 @@
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@null</item>
<item name="android:windowSoftInputMode">adjustResize</item>
+ <item name="md_color_button_text">?colorAccent</item>
+ <item name="md_corner_radius">@dimen/dialog_corner_radius</item>
</style>
<style name="FrostTheme" parent="@style/FrostThemeBase">
@@ -21,6 +23,8 @@
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@null</item>
<item name="android:windowSoftInputMode">adjustResize</item>
+ <item name="md_color_button_text">?colorAccent</item>
+ <item name="md_corner_radius">@dimen/dialog_corner_radius</item>
</style>
<style name="FrostTheme.Transparent">
diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml
index 3e4f9036..94c4fcdf 100644
--- a/app/src/main/res/xml/frost_changelog.xml
+++ b/app/src/main/res/xml/frost_changelog.xml
@@ -13,7 +13,7 @@
<item text="Update translations" />
<item text="Add fingerprint unlock screen" />
<item text="Fix messenger redirect" />
- <item text="" />
+ <item text="Lots of internal updates" />
<item text="" />
<item text="" />
<item text="" />
diff --git a/build.gradle b/build.gradle
index 33031d0b..cc64b047 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,27 +7,37 @@ buildscript {
}
dependencies {
- classpath "ca.allanwang:kau:${KAU}"
-// classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
- classpath "com.android.tools.build:gradle:${ANDROID_GRADLE}"
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${KOTLIN}"
- classpath "com.bugsnag:bugsnag-android-gradle-plugin:${BUGSNAG_PLUGIN}"
- classpath "com.diffplug.spotless:spotless-plugin-gradle:${SPOTLESS}"
- classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${DEX_PLUGIN}"
- classpath "com.gladed.androidgitversion:gradle-android-git-version:${GIT_PLUGIN}"
+ classpath kau.Plugins.android
+ classpath kau.Plugins.kotlin
+ classpath kau.Plugins.bugsnag
+ classpath kau.Plugins.spotless
+ classpath kau.Plugins.dexCount
+ classpath kau.Plugins.gitVersion
}
wrapper.setDistributionType(Wrapper.DistributionType.ALL)
}
-apply plugin: 'ca.allanwang.kau'
-
task clean(type: Delete) {
delete rootProject.buildDir
}
task generateChangelogMd() {
- kauChangelog.generate("$project.rootDir/app/src/main/res/xml/frost_changelog.xml")
+ def changelog = kau.ChangelogGenerator.generate("${project.rootDir}/app/src/main/res/xml/frost_changelog.xml", "${project.rootDir}/docs/Changelog.md")
+ // If we have no changelog, something is wrong
+ def entry = changelog[0]
+ def whatsNewFile = new File("${project.rootDir}/app/src/main/play/en-US/whatsnew")
+ if (!whatsNewFile.exists()) {
+ // Throw exceptions so that moving this file will require us to update the script
+ throw new RuntimeException("Whatsnew file not found")
+ }
+ whatsNewFile.withWriter { writer ->
+ writer.write(entry.version)
+ writer.write("\n")
+ entry.items.each {
+ writer.write("\n* ${it}")
+ }
+ }
}
task fullRelease(type: GradleBuild) {
diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore
new file mode 100644
index 00000000..192221b4
--- /dev/null
+++ b/buildSrc/.gitignore
@@ -0,0 +1,2 @@
+.gradle/
+build/ \ No newline at end of file
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
new file mode 100644
index 00000000..0c518118
--- /dev/null
+++ b/buildSrc/build.gradle.kts
@@ -0,0 +1,24 @@
+plugins {
+ `kotlin-dsl`
+}
+
+group = "com.pitchedapps"
+
+repositories {
+ jcenter()
+ maven("https://jitpack.io")
+}
+
+// Currently can't read properties from root project
+// Reading it manually since it's simple
+val rootProps =
+ File(project.rootDir.let { if (it.name == "buildSrc") it.parent else it.absolutePath }, "gradle.properties")
+val kau = rootProps.useLines {
+ it.first { s -> s.startsWith("KAU=") }
+}.substring(4).trim()
+
+println("Using kau $kau")
+
+dependencies {
+ implementation("ca.allanwang.kau:gradle-plugin:$kau")
+} \ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt
new file mode 100644
index 00000000..40b565b5
--- /dev/null
+++ b/buildSrc/src/main/kotlin/Versions.kt
@@ -0,0 +1,37 @@
+object Versions {
+
+ const val andxBiometric = "1.0.0-alpha04"
+
+ // https://mvnrepository.com/artifact/org.apache.commons/commons-text
+ // Updates blocked due to javax.script dependency
+ const val apacheCommonsText = "1.4"
+ // https://github.com/Raizlabs/DBFlow/releases
+ const val dbflow = "4.2.4"
+ // https://github.com/brianwernick/ExoMedia/releases
+ const val exoMedia = "4.3.0"
+ // https://github.com/InsertKoinIO/koin/blob/master/CHANGELOG.md
+ const val koin = "2.0.0-rc-2"
+ // https://github.com/mockk/mockk/releases
+ const val mockk = "1.9.3"
+ // https://mvnrepository.com/artifact/androidx.core/core-ktx?repo=google
+ const val ktx = "1.0.2"
+
+ // https://github.com/FasterXML/jackson-core/releases
+ const val jackson = "2.9.8"
+ // https://github.com/jhy/jsoup/releases
+ const val jsoup = "1.11.3"
+ // https://github.com/square/leakcanary/releases
+ const val leakCanary = "1.6.2"
+ // https://github.com/zsmb13/MaterialDrawerKt/releases
+ const val materialDrawerKt = "2.0.1"
+ // https://github.com/square/okhttp/releases
+ const val okhttp = "3.14.1"
+ // https://developer.android.com/jetpack/androidx/releases/room
+ const val room = "2.1.0"
+ // http://robolectric.org/getting-started/
+ const val roboelectric = "4.2"
+ // https://github.com/davemorrissey/subsampling-scale-image-view#quick-start
+ const val scaleImageView = "3.10.0"
+ // https://github.com/umano/AndroidSlidingUpPanel#importing-the-library
+ const val slidingPanel = "3.4.0"
+} \ No newline at end of file
diff --git a/docs/Changelog.md b/docs/Changelog.md
index b7320066..c54156d4 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -7,6 +7,7 @@
* Update translations
* Add fingerprint unlock screen
* Fix messenger redirect
+* Lots of internal updates
## v2.2.4
* Show top bar to allow sharing posts
diff --git a/gradle.properties b/gradle.properties
index c64655c4..d6291564 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -16,57 +16,7 @@ org.gradle.daemon = true
APP_ID=Frost
APP_GROUP=com.pitchedapps
-KAU=4.0.0
-KOTLIN=1.3.31
-
-# https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google
-ANDROID_GRADLE=3.3.2
-
-# https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md
-SPOTLESS=3.21.1
-
-ANDX_BIOMETRIC=1.0.0-alpha04
-
-# https://github.com/bugsnag/bugsnag-android/releases
-BUGSNAG=4.12.0
-# https://github.com/bugsnag/bugsnag-android-gradle-plugin/releases
-BUGSNAG_PLUGIN=4.1.1
-# https://github.com/KeepSafe/dexcount-gradle-plugin/releases
-DEX_PLUGIN=0.8.5
-# https://github.com/gladed/gradle-android-git-version/releases
-GIT_PLUGIN=0.4.9
-# https://mvnrepository.com/artifact/org.apache.commons/commons-text
-# Updates blocked due to javax.script dependency
-COMMONS_TEXT=1.4
-# https://github.com/Raizlabs/DBFlow/releases
-DBFLOW=4.2.4
-# https://github.com/brianwernick/ExoMedia/releases
-EXOMEDIA=4.3.0
-# https://github.com/InsertKoinIO/koin/blob/master/CHANGELOG.md
-KOIN=2.0.0-rc-2
-# https://github.com/mockk/mockk/releases
-MOCKK=1.9.3
-# https://mvnrepository.com/artifact/androidx.core/core-ktx?repo=google
-KTX=1.0.1
-
-# https://github.com/FasterXML/jackson-core/releases
-JACKSON=2.9.8
-# https://github.com/jhy/jsoup/releases
-JSOUP=1.11.3
-# https://github.com/square/leakcanary/releases
-LEAK_CANARY=1.6.2
-# https://github.com/zsmb13/MaterialDrawerKt/releases
-MATERIAL_DRAWER_KT=2.0.1
-# https://github.com/square/okhttp/releases
-OKHTTP=3.14.1
-# https://developer.android.com/jetpack/androidx/releases/room
-ROOM=2.1.0-alpha04
-# http://robolectric.org/getting-started/
-ROBOELECTRIC=4.2
-# https://github.com/davemorrissey/subsampling-scale-image-view#quick-start
-SCALE_IMAGE_VIEW=3.10.0
-# https://github.com/umano/AndroidSlidingUpPanel#importing-the-library
-SLIDING_PANEL=3.4.0
+KAU=20e7919
android.useAndroidX=true
android.enableJetifier=true
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 953390dc..ce46b811 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sun Dec 23 17:28:36 EST 2018
+#Sat Jun 01 20:58:39 EDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index 9d495b34..00000000
--- a/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app' \ No newline at end of file
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 00000000..270f7597
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1,3 @@
+include(":app", ":gradle-plugin")
+
+project(":gradle-plugin").projectDir = file("buildSrc") \ No newline at end of file