Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Formatting-only commits. Enable locally with:
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# The hashes are those of the PR branch, so merge it with a merge commit (not squash or rebase).

# style: reformat with google-java-format 2.0.0
8e4e5566d864e3b20bbf25dce824b10023d3bf36
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
java-version: '21'

- name: Cache Gradle
uses: actions/cache@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
java-version: '21'

- name: Cache Gradle
uses: actions/cache@v5
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
java-version: '21'

- name: Set up Android SDK
uses: android-actions/setup-android@v4
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ ext {
roomVersion = '2.8.5'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:34.18.0')
implementation platform('com.google.firebase:firebase-bom:35.2.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'androidx.appcompat:appcompat:1.8.0'
implementation 'com.google.android.material:material:1.14.0'
Expand All @@ -185,7 +185,7 @@ dependencies {
implementation 'androidx.credentials:credentials:1.6.0'
implementation 'androidx.credentials:credentials-play-services-auth:1.6.0'
implementation 'com.google.android.libraries.identity.googleid:googleid:1.2.1'
implementation 'com.google.android.gms:play-services-auth:21.4.0'
implementation 'com.google.android.gms:play-services-auth:22.0.0'

//DI (Hilt)
implementation "com.google.dagger:hilt-android:$daggerHilt"
Expand All @@ -200,7 +200,7 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$roomVersion"

//Pay Billing
implementation 'com.android.billingclient:billing:8.3.0'
implementation 'com.android.billingclient:billing:9.1.0'

//Other lib (Gson/PhotoView)
implementation 'com.google.code.gson:gson:2.15.0'
Expand Down Expand Up @@ -243,7 +243,7 @@ configurations.configureEach {
spotless {
java {
target 'src/**/*.java'
googleJavaFormat('1.22.0').aosp() // 4-space indent (AOSP style)
googleJavaFormat('2.0.0').aosp() // 4-space indent (AOSP style)
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1906,17 +1906,16 @@ private static final class PreferencesAdapter {
.thenAnswer(invocation -> current.get());
org.mockito.Mockito.when(
helper.commitListPreferences(org.mockito.ArgumentMatchers.any()))
.thenAnswer(
invocation -> {
if (!succeeds.get()) {
return false;
}
com.pasich.mynotes.utils.backup.models.PreferencesBackup value =
invocation.getArgument(0);
committed.set(value);
current.set(value);
return true;
});
.thenAnswer(invocation -> {
if (!succeeds.get()) {
return false;
}
com.pasich.mynotes.utils.backup.models.PreferencesBackup value =
invocation.getArgument(0);
committed.set(value);
current.set(value);
return true;
});
}
}

Expand Down
36 changes: 17 additions & 19 deletions app/src/main/java/com/pasich/mynotes/MyApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,24 @@ public void onCreate() {
NotificationChannelManager.ensureChannel(this, notificationPreferencesCache);

Executors.newSingleThreadExecutor()
.execute(
() -> {
themePreferencesCache.initialize();
notificationPreferencesCache.initialize();
GLOBAL_FONT_SCALE = themePreferencesCache.getUiFontScale();
CACHE_READY = true;
});
.execute(() -> {
themePreferencesCache.initialize();
notificationPreferencesCache.initialize();
GLOBAL_FONT_SCALE = themePreferencesCache.getUiFontScale();
CACHE_READY = true;
});

// Global RxJava ErrorHandler to avoid UndeliverableException
RxJavaPlugins.setErrorHandler(
e -> {
if (e instanceof UndeliverableException) {
Throwable cause = e.getCause();
if (cause instanceof InterruptedException) {
return;
}
Log.w(TAG, "Undeliverable exception received", cause);
} else {
Log.w(TAG, "Unhandled RxJava exception", e);
}
});
RxJavaPlugins.setErrorHandler(e -> {
if (e instanceof UndeliverableException) {
Throwable cause = e.getCause();
if (cause instanceof InterruptedException) {
return;
}
Log.w(TAG, "Undeliverable exception received", cause);
} else {
Log.w(TAG, "Unhandled RxJava exception", e);
}
});
}
}
14 changes: 6 additions & 8 deletions app/src/main/java/com/pasich/mynotes/data/AppDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,12 @@ public Completable transferNotesOutTrash(List<Integer> ids) {
public Completable clearTrash() {
return dbHelper.getNotesInTrash()
.firstOrError()
.flatMapCompletable(
notes -> {
for (Note note : notes) {
AttachmentCleaner.deleteAttachmentFolderByNoteId(
context, note.getId());
}
return dbHelper.clearTrash();
});
.flatMapCompletable(notes -> {
for (Note note : notes) {
AttachmentCleaner.deleteAttachmentFolderByNoteId(context, note.getId());
}
return dbHelper.clearTrash();
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ public void migrate(@NonNull SupportSQLiteDatabase db) {
db.execSQL("ALTER TABLE notes ADD COLUMN isTrash INTEGER NOT NULL DEFAULT 0");
db.execSQL(
"""
INSERT INTO notes (title, value, date, tag, valueJson, attachments, hasRichContent, isTrash)
SELECT title, value, date, '', '', '', 0, 1 FROM trash
""");
INSERT INTO notes (title, value, date, tag, valueJson, attachments, hasRichContent, isTrash)
SELECT title, value, date, '', '', '', 0, 1 FROM trash
""");
db.execSQL("DROP TABLE IF EXISTS trash");
}
};
Expand Down
58 changes: 24 additions & 34 deletions app/src/main/java/com/pasich/mynotes/data/database/AppDbHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ public Flowable<List<Tag>> getTags() {
return appDatabase
.tagsDao()
.getTags()
.map(
userTags -> {
userTags.addAll(SystemTagsManager.getSystemTags());
return userTags;
});
.map(userTags -> {
userTags.addAll(SystemTagsManager.getSystemTags());
return userTags;
});
}

@Override
Expand Down Expand Up @@ -180,21 +179,19 @@ public Completable addNotes(List<Note> notes) {

@Override
public Completable deleteNote(Note note) {
return Completable.fromAction(
() -> {
syncMutationCoordinator.deleteNote(note);
noteViewStateStore.remove(note.getId());
});
return Completable.fromAction(() -> {
syncMutationCoordinator.deleteNote(note);
noteViewStateStore.remove(note.getId());
});
}

@Override
public Completable deleteNote(ArrayList<Note> notes) {
return Completable.fromAction(
() -> {
syncMutationCoordinator.deleteNotes(notes);
if (notes == null) return;
for (Note note : notes) noteViewStateStore.remove(note.getId());
});
return Completable.fromAction(() -> {
syncMutationCoordinator.deleteNotes(notes);
if (notes == null) return;
for (Note note : notes) noteViewStateStore.remove(note.getId());
});
}

@Override
Expand Down Expand Up @@ -230,12 +227,10 @@ public Flowable<Long> getTotalCharacters() {

@Override
public Single<List<Note>> getNotesWithActiveReminders() {
return Single.fromCallable(
() ->
appDatabase
.noteDao()
.getNotesWithActiveRemindersSync(
System.currentTimeMillis()))
return Single.fromCallable(() ->
appDatabase
.noteDao()
.getNotesWithActiveRemindersSync(System.currentTimeMillis()))
.subscribeOn(io.reactivex.schedulers.Schedulers.io());
}

Expand All @@ -247,20 +242,17 @@ public Completable clearReminder(int noteId) {

@Override
public Completable updateNoteReminder(int noteId, long reminderTime, String repeat) {
return Completable.fromAction(
() ->
syncMutationCoordinator.updateNoteReminder(
noteId, reminderTime, repeat))
return Completable.fromAction(() ->
syncMutationCoordinator.updateNoteReminder(noteId, reminderTime, repeat))
.subscribeOn(io.reactivex.schedulers.Schedulers.io());
}

@Override
public Completable updateNoteReminderFull(
int noteId, long reminderTime, String repeat, int intervalMinutes) {
return Completable.fromAction(
() ->
syncMutationCoordinator.updateNoteReminderFull(
noteId, reminderTime, repeat, intervalMinutes))
return Completable.fromAction(() ->
syncMutationCoordinator.updateNoteReminderFull(
noteId, reminderTime, repeat, intervalMinutes))
.subscribeOn(io.reactivex.schedulers.Schedulers.io());
}

Expand Down Expand Up @@ -361,10 +353,8 @@ public Completable setTaskReminder(int taskId, long time) {

@Override
public Completable setTaskReminderFull(int taskId, long time, int intervalMinutes) {
return Completable.fromAction(
() ->
syncMutationCoordinator.setTaskReminderFull(
taskId, time, intervalMinutes))
return Completable.fromAction(() ->
syncMutationCoordinator.setTaskReminderFull(taskId, time, intervalMinutes))
.subscribeOn(io.reactivex.schedulers.Schedulers.io());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
package com.pasich.mynotes.data.model;

import java.util.Comparator;

/** Model representing an in-app donation product. */
public class DonationProduct {

/** Price amount for a product whose offer details are missing. */
public static final long NO_PRICE = Long.MAX_VALUE;

/**
* Cheapest first, by the exact amount Play reports. The formatted price is for display only:
* parsing it reads a thousands separator ("¥1,000") as a decimal point.
*/
public static final Comparator<DonationProduct> BY_PRICE =
Comparator.comparingLong(DonationProduct::getPriceAmountMicros);

private String id;
private String title;
private String description;
private String price;
private String iconResource;
private final long priceAmountMicros;
private boolean isPurchased;

public DonationProduct(
String id, String title, String description, String price, String iconResource) {
String id,
String title,
String description,
String price,
String iconResource,
long priceAmountMicros) {
this.id = id;
this.title = title;
this.description = description;
this.price = price;
this.iconResource = iconResource;
this.priceAmountMicros = priceAmountMicros;
this.isPurchased = false;
}

Expand Down Expand Up @@ -52,6 +72,11 @@ public void setPrice(String price) {
this.price = price;
}

/** The price in micro-units of its currency, or {@link #NO_PRICE}. */
public long getPriceAmountMicros() {
return priceAmountMicros;
}

public String getIconResource() {
return iconResource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,8 @@ private InputStream openAttachment(@NonNull String attachmentId) throws IOExcept
// ByteArrayOutputStream first doubled, then copied) was the largest single allocation in
// the sync and an OutOfMemoryError on an ordinary phone.
HttpURLConnection connection =
requestExecutor.executeIdempotent(
() ->
openSuccessful(
"GET", apiBase + "/files/" + attachmentId + "?alt=media"));
requestExecutor.executeIdempotent(() ->
openSuccessful("GET", apiBase + "/files/" + attachmentId + "?alt=media"));
try {
return new ConnectionInputStream(connection, maxAttachmentBytes);
} catch (IOException failure) {
Expand Down Expand Up @@ -967,16 +965,15 @@ private void uploadResumableAttachment(
// committed. Retrying is therefore safe, and it keeps one transient 5xx between
// chunks from discarding a large upload that is nearly complete.
long reported =
requestExecutor.executeIdempotent(
() ->
uploadChunk(
sessionUrl,
mimeType,
buffer,
0,
length,
chunkStart,
sizeBytes));
requestExecutor.executeIdempotent(() ->
uploadChunk(
sessionUrl,
mimeType,
buffer,
0,
length,
chunkStart,
sizeBytes));

if (reported < acknowledgedExclusive) {
throw new IOException(
Expand Down
Loading
Loading