Skip to content

Commit

Permalink
Merge pull request #67 from mhss1/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mhss1 authored Sep 8, 2022
2 parents 46d1cdb + eb2d430 commit ccb56fd
Show file tree
Hide file tree
Showing 33 changed files with 570 additions and 194 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: mhss1
ko_fi:
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
## Contributing
To get started, take a look at [CONTRIBUTING.md](CONTRIBUTING.md).

---
Icons Attribution
<a href="https://www.flaticon.com/free-icons/paper" title="paper icons">Paper icons created by Freepik - Flaticon</a>
<a href="https://www.flaticon.com/free-icons/list" title="list icons">List icons created by Freepik - Flaticon</a>
Expand Down
28 changes: 18 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ plugins {
}

android {
compileSdk 32
compileSdk 33

defaultConfig {
applicationId "com.mhss.app.mybrain"
minSdk 24
targetSdk 32
targetSdk 33
versionCode 2
versionName "1.0.1"
versionName "1.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
resConfigs "en", "ar", "zh-rCN", "hi", "pl", "ru"
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas")
Expand All @@ -32,6 +33,9 @@ android {
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -45,7 +49,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerExtensionVersion "1.3.0"
}
packagingOptions {
resources {
Expand All @@ -65,16 +69,16 @@ kotlin {
}

dependencies {
def nav_version = "2.5.0"
def room_version = "2.4.2"
def nav_version = "2.5.1"
def room_version = "2.4.3"
def coroutines_version = "1.6.1"

implementation 'androidx.core:core-ktx:1.8.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.0'
implementation 'androidx.activity:activity-compose:1.5.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand All @@ -91,8 +95,8 @@ dependencies {
implementation "androidx.room:room-ktx:$room_version"

//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-android-compiler:2.38.1"
implementation "com.google.dagger:hilt-android:2.43.2"
kapt "com.google.dagger:hilt-android-compiler:2.43.2"
kapt "androidx.hilt:hilt-compiler:1.0.0"

// Coroutines
Expand All @@ -116,4 +120,8 @@ dependencies {
// Compose Glance (Widgets)
implementation "androidx.glance:glance-appwidget:1.0.0-alpha03"

}

kapt {
correctErrorTypes = true
}
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mhss.app.mybrain">

<!-- For the Calendar events features -->
Expand All @@ -16,7 +17,9 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyBrain">
android:theme="@style/Theme.MyBrain"
android:localeConfig="@xml/locales_config"
tools:targetApi="33">
<activity
android:name=".presentation.main.MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.GridCells
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
Expand Down Expand Up @@ -102,7 +103,7 @@ fun NoteFolderDetailsScreen(
)
}
}
) {
) { _ ->
if (uiState.noteView == ItemView.LIST) {
LazyColumn(
verticalArrangement = Arrangement.spacedBy(8.dp),
Expand Down Expand Up @@ -132,7 +133,7 @@ fun NoteFolderDetailsScreen(
}
} else {
LazyVerticalGrid(
cells = GridCells.Adaptive(150.dp),
columns = GridCells.Adaptive(150.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
contentPadding = PaddingValues(
Expand All @@ -157,7 +158,7 @@ fun NoteFolderDetailsScreen(
)
)
},
modifier = Modifier.height(220.dp)
modifier = Modifier.animateItemPlacement().height(220.dp)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.mhss.app.mybrain.presentation.bookmarks

import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
Expand All @@ -22,17 +20,15 @@ import com.mhss.app.mybrain.R
import com.mhss.app.mybrain.domain.model.Bookmark
import com.mhss.app.mybrain.util.bookmarks.isValidUrl

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun LazyItemScope.BookmarkItem(
fun BookmarkItem(
modifier: Modifier = Modifier,
bookmark: Bookmark,
onClick: (Bookmark) -> Unit,
onInvalidUrl: () -> Unit
) {
Card(
modifier = modifier
.animateItemPlacement(),
modifier = modifier,
shape = RoundedCornerShape(20.dp),
elevation = 8.dp
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package com.mhss.app.mybrain.presentation.bookmarks

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.GridCells
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.OutlinedTextField
Expand Down Expand Up @@ -36,9 +37,9 @@ fun BookmarkSearchScreen(
val state = viewModel.uiState
val scope = rememberCoroutineScope()
val scaffoldState = rememberScaffoldState()
Scaffold(scaffoldState = scaffoldState) {
Scaffold(scaffoldState = scaffoldState) { paddingValues ->
Column(
modifier = Modifier.fillMaxSize(),
modifier = Modifier.fillMaxSize().padding(paddingValues),
) {
var query by rememberSaveable {
mutableStateOf("")
Expand Down Expand Up @@ -84,7 +85,7 @@ fun BookmarkSearchScreen(
}
} else {
LazyVerticalGrid(
cells = GridCells.Adaptive(150.dp),
columns = GridCells.Adaptive(150.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
contentPadding = PaddingValues(12.dp)
Expand All @@ -107,7 +108,8 @@ fun BookmarkSearchScreen(
getString(R.string.invalid_url)
)
}
}
},
modifier = Modifier.animateItemPlacement()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.GridCells
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.items
import androidx.compose.material.*
import androidx.compose.runtime.*
Expand Down Expand Up @@ -75,12 +76,12 @@ fun BookmarksScreen(
)
}
},
) {
) { paddingValues ->
if (uiState.bookmarks.isEmpty())
NoBookmarksMessage()
Column {
Row(
Modifier.fillMaxWidth(),
Modifier.fillMaxWidth().padding(paddingValues),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Expand Down Expand Up @@ -135,13 +136,14 @@ fun BookmarksScreen(
getString(R.string.invalid_url)
)
}
}
},
modifier = Modifier.animateItemPlacement()
)
}
}
} else {
LazyVerticalGrid(
cells = GridCells.Adaptive(150.dp),
columns = GridCells.Adaptive(150.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
contentPadding = PaddingValues(12.dp)
Expand All @@ -165,7 +167,7 @@ fun BookmarksScreen(
)
}
},
modifier = Modifier.height(220.dp)
modifier = Modifier.animateItemPlacement().height(220.dp)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ import com.google.gson.Gson
import com.mhss.app.mybrain.R
import com.mhss.app.mybrain.domain.model.Calendar
import com.mhss.app.mybrain.domain.model.CalendarEvent
import com.mhss.app.mybrain.presentation.util.Screen
import com.mhss.app.mybrain.util.calendar.*
import com.mhss.app.mybrain.util.date.HOUR_IN_MILLIS
import com.mhss.app.mybrain.util.date.formatDate
import com.mhss.app.mybrain.util.date.formatTime
import java.net.URLDecoder
import java.nio.charset.StandardCharsets

@OptIn(ExperimentalPermissionsApi::class)
@Composable
Expand All @@ -56,7 +57,8 @@ fun CalendarEventDetailsScreen(
val event by remember {
mutableStateOf(
if (eventJson.isNotEmpty()) {
Gson().fromJson(eventJson, CalendarEvent::class.java)
val decodedJson = URLDecoder.decode(eventJson, StandardCharsets.UTF_8.toString())
Gson().fromJson(decodedJson, CalendarEvent::class.java)
} else
null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ fun CalendarEventWidgetItem(
end = event.end,
location = event.location,
allDay = event.allDay,
)
),
style = TextStyle(color = ColorProvider(Color.LightGray))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import com.mhss.app.mybrain.presentation.util.Screen
import com.mhss.app.mybrain.util.Constants
import com.mhss.app.mybrain.util.date.*
import kotlinx.coroutines.launch
import java.net.URLEncoder
import java.nio.charset.StandardCharsets

@Composable
fun CalendarScreen(
Expand Down Expand Up @@ -156,10 +158,12 @@ fun CalendarScreen(
events.forEach { event ->
CalendarEventItem(event = event, onClick = {
val eventJson = Gson().toJson(event, CalendarEvent::class.java)
// encoding the string to avoid crashes when the event contains fields that equals a URL
val encodedJson = URLEncoder.encode(eventJson, StandardCharsets.UTF_8.toString())
navController.navigate(
Screen.CalendarEventDetailsScreen.route.replace(
"{${Constants.CALENDAR_EVENT_ARG}}",
eventJson
encodedJson
)
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun MoodCircularBar(
elevation = 8.dp,
modifier = modifier
.fillMaxWidth()
.padding(8.dp)
.padding(6.dp)
) {
Column(
Modifier.clickable {
Expand All @@ -66,7 +66,7 @@ fun MoodCircularBar(
}
Text(
text = stringResource(R.string.mood_summary),
style = MaterialTheme.typography.h5,
style = MaterialTheme.typography.h6.copy(fontWeight = FontWeight.Bold),
modifier = Modifier
.fillMaxWidth()
.padding(12.dp),
Expand Down Expand Up @@ -144,7 +144,7 @@ fun MoodCircularBar(
} else {
Text(
text = stringResource(R.string.no_data_yet),
style = MaterialTheme.typography.h6,
style = MaterialTheme.typography.body1,
modifier = Modifier
.fillMaxWidth()
.padding(12.dp),
Expand Down
Loading

0 comments on commit ccb56fd

Please sign in to comment.