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
22 changes: 11 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,24 @@ gradle.taskGraph.whenReady { graph ->

ext {
markwon_version = '4.6.2'
roomVersion = '2.8.4'
roomVersion = '2.8.5'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:34.18.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'androidx.appcompat:appcompat:1.7.1'
implementation 'androidx.appcompat:appcompat:1.8.0'
implementation 'com.google.android.material:material:1.14.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.2'
implementation 'androidx.preference:preference:1.2.1'
implementation "androidx.lifecycle:lifecycle-viewmodel:2.11.0"
implementation 'androidx.core:core-splashscreen:1.2.0'
implementation 'androidx.activity:activity:1.13.0'
implementation 'androidx.work:work-runtime:2.10.1'
implementation 'androidx.work:work-runtime:2.12.0'

// Google Credential Manager (authentication only; Drive authorization is requested separately)
implementation 'androidx.credentials:credentials:1.5.0'
implementation 'androidx.credentials:credentials-play-services-auth:1.5.0'
implementation 'com.google.android.libraries.identity.googleid:googleid:1.2.0'
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'

//DI (Hilt)
Expand All @@ -203,7 +203,7 @@ dependencies {
implementation 'com.android.billingclient:billing:8.3.0'

//Other lib (Gson/PhotoView)
implementation 'com.google.code.gson:gson:2.14.0'
implementation 'com.google.code.gson:gson:2.15.0'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'androidx.exifinterface:exifinterface:1.4.2'

Expand All @@ -214,17 +214,17 @@ dependencies {

// Unit tests
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.23.0'
testImplementation 'com.google.truth:truth:1.4.2'
testImplementation 'org.robolectric:robolectric:4.16.1'
testImplementation 'org.mockito:mockito-core:5.24.0'
testImplementation 'com.google.truth:truth:1.4.5'
testImplementation 'org.robolectric:robolectric:4.17'

// Room testing (integration tests)
testImplementation "androidx.room:room-testing:$roomVersion"
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test:rules:1.7.0'
androidTestImplementation 'androidx.test:runner:1.7.0'
androidTestImplementation "androidx.room:room-testing:$roomVersion"
androidTestImplementation 'org.mockito:mockito-android:5.23.0'
androidTestImplementation 'org.mockito:mockito-android:5.24.0'
androidTestImplementation 'com.google.truth:truth:1.4.5'

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -31,6 +32,8 @@
@AndroidEntryPoint
public class MediaSettingsFragment extends Fragment {

private static final String TAG = "MediaSettings";

@Inject ThemePreferencesCache themePreferencesCache;

@Inject AppPreferencesCache appPreferencesCache;
Expand Down Expand Up @@ -123,8 +126,18 @@ private void initListeners() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser && audioManager != null) {
audioManager.setStreamVolume(
AudioManager.STREAM_NOTIFICATION, progress, 0);
try {
audioManager.setStreamVolume(
AudioManager.STREAM_NOTIFICATION, progress, 0);
} catch (SecurityException e) {
// With Do Not Disturb on, the system refuses volume changes
// that would toggle it unless the app has notification policy
// access. The slider goes back to the volume actually in effect.
Log.w(TAG, "Notification volume change refused", e);
seekBar.setProgress(
audioManager.getStreamVolume(
AudioManager.STREAM_NOTIFICATION));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event
}
}
}
return super.onTouchEvent(widget, buffer, event);
try {
return super.onTouchEvent(widget, buffer, event);
} catch (IndexOutOfBoundsException e) {
// In selecting mode (Shift held on a hardware keyboard) the platform extends the
// selection from the offset it recorded on the down. When the down came before
// selecting started, nothing was recorded and it selects from -1, which throws. The
// selection is left as it was rather than taking the app down.
Log.w(TAG, "Selection gesture without a recorded start", e);
return true;
}
}

private boolean isTap(TextView widget, MotionEvent up) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.pasich.mynotes.utils.editor;

import static com.google.common.truth.Truth.assertThat;

import android.app.Activity;
import android.os.SystemClock;
import android.text.Editable;
import android.text.Selection;
import android.text.method.TextKeyListener;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = {28, 35})
public class EditableLinkMovementMethodTest {

private EditText field;

@Before
public void setUp() {
Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
field = new EditText(activity);
activity.setContentView(field);
field.setText("Some note text");
field.measure(
View.MeasureSpec.makeMeasureSpec(600, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.EXACTLY));
field.layout(0, 0, 600, 400);
field.setMovementMethod(EditableLinkMovementMethod.getInstance());
field.requestFocus();
field.setSelection(3);
}

/**
* Play Console crash in 2.7.56 ({@code setSpan (-1 ... -1) starts before 0}): the down lands
* while the field is not selecting, selecting mode turns on (Shift on a hardware keyboard)
* before the up, and {@code ArrowKeyMovementMethod} then selects from a start it never
* recorded.
*/
@Test
public void upInSelectingModeWithoutARecordedDown_doesNotCrashAndKeepsTheCaret() {
Editable buffer = field.getText();
long now = SystemClock.uptimeMillis();
MotionEvent down = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, 50f, 10f, 0);
field.onTouchEvent(down);
down.recycle();
TextKeyListener.getInstance()
.onKeyDown(
field,
buffer,
KeyEvent.KEYCODE_SHIFT_LEFT,
new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT));
int caretBefore = Selection.getSelectionStart(buffer);

MotionEvent up = MotionEvent.obtain(now, now + 50, MotionEvent.ACTION_UP, 50f, 10f, 0);
boolean handled = EditableLinkMovementMethod.getInstance().onTouchEvent(field, buffer, up);
up.recycle();

assertThat(handled).isTrue();
assertThat(Selection.getSelectionStart(buffer)).isEqualTo(caretBefore);
assertThat(Selection.getSelectionEnd(buffer)).isEqualTo(caretBefore);
}
}
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
daggerHilt = '2.57.2'
daggerHilt = '2.60.1'
}

repositories {
Expand All @@ -9,15 +9,15 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:9.0.1'
classpath 'com.android.tools.build:gradle:9.5.1'
classpath "com.google.dagger:hilt-android-gradle-plugin:$daggerHilt"
}

}
plugins {
id 'com.google.dagger.hilt.android' version "$daggerHilt" apply false
id 'com.diffplug.spotless' version '8.10.1' apply false
id 'com.google.gms.google-services' version '4.4.4' apply false
id 'com.diffplug.spotless' version '8.11.0' apply false
id 'com.google.gms.google-services' version '4.6.0' apply false
}

tasks.register('clean', Delete) {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 6 additions & 9 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading