Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.

Commit 8d9935b

Browse files
committed
added notifications to notes, updated libraries
1 parent 1a50a5e commit 8d9935b

File tree

13 files changed

+130
-22
lines changed

13 files changed

+130
-22
lines changed

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ plugins {
88
}
99

1010
android {
11-
compileSdk 34
11+
compileSdk 35
1212

1313
defaultConfig {
1414
applicationId "com.jjewuz.justnotes"
1515
minSdk 30
1616
targetSdk 35
17-
versionCode 183
18-
versionName "5.6.2"
17+
versionCode 184
18+
versionName "5.6.3"
1919

2020
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2121

@@ -56,13 +56,13 @@ android {
5656

5757
dependencies {
5858

59-
implementation 'androidx.core:core-ktx:1.13.1'
59+
implementation 'androidx.core:core-ktx:1.15.0'
6060
implementation 'androidx.appcompat:appcompat:1.7.0'
6161
implementation 'com.google.android.material:material:1.12.0'
62-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
63-
implementation 'androidx.navigation:navigation-fragment-ktx:2.8.3'
62+
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
63+
implementation 'androidx.navigation:navigation-fragment-ktx:2.8.4'
6464
implementation 'androidx.preference:preference-ktx:1.2.1'
65-
implementation 'androidx.core:core-ktx:1.13.1'
65+
implementation 'androidx.core:core-ktx:1.15.0'
6666
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
6767
implementation 'androidx.drawerlayout:drawerlayout:1.2.0'
6868
implementation 'com.google.firebase:firebase-analytics-ktx:22.1.2'
@@ -74,24 +74,24 @@ dependencies {
7474
testImplementation 'junit:junit:'
7575
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
7676
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
77-
implementation 'androidx.work:work-runtime-ktx:2.9.1'
77+
implementation 'androidx.work:work-runtime-ktx:2.10.0'
7878
implementation 'com.google.android.play:app-update-ktx:2.1.0'
7979
implementation 'com.google.android.play:review-ktx:2.0.2'
8080
implementation 'com.google.android.gms:play-services-oss-licenses:17.1.0'
81-
implementation 'com.google.firebase:firebase-messaging:24.0.3'
82-
implementation "androidx.work:work-runtime-ktx:2.9.1"
81+
implementation 'com.google.firebase:firebase-messaging:24.1.0'
82+
implementation "androidx.work:work-runtime-ktx:2.10.0"
8383

8484
implementation "androidx.biometric:biometric-ktx:1.2.0-alpha05"
8585
implementation "androidx.core:core-splashscreen:1.0.1"
86-
implementation 'androidx.navigation:navigation-ui-ktx:2.8.3'
86+
implementation 'androidx.navigation:navigation-ui-ktx:2.8.4'
8787

8888
implementation "androidx.room:room-ktx:2.6.1"
8989
kapt "androidx.room:room-compiler:2.6.1"
9090
androidTestImplementation "androidx.room:room-testing:2.6.1"
9191

92-
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.6"
93-
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.6"
94-
implementation "androidx.lifecycle:lifecycle-common-java8:2.8.6"
92+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7"
93+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.7"
94+
implementation "androidx.lifecycle:lifecycle-common-java8:2.8.7"
9595

9696
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
9797
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"

app/src/main/java/com/jjewuz/justnotes/Activities/InfoActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ class InfoActivity : AppCompatActivity() {
7676

7777
ghBtn.setOnClickListener { openLink("https://github.com/jjewuz/JustNotes") }
7878
sourceBtn.setOnClickListener { openLink("https://github.com/jjewuz") }
79-
siteBtn.setOnClickListener{ openLink("https://jjewuz.ru/justnotes/justnotes.html") }
79+
siteBtn.setOnClickListener{ openLink("https://jjewuz.com/justnotes.html") }
8080
weblateBtn.setOnClickListener {openLink("https://hosted.weblate.org/engage/justnotes/")}
8181
licenseBtn.setOnClickListener { startActivity(Intent(this, OssLicensesMenuActivity::class.java)) }
82-
tou.setOnClickListener { openLink("https://jjewuz.ru/justnotes/termsofuse.html") }
83-
pp.setOnClickListener { openLink("https://jjewuz.ru/justnotes/privacypolicy.html") }
82+
tou.setOnClickListener { openLink("https://jjewuz.com/justnotes/termsofuse.html") }
83+
pp.setOnClickListener { openLink("https://jjewuz.com/justnotes/privacypolicy.html") }
8484
tgBtn.setOnClickListener { openLink("https://t.me/jjewuz_support") }
8585
vkBtn.setOnClickListener { openLink("https://vk.com/jjewuzhub") }
8686

app/src/main/java/com/jjewuz/justnotes/Activities/MainActivity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,16 @@ class MainActivity : AppCompatActivity() {
696696
val name = getString(R.string.reminders)
697697
val descriptionText = getString(R.string.reminders)
698698
val importance = NotificationManager.IMPORTANCE_DEFAULT
699-
val channel = NotificationChannel("0", name, importance).apply {
699+
val channel = NotificationChannel("1", name, importance).apply {
700700
description = descriptionText
701701
}
702702
val notificationManager: NotificationManager =
703703
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
704+
val channel2 = NotificationChannel("0", getString(R.string.notes), importance).apply {
705+
description = getString(R.string.notes)
706+
}
704707
notificationManager.createNotificationChannel(channel)
708+
notificationManager.createNotificationChannel(channel2)
705709
}
706710

707711
override fun onDestroy() {

app/src/main/java/com/jjewuz/justnotes/Fragments/NotesFragment.kt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package com.jjewuz.justnotes.Fragments
22

3+
import android.app.NotificationManager
4+
import android.app.PendingIntent
35
import android.appwidget.AppWidgetManager
46
import android.content.ComponentName
57
import android.content.Context
68
import android.content.Intent
79
import android.content.SharedPreferences
10+
import android.os.Build
811
import android.os.Bundle
12+
import android.text.Html
13+
import android.text.Spanned
914
import android.view.LayoutInflater
1015
import android.view.MenuItem
1116
import android.view.View
@@ -16,6 +21,7 @@ import android.widget.ProgressBar
1621
import android.widget.SearchView
1722
import android.widget.TextView
1823
import android.widget.Toast
24+
import androidx.core.app.NotificationCompat
1925
import androidx.core.content.res.ResourcesCompat
2026
import androidx.core.view.ViewCompat
2127
import androidx.core.view.WindowInsetsCompat
@@ -46,6 +52,7 @@ import com.jjewuz.justnotes.Notes.NoteViewModal
4652
import com.jjewuz.justnotes.Notes.NoteWidget
4753
import com.jjewuz.justnotes.R
4854
import com.jjewuz.justnotes.Utils.OnSwipeTouchListener
55+
import com.jjewuz.justnotes.Utils.Utils
4956

5057
class NotesFragment : Fragment(), NoteClickInterface, NoteLongClickInterface {
5158
lateinit var viewModal: NoteViewModal
@@ -296,6 +303,7 @@ class NotesFragment : Fragment(), NoteClickInterface, NoteLongClickInterface {
296303
val edit = inf.findViewById<MaterialCardView>(R.id.edit)
297304
val widget = inf.findViewById<MaterialCardView>(R.id.tohome)
298305
val delete = inf.findViewById<MaterialCardView>(R.id.delete)
306+
val notify = inf.findViewById<MaterialCardView>(R.id.tonoti)
299307

300308
builder.setIcon(R.drawable.note)
301309
builder.setTitle(note.noteTitle)
@@ -330,6 +338,11 @@ class NotesFragment : Fragment(), NoteClickInterface, NoteLongClickInterface {
330338
Toast.makeText(requireContext(), R.string.note_set_to_widget, Toast.LENGTH_SHORT).show()
331339
editor.cancel()
332340
}
341+
notify.setOnClickListener {
342+
sendNotification(requireContext(), note)
343+
Toast.makeText(requireContext(), "Notification sent", Toast.LENGTH_SHORT).show()
344+
editor.cancel()
345+
}
333346
}
334347

335348
private fun pushWidget(){
@@ -356,4 +369,50 @@ class NotesFragment : Fragment(), NoteClickInterface, NoteLongClickInterface {
356369
}
357370
}
358371

372+
private fun sendNotification(context: Context, note: Note) {
373+
val notificationId = note.id
374+
val notificationManager =
375+
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
376+
377+
// Создаем Intent для открытия AddEditNoteActivity
378+
val intent = Intent(context, AddEditNoteActivity::class.java).apply {
379+
putExtra("noteType", "Edit")
380+
putExtra("noteId", note.id)
381+
putExtra("noteTitle", note.noteTitle)
382+
putExtra("noteDescription", note.noteDescription)
383+
putExtra("timestamp", note.timeStamp)
384+
putExtra("categoryId", note.categoryId ?: 0)
385+
putExtra("security", note.security)
386+
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
387+
}
388+
389+
val pendingIntent = PendingIntent.getActivity(
390+
context,
391+
notificationId,
392+
intent,
393+
PendingIntent.FLAG_IMMUTABLE
394+
)
395+
396+
val spannedContent = Html.fromHtml(note.noteDescription, Html.FROM_HTML_MODE_COMPACT).toString()
397+
val content = if (spannedContent.length > 50) {
398+
"${spannedContent.take(50)}..."
399+
} else {
400+
spannedContent
401+
}
402+
403+
val notification = NotificationCompat.Builder(context, "1")
404+
.setSmallIcon(R.drawable.note)
405+
.setContentTitle(note.noteTitle)
406+
.setContentText(content)
407+
.setContentIntent(pendingIntent)
408+
.setAutoCancel(true)
409+
.setOngoing(true)
410+
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
411+
.build()
412+
413+
notificationManager.notify(notificationId, notification)
414+
}
415+
416+
417+
359418
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960">
6+
<path
7+
android:pathData="M104.62,396.54q0,-88.46 37.57,-163.31 37.58,-74.84 101.43,-126.38l36.99,46.69q-53.46,43.23 -84.73,106 -31.26,62.77 -31.26,137h-60ZM795.38,396.54q0,-74.23 -31.26,-137.19 -31.27,-62.96 -84.73,-106.2l36.99,-46.3q63.85,51.54 101.43,126.38 37.57,74.85 37.57,163.31h-60ZM180,755.38v-59.99h72.31v-298.47q0,-80.69 49.81,-142.69 49.8,-62 127.88,-79.31L430,150q0,-20.77 14.62,-35.38Q459.23,100 480,100q20.77,0 35.38,14.62Q530,129.23 530,150v24.92q78.08,17.31 127.88,79.31 49.81,62 49.81,142.69v298.47L780,695.39v59.99L180,755.38ZM480,462.31ZM480,867.69q-29.92,0 -51.11,-21.19 -21.2,-21.19 -21.2,-51.12h144.62q0,29.93 -21.2,51.12Q509.92,867.69 480,867.69ZM312.31,695.39h335.38v-298.47q0,-69.46 -49.11,-118.57 -49.12,-49.12 -118.58,-49.12 -69.46,0 -118.58,49.12 -49.11,49.11 -49.11,118.57v298.47Z"
8+
android:fillColor="?colorOnBackground"/>
9+
</vector>

app/src/main/res/layout/note_options.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,38 @@
8080

8181
</com.google.android.material.card.MaterialCardView>
8282

83+
<com.google.android.material.card.MaterialCardView
84+
android:layout_width="match_parent"
85+
android:layout_marginTop="10dp"
86+
android:id="@+id/tonoti"
87+
style="@style/Widget.Material3.CardView.Filled"
88+
android:layout_height="wrap_content">
89+
90+
<LinearLayout
91+
android:layout_width="match_parent"
92+
android:layout_height="wrap_content"
93+
android:padding="15dp"
94+
android:gravity="center_vertical"
95+
android:orientation="horizontal">
96+
<ImageView
97+
android:layout_width="65dp"
98+
android:layout_height="65dp"
99+
android:scaleX="0.7"
100+
android:scaleY="0.7"
101+
app:srcCompat="@drawable/note_notification" />
102+
103+
<TextView
104+
android:layout_width="wrap_content"
105+
android:text="@string/note_sent_noti"
106+
android:paddingStart="25dp"
107+
android:paddingEnd="25dp"
108+
android:textSize="22sp"
109+
android:layout_height="wrap_content"/>
110+
111+
</LinearLayout>
112+
113+
</com.google.android.material.card.MaterialCardView>
114+
83115
<com.google.android.material.card.MaterialCardView
84116
android:layout_width="match_parent"
85117
style="@style/Widget.Material3.CardView.Filled"

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,5 @@
153153
<string name="app_desc">JustNotes ist eine einfache und funktionale Anwendung zum Notieren. Schönes Design, benutzerfreundliche Oberfläche, alle notwendigen Funktionen – alles in JustNotes! Schreiben Sie Ideen auf, erstellen Sie Listen, führen Sie ein Tagebuch – JustNotes wird zu Ihrem unverzichtbaren Assistenten.</string>
154154
<string name="about_app">Über die App</string>
155155
<string name="no_label">Unbeschriftet</string>
156+
<string name="note_sent_noti">An Benachrichtigungen senden</string>
156157
</resources>

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,5 @@
171171
<string name="executor_title">¡El ejecutor se ha lanzado!</string>
172172
<string name="contribuitors">Colaboradores</string>
173173
<string name="translators">Traductores</string>
174+
<string name="note_sent_noti">Enviar a notificaciones</string>
174175
</resources>

app/src/main/res/values-ru/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,5 @@
173173
<string name="executor_title">Executor вышел!</string>
174174
<string name="executor_promo">Посмотрите на новое приложение от jjewuz!</string>
175175
<string name="backup_warning">Из-за ограничений системы резервирования, приложение должно быть перезапущено после создания каждый резервной копии для стабильной работы. После восстановления приложение перезапускается самостоятельно.</string>
176+
<string name="note_sent_noti">Отправить в уведомления</string>
176177
</resources>

0 commit comments

Comments
 (0)