Skip to content

Commit f6f0261

Browse files
committed
Архитектура
[+] Добавил data,domain и presentation слои. [+] Перенёс в эти сло часть логики. [~] Подчистил код: удалил ненужные активити и фрагменты.
1 parent 81fcc82 commit f6f0261

50 files changed

Lines changed: 296 additions & 2063 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app-data/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app-data/build.gradle.kts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
plugins {
2+
id("com.android.library")
3+
}
4+
5+
android {
6+
namespace = "ru.plumsoftware.data"
7+
compileSdk = 34
8+
9+
defaultConfig {
10+
minSdk = 22
11+
12+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
13+
consumerProguardFiles("consumer-rules.pro")
14+
}
15+
16+
buildTypes {
17+
release {
18+
isMinifyEnabled = false
19+
proguardFiles(
20+
getDefaultProguardFile("proguard-android-optimize.txt"),
21+
"proguard-rules.pro"
22+
)
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility = JavaVersion.VERSION_1_8
27+
targetCompatibility = JavaVersion.VERSION_1_8
28+
}
29+
}
30+
31+
dependencies {
32+
33+
implementation("androidx.appcompat:appcompat:1.7.0")
34+
implementation("com.google.android.material:material:1.12.0")
35+
testImplementation("junit:junit:4.13.2")
36+
androidTestImplementation("androidx.test.ext:junit:1.2.1")
37+
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
38+
}

app-data/consumer-rules.pro

Whitespace-only changes.

app-data/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ru.plumsoftware.data;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("ru.plumsoftware.data.test", appContext.getPackageName());
25+
}
26+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</manifest>

app/src/main/java/ru/plumsoftware/notebook/databases/SQLiteDatabaseManager.java renamed to app-data/src/main/java/ru/plumsoftware/data/database/SQLiteDatabaseManager.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
package ru.plumsoftware.notebook.databases;
1+
package ru.plumsoftware.data.database;
22

33
import android.content.Context;
44
import android.database.sqlite.SQLiteDatabase;
55
import android.database.sqlite.SQLiteOpenHelper;
6-
import android.util.Log;
6+
7+
import ru.plumsoftware.data.model.database.DatabaseConstants;
78

89
public class SQLiteDatabaseManager extends SQLiteOpenHelper {
9-
public static final int DATABASE_VERSION = 5;
10-
public static final String DATABASE_NAME = DatabaseConstants.DATABASE_NAME;
10+
private static final int DATABASE_VERSION = 5;
11+
private static final String DATABASE_NAME = DatabaseConstants.DATABASE_NAME;
1112

1213
public SQLiteDatabaseManager(Context context) {
1314
super(context, DATABASE_NAME, null, DATABASE_VERSION);
@@ -21,23 +22,15 @@ public void onCreate(SQLiteDatabase db) {
2122
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
2223
if (newVersion > oldVersion) {
2324
String tempTable = "temp_table";
24-
25-
// Создаем временную таблицу и копируем данные
2625
db.execSQL("CREATE TABLE " + tempTable + " AS SELECT * FROM " + DatabaseConstants._NOTES_TABLE_NAME);
27-
28-
// Удаляем исходную таблицу
2926
db.execSQL(DatabaseConstants.DELETE_NOTES_TABLE);
30-
31-
// Создаем новую таблицу с новыми полями
3227
db.execSQL(DatabaseConstants.CREATE_NOTES_TABLE);
3328

3429
db.execSQL("ALTER TABLE " + tempTable + " ADD " + DatabaseConstants._CHANNEL_ID + " TEXT;");
3530
db.execSQL("ALTER TABLE " + tempTable + " ADD " + DatabaseConstants._IS_NOTIFY + " INTEGER;");
3631

37-
// Копируем данные из временной таблицы в новую таблицу
3832
db.execSQL("INSERT INTO " + DatabaseConstants._NOTES_TABLE_NAME + " SELECT * FROM " + tempTable);
3933

40-
// Удаляем временную таблицу
4134
db.execSQL("DROP TABLE IF EXISTS " + tempTable);
4235
}
4336
}

app/src/main/java/ru/plumsoftware/notebook/databases/DatabaseConstants.java renamed to app-data/src/main/java/ru/plumsoftware/data/model/database/DatabaseConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ru.plumsoftware.notebook.databases;
1+
package ru.plumsoftware.data.model.database;
22

33
import android.provider.BaseColumns;
44

app/src/main/java/ru/plumsoftware/notebook/data/items/Colors.java renamed to app-data/src/main/java/ru/plumsoftware/data/model/ui/Colors.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
package ru.plumsoftware.notebook.data.items;
1+
package ru.plumsoftware.data.model.ui;
2+
3+
import androidx.annotation.ColorRes;
24

35
public class Colors {
4-
private int colorRes;
6+
@ColorRes private final int colorRes;
57

68
public Colors(int colorRes) {
79
this.colorRes = colorRes;

app/src/main/java/ru/plumsoftware/notebook/data/items/Note.java renamed to app-data/src/main/java/ru/plumsoftware/data/model/ui/Note.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,15 @@
9999
// this.color = color;
100100
// }
101101
//}
102-
package ru.plumsoftware.notebook.data.items;
102+
package ru.plumsoftware.data.model.ui;
103103

104104
import android.os.Parcel;
105105
import android.os.Parcelable;
106106

107107
import androidx.annotation.NonNull;
108108

109+
import org.jetbrains.annotations.Contract;
110+
109111
import java.text.SimpleDateFormat;
110112
import java.util.Date;
111113
import java.util.Locale;
@@ -140,7 +142,7 @@ public Note(
140142
this.opacity = opacity;
141143
}
142144

143-
public Note(Parcel in) {
145+
public Note(@NonNull Parcel in) {
144146
id = in.readInt();
145147
count = in.readInt();
146148
notePromoResId = in.readInt();
@@ -339,7 +341,7 @@ public int describeContents() {
339341
}
340342

341343
@Override
342-
public void writeToParcel(Parcel dest, int flags) {
344+
public void writeToParcel(@NonNull Parcel dest, int flags) {
343345
dest.writeInt(id);
344346
dest.writeInt(count);
345347
dest.writeInt(notePromoResId);
@@ -355,11 +357,15 @@ public void writeToParcel(Parcel dest, int flags) {
355357
}
356358

357359
public static final Creator<Note> CREATOR = new Creator<Note>() {
360+
@NonNull
361+
@Contract("_ -> new")
358362
@Override
359363
public Note createFromParcel(Parcel in) {
360364
return new Note(in);
361365
}
362366

367+
@NonNull
368+
@Contract(value = "_ -> new", pure = true)
363369
@Override
364370
public Note[] newArray(int size) {
365371
return new Note[size];

0 commit comments

Comments
 (0)