diff --git a/.github/workflows/android lint.yml b/.github/workflows/android lint.yml
new file mode 100644
index 0000000..1645ec8
--- /dev/null
+++ b/.github/workflows/android lint.yml
@@ -0,0 +1,35 @@
+name: android lint
+
+on:
+ pull_request:
+ branches:
+ - 'master'
+ push:
+ branches:
+ - 'master'
+
+jobs:
+ android-lint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 1
+ - name: set up JDK
+ uses: actions/setup-java@v4
+ with:
+ distribution: zulu
+ java-version: 21
+ cache: gradle
+ - name: Make gradlew executable
+ run: chmod +x ./gradlew
+ - name: Create local.properties
+ run: |
+ echo "sdk.dir=$(pwd)/android-sdk" >> local.properties
+ - run: ./gradlew :app:lint
+ - uses: yutailang0119/action-android-lint@v4
+ with:
+ report-path: build/reports/*.xml
+ ignore-warnings: true
+ continue-on-error: false
+#I love android!
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index aa724b7..a38348e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,27 @@
-*.iml
-.gradle
-/local.properties
-/.idea/caches
-/.idea/libraries
-/.idea/modules.xml
-/.idea/workspace.xml
-/.idea/navEditor.xml
-/.idea/assetWizardSettings.xml
-.DS_Store
-/build
-/captures
-.externalNativeBuild
-.cxx
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
local.properties
+
+# Log/OS Files
+*.log
+
+# Android Studio generated files and folders
+captures/
+.externalNativeBuild/
+.cxx/
+*.apk
+*.aab
+output.json
+
+# IntelliJ
+*.iml
+.idea/
+misc.xml
+deploymentTargetDropDown.xml
+render.experimental.xml
+
+# Android Profiling
+*.hprof
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 7dce2e7..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-Блокнот
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index b589d56..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index ae388c2..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index b504811..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..25b12ee
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+# О проекте
+Этот проект начал историю, когда я ещё учился в старших классах школы. Суть простая - создаёшь заметки, ставишь напоминаянию и всё.
+
+# Стек технологий
+- Java
+- XML android UI
+- Foreground service
+- MVP
+- Clean architecture
+- Glide
+- РСЯ
+- FCM
+
+__Переменные для local.properties не требуются__
diff --git a/app-data/.gitignore b/app-data/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app-data/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app-data/build.gradle.kts b/app-data/build.gradle.kts
new file mode 100644
index 0000000..0c5acad
--- /dev/null
+++ b/app-data/build.gradle.kts
@@ -0,0 +1,38 @@
+plugins {
+ id("com.android.library")
+}
+
+android {
+ namespace = "ru.plumsoftware.data"
+ compileSdk = 34
+
+ defaultConfig {
+ minSdk = 22
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles("consumer-rules.pro")
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"),
+ "proguard-rules.pro"
+ )
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+
+ implementation("androidx.appcompat:appcompat:1.7.0")
+ implementation("com.google.android.material:material:1.12.0")
+ testImplementation("junit:junit:4.13.2")
+ androidTestImplementation("androidx.test.ext:junit:1.2.1")
+ androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
+}
\ No newline at end of file
diff --git a/app-data/consumer-rules.pro b/app-data/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/app-data/proguard-rules.pro b/app-data/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app-data/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/app-data/src/androidTest/java/ru/plumsoftware/data/ExampleInstrumentedTest.java b/app-data/src/androidTest/java/ru/plumsoftware/data/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..c629b50
--- /dev/null
+++ b/app-data/src/androidTest/java/ru/plumsoftware/data/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package ru.plumsoftware.data;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("ru.plumsoftware.data.test", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/app-data/src/main/AndroidManifest.xml b/app-data/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..a5918e6
--- /dev/null
+++ b/app-data/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app-data/src/main/java/ru/plumsoftware/data/database/SQLiteDatabaseManager.java b/app-data/src/main/java/ru/plumsoftware/data/database/SQLiteDatabaseManager.java
new file mode 100644
index 0000000..47f5de7
--- /dev/null
+++ b/app-data/src/main/java/ru/plumsoftware/data/database/SQLiteDatabaseManager.java
@@ -0,0 +1,41 @@
+package ru.plumsoftware.data.database;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+import ru.plumsoftware.data.model.database.DatabaseConstants;
+
+public class SQLiteDatabaseManager extends SQLiteOpenHelper {
+ private static final int DATABASE_VERSION = 5;
+ private static final String DATABASE_NAME = DatabaseConstants.DATABASE_NAME;
+
+ public SQLiteDatabaseManager(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(DatabaseConstants.CREATE_NOTES_TABLE);
+ db.execSQL(DatabaseConstants.CREATE_GROUPS_TABLE);
+ }
+
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ if (newVersion > oldVersion) {
+ String tempTable = "temp_table";
+ db.execSQL("CREATE TABLE " + tempTable + " AS SELECT * FROM " + DatabaseConstants._NOTES_TABLE_NAME);
+ db.execSQL(DatabaseConstants.DELETE_NOTES_TABLE);
+ db.execSQL(DatabaseConstants.CREATE_NOTES_TABLE);
+
+ db.execSQL("ALTER TABLE " + tempTable + " ADD " + DatabaseConstants._CHANNEL_ID + " TEXT;");
+ db.execSQL("ALTER TABLE " + tempTable + " ADD " + DatabaseConstants._IS_NOTIFY + " INTEGER;");
+
+ db.execSQL("INSERT INTO " + DatabaseConstants._NOTES_TABLE_NAME + " SELECT * FROM " + tempTable);
+
+ db.execSQL("DROP TABLE IF EXISTS " + tempTable);
+ }
+ }
+
+ public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ onUpgrade(db, oldVersion, newVersion);
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/databases/DatabaseConstants.java b/app-data/src/main/java/ru/plumsoftware/data/model/database/DatabaseConstants.java
similarity index 85%
rename from app/src/main/java/ru/plumsoftware/notebook/databases/DatabaseConstants.java
rename to app-data/src/main/java/ru/plumsoftware/data/model/database/DatabaseConstants.java
index ce323d1..e0726cc 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/databases/DatabaseConstants.java
+++ b/app-data/src/main/java/ru/plumsoftware/data/model/database/DatabaseConstants.java
@@ -1,4 +1,4 @@
-package ru.plumsoftware.notebook.databases;
+package ru.plumsoftware.data.model.database;
import android.provider.BaseColumns;
@@ -16,6 +16,9 @@ public class DatabaseConstants implements BaseColumns {
public static final String _IS_PINNED = "_is_pinned";
public static final String _IS_LIKED = "_is_liked";
+ public static final String _CHANNEL_ID = "_notification_channel_id";
+ public static final String _IS_NOTIFY = "_is_notify";
+
public static final String CREATE_NOTES_TABLE =
"CREATE TABLE IF NOT EXISTS " + DatabaseConstants._NOTES_TABLE_NAME +
" (" + DatabaseConstants._ID + " INTEGER PRIMARY KEY," +
@@ -25,7 +28,9 @@ public class DatabaseConstants implements BaseColumns {
DatabaseConstants._NOTE_PROMO + " INTEGER," +
DatabaseConstants._IS_PINNED + " INTEGER," +
DatabaseConstants._NOTE_COLOR + " INTEGER," +
- DatabaseConstants._IS_LIKED + " INTEGER)";
+ DatabaseConstants._IS_LIKED + " INTEGER," +
+ DatabaseConstants._CHANNEL_ID + " TEXT," +
+ DatabaseConstants._IS_NOTIFY + " INTEGER)";
public static final String CREATE_GROUPS_TABLE =
"CREATE TABLE IF NOT EXISTS " + DatabaseConstants._GROUPS_TABLE_NAME +
diff --git a/app/src/main/java/ru/plumsoftware/notebook/data/items/Colors.java b/app-data/src/main/java/ru/plumsoftware/data/model/ui/Colors.java
similarity index 57%
rename from app/src/main/java/ru/plumsoftware/notebook/data/items/Colors.java
rename to app-data/src/main/java/ru/plumsoftware/data/model/ui/Colors.java
index e467118..3ab3b97 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/data/items/Colors.java
+++ b/app-data/src/main/java/ru/plumsoftware/data/model/ui/Colors.java
@@ -1,7 +1,9 @@
-package ru.plumsoftware.notebook.data.items;
+package ru.plumsoftware.data.model.ui;
+
+import androidx.annotation.ColorRes;
public class Colors {
- private int colorRes;
+ @ColorRes private final int colorRes;
public Colors(int colorRes) {
this.colorRes = colorRes;
diff --git a/app/src/main/java/ru/plumsoftware/notebook/data/items/Note.java b/app-data/src/main/java/ru/plumsoftware/data/model/ui/Note.java
similarity index 55%
rename from app/src/main/java/ru/plumsoftware/notebook/data/items/Note.java
rename to app-data/src/main/java/ru/plumsoftware/data/model/ui/Note.java
index 948a43b..79a5fc9 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/data/items/Note.java
+++ b/app-data/src/main/java/ru/plumsoftware/data/model/ui/Note.java
@@ -99,18 +99,37 @@
// this.color = color;
// }
//}
-package ru.plumsoftware.notebook.data.items;
+package ru.plumsoftware.data.model.ui;
import android.os.Parcel;
import android.os.Parcelable;
+import androidx.annotation.NonNull;
+
+import org.jetbrains.annotations.Contract;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
public class Note implements Parcelable {
- private int id, count, notePromoResId, isPinned, isLiked, color;
- private String noteName, noteText;
+ private int id, count, notePromoResId, isPinned, isLiked, color, isNotify;
+ private String noteName, noteText, notificationChannelId;
private long addNoteTime;
private int opacity = 0x35674824;
- public Note(int id, int count, int notePromoResId, int isPinned, int isLiked, int color, String noteName, String noteText, long addNoteTime, int opacity) {
+ public Note(
+ int id,
+ int count,
+ int notePromoResId,
+ int isPinned,
+ int isLiked,
+ int color,
+ String noteName,
+ String noteText,
+ long addNoteTime,
+ int opacity
+ ) {
this.id = id;
this.count = count;
this.notePromoResId = notePromoResId;
@@ -123,7 +142,7 @@ public Note(int id, int count, int notePromoResId, int isPinned, int isLiked, in
this.opacity = opacity;
}
- public Note(Parcel in) {
+ public Note(@NonNull Parcel in) {
id = in.readInt();
count = in.readInt();
notePromoResId = in.readInt();
@@ -134,6 +153,90 @@ public Note(Parcel in) {
noteText = in.readString();
addNoteTime = in.readLong();
opacity = in.readInt();
+ notificationChannelId = in.readString();
+ isNotify = in.readInt();
+ }
+
+ public Note(
+ int id,
+ int count,
+ int notePromoResId,
+ int isPinned,
+ int isLiked,
+ int color,
+ int isNotify,
+ String noteName,
+ String noteText,
+ String notificationChannelId,
+ long addNoteTime,
+ int opacity
+ ) {
+ this.id = id;
+ this.count = count;
+ this.notePromoResId = notePromoResId;
+ this.isPinned = isPinned;
+ this.isLiked = isLiked;
+ this.color = color;
+ this.isNotify = isNotify;
+ this.noteName = noteName;
+ this.noteText = noteText;
+ this.notificationChannelId = notificationChannelId;
+ this.addNoteTime = addNoteTime;
+ this.opacity = opacity;
+ }
+
+ public Note(
+ int id,
+ int count,
+ int notePromoResId,
+ int isPinned,
+ int isLiked,
+ int color,
+ String noteName,
+ String noteText,
+ long addNoteTime,
+ int opacity,
+ String notificationChannelId
+ ) {
+ this.id = id;
+ this.count = count;
+ this.notePromoResId = notePromoResId;
+ this.isPinned = isPinned;
+ this.isLiked = isLiked;
+ this.color = color;
+ this.noteName = noteName;
+ this.noteText = noteText;
+ this.addNoteTime = addNoteTime;
+ this.opacity = opacity;
+ this.notificationChannelId = notificationChannelId;
+ }
+
+ public Note(
+ int id,
+ int count,
+ int notePromoResId,
+ int isPinned,
+ int isLiked,
+ int color,
+ String noteName,
+ String noteText,
+ long addNoteTime,
+ int opacity,
+ String notificationChannelId,
+ int isNotify
+ ) {
+ this.id = id;
+ this.count = count;
+ this.notePromoResId = notePromoResId;
+ this.isPinned = isPinned;
+ this.isLiked = isLiked;
+ this.color = color;
+ this.noteName = noteName;
+ this.noteText = noteText;
+ this.addNoteTime = addNoteTime;
+ this.opacity = opacity;
+ this.notificationChannelId = notificationChannelId;
+ this.isNotify = isNotify;
}
public int getId() {
@@ -216,13 +319,29 @@ public void setColor(int color) {
this.color = color;
}
+ public String getNotificationChannelId() {
+ return notificationChannelId;
+ }
+
+ public void setNotificationChannelId(String notificationChannelId) {
+ this.notificationChannelId = notificationChannelId;
+ }
+
+ public int getIsNotify() {
+ return isNotify;
+ }
+
+ public void setIsNotify(int isNotify) {
+ this.isNotify = isNotify;
+ }
+
@Override
public int describeContents() {
return 0;
}
@Override
- public void writeToParcel(Parcel dest, int flags) {
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(id);
dest.writeInt(count);
dest.writeInt(notePromoResId);
@@ -233,17 +352,43 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(noteText);
dest.writeLong(addNoteTime);
dest.writeInt(opacity);
+ dest.writeString(notificationChannelId);
+ dest.writeInt(isNotify);
}
public static final Creator CREATOR = new Creator() {
+ @NonNull
+ @Contract("_ -> new")
@Override
public Note createFromParcel(Parcel in) {
return new Note(in);
}
+ @NonNull
+ @Contract(value = "_ -> new", pure = true)
@Override
public Note[] newArray(int size) {
return new Note[size];
}
};
+
+ @NonNull
+ @Override
+ public String toString() {
+ return
+ Integer.toString(id) + "\n" +
+ Integer.toString(count) + "\n" +
+ Integer.toString(notePromoResId) + "\n" +
+ Integer.toString(isPinned) + "\n" +
+ Integer.toString(isLiked) + "\n" +
+ Integer.toString(color) + "\n" +
+ noteName + "\n" +
+ noteText + "\n" +
+ new SimpleDateFormat("yyyy.MM.dd, hh:mm:ss", Locale.getDefault()).format(new Date(addNoteTime)) + "\n" +
+ Integer.toString(opacity) + "\n" +
+ notificationChannelId + "\n" +
+ Integer.toString(isNotify);
+
+
+ }
}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/data/items/Shape.java b/app-data/src/main/java/ru/plumsoftware/data/model/ui/Shape.java
similarity index 57%
rename from app/src/main/java/ru/plumsoftware/notebook/data/items/Shape.java
rename to app-data/src/main/java/ru/plumsoftware/data/model/ui/Shape.java
index e62156a..1bf29a5 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/data/items/Shape.java
+++ b/app-data/src/main/java/ru/plumsoftware/data/model/ui/Shape.java
@@ -1,7 +1,9 @@
-package ru.plumsoftware.notebook.data.items;
+package ru.plumsoftware.data.model.ui;
+
+import androidx.annotation.DrawableRes;
public class Shape {
- private int shapeRes;
+ @DrawableRes private int shapeRes;
public Shape(int shapeRes) {
this.shapeRes = shapeRes;
diff --git a/app-data/src/test/java/ru/plumsoftware/data/ExampleUnitTest.java b/app-data/src/test/java/ru/plumsoftware/data/ExampleUnitTest.java
new file mode 100644
index 0000000..d48a919
--- /dev/null
+++ b/app-data/src/test/java/ru/plumsoftware/data/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package ru.plumsoftware.data;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/app-domain/.gitignore b/app-domain/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app-domain/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app-domain/build.gradle.kts b/app-domain/build.gradle.kts
new file mode 100644
index 0000000..e103928
--- /dev/null
+++ b/app-domain/build.gradle.kts
@@ -0,0 +1,8 @@
+plugins {
+ id("java-library")
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+}
\ No newline at end of file
diff --git a/app-domain/src/main/java/ru/plumsoftware/domain/MyClass.java b/app-domain/src/main/java/ru/plumsoftware/domain/MyClass.java
new file mode 100644
index 0000000..3e92721
--- /dev/null
+++ b/app-domain/src/main/java/ru/plumsoftware/domain/MyClass.java
@@ -0,0 +1,4 @@
+package ru.plumsoftware.domain;
+
+public class MyClass {
+}
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 0891102..ad65faa 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -10,8 +10,8 @@ android {
applicationId "ru.plumsoftware.notebook"
minSdk 22
targetSdk 34
- versionCode 15
- versionName "1.3.0"
+ versionCode 30
+ versionName "2.0.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -27,29 +27,37 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'ru.plumsoftware.notebook'
+
+ android {
+ lintOptions {
+ disable 'MobileAdsSdkOutdatedVersion'
+ }
+ }
}
dependencies {
- implementation 'androidx.appcompat:appcompat:1.6.1'
- implementation 'com.google.android.material:material:1.10.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
- implementation 'com.google.firebase:firebase-analytics:21.5.0'
- implementation 'com.google.firebase:firebase-messaging:23.3.1'
+ //Autogenerate
+ implementation 'androidx.appcompat:appcompat:1.7.0'
+ implementation 'com.google.android.material:material:1.12.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.5'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
+ androidTestImplementation 'androidx.test.ext:junit:1.2.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
//Yandex ads
- implementation 'com.yandex.android:mobileads:6.1.0'
- implementation 'com.yandex.android:mobmetricalib:5.2.0'
+ implementation 'com.yandex.android:mobileads:7.6.0'
//Glide
implementation 'com.github.bumptech.glide:glide:4.15.1'
-// //Blur
-// implementation 'jp.wasabeef:blurry:4.0.1'
+ //Messaging
+ implementation 'com.google.firebase:firebase-messaging:24.0.3'
+
+ //Analytics
+ implementation 'com.google.firebase:firebase-analytics:22.1.2'
- //RuStore push notifications
- //implementation 'ru.rustore.sdk:pushclient:0.1.0'
+ //Modules
+ implementation project(':app-domain')
+ implementation project(':app-data')
}
\ No newline at end of file
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
index efdc82d..eb76b18 100644
Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ
diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json
index e900d64..023ef05 100644
--- a/app/release/output-metadata.json
+++ b/app/release/output-metadata.json
@@ -11,10 +11,27 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
- "versionCode": 14,
- "versionName": "1.2.6 - Bug-fix",
+ "versionCode": 25,
+ "versionName": "1.5.5",
"outputFile": "app-release.apk"
}
],
- "elementType": "File"
+ "elementType": "File",
+ "baselineProfiles": [
+ {
+ "minApi": 28,
+ "maxApi": 30,
+ "baselineProfiles": [
+ "baselineProfiles/1/app-release.dm"
+ ]
+ },
+ {
+ "minApi": 31,
+ "maxApi": 2147483647,
+ "baselineProfiles": [
+ "baselineProfiles/0/app-release.dm"
+ ]
+ }
+ ],
+ "minSdkVersionForDexing": 22
}
\ No newline at end of file
diff --git a/app/src/debug/res/mipmap-hdpi/ic_launcher.png b/app/src/debug/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index 1b28da5..0000000
Binary files a/app/src/debug/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png
deleted file mode 100644
index 7da7071..0000000
Binary files a/app/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-hdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 7ea5bd7..0000000
Binary files a/app/src/debug/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-mdpi/ic_launcher.png b/app/src/debug/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index e1ddaef..0000000
Binary files a/app/src/debug/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png
deleted file mode 100644
index a950698..0000000
Binary files a/app/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-mdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index d29383e..0000000
Binary files a/app/src/debug/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index 888de49..0000000
Binary files a/app/src/debug/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png
deleted file mode 100644
index 8718ced..0000000
Binary files a/app/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 24d53e3..0000000
Binary files a/app/src/debug/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index e028af4..0000000
Binary files a/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png
deleted file mode 100644
index 2dd323d..0000000
Binary files a/app/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index 9304e93..0000000
Binary files a/app/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 8cb46af..0000000
Binary files a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png
deleted file mode 100644
index d920525..0000000
Binary files a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index 54f53d0..0000000
Binary files a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5a825ee..b960a6f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,8 +4,14 @@
-
+
+
+
+
+
+
+
-
-
-
-
-
-
@@ -40,10 +32,14 @@
+
+
@@ -51,17 +47,26 @@
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png
index 7656e9e..185f5ed 100644
Binary files a/app/src/main/ic_launcher-playstore.png and b/app/src/main/ic_launcher-playstore.png differ
diff --git a/app/src/main/java/ru/plumsoftware/notebook/activities/AddNoteActivity.java b/app/src/main/java/ru/plumsoftware/notebook/activities/AddNoteActivity.java
deleted file mode 100644
index 02c1f0c..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/activities/AddNoteActivity.java
+++ /dev/null
@@ -1,388 +0,0 @@
-package ru.plumsoftware.notebook.activities;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.cardview.widget.CardView;
-
-import android.annotation.SuppressLint;
-import android.app.DatePickerDialog;
-import android.app.TimePickerDialog;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.text.format.DateUtils;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.DatePicker;
-import android.widget.EditText;
-import android.widget.GridView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.TimePicker;
-import android.widget.Toast;
-
-import com.google.android.material.bottomsheet.BottomSheetDialog;
-import com.google.android.material.snackbar.Snackbar;
-import com.yandex.mobile.ads.common.AdError;
-import com.yandex.mobile.ads.common.AdRequest;
-import com.yandex.mobile.ads.common.AdRequestConfiguration;
-import com.yandex.mobile.ads.common.AdRequestError;
-import com.yandex.mobile.ads.common.ImpressionData;
-import com.yandex.mobile.ads.common.MobileAds;
-import com.yandex.mobile.ads.interstitial.InterstitialAd;
-import com.yandex.mobile.ads.interstitial.InterstitialAdEventListener;
-import com.yandex.mobile.ads.interstitial.InterstitialAdLoadListener;
-import com.yandex.mobile.ads.interstitial.InterstitialAdLoader;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-
-import ru.plumsoftware.notebook.dialogs.ProgressDialog;
-import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.adapters.ColorAdapter;
-import ru.plumsoftware.notebook.adapters.GroupAdapter;
-import ru.plumsoftware.notebook.adapters.OpacityAdapter;
-import ru.plumsoftware.notebook.data.items.Colors;
-import ru.plumsoftware.notebook.data.items.Group;
-import ru.plumsoftware.notebook.data.items.Note;
-import ru.plumsoftware.notebook.data.items.Shape;
-import ru.plumsoftware.notebook.databases.DatabaseConstants;
-import ru.plumsoftware.notebook.databases.SQLiteDatabaseManager;
-
-public class AddNoteActivity extends AppCompatActivity {
-
- private int
- color = 0xFFFFFF,
- opacityRes = R.drawable.ic_coffee;
- private long noteTime = 0L;
- private CardView cardViewBtnDone;
- private SQLiteDatabase sqLiteDatabaseNotes;
- @Nullable
- private InterstitialAd mInterstitialAd = null;
- @Nullable
- private InterstitialAdLoader mInterstitialAdLoader = null;
- private ProgressDialog progressDialog;
-
- private Calendar dateAndTime = Calendar.getInstance();
- private androidx.appcompat.widget.Toolbar toolbar;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_add_note);
-
- MobileAds.initialize(this, () -> {
-
- });
-
- toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.toolbar);
- toolbar = findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
- EditText tvTitle = (EditText) findViewById(R.id.Title);
- EditText tvText = (EditText) findViewById(R.id.Text);
- cardViewBtnDone = (CardView) findViewById(R.id.cardBtnDoneUltra);
- TextView textView5 = (TextView) findViewById(R.id.textView5);
- SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(this);
- sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
- noteTime = System.currentTimeMillis();
- progressDialog = new ProgressDialog(this, R.style.CustomProgressDialog);
-
- Note note = getIntent().getParcelableExtra("note");
- boolean isUpdate = getIntent().getBooleanExtra("update", false);
-
- if (isUpdate) {
- toolbar.setTitle("Редактировать заметку");
- toolbar.setSubtitle(new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(note.getAddNoteTime())));
-
-// Setup note data
- color = note.getColor();
- opacityRes = note.getOpacity();
-
- cardViewBtnDone.setCardBackgroundColor(color);
- tvTitle.setText(note.getNoteName());
- tvText.setText(note.getNoteText());
- textView5.setText("РЕДАКТИРОВАТЬ");
- } else {
- toolbar.setTitle("Добавить заметку");
- toolbar.setSubtitle(new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(noteTime)));
- }
-
- mInterstitialAdLoader = new InterstitialAdLoader(this);
-
- mInterstitialAdLoader.setAdLoadListener(new InterstitialAdLoadListener() {
- @Override
- public void onAdLoaded(@NonNull final InterstitialAd interstitialAd) {
- mInterstitialAd = interstitialAd;
- progressDialog.dismiss();
- if (mInterstitialAd != null) {
- mInterstitialAd.setAdEventListener(new InterstitialAdEventListener() {
- @Override
- public void onAdShown() {
-
- }
-
- @Override
- public void onAdFailedToShow(@NonNull AdError adError) {
-
- }
-
- @Override
- public void onAdDismissed() {
- startActivity(new Intent(AddNoteActivity.this, MainActivity.class));
- overridePendingTransition(0, 0);
- finish();
- }
-
- @Override
- public void onAdClicked() {
- startActivity(new Intent(AddNoteActivity.this, MainActivity.class));
- overridePendingTransition(0, 0);
- finish();
- }
-
- @Override
- public void onAdImpression(@Nullable ImpressionData impressionData) {
-
- }
- });
- }
- mInterstitialAd.show(AddNoteActivity.this);
- }
-
- @Override
- public void onAdFailedToLoad(@NonNull final AdRequestError adRequestError) {
- Toast.makeText(AddNoteActivity.this, adRequestError.getDescription(), Toast.LENGTH_SHORT).show();
- startActivity(new Intent(AddNoteActivity.this, MainActivity.class));
- overridePendingTransition(0, 0);
- finish();
- }
- });
-
-// interstitialAd.setAdUnitId("R-M-1957919-2");
-
- cardViewBtnDone.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String noteTitle = Objects.requireNonNull(tvTitle).getText().toString();
- String text = Objects.requireNonNull(tvText).getText().toString();
-
-// SAVE
- if (isUpdate) {
- note.setNoteName(noteTitle);
- note.setNoteText(text);
- note.setColor(color);
- note.setOpacity(opacityRes);
- note.setAddNoteTime(noteTime);
- updateNote(note);
-// deleteNote(noteTime);
-// saveNote(noteTitle, text, opacityRes, color, noteTime);
- onBackPressed();
- } else {
- saveNote(noteTitle, text, opacityRes, color, noteTime);
- onBackPressed();
- }
-
- List groupList = GroupAdapter.addedGroups;
-
- for (int i = 0; i < groupList.size(); i++) {
- String name = groupList.get(i).getName();
-
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._GROUP_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_COLOR, color);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, noteTime);
- contentValues.put(DatabaseConstants._ADD_GROUP_TIME, System.currentTimeMillis());
- sqLiteDatabaseNotes.update(DatabaseConstants._GROUPS_TABLE_NAME, contentValues, DatabaseConstants._GROUP_NAME + " = ?", new String[]{name});
-// try {
-// NotepadActivity.reloadRecyclerView(AddNoteActivity.this, AddNoteActivity.this);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
- }
- }
- });
- }
-
- public void saveNote(String name, String text, int or, int c, long time) {
- if (name == null || name.isEmpty())
- name = "";
- if (text == null || text.isEmpty())
- text = "";
-
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._NOTE_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_TEXT, text);
- contentValues.put(DatabaseConstants._NOTE_PROMO, or);
- contentValues.put(DatabaseConstants._NOTE_COLOR, c);
- contentValues.put(DatabaseConstants._IS_LIKED, 0);
- contentValues.put(DatabaseConstants._IS_PINNED, 0);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, time);
- sqLiteDatabaseNotes.insert(DatabaseConstants._NOTES_TABLE_NAME, null, contentValues);
-
- Snackbar
- .make(this, (LinearLayout) findViewById(R.id.layout), "Данные сохранены✅", Snackbar.LENGTH_SHORT)
- .setTextColor(Color.parseColor("#000000"))
- .setBackgroundTint(Color.WHITE)
- .show();
- }
-
- private void updateNote(Note note) {
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._NOTE_NAME, note.getNoteName());
- contentValues.put(DatabaseConstants._NOTE_TEXT, note.getNoteText());
- contentValues.put(DatabaseConstants._NOTE_PROMO, note.getNotePromoResId());
- contentValues.put(DatabaseConstants._NOTE_COLOR, note.getColor());
- contentValues.put(DatabaseConstants._IS_LIKED, note.getIsLiked());
- contentValues.put(DatabaseConstants._IS_PINNED, note.getIsPinned());
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, note.getAddNoteTime());
- sqLiteDatabaseNotes.update(DatabaseConstants._NOTES_TABLE_NAME, contentValues, DatabaseConstants._ID + " = ?", new String[]{String.valueOf(note.getId())});
- }
-
- private void deleteNote(long time) {
- sqLiteDatabaseNotes.delete(DatabaseConstants._NOTES_TABLE_NAME, DatabaseConstants._ADD_NOTE_TIME + "= ?", new String[]{String.valueOf(time)});
- }
-
- @SuppressLint("NonConstantResourceId")
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(this, R.style.BottomSheetTheme);
- bottomSheetDialog1.setContentView(R.layout.color_picker);
- bottomSheetDialog1.setCancelable(true);
- bottomSheetDialog1.setDismissWithAnimation(true);
- GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- case R.id.pick_time:
-
- new DatePickerDialog(AddNoteActivity.this, d,
- dateAndTime.get(Calendar.YEAR),
- dateAndTime.get(Calendar.MONTH),
- dateAndTime.get(Calendar.DAY_OF_MONTH))
- .show();
-
- return true;
- case R.id.small_icon:
- ArrayList shapes = new ArrayList<>();
- shapes.add(new Shape(R.drawable.ic_coffee));
- shapes.add(new Shape(R.drawable.ic_child_care));
- shapes.add(new Shape(R.drawable.ic_fitness_center));
- shapes.add(new Shape(R.drawable.ic_headphones));
- shapes.add(new Shape(R.drawable.ic_hotel));
- shapes.add(new Shape(R.drawable.ic_local_shipping));
- shapes.add(new Shape(R.drawable.ic_perm_phone_msg));
- shapes.add(new Shape(R.drawable.ic_phishing));
- shapes.add(new Shape(R.drawable.ic_work));
- shapes.add(new Shape(R.drawable.ic_work_outline));
- shapes.add(new Shape(R.drawable.ic_receipt_long));
- shapes.add(new Shape(R.drawable.ic_rocket_launch));
- shapes.add(new Shape(R.drawable.ic_school));
- shapes.add(new Shape(R.drawable.ic_shopping_basket));
- shapes.add(new Shape(R.drawable.ic_spa));
- shapes.add(new Shape(R.drawable.ic_square_foot));
- shapes.add(new Shape(R.drawable.ic_grade));
-
- OpacityAdapter shapeAdapter = new OpacityAdapter(this, 0, shapes);
- Objects.requireNonNull(colorGridView).setAdapter(shapeAdapter);
-
- bottomSheetDialog1.show();
-
- //Clicker
- colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- opacityRes = shapes.get(position).getShapeRes();
- bottomSheetDialog1.dismiss();
- }
- });
- return true;
- case R.id.small_color:
- ArrayList colors = new ArrayList<>();
- colors.add(new Colors(getResources().getColor(R.color.note_blue)));
- colors.add(new Colors(getResources().getColor(R.color.note_green)));
- colors.add(new Colors(getResources().getColor(R.color.note_orange)));
- colors.add(new Colors(getResources().getColor(R.color.note_pink)));
- colors.add(new Colors(getResources().getColor(R.color.note_purple)));
- colors.add(new Colors(getResources().getColor(R.color.note_red)));
- colors.add(new Colors(getResources().getColor(R.color.note_yellow)));
-
- ColorAdapter colorAdapter = new ColorAdapter(this, 0, colors);
- Objects.requireNonNull(colorGridView).setAdapter(colorAdapter);
-
- bottomSheetDialog1.show();
-
- //Clicker
- colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- color = colors.get(position).getColorRes();
- bottomSheetDialog1.dismiss();
-
- cardViewBtnDone.setCardBackgroundColor(color);
- }
- });
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.add_menu, menu);
- return true;
- }
-
- @Override
- public void onBackPressed() {
-// super.onBackPressed();
- progressDialog.showDialog();
- if (mInterstitialAdLoader != null) {
- final AdRequestConfiguration adRequestConfiguration =
- new AdRequestConfiguration.Builder("R-M-1957919-2").build();
- mInterstitialAdLoader.loadAd(adRequestConfiguration);
- }
- }
-
- private void setDateAndTime() {
- noteTime = dateAndTime.getTimeInMillis();
- toolbar.setSubtitle(new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(noteTime)));
- }
-
- // установка обработчика выбора времени
- TimePickerDialog.OnTimeSetListener t = new TimePickerDialog.OnTimeSetListener() {
- public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
- dateAndTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
- dateAndTime.set(Calendar.MINUTE, minute);
- setDateAndTime();
- }
- };
-
- // установка обработчика выбора даты
- DatePickerDialog.OnDateSetListener d = new DatePickerDialog.OnDateSetListener() {
- public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- dateAndTime.set(Calendar.YEAR, year);
- dateAndTime.set(Calendar.MONTH, monthOfYear);
- dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- setDateAndTime();
-
- new TimePickerDialog(AddNoteActivity.this, t,
- dateAndTime.get(Calendar.HOUR_OF_DAY),
- dateAndTime.get(Calendar.MINUTE), true)
- .show();
- }
- };
-}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/activities/MainActivity.java b/app/src/main/java/ru/plumsoftware/notebook/activities/MainActivity.java
deleted file mode 100644
index 8b49b09..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/activities/MainActivity.java
+++ /dev/null
@@ -1,626 +0,0 @@
-package ru.plumsoftware.notebook.activities;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.constraintlayout.widget.ConstraintLayout;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.SearchView;
-import android.widget.Toast;
-
-import com.google.android.material.snackbar.Snackbar;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.adapters.NoteAdapter;
-import ru.plumsoftware.notebook.data.items.Group;
-import ru.plumsoftware.notebook.data.items.Note;
-import ru.plumsoftware.notebook.databases.DatabaseConstants;
-import ru.plumsoftware.notebook.databases.SQLiteDatabaseManager;
-
-public class MainActivity extends AppCompatActivity {
- public static SQLiteDatabase sqLiteDatabaseNotes;
- private static RecyclerView recyclerViewNotes; //recyclerViewGroups;
- private static boolean isList = true;
- private int
- color,
- opacityRes = R.drawable.ic_coffee;
- private Context context;
- private Activity activity;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_notepad);
-
-// FVI
- SearchView searchView = (SearchView) findViewById(R.id.searchView);
- recyclerViewNotes = (RecyclerView) findViewById(R.id.recyclerViewNotes);
- //recyclerViewGroups = (RecyclerView) findViewById(R.id.recyclerViewGroups);
- ImageView filterAsList = (ImageView) findViewById(R.id.filterAsList);
- ImageButton addNote = (ImageButton) findViewById(R.id.addNote);
-
-// Data
- context = MainActivity.this;
- activity = MainActivity.this;
- SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(context);
- sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
- List notes = new ArrayList<>();
- List groups = new ArrayList<>();
-
- String groupName;
-
- if (getIntent().getStringExtra("group") != null) {
- groupName = getIntent().getStringExtra("group");
-
- List addTimeList = new ArrayList<>();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._GROUPS_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._GROUP_NAME + " = ?", // The columns for the WHERE clause
- new String[]{groupName}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- //"DATE_FORMAT("+new SimpleDateFormat("")+", '%m%d')" // The sort order
- DatabaseConstants._ADD_GROUP_TIME + " DESC"
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
- int color = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._GROUP_NAME));
- long addNoteTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
- long addGroupTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_GROUP_TIME));
-
- //Group group = new Group(name, id, color, addGroupTime, addNoteTime);
- addTimeList.add(addNoteTime);
- //groups.add(group);
- }
- cursor.close();
-
- for (int i = 0; i < addTimeList.size(); i++) {
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._ADD_NOTE_TIME + " = ?", // The columns for the WHERE clause
- new String[]{Long.toString(addTimeList.get(i))}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor1.close();
- }
- Toast.makeText(context, new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(addTimeList.get(0))), Toast.LENGTH_SHORT).show();
- //Toast.makeText(context, Integer.toString(notes.size()), Toast.LENGTH_SHORT).show();
- } else {
- notes = loadNotes(context);
- //groups = loadGroups(context);
- }
-
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, notes, 1);
- //GroupAdapter groupAdapter = new GroupAdapter(context, activity, groups, 1);
-
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
-// recyclerViewGroups.setHasFixedSize(true);
-// recyclerViewGroups.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
-// recyclerViewGroups.setAdapter(groupAdapter);
- filterAsList.setImageResource(R.drawable.ic_baseline_filter_list);
-
- color = getResources().getColor(R.color.note_blue);
-
-// Clickers
- filterAsList.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (isList) {
- isList = false;
-
- recyclerViewNotes.setVisibility(View.GONE);
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, loadNotes(context), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
-
- filterAsList.setImageResource(R.drawable.ic_table_rows);
- } else {
- isList = true;
-
- recyclerViewNotes.setVisibility(View.GONE);
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, loadNotes(context), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
-
- filterAsList.setImageResource(R.drawable.ic_baseline_filter_list);
- }
- }
- });
-
- addNote.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(MainActivity.this, AddNoteActivity.class));
- finish();
-// BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.this, R.style.BottomSheetTheme);
-// bottomSheetDialog.setContentView(R.layout.add_note_layout);
-// bottomSheetDialog.setCancelable(true);
-// bottomSheetDialog.setDismissWithAnimation(true);
-//
-// ImageButton addOpacity = (ImageButton) bottomSheetDialog.findViewById(R.id.noteOpacity);
-// ImageButton addColor = (ImageButton) bottomSheetDialog.findViewById(R.id.noteColor);
-// ImageButton btnDone = (ImageButton) bottomSheetDialog.findViewById(R.id.btnDone);
-// EditText tvTitle = (EditText) bottomSheetDialog.findViewById(R.id.Title);
-// EditText tvText = (EditText) bottomSheetDialog.findViewById(R.id.Text);
-// CardView cardViewBtnDone = (CardView) bottomSheetDialog.findViewById(R.id.cardBtnDone);
-// //RecyclerView recyclerGroups = (RecyclerView) bottomSheetDialog.findViewById(R.id.recyclerGroups);
-//
-// //List groups = loadGroups(context);
-//// GroupAdapter groupAdapter = new GroupAdapter(context, activity, groups, 0);
-//// assert recyclerGroups != null;
-//// recyclerGroups.setHasFixedSize(true);
-//// recyclerGroups.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
-//// recyclerGroups.setAdapter(groupAdapter);
-//
-// Objects.requireNonNull(cardViewBtnDone).setCardBackgroundColor(color);
-//
-// bottomSheetDialog.show();
-//
-// //Clickers
-//
-// //Color
-// Objects.requireNonNull(addColor).setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View v) {
-// BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(context, R.style.BottomSheetTheme);
-// bottomSheetDialog1.setContentView(R.layout.color_picker);
-// bottomSheetDialog1.setCancelable(true);
-// bottomSheetDialog1.setDismissWithAnimation(true);
-//
-// GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-//
-// ArrayList colors = new ArrayList<>();
-// colors.add(new Colors(getResources().getColor(R.color.note_blue)));
-// colors.add(new Colors(getResources().getColor(R.color.note_green)));
-// colors.add(new Colors(getResources().getColor(R.color.note_orange)));
-// colors.add(new Colors(getResources().getColor(R.color.note_pink)));
-// colors.add(new Colors(getResources().getColor(R.color.note_purple)));
-// colors.add(new Colors(getResources().getColor(R.color.note_red)));
-// colors.add(new Colors(getResources().getColor(R.color.note_yellow)));
-//
-// ColorAdapter colorAdapter = new ColorAdapter(context, 0, colors);
-// Objects.requireNonNull(colorGridView).setAdapter(colorAdapter);
-//
-// bottomSheetDialog1.show();
-//
-// //Clicker
-// colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-// @Override
-// public void onItemClick(AdapterView> parent, View view, int position, long id) {
-// color = colors.get(position).getColorRes();
-// bottomSheetDialog1.dismiss();
-//
-// cardViewBtnDone.setCardBackgroundColor(color);
-// }
-// });
-// }
-// });
-//
-// //Opacity
-// Objects.requireNonNull(addOpacity).setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View v) {
-// BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(context, R.style.BottomSheetTheme);
-// bottomSheetDialog1.setContentView(R.layout.color_picker);
-// bottomSheetDialog1.setCancelable(true);
-// bottomSheetDialog1.setDismissWithAnimation(true);
-//
-// GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-//
-// ArrayList shapes = new ArrayList<>();
-// shapes.add(new Shape(R.drawable.ic_coffee));
-// shapes.add(new Shape(R.drawable.ic_child_care));
-// shapes.add(new Shape(R.drawable.ic_fitness_center));
-// shapes.add(new Shape(R.drawable.ic_headphones));
-// shapes.add(new Shape(R.drawable.ic_hotel));
-// shapes.add(new Shape(R.drawable.ic_local_shipping));
-// shapes.add(new Shape(R.drawable.ic_perm_phone_msg));
-// shapes.add(new Shape(R.drawable.ic_phishing));
-// shapes.add(new Shape(R.drawable.ic_work));
-// shapes.add(new Shape(R.drawable.ic_work_outline));
-// shapes.add(new Shape(R.drawable.ic_receipt_long));
-// shapes.add(new Shape(R.drawable.ic_rocket_launch));
-// shapes.add(new Shape(R.drawable.ic_school));
-// shapes.add(new Shape(R.drawable.ic_shopping_basket));
-// shapes.add(new Shape(R.drawable.ic_spa));
-// shapes.add(new Shape(R.drawable.ic_square_foot));
-// shapes.add(new Shape(R.drawable.ic_grade));
-//
-// OpacityAdapter shapeAdapter = new OpacityAdapter(context, 0, shapes);
-// Objects.requireNonNull(colorGridView).setAdapter(shapeAdapter);
-//
-// bottomSheetDialog1.show();
-//
-// //Clicker
-// colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-// @Override
-// public void onItemClick(AdapterView> parent, View view, int position, long id) {
-// opacityRes = shapes.get(position).getShapeRes();
-// bottomSheetDialog1.dismiss();
-// }
-// });
-// }
-// });
-//
-// //Done
-// Objects.requireNonNull(btnDone).setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View v) {
-// String note = Objects.requireNonNull(tvTitle).getText().toString();
-// String text = Objects.requireNonNull(tvText).getText().toString();
-//
-//// SAVE
-// long time = System.currentTimeMillis();
-// saveNote(note, text, opacityRes, color, time);
-//
-// List groupList = GroupAdapter.addedGroups;
-//
-// for (int i = 0; i < groupList.size(); i++) {
-// String name = groupList.get(i).getName();
-//
-// ContentValues contentValues = new ContentValues();
-// contentValues.put(DatabaseConstants._GROUP_NAME, name);
-// contentValues.put(DatabaseConstants._NOTE_COLOR, color);
-// contentValues.put(DatabaseConstants._ADD_NOTE_TIME, time);
-// contentValues.put(DatabaseConstants._ADD_GROUP_TIME, System.currentTimeMillis());
-// sqLiteDatabaseNotes.update(DatabaseConstants._GROUPS_TABLE_NAME, contentValues, DatabaseConstants._GROUP_NAME + " = ?", new String[]{name});
-// try {
-// NotepadActivity.reloadRecyclerView(context, activity);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-//
-// bottomSheetDialog.dismiss();
-// }
-// });
-//
-// bottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
-// @Override
-// public void onDismiss(DialogInterface dialog) {
-//// UPDATE
-// reloadRecyclerView(context, activity);
-// }
-// });
- }
- });
-
- searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
- @Override
- public boolean onQueryTextSubmit(String s) {
- return false;
- }
-
- @Override
- public boolean onQueryTextChange(String s) {
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, loadNotesWithCondition(s), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
- return false;
- }
- });
- }
-
- public static List loadNotes(Context context) {
- List notes = new ArrayList<>();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"1"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- //"DATE_FORMAT("+new SimpleDateFormat("")+", '%m%d')" // The sort order
- DatabaseConstants._ADD_NOTE_TIME + " DESC"
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor.close();
-
-// Simple notes
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"0"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor1.close();
-
- return notes;
- }
-
-// public static List loadGroups(Context context) {
-// List groups = new ArrayList<>();
-//
-//// Pinned notes
-// @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
-// DatabaseConstants._GROUPS_TABLE_NAME, // The table to query
-// null, // The array of columns to return (pass null to get all)
-// null, // The columns for the WHERE clause
-// null, // The values for the WHERE clause
-// null, // don't group the rows
-// null, // don't filter by row groups
-// //"DATE_FORMAT("+new SimpleDateFormat("")+", '%m%d')" // The sort order
-// DatabaseConstants._ADD_GROUP_TIME + " DESC"
-// );
-//
-// while (cursor.moveToNext()) {
-//// Read data
-// int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int color = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
-// String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._GROUP_NAME));
-// long addNoteTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-// long addGroupTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_GROUP_TIME));
-//
-// Group group = new Group(name, id, color, addGroupTime, addNoteTime);
-// groups.add(group);
-// }
-// cursor.close();
-//
-// return groups;
-// }
-
- public static List loadNotesWithCondition(String condition) {
- List notes = new ArrayList<>();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"1"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor.close();
-
-// Simple notes
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"0"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- if (noteName.contains(condition) || noteText.contains(condition) || new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(addTime)).contains(condition)) {
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- }
- cursor1.close();
-
- return notes;
- }
-
- public void saveNote(String name, String text, int or, int c, long time) {
- if (name == null || name.isEmpty())
- name = "";
- if (text == null || text.isEmpty())
- text = "";
-
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._NOTE_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_TEXT, text);
- contentValues.put(DatabaseConstants._NOTE_PROMO, or);
- contentValues.put(DatabaseConstants._NOTE_COLOR, c);
- contentValues.put(DatabaseConstants._IS_LIKED, 0);
- contentValues.put(DatabaseConstants._IS_PINNED, 0);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, time);
- sqLiteDatabaseNotes.insert(DatabaseConstants._NOTES_TABLE_NAME, null, contentValues);
-
- Snackbar
- .make(context, (ConstraintLayout) findViewById(R.id.layout), "Данные сохранены✅", Snackbar.LENGTH_SHORT)
- .setTextColor(Color.parseColor("#000000"))
- .setBackgroundTint(Color.WHITE)
- .show();
- }
-
-// public void saveGroup(String name, int c) {
-// if (name == null || name.isEmpty())
-// name = "";
-//
-// ContentValues contentValues = new ContentValues();
-// contentValues.put(DatabaseConstants._GROUP_NAME, name);
-// contentValues.put(DatabaseConstants._NOTE_COLOR, c);
-// contentValues.put(DatabaseConstants._ADD_GROUP_TIME, System.currentTimeMillis());
-// contentValues.put(DatabaseConstants._ADD_NOTE_TIME, 0);
-// sqLiteDatabaseNotes.insert(DatabaseConstants._GROUPS_TABLE_NAME, null, contentValues);
-//
-// Snackbar
-// .make(NotepadActivity.this, (ConstraintLayout) findViewById(R.id.layout), "Данные сохранены✅", Snackbar.LENGTH_SHORT)
-// .setTextColor(Color.parseColor("#000000"))
-// .setBackgroundTint(Color.WHITE)
-// .show();
-// }
-
- public static void reloadRecyclerView(Context context, Activity activity) {
- recyclerViewNotes.setVisibility(View.GONE);
- List notes = loadNotes(context);
- //Collections.reverse(notes);
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, notes, 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
- isList = true;
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- sqLiteDatabaseNotes.close();
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/activities/MainMenuActivity.java b/app/src/main/java/ru/plumsoftware/notebook/activities/MainMenuActivity.java
deleted file mode 100644
index a81d645..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/activities/MainMenuActivity.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package ru.plumsoftware.notebook.activities;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.cardview.widget.CardView;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.google.firebase.analytics.FirebaseAnalytics;
-import com.yandex.mobile.ads.common.AdRequestError;
-import com.yandex.mobile.ads.common.ImpressionData;
-import com.yandex.mobile.ads.common.InitializationListener;
-import com.yandex.mobile.ads.common.MobileAds;
-import com.yandex.mobile.ads.nativeads.MediaView;
-import com.yandex.mobile.ads.nativeads.NativeAd;
-import com.yandex.mobile.ads.nativeads.NativeAdEventListener;
-import com.yandex.mobile.ads.nativeads.NativeAdException;
-import com.yandex.mobile.ads.nativeads.NativeAdRequestConfiguration;
-import com.yandex.mobile.ads.nativeads.NativeAdView;
-import com.yandex.mobile.ads.nativeads.NativeAdViewBinder;
-import com.yandex.mobile.ads.nativeads.NativeBulkAdLoadListener;
-import com.yandex.mobile.ads.nativeads.NativeBulkAdLoader;
-
-import java.util.List;
-
-import ru.plumsoftware.notebook.fragments.NotepadFragment;
-import ru.plumsoftware.notebook.dialogs.ProgressDialog;
-import ru.plumsoftware.notebook.R;
-
-public class MainMenuActivity extends AppCompatActivity {
- private FirebaseAnalytics mFirebaseAnalytics;
- private Context context;
- private ProgressDialog progressDialog;
- private LinearLayout l1, l2;
-
- private CardView adsCard;
- private NativeAdView mNativeAdView;
- private MediaView mediaView;
- private TextView age;
- private TextView bodyView;
- private TextView call_to_action;
- private TextView priceView;
- private TextView storeView;
- private TextView tvHeadline;
- private TextView warning;
- private TextView domain;
- private ImageView favicon;
- private ImageView imageViewFeedback;
-
- @SuppressLint("MissingInflatedId")
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main_menu_layout);
-
- //Native ads
- mNativeAdView = (NativeAdView) findViewById(R.id.nativeAdView);
- mediaView = (MediaView) findViewById(R.id.media);
- age = (TextView) findViewById(R.id.age);
- bodyView = (TextView) findViewById(R.id.tvAdvertiser);
- call_to_action = (TextView) findViewById(R.id.btnVisitSite);
- domain = (TextView) findViewById(R.id.textViewDomain);
- favicon = (ImageView) findViewById(R.id.adsPromo);
- imageViewFeedback = (ImageView) findViewById(R.id.imageViewFeedback);
- priceView = (TextView) findViewById(R.id.priceView);
- storeView = (TextView) findViewById(R.id.storeView);
- tvHeadline = (TextView) findViewById(R.id.tvHeadline);
- warning = (TextView) findViewById(R.id.textViewWarning);
- adsCard = (CardView) findViewById(R.id.cardView2);
-
-// Variables
- context = MainMenuActivity.this;
- progressDialog = new ProgressDialog(context);
-
- l1 = (LinearLayout) findViewById(R.id.l1);
- l2 = (LinearLayout) findViewById(R.id.l2);
-
-// Get instance
- mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
-
-// ADS
- MobileAds.initialize(context, new InitializationListener() {
- @Override
- public void onInitializationCompleted() {
-
- }
- });
- progressDialog.showDialog();
- adsCard.setVisibility(View.GONE);
- final NativeBulkAdLoader nativeBulkAdLoader = new NativeBulkAdLoader(context);
- nativeBulkAdLoader.setNativeBulkAdLoadListener(new NativeBulkAdLoadListener() {
- @Override
- public void onAdsLoaded(@NonNull final List nativeAds) {
- for (final NativeAd nativeAd : nativeAds) {
- final NativeAdViewBinder nativeAdViewBinder = new NativeAdViewBinder.Builder(mNativeAdView)
- .setAgeView(age)
- .setBodyView(bodyView)
- .setCallToActionView(call_to_action)
- .setDomainView(domain)
- //.setFaviconView(notesViewHolder.favicon)
- .setFeedbackView(imageViewFeedback)
- .setIconView(favicon)
- .setMediaView(mediaView)
- .setPriceView(priceView)
- //.setRatingView((MyRatingView) findViewById(R.id.rating))
- //.setReviewCountView((TextView) findViewById(R.id.review_count))
- .setSponsoredView(storeView)
- .setTitleView(tvHeadline)
- .setWarningView(warning)
- .build();
-
- try {
- nativeAd.bindNativeAd(nativeAdViewBinder);
- nativeAd.setNativeAdEventListener(new NativeAdEventListener() {
- @Override
- public void onAdClicked() {
-
- }
-
- @Override
- public void onLeftApplication() {
-
- }
-
- @Override
- public void onReturnedToApplication() {
-
- }
-
- @Override
- public void onImpression(@Nullable ImpressionData impressionData) {
-
- }
- });
- mNativeAdView.setVisibility(View.VISIBLE);
- } catch (final NativeAdException exception) {
- Toast.makeText(context, exception.toString(), Toast.LENGTH_LONG).show();
- }
- }
- progressDialog.dismiss();
- }
-
- @Override
- public void onAdsFailedToLoad(@NonNull final AdRequestError error) {
- adsCard.setVisibility(View.GONE);
- }
- });
-
- final NativeAdRequestConfiguration nativeAdRequestConfiguration = new NativeAdRequestConfiguration.Builder("R-M-1957919-1").build();
- nativeBulkAdLoader.loadAds(nativeAdRequestConfiguration, 1);
-
-// Clickers
- l1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout, new NotepadFragment()).commit();
- }
- });
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/activities/NotepadActivity.java b/app/src/main/java/ru/plumsoftware/notebook/activities/NotepadActivity.java
deleted file mode 100644
index e92ef98..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/activities/NotepadActivity.java
+++ /dev/null
@@ -1,657 +0,0 @@
-package ru.plumsoftware.notebook.activities;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.cardview.widget.CardView;
-import androidx.constraintlayout.widget.ConstraintLayout;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.EditText;
-import android.widget.GridView;
-import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.SearchView;
-import android.widget.Toast;
-
-import com.google.android.material.bottomsheet.BottomSheetDialog;
-import com.google.android.material.snackbar.Snackbar;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-
-import ru.plumsoftware.notebook.dialogs.ProgressDialog;
-import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.adapters.ColorAdapter;
-import ru.plumsoftware.notebook.adapters.GroupAdapter;
-import ru.plumsoftware.notebook.adapters.NoteAdapter;
-import ru.plumsoftware.notebook.adapters.OpacityAdapter;
-import ru.plumsoftware.notebook.data.items.Colors;
-import ru.plumsoftware.notebook.data.items.Group;
-import ru.plumsoftware.notebook.data.items.Note;
-import ru.plumsoftware.notebook.data.items.Shape;
-import ru.plumsoftware.notebook.databases.DatabaseConstants;
-import ru.plumsoftware.notebook.databases.SQLiteDatabaseManager;
-
-public class NotepadActivity extends AppCompatActivity {
- public static SQLiteDatabase sqLiteDatabaseNotes;
- private static RecyclerView recyclerViewNotes; //recyclerViewGroups;
- private static boolean isList = true;
- private int
- color,
- opacityRes = R.drawable.ic_coffee;
- private Context context;
- private Activity activity;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_notepad);
-
-// FVI
- SearchView searchView = (SearchView) findViewById(R.id.searchView);
- recyclerViewNotes = (RecyclerView) findViewById(R.id.recyclerViewNotes);
- //recyclerViewGroups = (RecyclerView) findViewById(R.id.recyclerViewGroups);
- ImageView filterAsList = (ImageView) findViewById(R.id.filterAsList);
- ImageButton addNote = (ImageButton) findViewById(R.id.addNote);
-
-// Data
- context = NotepadActivity.this;
- activity = NotepadActivity.this;
- ProgressDialog dialog = new ProgressDialog(context);
- dialog.showDialog();
- SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(context);
- sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
- List notes = new ArrayList<>();
- List groups = new ArrayList<>();
-
- String groupName;
-
- if (getIntent().getStringExtra("group") != null) {
- groupName = getIntent().getStringExtra("group");
-
- List addTimeList = new ArrayList<>();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._GROUPS_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._GROUP_NAME + " = ?", // The columns for the WHERE clause
- new String[]{groupName}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- //"DATE_FORMAT("+new SimpleDateFormat("")+", '%m%d')" // The sort order
- DatabaseConstants._ADD_GROUP_TIME + " DESC"
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
- int color = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._GROUP_NAME));
- long addNoteTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
- long addGroupTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_GROUP_TIME));
-
- //Group group = new Group(name, id, color, addGroupTime, addNoteTime);
- addTimeList.add(addNoteTime);
- //groups.add(group);
- }
- cursor.close();
-
- for (int i = 0; i < addTimeList.size(); i++) {
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._ADD_NOTE_TIME + " = ?", // The columns for the WHERE clause
- new String[]{Long.toString(addTimeList.get(i))}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor1.close();
- }
- Toast.makeText(context, new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(addTimeList.get(0))), Toast.LENGTH_SHORT).show();
- //Toast.makeText(context, Integer.toString(notes.size()), Toast.LENGTH_SHORT).show();
- } else {
- notes = loadNotes(context);
- //groups = loadGroups(context);
- }
-
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, notes, 1);
- //GroupAdapter groupAdapter = new GroupAdapter(context, activity, groups, 1);
-
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
-// recyclerViewGroups.setHasFixedSize(true);
-// recyclerViewGroups.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
-// recyclerViewGroups.setAdapter(groupAdapter);
- filterAsList.setImageResource(R.drawable.ic_baseline_filter_list);
-
- color = getResources().getColor(R.color.note_blue);
-
-// Clickers
- filterAsList.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (isList) {
- isList = false;
-
- recyclerViewNotes.setVisibility(View.GONE);
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, loadNotes(context), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
-
- filterAsList.setImageResource(R.drawable.ic_table_rows);
- } else {
- isList = true;
-
- recyclerViewNotes.setVisibility(View.GONE);
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, loadNotes(context), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
-
- filterAsList.setImageResource(R.drawable.ic_baseline_filter_list);
- }
- }
- });
-
- addNote.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(NotepadActivity.this, R.style.BottomSheetTheme);
- bottomSheetDialog.setContentView(R.layout.add_note_layout);
- bottomSheetDialog.setCancelable(true);
- bottomSheetDialog.setDismissWithAnimation(true);
-
- ImageButton addOpacity = (ImageButton) bottomSheetDialog.findViewById(R.id.noteOpacity);
- ImageButton addColor = (ImageButton) bottomSheetDialog.findViewById(R.id.noteColor);
- ImageButton btnDone = (ImageButton) bottomSheetDialog.findViewById(R.id.btnDone1);
- EditText tvTitle = (EditText) bottomSheetDialog.findViewById(R.id.Title);
- EditText tvText = (EditText) bottomSheetDialog.findViewById(R.id.Text);
- CardView cardViewBtnDone = (CardView) bottomSheetDialog.findViewById(R.id.cardBtnDone1);
- //RecyclerView recyclerGroups = (RecyclerView) bottomSheetDialog.findViewById(R.id.recyclerGroups);
-
- //List groups = loadGroups(context);
-// GroupAdapter groupAdapter = new GroupAdapter(context, NotepadActivity.this, groups, 0);
-// assert recyclerGroups != null;
-// recyclerGroups.setHasFixedSize(true);
-// recyclerGroups.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
-// recyclerGroups.setAdapter(groupAdapter);
-
- Objects.requireNonNull(cardViewBtnDone).setCardBackgroundColor(color);
-
- bottomSheetDialog.show();
-
- //Clickers
-
- //Color
- Objects.requireNonNull(addColor).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(NotepadActivity.this, R.style.BottomSheetTheme);
- bottomSheetDialog1.setContentView(R.layout.color_picker);
- bottomSheetDialog1.setCancelable(true);
- bottomSheetDialog1.setDismissWithAnimation(true);
-
- GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-
- ArrayList colors = new ArrayList<>();
- colors.add(new Colors(getResources().getColor(R.color.note_blue)));
- colors.add(new Colors(getResources().getColor(R.color.note_green)));
- colors.add(new Colors(getResources().getColor(R.color.note_orange)));
- colors.add(new Colors(getResources().getColor(R.color.note_pink)));
- colors.add(new Colors(getResources().getColor(R.color.note_purple)));
- colors.add(new Colors(getResources().getColor(R.color.note_red)));
- colors.add(new Colors(getResources().getColor(R.color.note_yellow)));
-
- ColorAdapter colorAdapter = new ColorAdapter(NotepadActivity.this, 0, colors);
- Objects.requireNonNull(colorGridView).setAdapter(colorAdapter);
-
- bottomSheetDialog1.show();
-
- //Clicker
- colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- color = colors.get(position).getColorRes();
- bottomSheetDialog1.dismiss();
-
- cardViewBtnDone.setCardBackgroundColor(color);
- }
- });
- }
- });
-
- //Opacity
- Objects.requireNonNull(addOpacity).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(NotepadActivity.this, R.style.BottomSheetTheme);
- bottomSheetDialog1.setContentView(R.layout.color_picker);
- bottomSheetDialog1.setCancelable(true);
- bottomSheetDialog1.setDismissWithAnimation(true);
-
- GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-
- ArrayList shapes = new ArrayList<>();
- shapes.add(new Shape(R.drawable.ic_coffee));
- shapes.add(new Shape(R.drawable.ic_child_care));
- shapes.add(new Shape(R.drawable.ic_fitness_center));
- shapes.add(new Shape(R.drawable.ic_headphones));
- shapes.add(new Shape(R.drawable.ic_hotel));
- shapes.add(new Shape(R.drawable.ic_local_shipping));
- shapes.add(new Shape(R.drawable.ic_perm_phone_msg));
- shapes.add(new Shape(R.drawable.ic_phishing));
- shapes.add(new Shape(R.drawable.ic_work));
- shapes.add(new Shape(R.drawable.ic_work_outline));
- shapes.add(new Shape(R.drawable.ic_receipt_long));
- shapes.add(new Shape(R.drawable.ic_rocket_launch));
- shapes.add(new Shape(R.drawable.ic_school));
- shapes.add(new Shape(R.drawable.ic_shopping_basket));
- shapes.add(new Shape(R.drawable.ic_spa));
- shapes.add(new Shape(R.drawable.ic_square_foot));
- shapes.add(new Shape(R.drawable.ic_grade));
-
- OpacityAdapter shapeAdapter = new OpacityAdapter(NotepadActivity.this, 0, shapes);
- Objects.requireNonNull(colorGridView).setAdapter(shapeAdapter);
-
- bottomSheetDialog1.show();
-
- //Clicker
- colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- opacityRes = shapes.get(position).getShapeRes();
- bottomSheetDialog1.dismiss();
- }
- });
- }
- });
-
- ProgressDialog progressDialog = new ProgressDialog(NotepadActivity.this);
-
- //Done
- Objects.requireNonNull(btnDone).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- progressDialog.showDialog();
- String note = Objects.requireNonNull(tvTitle).getText().toString();
- String text = Objects.requireNonNull(tvText).getText().toString();
-
-// SAVE
- long time = System.currentTimeMillis();
- saveNote(note, text, opacityRes, color, time);
-
- List groupList = GroupAdapter.addedGroups;
-
- for (int i = 0; i < groupList.size(); i++) {
- String name = groupList.get(i).getName();
-
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._GROUP_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_COLOR, color);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, time);
- contentValues.put(DatabaseConstants._ADD_GROUP_TIME, System.currentTimeMillis());
- sqLiteDatabaseNotes.update(DatabaseConstants._GROUPS_TABLE_NAME, contentValues, DatabaseConstants._GROUP_NAME + " = ?", new String[]{name});
- try {
- NotepadActivity.reloadRecyclerView(context, NotepadActivity.this);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- progressDialog.dismiss();
- bottomSheetDialog.dismiss();
- //sqLiteDatabaseNotes.close();
- }
- });
-
- bottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
-// UPDATE
- //reloadRecyclerView(context, activity);
- finish();
- overridePendingTransition(0, 0);
- startActivity(new Intent(NotepadActivity.this, NotepadActivity.class));
- }
- });
- }
- });
-
- searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
- @Override
- public boolean onQueryTextSubmit(String s) {
- return false;
- }
-
- @Override
- public boolean onQueryTextChange(String s) {
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, loadNotesWithCondition(s), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
- return false;
- }
- });
-
- dialog.dismiss();
- }
-
- public static List loadNotes(Context context) {
- List notes = new ArrayList<>();
-
- SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(context);
- sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"1"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- //"DATE_FORMAT("+new SimpleDateFormat("")+", '%m%d')" // The sort order
- DatabaseConstants._ADD_NOTE_TIME + " DESC"
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor.close();
-
-// Simple notes
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"0"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor1.close();
-
- return notes;
- }
-
-// public static List loadGroups(Context context) {
-// List groups = new ArrayList<>();
-//
-//// Pinned notes
-// @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
-// DatabaseConstants._GROUPS_TABLE_NAME, // The table to query
-// null, // The array of columns to return (pass null to get all)
-// null, // The columns for the WHERE clause
-// null, // The values for the WHERE clause
-// null, // don't group the rows
-// null, // don't filter by row groups
-// //"DATE_FORMAT("+new SimpleDateFormat("")+", '%m%d')" // The sort order
-// DatabaseConstants._ADD_GROUP_TIME + " DESC"
-// );
-//
-// while (cursor.moveToNext()) {
-//// Read data
-// int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int color = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
-// String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._GROUP_NAME));
-// long addNoteTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-// long addGroupTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_GROUP_TIME));
-//
-// Group group = new Group(name, id, color, addGroupTime, addNoteTime);
-// groups.add(group);
-// }
-// cursor.close();
-//
-// return groups;
-// }
-
- public static List loadNotesWithCondition(String condition) {
- List notes = new ArrayList<>();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"1"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor.close();
-
-// Simple notes
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"0"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- if (noteName.contains(condition) || noteText.contains(condition) || new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(addTime)).contains(condition)) {
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- }
- cursor1.close();
-
- return notes;
- }
-
- public void saveNote(String name, String text, int or, int c, long time) {
- if (name == null || name.isEmpty())
- name = "";
- if (text == null || text.isEmpty())
- text = "";
-
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._NOTE_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_TEXT, text);
- contentValues.put(DatabaseConstants._NOTE_PROMO, or);
- contentValues.put(DatabaseConstants._NOTE_COLOR, c);
- contentValues.put(DatabaseConstants._IS_LIKED, 0);
- contentValues.put(DatabaseConstants._IS_PINNED, 0);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, time);
- sqLiteDatabaseNotes.insert(DatabaseConstants._NOTES_TABLE_NAME, null, contentValues);
-
- Snackbar
- .make(NotepadActivity.this, (ConstraintLayout) findViewById(R.id.layout), "Данные сохранены✅", Snackbar.LENGTH_SHORT)
- .setTextColor(Color.parseColor("#000000"))
- .setBackgroundTint(Color.WHITE)
- .show();
- }
-
-// public void saveGroup(String name, int c) {
-// if (name == null || name.isEmpty())
-// name = "";
-//
-// ContentValues contentValues = new ContentValues();
-// contentValues.put(DatabaseConstants._GROUP_NAME, name);
-// contentValues.put(DatabaseConstants._NOTE_COLOR, c);
-// contentValues.put(DatabaseConstants._ADD_GROUP_TIME, System.currentTimeMillis());
-// contentValues.put(DatabaseConstants._ADD_NOTE_TIME, 0);
-// sqLiteDatabaseNotes.insert(DatabaseConstants._GROUPS_TABLE_NAME, null, contentValues);
-//
-// Snackbar
-// .make(NotepadActivity.this, (ConstraintLayout) findViewById(R.id.layout), "Данные сохранены✅", Snackbar.LENGTH_SHORT)
-// .setTextColor(Color.parseColor("#000000"))
-// .setBackgroundTint(Color.WHITE)
-// .show();
-// }
-
- public static void reloadRecyclerView(Context context, Activity activity) {
- //recyclerViewNotes.setVisibility(View.GONE);
- List notes = loadNotes(context);
- //Collections.reverse(notes);
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, notes, 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
- isList = true;
- }
-
-// public static void reloadRecyclerViewGroups(Context context, Activity activity) {
-// recyclerViewNotes.setVisibility(View.GONE);
-// List groups = loadGroups(context);
-// //Collections.reverse(notes);
-// GroupAdapter groupAdapter = new GroupAdapter(context, activity, groups, 1);
-// recyclerViewGroups.setHasFixedSize(true);
-// recyclerViewGroups.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
-// recyclerViewGroups.setAdapter(groupAdapter);
-// recyclerViewGroups.setVisibility(View.VISIBLE);
-// isList = true;
-// }
-}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/adapters/GroupAdapter.java b/app/src/main/java/ru/plumsoftware/notebook/adapters/GroupAdapter.java
deleted file mode 100644
index 418cb59..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/adapters/GroupAdapter.java
+++ /dev/null
@@ -1,230 +0,0 @@
-package ru.plumsoftware.notebook.adapters;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.VibrationEffect;
-import android.os.Vibrator;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.PopupMenu;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.cardview.widget.CardView;
-import androidx.recyclerview.widget.RecyclerView;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ru.plumsoftware.notebook.activities.MainActivity;
-import ru.plumsoftware.notebook.activities.NotepadActivity;
-import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.data.items.Group;
-import ru.plumsoftware.notebook.databases.DatabaseConstants;
-
-public class GroupAdapter extends RecyclerView.Adapter {
- private Context context;
- private Activity activity;
- private List groupList;
- private int mode = 0;
- public static List addedGroups = new ArrayList<>();
-
- public GroupAdapter(Context context, Activity activity, List groupList) {
- this.context = context;
- this.activity = activity;
- this.groupList = groupList;
- }
-
- public GroupAdapter(Context context, Activity activity, List groupList, int mode) {
- this.context = context;
- this.activity = activity;
- this.groupList = groupList;
- this.mode = mode;
- }
-
- @NonNull
- @Override
- public GroupViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- return new GroupViewHolder(LayoutInflater.from(context).inflate(R.layout.group_item_layout, parent, false));
- }
-
- @Override
- public void onBindViewHolder(@NonNull GroupViewHolder holder, int position) {
- Group group = groupList.get(position);
-
- holder.cardView.setCardBackgroundColor(group.getColor());
- holder.textView.setText(group.getName());
-
- final int[] color = {group.getColor()};
-
-// Clickers
- holder.cardView.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View view) {
- Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
- vibrator.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
- showPopupMenu(view, group);
- return false;
- }
- });
- holder.cardView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
-// BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(context, R.style.BottomSheetTheme);
-// bottomSheetDialog.setContentView(R.layout.add_group_layout);
-// bottomSheetDialog.setCancelable(true);
-// bottomSheetDialog.setDismissWithAnimation(true);
-//
-// ImageButton addColor = (ImageButton) bottomSheetDialog.findViewById(R.id.noteColor);
-// ImageButton btnDone = (ImageButton) bottomSheetDialog.findViewById(R.id.btnDone);
-// EditText tvTitle = (EditText) bottomSheetDialog.findViewById(R.id.Title);
-// CardView cardViewBtnDone = (CardView) bottomSheetDialog.findViewById(R.id.cardBtnDone);
-//
-// color[0] = group.getColor();
-//
-// Objects.requireNonNull(cardViewBtnDone).setCardBackgroundColor(color[0]);
-//
-// bottomSheetDialog.show();
-//
-// //Color
-// Objects.requireNonNull(addColor).setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View v) {
-// BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(context, R.style.BottomSheetTheme);
-// bottomSheetDialog1.setContentView(R.layout.color_picker);
-// bottomSheetDialog1.setCancelable(true);
-// bottomSheetDialog1.setDismissWithAnimation(true);
-//
-// GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-//
-// ArrayList colors = new ArrayList<>();
-// colors.add(new Colors(context.getResources().getColor(R.color.note_blue)));
-// colors.add(new Colors(context.getResources().getColor(R.color.note_green)));
-// colors.add(new Colors(context.getResources().getColor(R.color.note_orange)));
-// colors.add(new Colors(context.getResources().getColor(R.color.note_pink)));
-// colors.add(new Colors(context.getResources().getColor(R.color.note_purple)));
-// colors.add(new Colors(context.getResources().getColor(R.color.note_red)));
-// colors.add(new Colors(context.getResources().getColor(R.color.note_yellow)));
-//
-// ColorAdapter colorAdapter = new ColorAdapter(context, 0, colors);
-// Objects.requireNonNull(colorGridView).setAdapter(colorAdapter);
-//
-// bottomSheetDialog1.show();
-//
-// //Clicker
-// colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-// @Override
-// public void onItemClick(AdapterView> parent, View view, int position, long id) {
-// color[0] = colors.get(position).getColorRes();
-// bottomSheetDialog1.dismiss();
-//
-// cardViewBtnDone.setCardBackgroundColor(color[0]);
-// }
-// });
-// }
-// });
-//
-// Objects.requireNonNull(tvTitle).setText(group.getName());
-//
-// //Done
-// Objects.requireNonNull(btnDone).setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View v) {
-// String name = Objects.requireNonNull(tvTitle).getText().toString();
-//
-// ContentValues contentValues = new ContentValues();
-// contentValues.put(DatabaseConstants._GROUP_NAME, name);
-// contentValues.put(DatabaseConstants._NOTE_COLOR, color[0]);
-// contentValues.put(DatabaseConstants._ADD_NOTE_TIME, 0);
-// contentValues.put(DatabaseConstants._ADD_NOTE_TIME, System.currentTimeMillis());
-// //MainActivity.sqLiteDatabaseNotes.update(DatabaseConstants._GROUPS_TABLE_NAME, contentValues, DatabaseConstants._ADD_NOTE_TIME + " = ?", new String[]{Long.toString(note.getAddNoteTime())});
-// try {
-// NotepadActivity.reloadRecyclerView(context, activity);
-// } catch (Exception e){
-// e.printStackTrace();
-// }
-//
-// bottomSheetDialog.dismiss();
-// }
-// });
-//
-// bottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
-// @Override
-// public void onDismiss(DialogInterface dialog) {
-// activity.startActivity(new Intent(context, NotepadActivity.class));
-// activity.overridePendingTransition(0, 0);
-// activity.finish();
-// }
-// });
- switch (mode) {
- case 0:
- if (!addedGroups.contains(group)) {
- addedGroups.add(group);
- Toast.makeText(context, "Записка будет добавлена в группу: " + group.getName() + ". Сохраните изменения.", Toast.LENGTH_SHORT).show();
- }
- break;
- case 1:
- activity.startActivity(new Intent(context, NotepadActivity.class).putExtra("group", group.getName()));
- activity.overridePendingTransition(0, 0);
- break;
- }
- }
- });
- }
-
- @Override
- public int getItemCount() {
- return groupList.size();
- }
-
- private void showPopupMenu(View v, Group group) {
- PopupMenu popupMenu = new PopupMenu(context, v);
- popupMenu.inflate(R.menu.popup_menu_3);
-
- popupMenu
- .setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
- @SuppressLint("NonConstantResourceId")
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.delete:
- MainActivity.sqLiteDatabaseNotes.delete(DatabaseConstants._GROUPS_TABLE_NAME, DatabaseConstants._GROUP_NAME + " = ? ", new String[]{group.getName()});
- try {
- //NotepadActivity.reloadRecyclerViewGroups(context, activity);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return true;
- default:
- return false;
- }
- }
- });
-
- popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
- @Override
- public void onDismiss(PopupMenu menu) {
-
- }
- });
- popupMenu.show();
- }
-}
-
-class GroupViewHolder extends RecyclerView.ViewHolder {
- protected CardView cardView;
- protected TextView textView;
-
-
- public GroupViewHolder(@NonNull View itemView) {
- super(itemView);
-
- cardView = (CardView) itemView.findViewById(R.id.cardView1);
- textView = (TextView) itemView.findViewById(R.id.textViewNoteName);
- }
-}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/data/ConstantsManager.java b/app/src/main/java/ru/plumsoftware/notebook/data/ConstantsManager.java
deleted file mode 100644
index 4f6e0fe..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/data/ConstantsManager.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package ru.plumsoftware.notebook.data;
-
-import android.graphics.Color;
-
-import ru.plumsoftware.notebook.R;
-
-public class ConstantsManager {
- public static final int[] RES_COLORS = new int[]{
- R.color.note_blue,
- R.color.note_green,
- R.color.note_orange,
- R.color.note_pink,
- R.color.note_purple,
- R.color.note_yellow,
- R.color.note_red
- };
-
- public static final Color[] COLORS = new Color[]{
- Color.valueOf(0xFF3F73F6),
- Color.valueOf(0x46B351),
- Color.valueOf(0xE38242),
- Color.valueOf(0xDC43C7),
- Color.valueOf(0x8449E4),
- Color.valueOf(0xDCD343),
- Color.valueOf(0xEA4141)
- };
-}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/data/Data.java b/app/src/main/java/ru/plumsoftware/notebook/data/Data.java
deleted file mode 100644
index 2c15c04..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/data/Data.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package ru.plumsoftware.notebook.data;
-
-public abstract class Data {
-
- public static void addNote(){
-
- }
-}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/data/items/Group.java b/app/src/main/java/ru/plumsoftware/notebook/data/items/Group.java
deleted file mode 100644
index a89c216..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/data/items/Group.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package ru.plumsoftware.notebook.data.items;
-
-public class Group {
- private String name;
- private int id, color;
- private long addGroup, addNote;
-
- public Group(String name, int id, int color, long addGroup, long addNote) {
- this.name = name;
- this.id = id;
- this.color = color;
- this.addGroup = addGroup;
- this.addNote = addNote;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public int getColor() {
- return color;
- }
-
- public void setColor(int color) {
- this.color = color;
- }
-
- public long getAddGroup() {
- return addGroup;
- }
-
- public void setAddGroup(long addGroup) {
- this.addGroup = addGroup;
- }
-
- public long getAddNote() {
- return addNote;
- }
-
- public void setAddNote(long addNote) {
- this.addNote = addNote;
- }
-}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/databases/SQLiteDatabaseManager.java b/app/src/main/java/ru/plumsoftware/notebook/databases/SQLiteDatabaseManager.java
deleted file mode 100644
index e0fb9dc..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/databases/SQLiteDatabaseManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package ru.plumsoftware.notebook.databases;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class SQLiteDatabaseManager extends SQLiteOpenHelper {
- public static final int DATABASE_VERSION = 4;
- public static final String DATABASE_NAME = DatabaseConstants.DATABASE_NAME;
-
- public SQLiteDatabaseManager(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(DatabaseConstants.CREATE_NOTES_TABLE);
- db.execSQL(DatabaseConstants.CREATE_GROUPS_TABLE);
- }
-
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL(DatabaseConstants.DELETE_NOTES_TABLE);
- db.execSQL(DatabaseConstants.DELETE_GROUPS_TABLE);
- onCreate(db);
- }
-
- public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- onUpgrade(db, oldVersion, newVersion);
- }
-}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/fragments/NotepadFragment.java b/app/src/main/java/ru/plumsoftware/notebook/fragments/NotepadFragment.java
deleted file mode 100644
index fa0e10a..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/fragments/NotepadFragment.java
+++ /dev/null
@@ -1,514 +0,0 @@
-package ru.plumsoftware.notebook.fragments;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Color;
-import android.os.Bundle;
-
-import androidx.cardview.widget.CardView;
-import androidx.constraintlayout.widget.ConstraintLayout;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.EditText;
-import android.widget.GridView;
-import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.SearchView;
-
-import com.google.android.material.bottomsheet.BottomSheetDialog;
-import com.google.android.material.snackbar.Snackbar;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-
-import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.adapters.ColorAdapter;
-import ru.plumsoftware.notebook.adapters.NoteAdapter;
-import ru.plumsoftware.notebook.adapters.OpacityAdapter;
-import ru.plumsoftware.notebook.data.items.Colors;
-import ru.plumsoftware.notebook.data.items.Note;
-import ru.plumsoftware.notebook.data.items.Shape;
-import ru.plumsoftware.notebook.databases.DatabaseConstants;
-import ru.plumsoftware.notebook.databases.SQLiteDatabaseManager;
-
-public class NotepadFragment extends Fragment {
- private static final String ARG_PARAM1 = "param1";
- private static final String ARG_PARAM2 = "param2";
-
- private String mParam1;
- private String mParam2;
-
- public static SQLiteDatabase sqLiteDatabaseNotes;
- private static RecyclerView recyclerViewNotes;
- private static boolean isList = true;
- private int
- color,
- opacityRes = R.drawable.ic_coffee;
-
- public NotepadFragment() {
- }
-
- public static NotepadFragment newInstance(String param1, String param2) {
- NotepadFragment fragment = new NotepadFragment();
- Bundle args = new Bundle();
- args.putString(ARG_PARAM1, param1);
- args.putString(ARG_PARAM2, param2);
- fragment.setArguments(args);
- return fragment;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- mParam1 = getArguments().getString(ARG_PARAM1);
- mParam2 = getArguments().getString(ARG_PARAM2);
- }
- }
-
- @SuppressLint({"MissingInflatedId", "LocalSuppress"})
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_notepad, container, false);
-
-// FVI
- SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
- recyclerViewNotes = (RecyclerView) view.findViewById(R.id.recyclerViewNotes);
- ImageView filterAsList = (ImageView) view.findViewById(R.id.filterAsList);
- ImageButton addNote = (ImageButton) view.findViewById(R.id.addNote);
- ConstraintLayout layout = (ConstraintLayout) view.findViewById(R.id.layout);
-
-// Blur
-
-// Data
- SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(getContext());
- sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
- NoteAdapter noteAdapter = new NoteAdapter(getContext(), getActivity(), loadNotes(getContext()), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(getContext()));
- recyclerViewNotes.setAdapter(noteAdapter);
- filterAsList.setImageResource(R.drawable.ic_baseline_filter_list);
-
- color = getResources().getColor(R.color.note_blue);
-
-// Clickers
- filterAsList.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (isList) {
- isList = false;
-
- recyclerViewNotes.setVisibility(View.GONE);
- NoteAdapter noteAdapter = new NoteAdapter(getContext(), getActivity(), loadNotes(getContext()), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
-
- filterAsList.setImageResource(R.drawable.ic_table_rows);
- } else {
- isList = true;
-
- recyclerViewNotes.setVisibility(View.GONE);
- NoteAdapter noteAdapter = new NoteAdapter(getContext(), getActivity(), loadNotes(getContext()), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(getContext()));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
-
- filterAsList.setImageResource(R.drawable.ic_baseline_filter_list);
- }
- }
- });
-
- addNote.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(requireContext(), R.style.BottomSheetTheme);
- bottomSheetDialog.setContentView(R.layout.add_note_layout);
- bottomSheetDialog.setCancelable(true);
- bottomSheetDialog.setDismissWithAnimation(true);
-
- ImageButton addOpacity = (ImageButton) bottomSheetDialog.findViewById(R.id.noteOpacity);
- ImageButton addColor = (ImageButton) bottomSheetDialog.findViewById(R.id.noteColor);
- ImageButton btnDone = (ImageButton) bottomSheetDialog.findViewById(R.id.btnDone1);
- EditText tvTitle = (EditText) bottomSheetDialog.findViewById(R.id.Title);
- EditText tvText = (EditText) bottomSheetDialog.findViewById(R.id.Text);
- CardView cardViewBtnDone = (CardView) bottomSheetDialog.findViewById(R.id.cardBtnDone1);
-
- Objects.requireNonNull(cardViewBtnDone).setCardBackgroundColor(color);
-
- bottomSheetDialog.show();
-
- //Clickers
-
- //Color
- Objects.requireNonNull(addColor).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(requireContext(), R.style.BottomSheetTheme);
- bottomSheetDialog1.setContentView(R.layout.color_picker);
- bottomSheetDialog1.setCancelable(true);
- bottomSheetDialog1.setDismissWithAnimation(true);
-
- GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-
- ArrayList colors = new ArrayList<>();
- colors.add(new Colors(getResources().getColor(R.color.note_blue)));
- colors.add(new Colors(getResources().getColor(R.color.note_green)));
- colors.add(new Colors(getResources().getColor(R.color.note_orange)));
- colors.add(new Colors(getResources().getColor(R.color.note_pink)));
- colors.add(new Colors(getResources().getColor(R.color.note_purple)));
- colors.add(new Colors(getResources().getColor(R.color.note_red)));
- colors.add(new Colors(getResources().getColor(R.color.note_yellow)));
-
- ColorAdapter colorAdapter = new ColorAdapter(getContext(), 0, colors);
- Objects.requireNonNull(colorGridView).setAdapter(colorAdapter);
-
- bottomSheetDialog1.show();
-
- //Clicker
- colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- color = colors.get(position).getColorRes();
- bottomSheetDialog1.dismiss();
-
- cardViewBtnDone.setCardBackgroundColor(color);
- }
- });
- }
- });
-
- //Opacity
- Objects.requireNonNull(addOpacity).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(requireContext(), R.style.BottomSheetTheme);
- bottomSheetDialog1.setContentView(R.layout.color_picker);
- bottomSheetDialog1.setCancelable(true);
- bottomSheetDialog1.setDismissWithAnimation(true);
-
- GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
-
- ArrayList shapes = new ArrayList<>();
- shapes.add(new Shape(R.drawable.ic_coffee));
- shapes.add(new Shape(R.drawable.ic_child_care));
- shapes.add(new Shape(R.drawable.ic_fitness_center));
- shapes.add(new Shape(R.drawable.ic_headphones));
- shapes.add(new Shape(R.drawable.ic_hotel));
- shapes.add(new Shape(R.drawable.ic_local_shipping));
- shapes.add(new Shape(R.drawable.ic_perm_phone_msg));
- shapes.add(new Shape(R.drawable.ic_phishing));
- shapes.add(new Shape(R.drawable.ic_work));
- shapes.add(new Shape(R.drawable.ic_work_outline));
- shapes.add(new Shape(R.drawable.ic_receipt_long));
- shapes.add(new Shape(R.drawable.ic_rocket_launch));
- shapes.add(new Shape(R.drawable.ic_school));
- shapes.add(new Shape(R.drawable.ic_shopping_basket));
- shapes.add(new Shape(R.drawable.ic_spa));
- shapes.add(new Shape(R.drawable.ic_square_foot));
- shapes.add(new Shape(R.drawable.ic_grade));
-
- OpacityAdapter shapeAdapter = new OpacityAdapter(getContext(), 0, shapes);
- Objects.requireNonNull(colorGridView).setAdapter(shapeAdapter);
-
- bottomSheetDialog1.show();
-
- //Clicker
- colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- opacityRes = shapes.get(position).getShapeRes();
- bottomSheetDialog1.dismiss();
- }
- });
- }
- });
-
- //Done
- Objects.requireNonNull(btnDone).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String note = Objects.requireNonNull(tvTitle).getText().toString();
- String text = Objects.requireNonNull(tvText).getText().toString();
-
-// SAVE
- saveNote(note, text, opacityRes, color, view);
- bottomSheetDialog.dismiss();
- }
- });
-
- bottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
-// UPDATE
- reloadRecyclerView(getContext(), getActivity());
- }
- });
- }
- });
-
- searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
- @Override
- public boolean onQueryTextSubmit(String s) {
- return false;
- }
-
- @Override
- public boolean onQueryTextChange(String s) {
- NoteAdapter noteAdapter = new NoteAdapter(getContext(), getActivity(), loadNotesWithCondition(s), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(getContext()));
- recyclerViewNotes.setAdapter(noteAdapter);
- return false;
- }
- });
- return view;
- }
-
- public static List loadNotes(Context context) {
- List notes = new ArrayList<>();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"1"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- null // The sort order
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor.close();
-
-// Simple notes
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"0"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- null // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor1.close();
-
- return notes;
- }
-
- public static List loadNotesWithCondition(String condition) {
- List notes = new ArrayList<>();
-
-// Pinned notes
- @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"1"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- null // The sort order
- );
-
- while (cursor.moveToNext()) {
-// Read data
- int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- cursor.close();
-
-// Simple notes
- @SuppressLint("Recycle") Cursor cursor1 = sqLiteDatabaseNotes.query(
- DatabaseConstants._NOTES_TABLE_NAME, // The table to query
- null, // The array of columns to return (pass null to get all)
- DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
- new String[]{"0"}, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- null // The sort order
- );
-
- while (cursor1.moveToNext()) {
-// Read data
- int id = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
-// int count = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._COUNT));
- int notePromoResId = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
- int isPinned = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
- int isLiked = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
- int colorRes = cursor1.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
- String noteName = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
- String noteText = cursor1.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
- long addTime = cursor1.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
-
- if (noteName.contains(condition) || noteText.contains(condition) || new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(addTime)).contains(condition)) {
- Note note = new Note(
- id,
- 0,
- notePromoResId,
- isPinned,
- isLiked,
- colorRes,
- noteName,
- noteText,
- addTime,
- 0
- );
- notes.add(note);
- }
- }
- cursor1.close();
-
- return notes;
- }
-
- public void saveNote(String name, String text, int or, int c, View view) {
- if (name == null || name.isEmpty())
- name = "";
- if (text == null || text.isEmpty())
- text = "";
-
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._NOTE_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_TEXT, text);
- contentValues.put(DatabaseConstants._NOTE_PROMO, or);
- contentValues.put(DatabaseConstants._NOTE_COLOR, c);
- contentValues.put(DatabaseConstants._IS_LIKED, 0);
- contentValues.put(DatabaseConstants._IS_PINNED, 0);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, System.currentTimeMillis());
- sqLiteDatabaseNotes.insert(DatabaseConstants._NOTES_TABLE_NAME, null, contentValues);
-
- Snackbar
- .make(requireContext(), (ConstraintLayout) view.findViewById(R.id.layout), "Данные сохранены✅", Snackbar.LENGTH_SHORT)
- .setTextColor(Color.parseColor("#000000"))
- .setBackgroundTint(Color.WHITE)
- .show();
-
- reloadRecyclerView(getContext(), getActivity());
- }
-
- public static void saveNote(String name, String text, int or, int c, int isLiked) {
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._NOTE_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_TEXT, text);
- contentValues.put(DatabaseConstants._NOTE_PROMO, or);
- contentValues.put(DatabaseConstants._NOTE_COLOR, c);
- contentValues.put(DatabaseConstants._IS_LIKED, isLiked);
- contentValues.put(DatabaseConstants._IS_PINNED, 0);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, System.currentTimeMillis());
- sqLiteDatabaseNotes.insert(DatabaseConstants._NOTES_TABLE_NAME, null, contentValues);
- }
-
- public static void saveNote(String name, String text, int or, int c, int isLiked, int isPinned) {
- ContentValues contentValues = new ContentValues();
- contentValues.put(DatabaseConstants._NOTE_NAME, name);
- contentValues.put(DatabaseConstants._NOTE_TEXT, text);
- contentValues.put(DatabaseConstants._NOTE_PROMO, or);
- contentValues.put(DatabaseConstants._NOTE_COLOR, c);
- contentValues.put(DatabaseConstants._IS_LIKED, isLiked);
- contentValues.put(DatabaseConstants._IS_PINNED, isPinned);
- contentValues.put(DatabaseConstants._ADD_NOTE_TIME, System.currentTimeMillis());
- sqLiteDatabaseNotes.insert(DatabaseConstants._NOTES_TABLE_NAME, null, contentValues);
- }
-
- public static void reloadRecyclerView(Context context, Activity activity) {
- recyclerViewNotes.setVisibility(View.GONE);
- NoteAdapter noteAdapter = new NoteAdapter(context, activity, loadNotes(context), 1);
- recyclerViewNotes.setHasFixedSize(true);
- recyclerViewNotes.setLayoutManager(new LinearLayoutManager(context));
- recyclerViewNotes.setAdapter(noteAdapter);
- recyclerViewNotes.setVisibility(View.VISIBLE);
- isList = true;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/fragments/SearchFragment.java b/app/src/main/java/ru/plumsoftware/notebook/fragments/SearchFragment.java
deleted file mode 100644
index 1075ff8..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/fragments/SearchFragment.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package ru.plumsoftware.notebook.fragments;
-
-import android.os.Bundle;
-
-import androidx.fragment.app.Fragment;
-
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import ru.plumsoftware.notebook.R;
-
-public class SearchFragment extends Fragment {
-
- private static final String ARG_PARAM1 = "param1";
- private static final String ARG_PARAM2 = "param2";
-
- private String mParam1;
- private String mParam2;
-
- public SearchFragment() {
- // Required empty public constructor
- }
-
- public static SearchFragment newInstance(String param1, String param2) {
- SearchFragment fragment = new SearchFragment();
- Bundle args = new Bundle();
- args.putString(ARG_PARAM1, param1);
- args.putString(ARG_PARAM2, param2);
- fragment.setArguments(args);
- return fragment;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- mParam1 = getArguments().getString(ARG_PARAM1);
- mParam2 = getArguments().getString(ARG_PARAM2);
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_search, container, false);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/manager/ads/AdsIds.java b/app/src/main/java/ru/plumsoftware/notebook/manager/ads/AdsIds.java
new file mode 100644
index 0000000..7afc6c4
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/manager/ads/AdsIds.java
@@ -0,0 +1,6 @@
+package ru.plumsoftware.notebook.manager.ads;
+
+public class AdsIds {
+ public static final String OPEN_AD_UNIT_ID = "R-M-1957919-3";
+ public static final String INTERSTITIAL_AD_UNIT_ID = "R-M-1957919-2";
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/manager/extra/ExtraNames.java b/app/src/main/java/ru/plumsoftware/notebook/manager/extra/ExtraNames.java
new file mode 100644
index 0000000..af9c10e
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/manager/extra/ExtraNames.java
@@ -0,0 +1,21 @@
+package ru.plumsoftware.notebook.manager.extra;
+
+import kotlin.Pair;
+
+public class ExtraNames {
+ public static class LocalNotificationExtra {
+ public static String message = "message";
+ public static String notificationChannelId = "notificationChannelId";
+ public static Pair colorPair = new Pair<>("color", 0);
+ }
+
+ public static class MainActivity {
+ public static String isLoadAppOpenAd = "isLoadAppOpenAd";
+ public static String LoadInterstitialAd = "LoadInterstitialAd";
+ }
+
+ public static class AddNoteActivity {
+ public static String note = "note";
+ public static String update = "update";
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/manager/notification/LocalNotificationConstants.java b/app/src/main/java/ru/plumsoftware/notebook/manager/notification/LocalNotificationConstants.java
new file mode 100644
index 0000000..e71ec8f
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/manager/notification/LocalNotificationConstants.java
@@ -0,0 +1,6 @@
+package ru.plumsoftware.notebook.manager.notification;
+
+public class LocalNotificationConstants {
+ public static String CHANNEL_ID = "ru.plumsoftware.notebook.notif_channel";
+ public static final String GROUP_KEY = "ru.plumsoftware.notebook.group_key";
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/manager/notification/NotificationManager.java b/app/src/main/java/ru/plumsoftware/notebook/manager/notification/NotificationManager.java
new file mode 100644
index 0000000..cb22c58
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/manager/notification/NotificationManager.java
@@ -0,0 +1,59 @@
+package ru.plumsoftware.notebook.manager.notification;
+
+import android.annotation.SuppressLint;
+import android.app.NotificationChannel;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+
+import androidx.core.app.NotificationCompat;
+import androidx.core.app.NotificationManagerCompat;
+
+import java.util.Calendar;
+
+import ru.plumsoftware.notebook.R;
+import ru.plumsoftware.notebook.presentation.activities.main.view.MainActivity;
+
+public class NotificationManager {
+
+ @SuppressLint("MissingPermission")
+ public static void createNotification(Context context, String title, String message, int color, String notificationChannelId) {
+ LocalNotificationConstants.CHANNEL_ID = notificationChannelId;
+
+ Intent intent = new Intent(context, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
+
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ CharSequence name = "plumsoftware.notebook.notif_name_" + LocalNotificationConstants.CHANNEL_ID;
+ String description = "plumsoftware.notebook.notif_channel_description";
+ int importance = android.app.NotificationManager.IMPORTANCE_HIGH;
+ NotificationChannel channel = new NotificationChannel(LocalNotificationConstants.CHANNEL_ID, name, importance);
+ channel.setDescription(description);
+ channel.enableLights(true);
+ channel.setLightColor(color);
+ android.app.NotificationManager notificationManager = context.getSystemService(android.app.NotificationManager.class);
+ notificationManager.createNotificationChannel(channel);
+ }
+
+ NotificationCompat.Builder builder = buildStandardNotification(context, title, message, pendingIntent, color);
+ NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
+ notificationManager.notify(Calendar.getInstance().get(Calendar.MILLISECOND), builder.build());
+ }
+
+ private static NotificationCompat.Builder buildStandardNotification(Context context, String title, String message, PendingIntent pendingIntent, int color) {
+ return new NotificationCompat.Builder(context, LocalNotificationConstants.CHANNEL_ID)
+ .setSmallIcon(R.mipmap.ic_launcher)
+ .setContentTitle(title)
+ .setContentText(message)
+ .setContentIntent(pendingIntent)
+ .setPriority(NotificationCompat.PRIORITY_HIGH)
+ .setAutoCancel(true)
+ .setColorized(true)
+ .setColor(color)
+ .setStyle(new NotificationCompat.BigTextStyle())
+ .setGroup(LocalNotificationConstants.GROUP_KEY);
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/manager/unique/UniqueIdGenerator.java b/app/src/main/java/ru/plumsoftware/notebook/manager/unique/UniqueIdGenerator.java
new file mode 100644
index 0000000..c1b4f62
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/manager/unique/UniqueIdGenerator.java
@@ -0,0 +1,65 @@
+package ru.plumsoftware.notebook.manager.unique;
+
+import androidx.annotation.NonNull;
+
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+
+public class UniqueIdGenerator {
+
+ private static final String UPPER_CASE_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ private static final String LOWER_CASE_ALPHABET = UPPER_CASE_ALPHABET.toLowerCase();
+ private static final String DIGITS = "0123456789";
+ private static final int ID_LENGTH = 16;
+
+
+ public static String generateUniqueId() {
+ StringBuilder sb = new StringBuilder();
+ Random random = new Random();
+
+ for (int i = 0; i < 4; i++) {
+ sb.append(getRandomCharacter(UPPER_CASE_ALPHABET, random));
+ sb.append(getRandomCharacter(LOWER_CASE_ALPHABET, random));
+ sb.append(getRandomCharacter(DIGITS, random));
+ sb.append(getRandomCharacter(UPPER_CASE_ALPHABET + LOWER_CASE_ALPHABET + DIGITS, random));
+
+ if (i != 3) {
+ sb.append("-");
+ }
+ }
+
+ return sb.toString();
+ }
+
+ @NonNull
+ public static String generateUniqueId_2() {
+ Set generatedIds = new HashSet<>();
+ Random random = new Random();
+ StringBuilder idBuilder = new StringBuilder(ID_LENGTH);
+
+ while (true) {
+ idBuilder.setLength(0);
+
+ for (int i = 0; i < ID_LENGTH; i++) {
+ char randomChar;
+ if (random.nextBoolean()) {
+ randomChar = (char) (random.nextInt(26) + 'A');
+ } else {
+ randomChar = (char) (random.nextInt(26) + 'a');
+ }
+ idBuilder.append(randomChar);
+ }
+
+ String newId = idBuilder.toString();
+
+ generatedIds.add(newId);
+ return newId;
+ }
+ }
+
+ private static char getRandomCharacter(@NonNull String characters, @NonNull Random random) {
+ int index = random.nextInt(characters.length());
+ return characters.charAt(index);
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/Conditions.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/Conditions.java
new file mode 100644
index 0000000..6f12354
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/Conditions.java
@@ -0,0 +1,15 @@
+package ru.plumsoftware.notebook.presentation.activities.main.presenter;
+
+public abstract class Conditions {
+ public static class All extends Conditions {}
+ public static class Search extends Conditions {
+ private final String query;
+ public Search(String str){
+ this.query = str;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/MainPresenter.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/MainPresenter.java
new file mode 100644
index 0000000..8c7be4d
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/MainPresenter.java
@@ -0,0 +1,10 @@
+package ru.plumsoftware.notebook.presentation.activities.main.presenter;
+
+public interface MainPresenter {
+ void initMobileSdk();
+ void initNotes(Conditions conditions);
+ void initOpenAds();
+
+ void changeListStyle();
+ void openAddNoteActivity();
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/MainPresenterImpl.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/MainPresenterImpl.java
new file mode 100644
index 0000000..8a52e3f
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/presenter/MainPresenterImpl.java
@@ -0,0 +1,288 @@
+package ru.plumsoftware.notebook.presentation.activities.main.presenter;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.StaggeredGridLayoutManager;
+
+import com.yandex.mobile.ads.appopenad.AppOpenAd;
+import com.yandex.mobile.ads.appopenad.AppOpenAdEventListener;
+import com.yandex.mobile.ads.appopenad.AppOpenAdLoadListener;
+import com.yandex.mobile.ads.appopenad.AppOpenAdLoader;
+import com.yandex.mobile.ads.common.AdError;
+import com.yandex.mobile.ads.common.AdRequestConfiguration;
+import com.yandex.mobile.ads.common.AdRequestError;
+import com.yandex.mobile.ads.common.ImpressionData;
+import com.yandex.mobile.ads.common.MobileAds;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import ru.plumsoftware.data.database.SQLiteDatabaseManager;
+import ru.plumsoftware.data.model.database.DatabaseConstants;
+import ru.plumsoftware.data.model.ui.Note;
+import ru.plumsoftware.notebook.R;
+import ru.plumsoftware.notebook.manager.ads.AdsIds;
+import ru.plumsoftware.notebook.manager.extra.ExtraNames;
+import ru.plumsoftware.notebook.presentation.activities.note.view.AddNoteActivity;
+import ru.plumsoftware.notebook.presentation.activities.main.view.MainView;
+import ru.plumsoftware.notebook.presentation.dialogs.ProgressDialog;
+
+public class MainPresenterImpl implements MainPresenter {
+
+ private final MainView mainView;
+
+ private final Context context;
+ private final Activity activity;
+ private SQLiteDatabase sqLiteDatabaseNotes;
+
+ private AppOpenAd mainAppOpenAd = null;
+
+ private boolean isList = true;
+ private List notes;
+ private final List filteredNotes;
+
+ public MainPresenterImpl(Context context, @NonNull Activity activity, MainView mainView) {
+ this.context = context;
+ this.activity = activity;
+ this.mainView = mainView;
+ filteredNotes = new ArrayList<>();
+ notes = new ArrayList<>();
+ }
+
+ @Override
+ public void changeListStyle() {
+ if (isList) {
+ mainView.initRecyclerView(notes, new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
+ mainView.changeFilterButtonImage(R.drawable.ic_table_rows);
+ } else {
+ mainView.initRecyclerView(notes, new LinearLayoutManager(context));
+ mainView.changeFilterButtonImage(R.drawable.ic_baseline_filter_list);
+ }
+ isList = !isList;
+ }
+
+ @Override
+ public void openAddNoteActivity() {
+ Intent intent = new Intent(activity, AddNoteActivity.class);
+ intent.putExtra(ExtraNames.MainActivity.isLoadAppOpenAd, false);
+ intent.putExtra(ExtraNames.MainActivity.LoadInterstitialAd, activity.getIntent().getBooleanExtra(ExtraNames.MainActivity.LoadInterstitialAd, true));
+ activity.startActivity(intent);
+ }
+
+ @Override
+ public void initMobileSdk() {
+ MobileAds.initialize(context, () -> {
+ });
+ }
+
+
+ @Override
+ public void initNotes(Conditions conditions) {
+ mainView.showProgressDialog();
+ if (conditions instanceof Conditions.Search) {
+ filteredNotes.clear();
+ String query = ((Conditions.Search) conditions).getQuery();
+
+ for (Note note : notes) {
+ if (note.getNoteName().contains(query) ||
+ note.getNoteText().contains(query) ||
+ new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(note.getAddNoteTime())).contains(query)
+ ) {
+ filteredNotes.add(note);
+ }
+ }
+ RecyclerView.LayoutManager layoutManager;
+ if (isList) {
+ layoutManager = new LinearLayoutManager(context);
+ } else {
+ layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
+ }
+
+ mainView.initRecyclerView(filteredNotes, layoutManager);
+ } else if (conditions instanceof Conditions.All) {
+ notes.clear();
+ SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(context);
+ sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
+ notes = loadNotes();
+
+ isList = true;
+ mainView.changeFilterButtonImage(R.drawable.ic_baseline_filter_list);
+ mainView.initRecyclerView(notes, new LinearLayoutManager(context));
+ }
+ mainView.dismissProgressDialog();
+ }
+
+ @Override
+ public void initOpenAds() {
+ mainView.showProgressDialog();
+ final AppOpenAdLoader appOpenAdLoader = new AppOpenAdLoader(context);
+ final AdRequestConfiguration adRequestConfiguration = new AdRequestConfiguration.Builder(AdsIds.OPEN_AD_UNIT_ID).build();
+
+ AppOpenAdEventListener appOpenAdEventListener = new AppOpenAdEventListener() {
+ @Override
+ public void onAdShown() {
+ mainView.dismissProgressDialog();
+ }
+
+ @Override
+ public void onAdFailedToShow(@NonNull final AdError adError) {
+ mainView.dismissProgressDialog();
+ }
+
+ @Override
+ public void onAdDismissed() {
+ clearAppOpenAd();
+ }
+
+ @Override
+ public void onAdClicked() {
+ // Called when a click is recorded for an ad.
+ }
+
+ @Override
+ public void onAdImpression(@Nullable final ImpressionData impressionData) {
+ // Called when an impression is recorded for an ad.
+ }
+ };
+ AppOpenAdLoadListener appOpenAdLoadListener = new AppOpenAdLoadListener() {
+ @Override
+ public void onAdLoaded(@NonNull final AppOpenAd appOpenAd) {
+ mainAppOpenAd = appOpenAd;
+ appOpenAd.setAdEventListener(appOpenAdEventListener);
+ mainView.dismissProgressDialog();
+ mainAppOpenAd.show(activity);
+ }
+
+ @Override
+ public void onAdFailedToLoad(@NonNull final AdRequestError adRequestError) {
+ mainView.dismissProgressDialog();
+ }
+ };
+
+ appOpenAdLoader.setAdLoadListener(appOpenAdLoadListener);
+ appOpenAdLoader.loadAd(adRequestConfiguration);
+ mainView.dismissProgressDialog();
+ }
+
+ @NonNull
+ private List loadNotes() {
+ List notes = new ArrayList<>();
+ List pinnedNotes = loadPinnedNotes();
+ List simpleNotes = loadSimpleNotes();
+ notes.addAll(pinnedNotes);
+ notes.addAll(simpleNotes);
+ return notes;
+ }
+
+ @NonNull
+ private List loadPinnedNotes() {
+ List notes = new ArrayList<>();
+
+ @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
+ DatabaseConstants._NOTES_TABLE_NAME, // The table to query
+ null, // The array of columns to return (pass null to get all)
+ DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
+ new String[]{"1"}, // The values for the WHERE clause
+ null, // don't group the rows
+ null, // don't filter by row groups
+ //"DATE_FORMAT("+new SimpleDateFormat("")+", '%m%d')" // The sort order
+ DatabaseConstants._ADD_NOTE_TIME + " DESC"
+ );
+ while (cursor.moveToNext()) {
+ int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
+ int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
+ int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
+ int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
+ int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
+ String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
+ String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
+ long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
+ String notificationChannelId = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._CHANNEL_ID));
+ int isNotify = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_NOTIFY));
+
+ Note note = new Note(
+ id,
+ 0,
+ notePromoResId,
+ isPinned,
+ isLiked,
+ colorRes,
+ noteName,
+ noteText,
+ addTime,
+ 0,
+ notificationChannelId,
+ isNotify
+
+ );
+ notes.add(note);
+ }
+ cursor.close();
+ return notes;
+ }
+
+ @NonNull
+ private List loadSimpleNotes() {
+ List notes = new ArrayList<>();
+
+ @SuppressLint("Recycle") Cursor cursor = sqLiteDatabaseNotes.query(
+ DatabaseConstants._NOTES_TABLE_NAME, // The table to query
+ null, // The array of columns to return (pass null to get all)
+ DatabaseConstants._IS_PINNED + " = ?", // The columns for the WHERE clause
+ new String[]{"0"}, // The values for the WHERE clause
+ null, // don't group the rows
+ null, // don't filter by row groups
+ DatabaseConstants._ADD_NOTE_TIME + " DESC" // The sort order
+ );
+
+ while (cursor.moveToNext()) {
+ int id = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._ID));
+ int notePromoResId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_PROMO));
+ int isPinned = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_PINNED));
+ int isLiked = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_LIKED));
+ int colorRes = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_COLOR));
+ String noteName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_NAME));
+ String noteText = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._NOTE_TEXT));
+ long addTime = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseConstants._ADD_NOTE_TIME));
+ String notificationChannelId = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseConstants._CHANNEL_ID));
+ int isNotify = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseConstants._IS_NOTIFY));
+
+ Note note = new Note(
+ id,
+ 0,
+ notePromoResId,
+ isPinned,
+ isLiked,
+ colorRes,
+ noteName,
+ noteText,
+ addTime,
+ 0,
+ notificationChannelId,
+ isNotify
+ );
+ notes.add(note);
+ }
+ cursor.close();
+ return notes;
+ }
+
+ private void clearAppOpenAd() {
+ if (mainAppOpenAd != null) {
+ mainAppOpenAd.setAdEventListener(null);
+ mainAppOpenAd = null;
+ }
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/view/MainActivity.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/view/MainActivity.java
new file mode 100644
index 0000000..60728b1
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/view/MainActivity.java
@@ -0,0 +1,115 @@
+package ru.plumsoftware.notebook.presentation.activities.main.view;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.RecyclerView;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.SearchView;
+
+import java.util.List;
+
+import ru.plumsoftware.data.model.ui.Note;
+import ru.plumsoftware.notebook.R;
+import ru.plumsoftware.notebook.presentation.activities.main.presenter.Conditions;
+import ru.plumsoftware.notebook.presentation.activities.main.presenter.MainPresenterImpl;
+import ru.plumsoftware.notebook.presentation.adapters.NoteAdapter;
+import ru.plumsoftware.notebook.presentation.activities.main.presenter.MainPresenter;
+import ru.plumsoftware.notebook.presentation.dialogs.ProgressDialog;
+
+public class MainActivity extends AppCompatActivity implements MainView {
+
+ private MainPresenter presenter;
+
+ private Context context;
+ private Activity activity;
+
+ private ImageView filterAsList;
+ private RecyclerView recyclerViewNotes;
+
+ private ProgressDialog progressDialog;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+// Base variables
+ context = MainActivity.this;
+ activity = MainActivity.this;
+
+ presenter = new MainPresenterImpl(context, activity, this);
+
+// Find views by id
+ SearchView searchView = findViewById(R.id.searchView);
+ filterAsList = findViewById(R.id.filterAsList);
+ recyclerViewNotes = activity.findViewById(R.id.recyclerViewNotes);
+ ImageButton addNote = findViewById(R.id.addNote);
+ progressDialog = new ProgressDialog(context, R.style.CustomProgressDialog);
+
+// load ad
+ presenter.initOpenAds();
+
+// Clickers
+ filterAsList.setOnClickListener(view -> presenter.changeListStyle());
+ addNote.setOnClickListener(view -> presenter.openAddNoteActivity());
+ searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
+ @Override
+ public boolean onQueryTextSubmit(String s) {
+ return false;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String s) {
+ if (!s.isEmpty())
+ presenter.initNotes(new Conditions.Search(s));
+ else
+ presenter.initNotes(new Conditions.All());
+ return false;
+ }
+ });
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ @Override
+ public void changeFilterButtonImage(int res) {
+ filterAsList.setImageResource(res);
+ }
+
+ @Override
+ public void initRecyclerView(List notes, RecyclerView.LayoutManager layoutManager) {
+ NoteAdapter noteAdapter = new NoteAdapter(context, activity, notes, 1);
+
+ recyclerViewNotes.setVisibility(View.GONE);
+ recyclerViewNotes.setHasFixedSize(true);
+ recyclerViewNotes.setLayoutManager(layoutManager);
+ recyclerViewNotes.setAdapter(noteAdapter);
+ recyclerViewNotes.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void showProgressDialog() {
+ progressDialog.showDialog();
+ }
+
+ @Override
+ public void dismissProgressDialog() {
+ progressDialog.dismiss();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ presenter.initNotes(new Conditions.All());
+ presenter.initMobileSdk();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/view/MainView.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/view/MainView.java
new file mode 100644
index 0000000..a04e42e
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/main/view/MainView.java
@@ -0,0 +1,16 @@
+package ru.plumsoftware.notebook.presentation.activities.main.view;
+
+import androidx.annotation.DrawableRes;
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.List;
+
+import ru.plumsoftware.data.model.ui.Note;
+
+public interface MainView {
+ void changeFilterButtonImage(@DrawableRes int res);
+ void initRecyclerView(List notes, RecyclerView.LayoutManager layoutManager);
+
+ void showProgressDialog();
+ void dismissProgressDialog();
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/model/AddNoteModel.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/model/AddNoteModel.java
new file mode 100644
index 0000000..e762a62
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/model/AddNoteModel.java
@@ -0,0 +1,68 @@
+package ru.plumsoftware.notebook.presentation.activities.note.model;
+
+import android.app.Activity;
+import android.content.Context;
+
+import androidx.annotation.Nullable;
+
+import com.yandex.mobile.ads.interstitial.InterstitialAd;
+import com.yandex.mobile.ads.interstitial.InterstitialAdLoader;
+
+import ru.plumsoftware.data.model.ui.Note;
+
+public class AddNoteModel {
+ private Mode mode;
+ private final Activity activity;
+ private final Context context;
+ private Note note;
+
+ private InterstitialAd mInterstitialAd;
+ private InterstitialAdLoader mInterstitialAdLoader;
+
+ public AddNoteModel(Activity activity, Context context) {
+ this.activity = activity;
+ this.context = context;
+
+ mode = Mode.New;
+ }
+
+ public InterstitialAd getmInterstitialAd() {
+ return mInterstitialAd;
+ }
+
+ public InterstitialAdLoader getmInterstitialAdLoader() {
+ return mInterstitialAdLoader;
+ }
+
+ public void setmInterstitialAd(InterstitialAd mInterstitialAd) {
+ this.mInterstitialAd = mInterstitialAd;
+ }
+
+ public void setmInterstitialAdLoader(InterstitialAdLoader mInterstitialAdLoader) {
+ this.mInterstitialAdLoader = mInterstitialAdLoader;
+ }
+
+ public void setMode(Mode mode) {
+ this.mode = mode;
+ }
+
+ public Mode getMode() {
+ return mode;
+ }
+
+ public Activity getActivity() {
+ return activity;
+ }
+
+ public Context getContext() {
+ return context;
+ }
+
+ public void setNote(Note note) {
+ this.note = note;
+ }
+
+ public Note getNote() {
+ return note;
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/model/Mode.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/model/Mode.java
new file mode 100644
index 0000000..3f2fa08
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/model/Mode.java
@@ -0,0 +1,6 @@
+package ru.plumsoftware.notebook.presentation.activities.note.model;
+
+public enum Mode {
+ New,
+ Edit
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/presenter/AddNotePresenter.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/presenter/AddNotePresenter.java
new file mode 100644
index 0000000..359614a
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/presenter/AddNotePresenter.java
@@ -0,0 +1,9 @@
+package ru.plumsoftware.notebook.presentation.activities.note.presenter;
+
+public interface AddNotePresenter {
+ void initNote();
+ void initMobileSdk();
+ void putNote(String name, String text, int or, int c, long time, boolean isNotify);
+ void initInterstitialAds();
+ void showInterstitialAd();
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/presenter/AddNotePresenterImpl.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/presenter/AddNotePresenterImpl.java
new file mode 100644
index 0000000..8da1ed4
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/presenter/AddNotePresenterImpl.java
@@ -0,0 +1,210 @@
+package ru.plumsoftware.notebook.presentation.activities.note.presenter;
+
+import android.app.Activity;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.yandex.mobile.ads.common.AdError;
+import com.yandex.mobile.ads.common.AdRequestConfiguration;
+import com.yandex.mobile.ads.common.AdRequestError;
+import com.yandex.mobile.ads.common.ImpressionData;
+import com.yandex.mobile.ads.common.MobileAds;
+import com.yandex.mobile.ads.interstitial.InterstitialAd;
+import com.yandex.mobile.ads.interstitial.InterstitialAdEventListener;
+import com.yandex.mobile.ads.interstitial.InterstitialAdLoadListener;
+import com.yandex.mobile.ads.interstitial.InterstitialAdLoader;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import ru.plumsoftware.data.database.SQLiteDatabaseManager;
+import ru.plumsoftware.data.model.database.DatabaseConstants;
+import ru.plumsoftware.data.model.ui.Note;
+import ru.plumsoftware.notebook.manager.ads.AdsIds;
+import ru.plumsoftware.notebook.manager.extra.ExtraNames;
+import ru.plumsoftware.notebook.manager.unique.UniqueIdGenerator;
+import ru.plumsoftware.notebook.presentation.activities.note.model.AddNoteModel;
+import ru.plumsoftware.notebook.presentation.activities.note.model.Mode;
+import ru.plumsoftware.notebook.presentation.activities.note.view.AddNoteView;
+
+public class AddNotePresenterImpl implements AddNotePresenter {
+
+ private final AddNoteView view;
+ private final AddNoteModel addNoteModel;
+ private SQLiteDatabase sqLiteDatabaseNotes;
+
+ public AddNotePresenterImpl(AddNoteView view, Context context, Activity activity) {
+ this.view = view;
+
+ addNoteModel = new AddNoteModel(
+ activity,
+ context
+ );
+ }
+
+ @Override
+ public void initNote() {
+
+ SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(addNoteModel.getContext());
+ sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
+
+ addNoteModel.setNote(addNoteModel.getActivity().getIntent().getParcelableExtra(ExtraNames.AddNoteActivity.note));
+ if (addNoteModel.getNote() != null) {
+ view.initNote(addNoteModel.getNote());
+ }
+
+ String title;
+ String textOnButton;
+ String time;
+
+ if (addNoteModel.getActivity().getIntent().getBooleanExtra(ExtraNames.AddNoteActivity.update, false)) {
+ addNoteModel.setMode(Mode.Edit);
+ title = "Редактировать заметку";
+ textOnButton = "РЕДАКТИРОВАТЬ";
+ time = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.getDefault()).format(new Date(addNoteModel.getNote().getAddNoteTime()));
+ } else {
+ addNoteModel.setMode(Mode.New);
+ title = "Добавить заметку";
+ textOnButton = "СОХРАНИТЬ";
+ time = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.getDefault()).format(new Date(System.currentTimeMillis()));
+ }
+ view.initToolbarTitle(title, textOnButton, time);
+ }
+
+ @Override
+ public void initMobileSdk() {
+ MobileAds.initialize(addNoteModel.getContext(), () -> {
+ });
+ }
+
+ @Override
+ public void putNote(String name, String text, int or, int c, long time, boolean isNotify) {
+ if (addNoteModel.getMode() == Mode.New) {
+ saveNote(name, text, or, c, time, isNotify);
+ } else if (addNoteModel.getMode() == Mode.Edit) {
+ updateNote(name, text, or, c, time, isNotify);
+ }
+ }
+
+ @Override
+ public void initInterstitialAds() {
+ InterstitialAdLoader mInterstitialAdLoader = new InterstitialAdLoader(addNoteModel.getContext());
+ mInterstitialAdLoader.setAdLoadListener(new InterstitialAdLoadListener() {
+ @Override
+ public void onAdLoaded(@NonNull final InterstitialAd interstitialAd) {
+ view.dismissProgressDialog();
+ interstitialAd.setAdEventListener(new InterstitialAdEventListener() {
+ @Override
+ public void onAdShown() {
+
+ }
+
+ @Override
+ public void onAdFailedToShow(@NonNull AdError adError) {
+
+ }
+
+ @Override
+ public void onAdDismissed() {
+ addNoteModel.getActivity().finish();
+ addNoteModel.getActivity().overridePendingTransition(0, 0);
+ }
+
+ @Override
+ public void onAdClicked() {
+ addNoteModel.getActivity().finish();
+ addNoteModel.getActivity().overridePendingTransition(0, 0);
+ }
+
+ @Override
+ public void onAdImpression(@Nullable ImpressionData impressionData) {
+
+ }
+ });
+ addNoteModel.setmInterstitialAd(interstitialAd);
+ interstitialAd.show(addNoteModel.getActivity());
+ }
+
+ @Override
+ public void onAdFailedToLoad(@NonNull final AdRequestError adRequestError) {
+ Toast.makeText(addNoteModel.getContext(), adRequestError.getDescription(), Toast.LENGTH_SHORT).show();
+ addNoteModel.getActivity().finish();
+ addNoteModel.getActivity().overridePendingTransition(0, 0);
+ }
+ });
+
+ addNoteModel.setmInterstitialAdLoader(mInterstitialAdLoader);
+ }
+
+ @Override
+ public void showInterstitialAd() {
+ view.showProgressDialog();
+ final AdRequestConfiguration adRequestConfiguration =
+ new AdRequestConfiguration.Builder(AdsIds.INTERSTITIAL_AD_UNIT_ID).build();
+ addNoteModel.getmInterstitialAdLoader().loadAd(adRequestConfiguration);
+ }
+
+ private void updateNote(String name, String text, int or, int c, long time, boolean isNotify) {
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(DatabaseConstants._NOTE_NAME, name);
+ contentValues.put(DatabaseConstants._NOTE_TEXT, text);
+ contentValues.put(DatabaseConstants._NOTE_PROMO, or);
+ contentValues.put(DatabaseConstants._NOTE_COLOR, c);
+ contentValues.put(DatabaseConstants._IS_LIKED, 0);
+ contentValues.put(DatabaseConstants._IS_PINNED, 0);
+ contentValues.put(DatabaseConstants._ADD_NOTE_TIME, time);
+ contentValues.put(DatabaseConstants._IS_NOTIFY, isNotify);
+ contentValues.put(DatabaseConstants._CHANNEL_ID, addNoteModel.getNote().getNotificationChannelId());
+ sqLiteDatabaseNotes.update(DatabaseConstants._NOTES_TABLE_NAME, contentValues, DatabaseConstants._ID + " = ?", new String[]{String.valueOf(addNoteModel.getNote().getId())});
+ }
+
+ private void saveNote(String name, String text, int or, int c, long time, boolean isNotify) {
+ if (name == null || name.isEmpty())
+ name = "";
+ if (text == null || text.isEmpty())
+ text = "";
+
+ String notificationChannelId = UniqueIdGenerator.generateUniqueId();
+
+ int isNotifyInt;
+ if (isNotify) {
+ isNotifyInt = 1;
+ } else {
+ isNotifyInt = 0;
+ }
+
+ Note note = new Note(
+ 0,
+ 0,
+ or,
+ 0,
+ 0,
+ c,
+ name,
+ text,
+ time,
+ 0,
+ notificationChannelId,
+ isNotifyInt
+ );
+
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(DatabaseConstants._NOTE_NAME, name);
+ contentValues.put(DatabaseConstants._NOTE_TEXT, text);
+ contentValues.put(DatabaseConstants._NOTE_PROMO, or);
+ contentValues.put(DatabaseConstants._NOTE_COLOR, c);
+ contentValues.put(DatabaseConstants._IS_LIKED, 0);
+ contentValues.put(DatabaseConstants._IS_PINNED, 0);
+ contentValues.put(DatabaseConstants._ADD_NOTE_TIME, time);
+ contentValues.put(DatabaseConstants._IS_NOTIFY, isNotifyInt);
+ contentValues.put(DatabaseConstants._CHANNEL_ID, notificationChannelId);
+ sqLiteDatabaseNotes.insert(DatabaseConstants._NOTES_TABLE_NAME, null, contentValues);
+ view.showSnackBar();
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/view/AddNoteActivity.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/view/AddNoteActivity.java
new file mode 100644
index 0000000..101e830
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/view/AddNoteActivity.java
@@ -0,0 +1,309 @@
+package ru.plumsoftware.notebook.presentation.activities.note.view;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.cardview.widget.CardView;
+import androidx.core.app.ActivityCompat;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.DatePickerDialog;
+import android.app.TimePickerDialog;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.CheckBox;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.GridView;
+import android.widget.TextView;
+import android.widget.TimePicker;
+
+import com.google.android.material.bottomsheet.BottomSheetDialog;
+import com.google.android.material.snackbar.Snackbar;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Objects;
+
+import ru.plumsoftware.data.model.ui.Colors;
+import ru.plumsoftware.data.model.ui.Note;
+import ru.plumsoftware.data.model.ui.Shape;
+import ru.plumsoftware.notebook.presentation.activities.note.presenter.AddNotePresenter;
+import ru.plumsoftware.notebook.presentation.activities.note.presenter.AddNotePresenterImpl;
+import ru.plumsoftware.notebook.presentation.dialogs.ProgressDialog;
+import ru.plumsoftware.notebook.R;
+import ru.plumsoftware.notebook.presentation.adapters.ColorAdapter;
+import ru.plumsoftware.notebook.presentation.adapters.OpacityAdapter;
+import ru.plumsoftware.notebook.services.scheduler.NotificationScheduler;
+import ru.plumsoftware.notebook.manager.unique.UniqueIdGenerator;
+
+public class AddNoteActivity extends AppCompatActivity implements AddNoteView {
+
+ private int REQUEST_CODE = 100;
+ private String notificationChannelId = "";
+
+ private int
+ color,
+ opacityRes = R.drawable.ic_coffee;
+
+ private Calendar dateAndTime = Calendar.getInstance();
+
+ private long noteTime = System.currentTimeMillis();
+
+ private Toolbar toolbar;
+ private CardView cardViewBtnDone;
+ private CheckBox checkBox;
+ private TextView textViewOnButton;
+ private EditText tvTitle;
+ private EditText tvText;
+ private ProgressDialog progressDialog;
+
+ private AddNotePresenter presenter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_add_note);
+
+ Context context = AddNoteActivity.this;
+ Activity activity = AddNoteActivity.this;
+ presenter = new AddNotePresenterImpl(this, context, activity);
+ color = getResources().getColor(R.color.note_green);
+
+ toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
+ tvTitle = findViewById(R.id.Title);
+ tvText = findViewById(R.id.Text);
+ checkBox = findViewById(R.id.checkBox);
+ cardViewBtnDone = findViewById(R.id.cardBtnDoneUltra);
+ textViewOnButton = findViewById(R.id.textView5);
+ progressDialog = new ProgressDialog(context, R.style.CustomProgressDialog);
+
+ presenter.initMobileSdk();
+ presenter.initNote();
+ presenter.initInterstitialAds();
+
+ cardViewBtnDone.setOnClickListener(view -> {
+ String noteTitle = Objects.requireNonNull(tvTitle).getText().toString();
+ String text = Objects.requireNonNull(tvText).getText().toString();
+
+ presenter.putNote(
+ noteTitle,
+ text,
+ opacityRes,
+ color,
+ noteTime,
+ checkBox.isChecked()
+ );
+ onBackPressed();
+
+ if (checkBox.isChecked()) {
+ if (!notificationChannelId.isEmpty()) {
+ setAlarmManager(noteTime, noteTitle, color, notificationChannelId);
+ } else {
+ notificationChannelId = UniqueIdGenerator.generateUniqueId();
+ setAlarmManager(noteTime, noteTitle, color, notificationChannelId);
+ }
+ }
+ });
+ checkBox.setOnClickListener(view -> {
+ if (ActivityCompat.checkSelfPermission(AddNoteActivity.this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ ActivityCompat.requestPermissions((Activity) AddNoteActivity.this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, REQUEST_CODE);
+ }
+ }
+ });
+ }
+
+
+ @SuppressLint("NonConstantResourceId")
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(this, R.style.BottomSheetTheme);
+ bottomSheetDialog1.setContentView(R.layout.color_picker);
+ bottomSheetDialog1.setCancelable(true);
+ bottomSheetDialog1.setDismissWithAnimation(true);
+ GridView colorGridView = (GridView) bottomSheetDialog1.findViewById(R.id.colorGridView);
+
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ case R.id.pick_time:
+
+ new DatePickerDialog(AddNoteActivity.this, d,
+ dateAndTime.get(Calendar.YEAR),
+ dateAndTime.get(Calendar.MONTH),
+ dateAndTime.get(Calendar.DAY_OF_MONTH))
+ .show();
+
+ return true;
+ case R.id.small_icon:
+ ArrayList shapes = new ArrayList<>();
+ shapes.add(new Shape(R.drawable.ic_coffee));
+ shapes.add(new Shape(R.drawable.ic_child_care));
+ shapes.add(new Shape(R.drawable.ic_fitness_center));
+ shapes.add(new Shape(R.drawable.ic_headphones));
+ shapes.add(new Shape(R.drawable.ic_hotel));
+ shapes.add(new Shape(R.drawable.ic_local_shipping));
+ shapes.add(new Shape(R.drawable.ic_perm_phone_msg));
+ shapes.add(new Shape(R.drawable.ic_phishing));
+ shapes.add(new Shape(R.drawable.ic_work));
+ shapes.add(new Shape(R.drawable.ic_work_outline));
+ shapes.add(new Shape(R.drawable.ic_receipt_long));
+ shapes.add(new Shape(R.drawable.ic_rocket_launch));
+ shapes.add(new Shape(R.drawable.ic_school));
+ shapes.add(new Shape(R.drawable.ic_shopping_basket));
+ shapes.add(new Shape(R.drawable.ic_spa));
+ shapes.add(new Shape(R.drawable.ic_square_foot));
+ shapes.add(new Shape(R.drawable.ic_grade));
+
+ OpacityAdapter shapeAdapter = new OpacityAdapter(this, 0, shapes);
+ Objects.requireNonNull(colorGridView).setAdapter(shapeAdapter);
+
+ bottomSheetDialog1.show();
+
+ //Clicker
+ colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ opacityRes = shapes.get(position).getShapeRes();
+ bottomSheetDialog1.dismiss();
+ }
+ });
+ return true;
+ case R.id.small_color:
+ ArrayList colors = new ArrayList<>();
+ colors.add(new Colors(getResources().getColor(R.color.note_blue)));
+ colors.add(new Colors(getResources().getColor(R.color.note_green)));
+ colors.add(new Colors(getResources().getColor(R.color.note_orange)));
+ colors.add(new Colors(getResources().getColor(R.color.note_pink)));
+ colors.add(new Colors(getResources().getColor(R.color.note_purple)));
+ colors.add(new Colors(getResources().getColor(R.color.note_red)));
+ colors.add(new Colors(getResources().getColor(R.color.note_yellow)));
+
+ ColorAdapter colorAdapter = new ColorAdapter(this, 0, colors);
+ Objects.requireNonNull(colorGridView).setAdapter(colorAdapter);
+
+ bottomSheetDialog1.show();
+
+ //Clicker
+ colorGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ color = colors.get(position).getColorRes();
+ bottomSheetDialog1.dismiss();
+
+ cardViewBtnDone.setCardBackgroundColor(color);
+ }
+ });
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.add_menu, menu);
+ return true;
+ }
+
+ @SuppressLint("MissingSuperCall")
+ @Override
+ public void onBackPressed() {
+ presenter.showInterstitialAd();
+ }
+
+ private void setDateAndTime() {
+ noteTime = dateAndTime.getTimeInMillis();
+ toolbar.setSubtitle(new SimpleDateFormat("dd.MM.yyyy HH.mm", Locale.getDefault()).format(new Date(noteTime)));
+ }
+
+ // установка обработчика выбора времени
+ TimePickerDialog.OnTimeSetListener t = new TimePickerDialog.OnTimeSetListener() {
+ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+ dateAndTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
+ dateAndTime.set(Calendar.MINUTE, minute);
+ setDateAndTime();
+ }
+ };
+
+ // установка обработчика выбора даты
+ DatePickerDialog.OnDateSetListener d = new DatePickerDialog.OnDateSetListener() {
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ dateAndTime.set(Calendar.YEAR, year);
+ dateAndTime.set(Calendar.MONTH, monthOfYear);
+ dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+ setDateAndTime();
+
+ new TimePickerDialog(AddNoteActivity.this, t,
+ dateAndTime.get(Calendar.HOUR_OF_DAY),
+ dateAndTime.get(Calendar.MINUTE), true)
+ .show();
+ }
+ };
+
+ //Alarm
+ @SuppressLint("ScheduleExactAlarm")
+ private void setAlarmManager(Long timeInMillis, String message, int color, String notificationChannelId) {
+ NotificationScheduler.scheduleNotification(AddNoteActivity.this, timeInMillis, message, color, notificationChannelId);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ @Override
+ public void initNote(@NonNull Note note) {
+ opacityRes = note.getOpacity();
+ notificationChannelId = note.getNotificationChannelId();
+ checkBox.setChecked(note.getIsNotify() == 1);
+
+ cardViewBtnDone.setCardBackgroundColor(note.getColor());
+ tvTitle.setText(note.getNoteName());
+ tvText.setText(note.getNoteText());
+ }
+
+ @Override
+ public void initToolbarTitle(String title, String textOnButton, String time) {
+ toolbar.setTitle(title);
+ toolbar.setSubtitle(time);
+ textViewOnButton.setText(textOnButton);
+ }
+
+ @Override
+ public void showSnackBar() {
+ Snackbar
+ .make(AddNoteActivity.this, findViewById(R.id.layout), "Данные сохранены✅", Snackbar.LENGTH_SHORT)
+ .setTextColor(Color.parseColor("#000000"))
+ .setBackgroundTint(Color.WHITE)
+ .show();
+ }
+
+ @Override
+ public void showProgressDialog() {
+ progressDialog.showDialog();
+ }
+
+ @Override
+ public void dismissProgressDialog() {
+ progressDialog.dismiss();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/view/AddNoteView.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/view/AddNoteView.java
new file mode 100644
index 0000000..011ed27
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/activities/note/view/AddNoteView.java
@@ -0,0 +1,11 @@
+package ru.plumsoftware.notebook.presentation.activities.note.view;
+
+import ru.plumsoftware.data.model.ui.Note;
+
+public interface AddNoteView {
+ void initNote(Note note);
+ void initToolbarTitle(String title, String textOnButton, String time);
+ void showSnackBar();
+ void showProgressDialog();
+ void dismissProgressDialog();
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/adapters/ColorAdapter.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/ColorAdapter.java
similarity index 89%
rename from app/src/main/java/ru/plumsoftware/notebook/adapters/ColorAdapter.java
rename to app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/ColorAdapter.java
index 1ff4412..84571f2 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/adapters/ColorAdapter.java
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/ColorAdapter.java
@@ -1,4 +1,4 @@
-package ru.plumsoftware.notebook.adapters;
+package ru.plumsoftware.notebook.presentation.adapters;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -13,8 +13,8 @@
import java.util.List;
+import ru.plumsoftware.data.model.ui.Colors;
import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.data.items.Colors;
public class ColorAdapter extends ArrayAdapter {
public ColorAdapter(@NonNull Context context, int resource, @NonNull List objects) {
@@ -29,6 +29,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
convertView = LayoutInflater.from(getContext()).inflate(R.layout.color_layout, parent, false);
Colors colors = getItem(position);
+ assert colors != null;
int colorRes = colors.getColorRes();
CardView cardView = (CardView) convertView.findViewById(R.id.colorView);
diff --git a/app/src/main/java/ru/plumsoftware/notebook/adapters/NoteAdapter.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/NoteAdapter.java
similarity index 95%
rename from app/src/main/java/ru/plumsoftware/notebook/adapters/NoteAdapter.java
rename to app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/NoteAdapter.java
index 65d5d6e..7e02994 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/adapters/NoteAdapter.java
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/NoteAdapter.java
@@ -1,4 +1,4 @@
-package ru.plumsoftware.notebook.adapters;
+package ru.plumsoftware.notebook.presentation.adapters;
import android.annotation.SuppressLint;
import android.app.Activity;
@@ -6,6 +6,7 @@
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
+import android.os.Build;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.view.LayoutInflater;
@@ -43,13 +44,13 @@
import java.util.List;
import java.util.Locale;
-import ru.plumsoftware.notebook.activities.AddNoteActivity;
-import ru.plumsoftware.notebook.activities.MainActivity;
-import ru.plumsoftware.notebook.dialogs.ProgressDialog;
+import ru.plumsoftware.data.database.SQLiteDatabaseManager;
+import ru.plumsoftware.data.model.database.DatabaseConstants;
+import ru.plumsoftware.data.model.ui.Note;
+import ru.plumsoftware.notebook.presentation.activities.note.view.AddNoteActivity;
+import ru.plumsoftware.notebook.presentation.activities.main.view.MainActivity;
+import ru.plumsoftware.notebook.presentation.dialogs.ProgressDialog;
import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.data.items.Note;
-import ru.plumsoftware.notebook.databases.DatabaseConstants;
-import ru.plumsoftware.notebook.databases.SQLiteDatabaseManager;
public class NoteAdapter extends RecyclerView.Adapter {
private Context context;
@@ -102,7 +103,8 @@ public void onInitializationCompleted() {
});
//Ads
- if (position == 2 || position == 5 || position == 8 || position == 11 || position == 14) {
+ if (position == 2 || position == 8 || position == 15 || position == 20) {
+// if (position == -1) {
holder.adsCard.setVisibility(View.GONE);
@@ -224,9 +226,10 @@ public void onClick(View view) {
Intent intent = new Intent(activity, AddNoteActivity.class);
intent.putExtra("update", true);
intent.putExtra("note", note);
+ intent.putExtra("LoadInterstitialAd", true);
+ intent.putExtra("isLoadAppOpenAd", false);
activity.startActivity(intent);
activity.overridePendingTransition(0, 0);
- activity.finish();
// BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(context, R.style.BottomSheetTheme);
// bottomSheetDialog.setContentView(R.layout.add_note_layout);
@@ -411,7 +414,9 @@ public void onClick(View view) {
@Override
public boolean onLongClick(View view) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
- vibrator.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ vibrator.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
+ }
if (note.getIsPinned() == 0)
showPopupMenu(view, note.getAddNoteTime(), note);
else if (note.getIsPinned() == 1)
@@ -454,6 +459,8 @@ public boolean onMenuItemClick(MenuItem item) {
contentValues.put(DatabaseConstants._NOTE_COLOR, note.getColor());
contentValues.put(DatabaseConstants._IS_LIKED, 0);
contentValues.put(DatabaseConstants._IS_PINNED, 1);
+ contentValues.put(DatabaseConstants._IS_NOTIFY, note.getIsNotify());
+ contentValues.put(DatabaseConstants._CHANNEL_ID, note.getNotificationChannelId());
contentValues.put(DatabaseConstants._ADD_NOTE_TIME, note.getAddNoteTime());
sqLiteDatabaseNotes.update(DatabaseConstants._NOTES_TABLE_NAME, contentValues, DatabaseConstants._ADD_NOTE_TIME + " = ?", new String[]{Long.toString(addTime)});
// NotepadActivity.reloadRecyclerView(context, activity);
@@ -506,6 +513,8 @@ public boolean onMenuItemClick(MenuItem item) {
contentValues.put(DatabaseConstants._NOTE_COLOR, note.getColor());
contentValues.put(DatabaseConstants._IS_LIKED, 0);
contentValues.put(DatabaseConstants._IS_PINNED, 0);
+ contentValues.put(DatabaseConstants._IS_NOTIFY, note.getIsNotify());
+ contentValues.put(DatabaseConstants._CHANNEL_ID, note.getNotificationChannelId());
contentValues.put(DatabaseConstants._ADD_NOTE_TIME, note.getAddNoteTime());
sqLiteDatabaseNotes.update(DatabaseConstants._NOTES_TABLE_NAME, contentValues, DatabaseConstants._ADD_NOTE_TIME + " = ?", new String[]{Long.toString(addTime)});
// NotepadActivity.reloadRecyclerView(context, activity);
diff --git a/app/src/main/java/ru/plumsoftware/notebook/adapters/OpacityAdapter.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/OpacityAdapter.java
similarity index 88%
rename from app/src/main/java/ru/plumsoftware/notebook/adapters/OpacityAdapter.java
rename to app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/OpacityAdapter.java
index c5c9478..70b4f8a 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/adapters/OpacityAdapter.java
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/adapters/OpacityAdapter.java
@@ -1,4 +1,4 @@
-package ru.plumsoftware.notebook.adapters;
+package ru.plumsoftware.notebook.presentation.adapters;
import android.content.Context;
import android.view.LayoutInflater;
@@ -6,16 +6,14 @@
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-
import java.util.List;
-
+import ru.plumsoftware.data.model.ui.Shape;
import ru.plumsoftware.notebook.R;
-import ru.plumsoftware.notebook.data.items.Shape;
public class OpacityAdapter extends ArrayAdapter {
+ @NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
Shape shape = getItem(position);
@@ -24,6 +22,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
convertView = LayoutInflater.from(getContext()).inflate(R.layout.color_layout, parent, false);
}
+ assert shape != null;
int shapeRes = shape.getShapeRes();
ImageView imageView = (ImageView) convertView.findViewById(R.id.shapeView);
@@ -34,6 +33,5 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
public OpacityAdapter(@NonNull Context context, int resource, @NonNull List objects) {
super(context, resource, objects);
-
}
}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/dialogs/ProgressDialog.java b/app/src/main/java/ru/plumsoftware/notebook/presentation/dialogs/ProgressDialog.java
similarity index 95%
rename from app/src/main/java/ru/plumsoftware/notebook/dialogs/ProgressDialog.java
rename to app/src/main/java/ru/plumsoftware/notebook/presentation/dialogs/ProgressDialog.java
index 220debc..d86cdf3 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/dialogs/ProgressDialog.java
+++ b/app/src/main/java/ru/plumsoftware/notebook/presentation/dialogs/ProgressDialog.java
@@ -1,4 +1,4 @@
-package ru.plumsoftware.notebook.dialogs;
+package ru.plumsoftware.notebook.presentation.dialogs;
import android.annotation.SuppressLint;
import android.app.Dialog;
diff --git a/app/src/main/java/ru/plumsoftware/notebook/services/MyFirebaseMessagingService.java b/app/src/main/java/ru/plumsoftware/notebook/services/MyFirebaseMessagingService.java
deleted file mode 100644
index 25541fb..0000000
--- a/app/src/main/java/ru/plumsoftware/notebook/services/MyFirebaseMessagingService.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package ru.plumsoftware.notebook.services;
-
-import android.annotation.SuppressLint;
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-import android.util.Log;
-
-import androidx.annotation.Nullable;
-
-import com.google.firebase.messaging.FirebaseMessagingService;
-import com.google.firebase.messaging.RemoteMessage;
-
-@SuppressLint("MissingFirebaseInstanceTokenRefresh")
-public class MyFirebaseMessagingService extends FirebaseMessagingService {
- private static final String TAG = "TAG_1";
- @Override
- public void onMessageReceived(RemoteMessage remoteMessage) {
- // ...
-
- // TODO(developer): Handle FCM messages here.
- // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
- Log.d(TAG, "From: " + remoteMessage.getFrom());
-
- // Check if message contains a data payload.
- if (remoteMessage.getData().size() > 0) {
- Log.d(TAG, "Message data payload: " + remoteMessage.getData());
-
- if (/* Check if data needs to be processed by long running job */ true) {
- // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
- //scheduleJob();
- } else {
- // Handle message within 10 seconds
- //handleNow();
- }
-
- }
-
- // Check if message contains a notification payload.
- if (remoteMessage.getNotification() != null) {
- Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
- }
-
- // Also if you intend on generating your own notifications as a result of a received FCM
- // message, here is where that should be initiated. See sendNotification method below.
- }
-}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/services/push/MyFirebaseMessagingService.java b/app/src/main/java/ru/plumsoftware/notebook/services/push/MyFirebaseMessagingService.java
new file mode 100644
index 0000000..5e9796a
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/services/push/MyFirebaseMessagingService.java
@@ -0,0 +1,22 @@
+package ru.plumsoftware.notebook.services.push;
+
+import android.annotation.SuppressLint;
+import android.util.Log;
+
+import com.google.firebase.messaging.FirebaseMessagingService;
+import com.google.firebase.messaging.RemoteMessage;
+
+@SuppressLint("MissingFirebaseInstanceTokenRefresh")
+public class MyFirebaseMessagingService extends FirebaseMessagingService {
+ private static final String TAG = "TAG_1";
+ @Override
+ public void onMessageReceived(RemoteMessage remoteMessage) {
+ Log.d(TAG, "From: " + remoteMessage.getFrom());
+ if (!remoteMessage.getData().isEmpty()) {
+ Log.d(TAG, "Message data payload: " + remoteMessage.getData());
+ }
+ if (remoteMessage.getNotification() != null) {
+ Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
+ }
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/services/MyRuStoreMessagingService.java b/app/src/main/java/ru/plumsoftware/notebook/services/push/MyRuStoreMessagingService.java
similarity index 85%
rename from app/src/main/java/ru/plumsoftware/notebook/services/MyRuStoreMessagingService.java
rename to app/src/main/java/ru/plumsoftware/notebook/services/push/MyRuStoreMessagingService.java
index f7dade2..c9b3a44 100644
--- a/app/src/main/java/ru/plumsoftware/notebook/services/MyRuStoreMessagingService.java
+++ b/app/src/main/java/ru/plumsoftware/notebook/services/push/MyRuStoreMessagingService.java
@@ -1,4 +1,4 @@
-package ru.plumsoftware.notebook.services;
+package ru.plumsoftware.notebook.services.push;
import android.app.Service;
import android.content.Intent;
diff --git a/app/src/main/java/ru/plumsoftware/notebook/services/receive/NotificationReceiver.java b/app/src/main/java/ru/plumsoftware/notebook/services/receive/NotificationReceiver.java
new file mode 100644
index 0000000..1227d43
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/services/receive/NotificationReceiver.java
@@ -0,0 +1,21 @@
+package ru.plumsoftware.notebook.services.receive;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import androidx.annotation.NonNull;
+
+import ru.plumsoftware.notebook.manager.extra.ExtraNames;
+import ru.plumsoftware.notebook.manager.notification.NotificationManager;
+
+public class NotificationReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, @NonNull Intent intent) {
+ String message = intent.getStringExtra(ExtraNames.LocalNotificationExtra.message);
+ String notificationChannelId = intent.getStringExtra(ExtraNames.LocalNotificationExtra.notificationChannelId);
+ int color = intent.getIntExtra(ExtraNames.LocalNotificationExtra.colorPair.getFirst(), ExtraNames.LocalNotificationExtra.colorPair.getSecond());
+
+ NotificationManager.createNotification(context, "\uD83D\uDD14 Напоминание о событии ", message, color, notificationChannelId);
+ }
+}
diff --git a/app/src/main/java/ru/plumsoftware/notebook/services/scheduler/NotificationScheduler.java b/app/src/main/java/ru/plumsoftware/notebook/services/scheduler/NotificationScheduler.java
new file mode 100644
index 0000000..f2df9a2
--- /dev/null
+++ b/app/src/main/java/ru/plumsoftware/notebook/services/scheduler/NotificationScheduler.java
@@ -0,0 +1,29 @@
+package ru.plumsoftware.notebook.services.scheduler;
+
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+
+import ru.plumsoftware.notebook.services.receive.NotificationReceiver;
+
+public class NotificationScheduler {
+ public static void scheduleNotification(Context context, long timeInMillis, String message, int color, String notificationChannelId) {
+ // Создание намерения для запуска BroadcastReceiver
+ Intent notificationIntent = new Intent(context, NotificationReceiver.class);
+ notificationIntent.putExtra("message", message);
+ notificationIntent.putExtra("color", color);
+ notificationIntent.putExtra("notificationChannelId", notificationChannelId);
+
+ // Создание PendingIntent
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
+
+ // Получение AlarmManager
+ AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+
+ // Установка уведомления на указанное время
+ if (alarmManager != null) {
+ alarmManager.set(AlarmManager.RTC_WAKEUP, timeInMillis, pendingIntent);
+ }
+ }
+}
diff --git a/app/src/main/res/drawable/add_note_icon.xml b/app/src/main/res/drawable/add_note_icon.xml
new file mode 100644
index 0000000..db1d0c1
--- /dev/null
+++ b/app/src/main/res/drawable/add_note_icon.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_add_note.xml b/app/src/main/res/layout/activity_add_note.xml
index f7830de..594f32c 100644
--- a/app/src/main/res/layout/activity_add_note.xml
+++ b/app/src/main/res/layout/activity_add_note.xml
@@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- tools:context=".activities.AddNoteActivity">
+ tools:context=".presentation.activities.note.view.AddNoteActivity">
+
+
+ tools:context=".presentation.activities.main.view.MainActivity">
+ app:srcCompat="@drawable/ic_add"
+ tools:ignore="ContentDescription" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/add_group_layout.xml b/app/src/main/res/layout/add_group_layout.xml
deleted file mode 100644
index f576fad..0000000
--- a/app/src/main/res/layout/add_group_layout.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_notepad.xml b/app/src/main/res/layout/fragment_notepad.xml
deleted file mode 100644
index b28612d..0000000
--- a/app/src/main/res/layout/fragment_notepad.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml
deleted file mode 100644
index df3265b..0000000
--- a/app/src/main/res/layout/fragment_search.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/group_item_layout.xml b/app/src/main/res/layout/group_item_layout.xml
deleted file mode 100644
index 00c5eac..0000000
--- a/app/src/main/res/layout/group_item_layout.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/main_menu_layout.xml b/app/src/main/res/layout/main_menu_layout.xml
deleted file mode 100644
index 61fda0d..0000000
--- a/app/src/main/res/layout/main_menu_layout.xml
+++ /dev/null
@@ -1,538 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index 1b28da5..0000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 0000000..c646cc2
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
deleted file mode 100644
index 7da7071..0000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..5d2f6e4
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 7ea5bd7..0000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..690bcdb
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index e1ddaef..0000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 0000000..48c4d1f
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
deleted file mode 100644
index a950698..0000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..ee91435
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index d29383e..0000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..8c6f937
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index 888de49..0000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 0000000..7985ec9
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
deleted file mode 100644
index 8718ced..0000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..e16c298
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 24d53e3..0000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..3854b37
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index e028af4..0000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..6fdcf15
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
deleted file mode 100644
index 2dd323d..0000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..adc52a9
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index 9304e93..0000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..e3f5373
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 8cb46af..0000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..683e2c0
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
deleted file mode 100644
index d920525..0000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..067ef5d
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index 54f53d0..0000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..f52dffc
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/values-v23/themes.xml b/app/src/main/res/values-v23/themes.xml
new file mode 100644
index 0000000..7b575cb
--- /dev/null
+++ b/app/src/main/res/values-v23/themes.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v27/themes.xml
new file mode 100644
index 0000000..d243753
--- /dev/null
+++ b/app/src/main/res/values-v27/themes.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5ec0414..887cdcf 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,4 +2,7 @@
Блокнот
Hello blank fragment
+ Добавить
+ Добавить новую заметку
+ Не добавлять новую заметку
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index c15804d..4d7ccef 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -11,10 +11,10 @@
- @color/black
- @color/black
- - false
+ - false
- @color/black
- - false
+ - false
- ?android:attr/statusBarColor
- @font/roboto
diff --git a/app/src/main/res/xml-v25/shortcuts.xml b/app/src/main/res/xml-v25/shortcuts.xml
new file mode 100644
index 0000000..ac0d121
--- /dev/null
+++ b/app/src/main/res/xml-v25/shortcuts.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/shortcuts.xml b/app/src/main/res/xml/shortcuts.xml
new file mode 100644
index 0000000..7c3765e
--- /dev/null
+++ b/app/src/main/res/xml/shortcuts.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/release/ic_launcher-playstore.png b/app/src/release/ic_launcher-playstore.png
index 7656e9e..185f5ed 100644
Binary files a/app/src/release/ic_launcher-playstore.png and b/app/src/release/ic_launcher-playstore.png differ
diff --git a/app/src/release/res/mipmap-hdpi/ic_launcher.png b/app/src/release/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index 1b28da5..0000000
Binary files a/app/src/release/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-hdpi/ic_launcher.webp b/app/src/release/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 0000000..c646cc2
Binary files /dev/null and b/app/src/release/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/app/src/release/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/release/res/mipmap-hdpi/ic_launcher_foreground.png
deleted file mode 100644
index 7da7071..0000000
Binary files a/app/src/release/res/mipmap-hdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-hdpi/ic_launcher_foreground.webp b/app/src/release/res/mipmap-hdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..5d2f6e4
Binary files /dev/null and b/app/src/release/res/mipmap-hdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/release/res/mipmap-hdpi/ic_launcher_round.png b/app/src/release/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 7ea5bd7..0000000
Binary files a/app/src/release/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/release/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..690bcdb
Binary files /dev/null and b/app/src/release/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/app/src/release/res/mipmap-mdpi/ic_launcher.png b/app/src/release/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index e1ddaef..0000000
Binary files a/app/src/release/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-mdpi/ic_launcher.webp b/app/src/release/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 0000000..48c4d1f
Binary files /dev/null and b/app/src/release/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/app/src/release/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/release/res/mipmap-mdpi/ic_launcher_foreground.png
deleted file mode 100644
index a950698..0000000
Binary files a/app/src/release/res/mipmap-mdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-mdpi/ic_launcher_foreground.webp b/app/src/release/res/mipmap-mdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..ee91435
Binary files /dev/null and b/app/src/release/res/mipmap-mdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/release/res/mipmap-mdpi/ic_launcher_round.png b/app/src/release/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index d29383e..0000000
Binary files a/app/src/release/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/release/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..8c6f937
Binary files /dev/null and b/app/src/release/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/app/src/release/res/mipmap-xhdpi/ic_launcher.png b/app/src/release/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index 888de49..0000000
Binary files a/app/src/release/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xhdpi/ic_launcher.webp b/app/src/release/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 0000000..7985ec9
Binary files /dev/null and b/app/src/release/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/app/src/release/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/release/res/mipmap-xhdpi/ic_launcher_foreground.png
deleted file mode 100644
index 8718ced..0000000
Binary files a/app/src/release/res/mipmap-xhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xhdpi/ic_launcher_foreground.webp b/app/src/release/res/mipmap-xhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..e16c298
Binary files /dev/null and b/app/src/release/res/mipmap-xhdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/release/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/release/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 24d53e3..0000000
Binary files a/app/src/release/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/release/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..3854b37
Binary files /dev/null and b/app/src/release/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/app/src/release/res/mipmap-xxhdpi/ic_launcher.png b/app/src/release/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index e028af4..0000000
Binary files a/app/src/release/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/release/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..6fdcf15
Binary files /dev/null and b/app/src/release/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/app/src/release/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/release/res/mipmap-xxhdpi/ic_launcher_foreground.png
deleted file mode 100644
index 2dd323d..0000000
Binary files a/app/src/release/res/mipmap-xxhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/app/src/release/res/mipmap-xxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..adc52a9
Binary files /dev/null and b/app/src/release/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/release/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/release/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index 9304e93..0000000
Binary files a/app/src/release/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/release/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..e3f5373
Binary files /dev/null and b/app/src/release/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/release/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/release/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 8cb46af..0000000
Binary files a/app/src/release/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/release/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..683e2c0
Binary files /dev/null and b/app/src/release/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/app/src/release/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/release/res/mipmap-xxxhdpi/ic_launcher_foreground.png
deleted file mode 100644
index d920525..0000000
Binary files a/app/src/release/res/mipmap-xxxhdpi/ic_launcher_foreground.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/app/src/release/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..067ef5d
Binary files /dev/null and b/app/src/release/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ
diff --git a/app/src/release/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/release/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index 54f53d0..0000000
Binary files a/app/src/release/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/release/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/release/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..f52dffc
Binary files /dev/null and b/app/src/release/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/build.gradle b/build.gradle
index c01351d..5782086 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,13 +1,13 @@
buildscript {
dependencies {
- classpath 'com.google.gms:google-services:4.3.14'
+ classpath 'com.google.gms:google-services:4.4.0'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
- id 'com.android.application' version '8.0.2' apply false
- id 'com.android.library' version '8.0.2' apply false
+ id 'com.android.application' version '8.6.0' apply false
+ id 'com.android.library' version '8.6.0' apply false
}
-task clean(type: Delete) {
+tasks.register('clean', Delete) {
delete rootProject.buildDir
}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 5ca382b..e8f7b1e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Thu Sep 29 00:05:39 GMT+06:00 2022
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
diff --git a/private_key.pepk b/private_key.pepk
index dd6e5e0..3e3f221 100644
Binary files a/private_key.pepk and b/private_key.pepk differ
diff --git a/release/app-release.aab b/release/.aab/app-release.aab
similarity index 100%
rename from release/app-release.aab
rename to release/.aab/app-release.aab
diff --git a/release/app-release.apk b/release/.apk/app-release.apk
similarity index 100%
rename from release/app-release.apk
rename to release/.apk/app-release.apk
diff --git a/release/output-metadata.json b/release/.apk/output-metadata.json
similarity index 100%
rename from release/output-metadata.json
rename to release/.apk/output-metadata.json
diff --git a/release/release/app-release.aab b/release/release/app-release.aab
deleted file mode 100644
index 543a1cf..0000000
Binary files a/release/release/app-release.aab and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index eb8f561..bf8a1d8 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -17,3 +17,5 @@ dependencyResolutionManagement {
}
rootProject.name = "Блокнот"
include ':app'
+include ':app-domain'
+include ':app-data'