Skip to content

Commit

Permalink
Add ability to select texts in reader (#95)
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam authored Nov 10, 2023
1 parent 4ace350 commit 188db67
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
8 changes: 2 additions & 6 deletions app/src/main/java/com/starry/myne/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ class MainActivity : AppCompatActivity() {
settingsViewModel = ViewModelProvider(this)[SettingsViewModel::class.java]
mainViewModel = ViewModelProvider(this)[MainViewModel::class.java]

when (settingsViewModel.getThemeValue()) {
ThemeMode.Auto.ordinal -> settingsViewModel.setTheme(ThemeMode.Auto)
ThemeMode.Dark.ordinal -> settingsViewModel.setTheme(ThemeMode.Dark)
ThemeMode.Light.ordinal -> settingsViewModel.setTheme(ThemeMode.Light)
}

ThemeMode.entries.find { it.ordinal == settingsViewModel.getThemeValue()}
?.let { settingsViewModel.setTheme(it) }
settingsViewModel.setMaterialYou(settingsViewModel.getMaterialYouValue())

// Install splash screen before setting content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -82,10 +83,9 @@ class ReaderRVAdapter(
val chapter = allChapters[position]
composeView.setContent {
MyneTheme(settingsViewModel = activity.settingsViewModel) {
ReaderItem(
chapter = chapter,
viewModel = viewModel
)
SelectionContainer {
ReaderItem(chapter = chapter, viewModel = viewModel)
}
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/java/com/starry/myne/utils/Preferencesutils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ class PreferenceUtil(context: Context) {
prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
}

fun keyExists(key: String): Boolean {
if (prefs.contains(key))
return true
return false
}
fun keyExists(key: String): Boolean = prefs.contains(key)

fun putString(key: String, value: String) {
val prefsEditor = prefs.edit()
Expand Down

0 comments on commit 188db67

Please sign in to comment.