Skip to content

Commit

Permalink
Added notification icon + bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Pine committed Mar 25, 2022
1 parent 598c2b7 commit a395329
Show file tree
Hide file tree
Showing 10 changed files with 823 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
/release/
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/new_comic_channel_id" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_thick"
/>

<activity
android:name="de.mr_pine.xkcdfeed.MainActivity"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/de/mr_pine/xkcdfeed/SingleComicViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class SingleComicViewModel: ViewModel() {
var currentNumber by mutableStateOf(-1)
var imageLoaded by mutableStateOf(true)

fun getNumber(): Int {
return currentComic?.id ?: -1
}

fun setComic(number: Int, context: Context){
currentNumber = number

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fun SingleViewContent(
setFavorite: (XKCDComic) -> Unit,
removeFavorite: (XKCDComic) -> Unit,
colorMatrix: ColorMatrix,
getNumber: () -> Int,
navigateHome: () -> Unit,
startActivity: (Intent) -> Unit
) {
Expand All @@ -93,7 +94,9 @@ fun SingleViewContent(
scaffoldState.bottomSheetState.expand()
})

fun getId() = comic.id
fun getId(): Int {
return comic.id
}
var currentNumberString by remember(comic.id) { mutableStateOf(comic.id.toString()) }

var parentSize by remember { mutableStateOf(IntSize(0, 0)) }
Expand Down Expand Up @@ -195,10 +198,10 @@ fun SingleViewContent(
coroutineScope = scope,
zoomableState = zoomableState,
onSwipeLeft = {
if (getId() < maxNumber) setNumber(getId() + 1)
if (getNumber() < maxNumber) setNumber(getNumber() + 1)
},
onSwipeRight = {
if (getId() > 0) setNumber(getId() - 1)
if (getNumber() > 0) setNumber(getNumber() - 1)
},
) {
Image(
Expand Down Expand Up @@ -478,10 +481,10 @@ fun bottomSheetContent(
verticalAlignment = Alignment.Bottom
) {
Text(
text = comic.title ?: "I am a title :)",
text = comic.title ?: "",
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
modifier = Modifier.placeholder(comic.title == null)
modifier = Modifier.widthIn(min = if(comic.title == null) 200.dp else 0.dp).placeholder(comic.title == null)
)
Text(
text = "(${comic.id})",
Expand Down Expand Up @@ -595,6 +598,7 @@ fun SingleViewContentStateful(
setNumber = { singleViewModel.currentComic = mainViewModel.loadComic(it) },
maxNumber = mainViewModel.latestComicNumber,
colorMatrix = ColorMatrix(mainViewModel.matrix.toColorMatrix()),
getNumber = singleViewModel::getNumber,
startActivity = { mainViewModel.startActivity(it) },
navigateHome = navigateHome
)
Expand Down
Binary file added app/src/main/res/drawable-v24/notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a395329

Please sign in to comment.