Update dependencies

This commit is contained in:
William Brawner 2020-04-19 21:19:28 -07:00
parent 452f334dd1
commit f01909eb83
6 changed files with 25 additions and 32 deletions

View file

@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'jacoco' apply plugin: 'jacoco'
def keystoreProperties = new Properties() def keystoreProperties = new Properties()
@ -34,6 +33,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
kotlinOptions {
jvmTarget = "1.8"
}
defaultConfig { defaultConfig {
applicationId "com.wbrawner.simplemarkdown" applicationId "com.wbrawner.simplemarkdown"
minSdkVersion 21 minSdkVersion 21
@ -75,7 +77,7 @@ android {
dependencies { dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.2' testImplementation 'org.robolectric:robolectric:4.2.1'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
def espresso_version = '3.2.0' def espresso_version = '3.2.0'
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version" androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
@ -88,13 +90,14 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.preference:preference:1.1.0' implementation 'androidx.preference:preference:1.1.1'
implementation "androidx.fragment:fragment-ktx:1.2.4"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0' implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0' implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'com.commonsware.cwac:anddown:0.3.0' implementation 'com.commonsware.cwac:anddown:0.3.0'
implementation 'com.google.firebase:firebase-core:17.2.3' implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.android.billingclient:billing:2.1.0' implementation 'com.android.billingclient:billing:2.2.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation "androidx.core:core-ktx:1.2.0" implementation "androidx.core:core-ktx:1.2.0"
implementation 'androidx.browser:browser:1.2.0' implementation 'androidx.browser:browser:1.2.0'

View file

@ -13,12 +13,12 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import android.widget.Toast import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.wbrawner.simplemarkdown.R import com.wbrawner.simplemarkdown.R
import com.wbrawner.simplemarkdown.utility.hideKeyboard import com.wbrawner.simplemarkdown.utility.hideKeyboard
@ -34,7 +34,7 @@ class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsRes
private var shouldAutoSave = true private var shouldAutoSave = true
override val coroutineContext: CoroutineContext = Dispatchers.Main override val coroutineContext: CoroutineContext = Dispatchers.Main
private lateinit var viewModel: MarkdownViewModel private val viewModel: MarkdownViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -49,7 +49,6 @@ class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsRes
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
) )
} }
viewModel = ViewModelProviders.of(this).get(MarkdownViewModel::class.java)
val adapter = EditPagerAdapter(supportFragmentManager, this@MainActivity) val adapter = EditPagerAdapter(supportFragmentManager, this@MainActivity)
pager.adapter = adapter pager.adapter = adapter
pager.addOnPageChangeListener(adapter) pager.addOnPageChangeListener(adapter)
@ -60,7 +59,7 @@ class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsRes
tabLayout!!.visibility = View.GONE tabLayout!!.visibility = View.GONE
} }
@Suppress("CAST_NEVER_SUCCEEDS") @Suppress("CAST_NEVER_SUCCEEDS")
viewModel.fileName.observe(this, Observer<String> { viewModel.fileName.observe(this, Observer {
title = it title = it
}) })
intent?.data?.let { intent?.data?.let {

View file

@ -11,7 +11,10 @@ import com.wbrawner.simplemarkdown.R
import com.wbrawner.simplemarkdown.utility.readAssetToString import com.wbrawner.simplemarkdown.utility.readAssetToString
import com.wbrawner.simplemarkdown.utility.toHtml import com.wbrawner.simplemarkdown.utility.toHtml
import kotlinx.android.synthetic.main.activity_markdown_info.* import kotlinx.android.synthetic.main.activity_markdown_info.*
import kotlinx.coroutines.* import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
class MarkdownInfoActivity : AppCompatActivity(), CoroutineScope { class MarkdownInfoActivity : AppCompatActivity(), CoroutineScope {
@ -57,9 +60,7 @@ class MarkdownInfoActivity : AppCompatActivity(), CoroutineScope {
} }
override fun onDestroy() { override fun onDestroy() {
coroutineContext[Job]?.let { coroutineContext[Job]?.cancel()
cancel()
}
super.onDestroy() super.onDestroy()
} }

View file

@ -16,8 +16,8 @@ import android.widget.EditText
import android.widget.ScrollView import android.widget.ScrollView
import android.widget.TextView import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.wbrawner.simplemarkdown.R import com.wbrawner.simplemarkdown.R
import com.wbrawner.simplemarkdown.model.Readability import com.wbrawner.simplemarkdown.model.Readability
@ -32,7 +32,7 @@ import kotlin.math.abs
class EditFragment : Fragment(), ViewPagerPage, CoroutineScope { class EditFragment : Fragment(), ViewPagerPage, CoroutineScope {
private var markdownEditor: EditText? = null private var markdownEditor: EditText? = null
private var markdownEditorScroller: ScrollView? = null private var markdownEditorScroller: ScrollView? = null
lateinit var viewModel: MarkdownViewModel private val viewModel: MarkdownViewModel by activityViewModels()
override val coroutineContext: CoroutineContext = Dispatchers.Main override val coroutineContext: CoroutineContext = Dispatchers.Main
private var readabilityWatcher: TextWatcher? = null private var readabilityWatcher: TextWatcher? = null
@ -44,9 +44,6 @@ class EditFragment : Fragment(), ViewPagerPage, CoroutineScope {
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
activity?.let {
viewModel = ViewModelProviders.of(it).get(MarkdownViewModel::class.java)
} ?: return
markdownEditor = view.findViewById(R.id.markdown_edit) markdownEditor = view.findViewById(R.id.markdown_edit)
markdownEditorScroller = view.findViewById(R.id.markdown_edit_container) markdownEditorScroller = view.findViewById(R.id.markdown_edit_container)
markdownEditor?.addTextChangedListener(object : TextWatcher { markdownEditor?.addTextChangedListener(object : TextWatcher {
@ -97,7 +94,7 @@ class EditFragment : Fragment(), ViewPagerPage, CoroutineScope {
} }
false false
} }
viewModel.originalMarkdown.observe(this, Observer<String> { viewModel.originalMarkdown.observe(viewLifecycleOwner, Observer {
markdownEditor?.setText(it) markdownEditor?.setText(it)
}) })
launch { launch {

View file

@ -9,8 +9,8 @@ import android.view.ViewGroup
import android.webkit.WebView import android.webkit.WebView
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.wbrawner.simplemarkdown.BuildConfig import com.wbrawner.simplemarkdown.BuildConfig
import com.wbrawner.simplemarkdown.R import com.wbrawner.simplemarkdown.R
@ -21,7 +21,7 @@ import kotlin.coroutines.CoroutineContext
class PreviewFragment : Fragment(), CoroutineScope { class PreviewFragment : Fragment(), CoroutineScope {
override val coroutineContext: CoroutineContext = Dispatchers.Main override val coroutineContext: CoroutineContext = Dispatchers.Main
lateinit var viewModel: MarkdownViewModel private val viewModel: MarkdownViewModel by activityViewModels()
private var markdownPreview: WebView? = null private var markdownPreview: WebView? = null
private var style: String = "" private var style: String = ""
@ -34,13 +34,10 @@ class PreviewFragment : Fragment(), CoroutineScope {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
markdownPreview = view.findViewById(R.id.markdown_view) markdownPreview = view.findViewById(R.id.markdown_view)
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG) WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG)
activity?.let {
viewModel = ViewModelProviders.of(it).get(MarkdownViewModel::class.java)
} ?: return
launch { launch {
val isNightMode = AppCompatDelegate.getDefaultNightMode() == val isNightMode = AppCompatDelegate.getDefaultNightMode() ==
AppCompatDelegate.MODE_NIGHT_YES AppCompatDelegate.MODE_NIGHT_YES
|| context!!.resources.configuration.uiMode and UI_MODE_NIGHT_MASK == UI_MODE_NIGHT_YES || requireContext().resources.configuration.uiMode and UI_MODE_NIGHT_MASK == UI_MODE_NIGHT_YES
val defaultCssId = if (isNightMode) { val defaultCssId = if (isNightMode) {
R.string.pref_custom_css_default_dark R.string.pref_custom_css_default_dark
} else { } else {
@ -61,7 +58,7 @@ class PreviewFragment : Fragment(), CoroutineScope {
} }
style = String.format(FORMAT_CSS, css ?: "") style = String.format(FORMAT_CSS, css ?: "")
updateWebContent(viewModel.markdownUpdates.value ?: "") updateWebContent(viewModel.markdownUpdates.value ?: "")
viewModel.markdownUpdates.observe(this@PreviewFragment, Observer<String> { viewModel.markdownUpdates.observe(viewLifecycleOwner, Observer {
updateWebContent(it) updateWebContent(it)
}) })
} }

View file

@ -1,18 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.3.61' ext.kotlin_version = '1.3.72'
repositories { repositories {
jcenter() jcenter()
google() google()
maven {
url 'https://maven.fabric.io/public'
}
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.6.1' classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }