Compare commits
2 commits
ee5db64532
...
ebe47c4126
Author | SHA1 | Date | |
---|---|---|---|
ebe47c4126 | |||
e2bb38d730 |
6 changed files with 45 additions and 16 deletions
|
@ -182,6 +182,29 @@ class MarkdownTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun launchWithContentUriTest() = runTest {
|
||||||
|
val markdownText = "# UI Testing\n\nThe quick brown fox jumped over the lazy dog."
|
||||||
|
file.outputStream().writer().use { it.write(markdownText) }
|
||||||
|
val fileUri = FileProvider.getUriForFile(
|
||||||
|
getApplicationContext(),
|
||||||
|
"${BuildConfig.APPLICATION_ID}.fileprovider",
|
||||||
|
file
|
||||||
|
)
|
||||||
|
ActivityScenario.launch<MainActivity>(
|
||||||
|
Intent(
|
||||||
|
Intent.ACTION_VIEW,
|
||||||
|
fileUri,
|
||||||
|
getInstrumentation().targetContext,
|
||||||
|
MainActivity::class.java
|
||||||
|
)
|
||||||
|
)
|
||||||
|
onMainScreen(composeRule) {
|
||||||
|
awaitIdle()
|
||||||
|
checkMarkdownEquals(markdownText)
|
||||||
|
checkTitleEquals("temp.md")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun openEditAndSaveMarkdownTest() = runTest {
|
fun openEditAndSaveMarkdownTest() = runTest {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
@ -50,9 +49,6 @@ class MarkdownViewModel(
|
||||||
private val saveMutex = Mutex()
|
private val saveMutex = Mutex()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
|
||||||
load(null)
|
|
||||||
}
|
|
||||||
preferenceHelper.observe<Boolean>(Preference.LOCK_SWIPING)
|
preferenceHelper.observe<Boolean>(Preference.LOCK_SWIPING)
|
||||||
.onEach {
|
.onEach {
|
||||||
_state.value = _state.value.copy(lockSwiping = it)
|
_state.value = _state.value.copy(lockSwiping = it)
|
||||||
|
|
|
@ -62,6 +62,7 @@ import com.wbrawner.simplemarkdown.MarkdownViewModel
|
||||||
import com.wbrawner.simplemarkdown.ParameterizedText
|
import com.wbrawner.simplemarkdown.ParameterizedText
|
||||||
import com.wbrawner.simplemarkdown.R
|
import com.wbrawner.simplemarkdown.R
|
||||||
import com.wbrawner.simplemarkdown.Route
|
import com.wbrawner.simplemarkdown.Route
|
||||||
|
import com.wbrawner.simplemarkdown.utility.activity
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
@ -87,6 +88,10 @@ fun MainScreen(
|
||||||
val alert by viewModel.collectAsState(EditorState::alert, null)
|
val alert by viewModel.collectAsState(EditorState::alert, null)
|
||||||
val saveCallback by viewModel.collectAsState(EditorState::saveCallback, null)
|
val saveCallback by viewModel.collectAsState(EditorState::saveCallback, null)
|
||||||
val lockSwiping by viewModel.collectAsState(EditorState::lockSwiping, false)
|
val lockSwiping by viewModel.collectAsState(EditorState::lockSwiping, false)
|
||||||
|
val intentData = LocalContext.current.activity?.intent?.data
|
||||||
|
LaunchedEffect(intentData) {
|
||||||
|
viewModel.load(intentData?.toString())
|
||||||
|
}
|
||||||
LaunchedEffect(enableAutosave) {
|
LaunchedEffect(enableAutosave) {
|
||||||
if (!enableAutosave) return@LaunchedEffect
|
if (!enableAutosave) return@LaunchedEffect
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.wbrawner.simplemarkdown.utility
|
package com.wbrawner.simplemarkdown.utility
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.ContextWrapper
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.OpenableColumns
|
import android.provider.OpenableColumns
|
||||||
import android.view.View
|
|
||||||
import android.view.inputmethod.InputMethodManager
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.Reader
|
import java.io.Reader
|
||||||
|
@ -41,3 +41,11 @@ suspend fun Uri.getName(context: Context): String {
|
||||||
}
|
}
|
||||||
return fileName ?: "Untitled.md"
|
return fileName ?: "Untitled.md"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("RecursivePropertyAccessor")
|
||||||
|
val Context.activity: Activity?
|
||||||
|
get() = when (this) {
|
||||||
|
is Activity -> this
|
||||||
|
is ContextWrapper -> baseContext.activity
|
||||||
|
else -> null
|
||||||
|
}
|
2
app/src/play/play/release-notes/en-US/default.txt
Normal file
2
app/src/play/play/release-notes/en-US/default.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
- Fix opening files from external apps
|
||||||
|
- Update dependencies
|
|
@ -1,5 +0,0 @@
|
||||||
- Fix crash on markdown preview
|
|
||||||
- Persist preference for Lock Swiping
|
|
||||||
- Enable gestures on nav drawer when open
|
|
||||||
- Close navigation drawer on back press
|
|
||||||
- Various dependency updates
|
|
Loading…
Reference in a new issue