Skip to content

Commit

Permalink
Merge pull request #215 from PatilShreyas/v1.2.0
Browse files Browse the repository at this point in the history
Release v1.2.0
  • Loading branch information
PatilShreyas authored Aug 29, 2021
2 parents c7fc724 + 1eedd6a commit 3fc3ad7
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 38 deletions.
23 changes: 23 additions & 0 deletions docs/pages/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ You can see [GitHub releases](https://github.com/PatilShreyas/NotyKT/releases) w

---

## _v1.2.0_ (2021-08-29)

This release includes User experience improvements in the Jetpack Compose Application. Minor fixes in Simple app.

### 🔮 What's New?

- [[#209](https://github.com/PatilShreyas/NotyKT/issues/209)] Added connectivity indicator in compose app.

### ✅ Bug Fixes / Improvements

- [[#202](https://github.com/PatilShreyas/NotyKT/issues/202)] Fixed continuous flickering issue after Signup/Login in compose app.
- [[#203](https://github.com/PatilShreyas/NotyKT/issues/203)] Avoided/Fixed re-syncing of notes after configuration changes in compose app.

### 🎯 Codebase Improvements

- [[#201](https://github.com/PatilShreyas/NotyKT/issues/201)] Optimized APK size by enabling R8.
- [[#206](https://github.com/PatilShreyas/NotyKT/issues/206)] Fixed memory leak of `mAdapter` in simple app.
- Set flag `android:exported="true"` for Activity to support Android 12 and above.
- Provide content padding to `LazyColumn` _(to achieve same behavior as `clipToPadding` in RecyclerView)_.
- Cleaned up code.

---

## _v1.1.0_ (2021-08-06)

This release includes User experience improvements in the Jetpack Compose Application. No change in simple app.
Expand Down
1 change: 1 addition & 0 deletions noty-android/app/composeapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<activity
android:name=".ui.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|navigation|screenSize|screenLayout"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.Splash">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

package dev.shreyaspatil.noty.composeapp.component

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
import dev.shreyaspatil.noty.core.model.Note

@Composable
fun NotesList(notes: List<Note>, onClick: (Note) -> Unit) {
LazyColumn {
LazyColumn(contentPadding = PaddingValues(vertical = 4.dp)) {
items(
items = notes,
itemContent = { note ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun DeleteAction(onClick: () -> Unit) {
painter = icon,
contentDescription = "Delete",
modifier = Modifier
.padding(end = 8.dp)
.padding(8.dp)
.clickable(onClick = onClick)
)
}
Expand All @@ -44,7 +44,7 @@ fun ShareAction(onClick: () -> Unit) {
icon,
"share",
Modifier
.padding(end = 8.dp)
.padding(8.dp)
.clickable(onClick = onClick)
)
}
Expand All @@ -56,7 +56,7 @@ fun ThemeSwitchAction(onToggle: () -> Unit) {
icon,
"Theme switch",
Modifier
.padding(end = 8.dp)
.padding(8.dp)
.clickable(onClick = onToggle)
)
}
Expand All @@ -68,7 +68,7 @@ fun LogoutAction(onLogout: () -> Unit) {
icon,
"Logout",
Modifier
.padding(end = 8.dp)
.padding(8.dp)
.clickable(onClick = onLogout)
)
}
Expand All @@ -80,7 +80,7 @@ fun AboutAction(onClick: () -> Unit) {
icon,
"About",
Modifier
.padding(end = 8.dp)
.padding(8.dp)
.clickable(onClick = onClick)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun AddNoteScreen(
)
}
},
backgroundColor = MaterialTheme.colors.background,
backgroundColor = MaterialTheme.colors.surface,
contentColor = MaterialTheme.colors.onPrimary,
elevation = 0.dp,
)
Expand All @@ -107,13 +107,12 @@ fun AddNoteScreen(
Modifier.scrollable(
rememberScrollState(),
orientation = Orientation.Vertical
)
).padding(16.dp)
) {

NoteTitleField(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp, 0.dp, 16.dp, 0.dp)
.background(MaterialTheme.colors.background),
value = titleText.value,
onTextChange = { titleText.value = it },
Expand All @@ -123,7 +122,7 @@ fun AddNoteScreen(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.padding(16.dp, 8.dp, 16.dp, 0.dp)
.padding(top = 8.dp)
.background(MaterialTheme.colors.background),
value = noteText.value,
onTextChange = { noteText.value = it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fun NoteDetailsScreen(
)
}
},
backgroundColor = MaterialTheme.colors.background,
backgroundColor = MaterialTheme.colors.surface,
contentColor = MaterialTheme.colors.onPrimary,
elevation = 0.dp,
actions = {
Expand All @@ -119,12 +119,11 @@ fun NoteDetailsScreen(
Modifier.scrollable(
rememberScrollState(),
orientation = Orientation.Vertical
)
).padding(16.dp)
) {
NoteTitleField(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp, 0.dp, 16.dp, 0.dp)
.background(MaterialTheme.colors.background),
value = titleText,
onTextChange = { titleText = it }
Expand All @@ -134,7 +133,7 @@ fun NoteDetailsScreen(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(16.dp, 8.dp, 16.dp, 0.dp)
.padding(top = 8.dp)
.background(MaterialTheme.colors.background),
value = noteText,
onTextChange = { noteText = it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import dev.shreyaspatil.noty.composeapp.component.action.AboutAction
import dev.shreyaspatil.noty.composeapp.component.action.LogoutAction
import dev.shreyaspatil.noty.composeapp.component.action.ThemeSwitchAction
import dev.shreyaspatil.noty.composeapp.component.dialog.FailureDialog
import dev.shreyaspatil.noty.composeapp.navigation.NOTY_NAV_HOST_ROUTE
import dev.shreyaspatil.noty.composeapp.ui.Screen
import dev.shreyaspatil.noty.core.ui.UIDataState
import dev.shreyaspatil.noty.view.viewmodel.NotesViewModel
Expand All @@ -61,7 +62,9 @@ import kotlinx.coroutines.launch
@ExperimentalCoroutinesApi
@Composable
fun NotesScreen(navController: NavHostController, viewModel: NotesViewModel) {
if (!viewModel.isUserLoggedIn()) {
val isUserLoggedIn by viewModel.userLoggedInState.collectAsState()

if (!isUserLoggedIn) {
navigateToLogin(navController)
return
}
Expand All @@ -81,7 +84,7 @@ fun NotesScreen(navController: NavHostController, viewModel: NotesViewModel) {
modifier = Modifier.fillMaxWidth()
)
},
backgroundColor = MaterialTheme.colors.background,
backgroundColor = MaterialTheme.colors.surface,
contentColor = MaterialTheme.colors.onPrimary,
elevation = 0.dp,
actions = {
Expand All @@ -93,10 +96,7 @@ fun NotesScreen(navController: NavHostController, viewModel: NotesViewModel) {
}
LogoutAction(
onLogout = {
scope.launch {
viewModel.clearUserSession()
navigateToLogin(navController)
}
scope.launch { viewModel.clearUserSession() }
}
)
}
Expand Down Expand Up @@ -157,6 +157,7 @@ private fun navigateToLogin(navController: NavHostController) {
navController.navigate(
Screen.Login.route,
builder = {
popUpTo(NOTY_NAV_HOST_ROUTE)
launchSingleTop = true
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import dev.shreyaspatil.noty.composeapp.component.text.ConfirmPasswordTextField
import dev.shreyaspatil.noty.composeapp.component.text.PasswordTextField
import dev.shreyaspatil.noty.composeapp.component.text.TextFieldValue.Valid
import dev.shreyaspatil.noty.composeapp.component.text.UsernameTextField
import dev.shreyaspatil.noty.composeapp.navigation.NOTY_NAV_HOST_ROUTE
import dev.shreyaspatil.noty.composeapp.ui.Screen
import dev.shreyaspatil.noty.composeapp.ui.theme.typography
import dev.shreyaspatil.noty.core.ui.UIDataState
Expand All @@ -64,13 +63,10 @@ fun SignUpScreen(
when (viewState) {
is UIDataState.Loading -> LoaderDialog()
is UIDataState.Success -> {
navController.navigate(
route = Screen.Notes.route,
builder = {
launchSingleTop = true
popUpTo(NOTY_NAV_HOST_ROUTE) { inclusive = true }
}
)
navController.navigate(Screen.Notes.route) {
launchSingleTop = true
popUpTo(Screen.SignUp.route) { inclusive = true }
}
}
is UIDataState.Failed -> FailureDialog(viewState.message)
}
Expand Down
1 change: 1 addition & 0 deletions noty-android/app/simpleapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<activity
android:name=".view.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|navigation|screenSize|screenLayout"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,13 @@ class NotesFragment : BaseFragment<NotesFragmentBinding, NotesViewModel>() {
}

private fun checkAuthentication() {
if (!viewModel.isUserLoggedIn()) {
logout()
}
viewModel.userLoggedInState
.shareWhileObserved(viewLifecycleOwner.lifecycleScope)
.asLiveData().observe(viewLifecycleOwner) { isLoggedIn ->
if (!isLoggedIn) {
logout()
}
}
}

private fun onNoteClicked(note: Note) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.first
Expand All @@ -58,6 +60,9 @@ class NotesViewModel @Inject constructor(
private val _syncState = MutableSharedFlow<UIDataState<Unit>>()
val syncState: SharedFlow<UIDataState<Unit>> = _syncState.shareWhileObserved(viewModelScope)

private val _loggedInState = MutableStateFlow(isUserLoggedIn())
val userLoggedInState: StateFlow<Boolean> = _loggedInState

val notes: SharedFlow<UIDataState<List<Note>>> = notyNoteRepository.getAllNotes()
.distinctUntilChanged()
.map { result ->
Expand Down Expand Up @@ -89,12 +94,13 @@ class NotesViewModel @Inject constructor(
}
}

fun isUserLoggedIn() = sessionManager.getToken() != null
private fun isUserLoggedIn() = sessionManager.getToken() != null

suspend fun clearUserSession() = withContext(Dispatchers.IO) {
sessionManager.saveToken(null)
notyTaskManager.abortAllTasks()
notyNoteRepository.deleteAllNotes()
_loggedInState.value = false
}

suspend fun isDarkModeEnabled() = preferenceManager.uiModeFlow.first()
Expand Down
4 changes: 2 additions & 2 deletions noty-android/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

ext {
// Android Plugin
androidGradlePluginVersion = '7.0.0'
androidGradlePluginVersion = '7.0.1'

// Kotlin
kotlinVersion = "1.5.21"
Expand Down Expand Up @@ -67,7 +67,7 @@ ext {
composeConstraintLayoutVersion = "1.0.0-beta01"

// Jetpack Compose Navigation
composeNavVersion = "2.4.0-alpha05"
composeNavVersion = "2.4.0-alpha07"

// Hilt Compose Navigation
hiltComposeNavVersion = "1.0.0-alpha03"
Expand Down
8 changes: 4 additions & 4 deletions noty-android/projectConfig.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

ext {
ProjectConfig = [
compileSdkVersion: 30,
compileSdkVersion: 31,
buildToolsVersion: "30.0.2",
minSdkVersion : 21,
targetSdkVersion : 30,
versionCode : 20210806,
versionName : "1.1.0"
targetSdkVersion : 31,
versionCode : 20210829,
versionName : "1.2.0"
]
}

0 comments on commit 3fc3ad7

Please sign in to comment.