diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 212fa616f..931860eb7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -16,7 +16,7 @@ steps: - wait - label: ":hammer_and_pick: Build and Test" - command: ./gradlew --stacktrace testRelease + command: ./gradlew --stacktrace testDebugUnitTest plugins: [$CI_TOOLKIT_PLUGIN] notify: - github_commit_status: @@ -36,7 +36,7 @@ steps: context: Danger - PR Check - label: ":microscope: Lint" - command: ./gradlew --stacktrace lintRelease + command: ./gradlew --stacktrace lintDebug plugins: [$CI_TOOLKIT_PLUGIN] notify: - github_commit_status: diff --git a/.java-version b/.java-version index 7f83a844e..5f39e9144 100644 --- a/.java-version +++ b/.java-version @@ -1 +1 @@ -17.0 \ No newline at end of file +21.0 diff --git a/PasscodeLock/build.gradle b/PasscodeLock/build.gradle index e19012618..801bcf863 100644 --- a/PasscodeLock/build.gradle +++ b/PasscodeLock/build.gradle @@ -12,7 +12,7 @@ plugins { android { namespace 'org.wordpress.passcodelock' - compileSdk 34 + compileSdk 36 defaultConfig { minSdk 23 @@ -28,14 +28,14 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } } dependencies { - implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'androidx.preference:preference:1.0.0' + implementation 'androidx.appcompat:appcompat:1.7.1' + implementation 'androidx.preference:preference:1.2.1' } android.buildTypes.all { buildType -> diff --git a/PasscodeLock/consumer-rules.pro b/PasscodeLock/consumer-rules.pro deleted file mode 100644 index e69de29bb..000000000 diff --git a/PasscodeLock/src/main/java/org/wordpress/passcodelock/AbstractPasscodeKeyboardActivity.java b/PasscodeLock/src/main/java/org/wordpress/passcodelock/AbstractPasscodeKeyboardActivity.java index 5e37cc32c..5fcb7cf66 100644 --- a/PasscodeLock/src/main/java/org/wordpress/passcodelock/AbstractPasscodeKeyboardActivity.java +++ b/PasscodeLock/src/main/java/org/wordpress/passcodelock/AbstractPasscodeKeyboardActivity.java @@ -1,5 +1,6 @@ package org.wordpress.passcodelock; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.pm.ActivityInfo; import android.os.Bundle; @@ -24,9 +25,11 @@ public abstract class AbstractPasscodeKeyboardActivity extends Activity { protected InputFilter[] filters = null; protected TextView topMessage = null; + @SuppressLint("RestrictedApi") protected FingerprintManagerCompat mFingerprintManager; protected CancellationSignal mCancel; + @SuppressLint("RestrictedApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -36,9 +39,9 @@ protected void onCreate(Bundle savedInstanceState) { } setContentView(R.layout.app_passcode_keyboard); - + topMessage = (TextView) findViewById(R.id.passcodelock_prompt); - + Bundle extras = getIntent().getExtras(); if (extras != null) { String message = extras.getString(KEY_MESSAGE); @@ -46,11 +49,11 @@ protected void onCreate(Bundle savedInstanceState) { topMessage.setText(message); } } - + filters = new InputFilter[2]; filters[0]= new InputFilter.LengthFilter(1); filters[1] = onlyNumber; - + mPinCodeField = (EditText)findViewById(R.id.pin_field); //setup the keyboard @@ -158,8 +161,9 @@ public void run() { protected void showPasswordError(){ Toast.makeText(AbstractPasscodeKeyboardActivity.this, R.string.passcode_wrong_passcode, Toast.LENGTH_SHORT).show(); } - + protected abstract void onPinLockInserted(); + @SuppressLint("RestrictedApi") protected abstract FingerprintManagerCompat.AuthenticationCallback getFingerprintCallback(); private InputFilter onlyNumber = new InputFilter() { diff --git a/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeManagePasswordActivity.java b/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeManagePasswordActivity.java index f8d5485c2..563294851 100644 --- a/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeManagePasswordActivity.java +++ b/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeManagePasswordActivity.java @@ -1,5 +1,6 @@ package org.wordpress.passcodelock; +import android.annotation.SuppressLint; import android.os.Bundle; import android.view.View; import android.widget.TextView; @@ -23,7 +24,8 @@ protected void onCreate(Bundle savedInstanceState) { } } - @Override + @SuppressLint("RestrictedApi") + @Override public void onResume() { super.onResume(); @@ -73,13 +75,14 @@ protected void onPinLockInserted() { type = PasscodePreferenceFragment.ENABLE_PASSLOCK; } else { authenticationFailed(); - } + } break; default: break; } } + @SuppressLint("RestrictedApi") @Override protected FingerprintManagerCompat.AuthenticationCallback getFingerprintCallback() { return new FingerprintManagerCompat.AuthenticationCallback() { diff --git a/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeUnlockActivity.java b/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeUnlockActivity.java index bc1bc7e2e..1cbe49599 100644 --- a/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeUnlockActivity.java +++ b/PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeUnlockActivity.java @@ -1,5 +1,6 @@ package org.wordpress.passcodelock; +import android.annotation.SuppressLint; import android.content.Intent; import android.view.View; @@ -7,6 +8,7 @@ import androidx.core.os.CancellationSignal; public class PasscodeUnlockActivity extends AbstractPasscodeKeyboardActivity { + @SuppressLint("RestrictedApi") @Override public void onResume() { super.onResume(); @@ -39,6 +41,7 @@ protected void onPinLockInserted() { } } + @SuppressLint("RestrictedApi") @Override protected FingerprintManagerCompat.AuthenticationCallback getFingerprintCallback() { return new FingerprintManagerCompat.AuthenticationCallback() { @@ -59,6 +62,7 @@ public void onAuthenticationFailed() { }; } + @SuppressLint("RestrictedApi") private boolean isFingerprintSupportedAndEnabled() { return mFingerprintManager.isHardwareDetected() && mFingerprintManager.hasEnrolledFingerprints() && diff --git a/Simplenote/build.gradle b/Simplenote/build.gradle index 0945c8ef2..a747821b6 100644 --- a/Simplenote/build.gradle +++ b/Simplenote/build.gradle @@ -8,7 +8,7 @@ def versionProperties = loadPropertiesFromFile(file("${rootDir}/version.properti android { namespace 'com.automattic.simplenote' - compileSdk 34 + compileSdk 36 buildTypes { debug { @@ -42,13 +42,8 @@ android { minSdkVersion 23 targetSdkVersion 34 - - testInstrumentationRunner 'com.automattic.simplenote.SimplenoteAppRunner' } - lintOptions { - checkReleaseBuilds false - } testOptions { unitTests.returnDefaultValues = true @@ -59,16 +54,19 @@ android { // Target Java8 to avoid use certain Kotlin's features compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + jvmTarget = JavaVersion.VERSION_11.toString() } viewBinding { enabled = true } + lint { + checkReleaseBuilds false + } } buildscript { @@ -78,21 +76,21 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } } dependencies { - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:4.0.0' - testImplementation 'org.mockito:mockito-inline:4.0.0' - androidTestImplementation 'androidx.test:core:1.3.0' - androidTestImplementation 'androidx.annotation:annotation:1.0.0' - androidTestImplementation 'androidx.test:runner:1.3.0' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' - androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0' - androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0') { + testImplementation 'junit:junit:4.13.2' + testImplementation 'org.mockito:mockito-core:5.18.0' + testImplementation 'org.mockito:mockito-inline:5.2.0' + androidTestImplementation 'androidx.test:core:1.7.0' + androidTestImplementation 'androidx.annotation:annotation:1.9.1' + androidTestImplementation 'androidx.test:runner:1.7.0' + androidTestImplementation 'androidx.test:rules:1.7.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0' + androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.7.0' + androidTestImplementation('androidx.test.espresso:espresso-contrib:3.7.0') { // Necessary to avoid version conflicts exclude group: 'androidx', module: 'appcompat' exclude group: 'androidx', module: 'support-v4' @@ -100,9 +98,9 @@ dependencies { exclude module: 'recyclerview-v7' } // Infrastructure to test fragments - testImplementation "androidx.arch.core:core-testing:2.1.0" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3" - testImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0" + testImplementation "androidx.arch.core:core-testing:2.2.0" + testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2" + testImplementation "org.mockito.kotlin:mockito-kotlin:6.0.0" // Support for JsonObjects in unit tests since they are used by BucketObjects @@ -116,32 +114,32 @@ dependencies { implementation "com.automattic.tracks:crashlogging:$automatticTracksVersion" // Kotlin's coroutines - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2' // Google Support - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'com.google.android.material:material:1.1.0-beta01' - implementation 'androidx.vectordrawable:vectordrawable:1.1.0' - implementation 'androidx.preference:preference:1.1.0' + implementation 'androidx.appcompat:appcompat:1.7.1' + implementation 'com.google.android.material:material:1.12.0' + implementation 'androidx.vectordrawable:vectordrawable:1.2.0' + implementation 'androidx.preference:preference:1.2.1' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' - implementation 'androidx.work:work-runtime:2.7.1' - implementation 'androidx.concurrent:concurrent-futures:1.1.0' - implementation "androidx.constraintlayout:constraintlayout:1.1.3" + implementation 'androidx.work:work-runtime:2.10.3' + implementation 'androidx.concurrent:concurrent-futures:1.3.0' + implementation "androidx.constraintlayout:constraintlayout:2.2.1" implementation "androidx.multidex:multidex:2.0.1" // Support for ViewModels and LiveData - implementation "androidx.activity:activity-ktx:1.3.1" - implementation "androidx.fragment:fragment-ktx:1.3.6" + implementation "androidx.activity:activity-ktx:1.10.1" + implementation "androidx.fragment:fragment-ktx:1.8.8" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$androidxLifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$androidxLifecycleVersion" // Support for androidx Fragments implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$androidxLifecycleVersion" // Google Play Services - implementation 'com.google.android.gms:play-services-wearable:17.0.0' + implementation 'com.google.android.gms:play-services-wearable:19.0.0' // Third Party - implementation 'com.squareup.okhttp3:okhttp:3.12.0' + implementation 'com.squareup.okhttp3:okhttp:5.1.0' implementation 'com.commonsware.cwac:anddown:0.4.0' - implementation 'net.openid:appauth:0.7.0' + implementation 'net.openid:appauth:0.11.1' // Dagger Hilt dependencies implementation "com.google.dagger:hilt-android:$google_dagger" @@ -162,7 +160,7 @@ repositories { } maven { url "https://maven.google.com" } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } - jcenter() + mavenCentral() maven { url 'https://jitpack.io' content { diff --git a/Simplenote/src/main/AndroidManifest.xml b/Simplenote/src/main/AndroidManifest.xml index 5dca92779..012095aea 100644 --- a/Simplenote/src/main/AndroidManifest.xml +++ b/Simplenote/src/main/AndroidManifest.xml @@ -41,12 +41,13 @@ + android:windowSoftInputMode="adjustResize|stateHidden" + android:theme="@style/Theme.Simplestyle"> @@ -85,7 +86,7 @@ @@ -121,7 +122,7 @@ @@ -180,11 +181,11 @@ + android:parentActivityName=".PreferencesActivity" /> + android:configChanges="orientation|keyboardHidden|screenSize" /> { - // New MagicLink - startMagicLinkConfirmation(uri) + // Check if this is a password reset URL + if (uri.path?.contains("/account/") == true && uri.path?.contains("/reset") == true) { + // launch the app if they tapped on a password reset link on app.simplenote.com + handlePasswordReset() + } else { + // New MagicLink + startMagicLinkConfirmation(uri) + } } LOGIN_SCHEME -> { if (queryParamContainsData(uri.query, USERNAME_KEY_QUERY) && queryParamContainsData(uri.query, AUTH_CODE_QUERY)) { @@ -88,6 +94,12 @@ class DeepLinkActivity : AppCompatActivity() { } } + private fun handlePasswordReset() { + val intent = IntentUtils.maybeAliasedIntent(applicationContext) + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) + startActivity(intent) + } + private fun queryParamContainsData(path: String?, otherString: String) : Boolean = path?.contains(otherString, true) == true diff --git a/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorActivity.java b/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorActivity.java index e0252846d..e7338d8d8 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorActivity.java +++ b/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorActivity.java @@ -234,7 +234,8 @@ public void onPageScrollStateChanged(int state) { @Override public void onBackPressed() { - handleBackPressed(); + super.onBackPressed(); + handleBackPressed(); } private void handleBackPressed() { @@ -249,7 +250,7 @@ private void handleBackPressed() { finish(); } else { - super.onBackPressed(); + getOnBackPressedDispatcher().onBackPressed(); } } diff --git a/Simplenote/src/main/java/com/automattic/simplenote/NoteListFragment.java b/Simplenote/src/main/java/com/automattic/simplenote/NoteListFragment.java index f58d8d60a..1bbb67858 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/NoteListFragment.java +++ b/Simplenote/src/main/java/com/automattic/simplenote/NoteListFragment.java @@ -399,7 +399,7 @@ public boolean onLongClick(View v) { mList = view.findViewById(android.R.id.list); - mNotesAdapter = new NotesCursorAdapter(requireActivity().getBaseContext(), null, 0); + mNotesAdapter = new NotesCursorAdapter(requireContext(), null, 0); setListAdapter(mNotesAdapter); getListView().setOnItemLongClickListener(this); @@ -935,7 +935,7 @@ public View getView(final int position, View view, ViewGroup parent) { final NoteViewHolder holder; if (view == null) { - view = View.inflate(requireActivity().getBaseContext(), R.layout.note_list_row, null); + view = View.inflate(requireContext(), R.layout.note_list_row, null); holder = new NoteViewHolder(); holder.mTitle = view.findViewById(R.id.note_title); holder.mContent = view.findViewById(R.id.note_content); diff --git a/Simplenote/src/main/java/com/automattic/simplenote/authentication/NewCredentialsActivity.kt b/Simplenote/src/main/java/com/automattic/simplenote/authentication/NewCredentialsActivity.kt index f92c54062..4b47e4f0d 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/authentication/NewCredentialsActivity.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/authentication/NewCredentialsActivity.kt @@ -90,6 +90,7 @@ open class NewCredentialsActivity : AppCompatActivity() { } override fun onBackPressed() { + super.onBackPressed() this.startActivity(Intent(this, SimplenoteAuthenticationActivity::class.java)) finish() } diff --git a/Simplenote/src/main/java/com/automattic/simplenote/widgets/SimplenoteEditText.java b/Simplenote/src/main/java/com/automattic/simplenote/widgets/SimplenoteEditText.java index cf63c105c..667cb9f5e 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/widgets/SimplenoteEditText.java +++ b/Simplenote/src/main/java/com/automattic/simplenote/widgets/SimplenoteEditText.java @@ -73,6 +73,13 @@ public boolean enoughToFilter() { return false; } + // solves a crash after updating dependencies in which this method + // gets called in super() instantiation before the mTokenizer variable + // is instantiated + if (mTokenizer == null) { + return false; + } + int start = mTokenizer.findTokenStart(text, end); return start > 0 && end - start >= 1; } diff --git a/Simplenote/src/main/res/layout-large-land/fragment_note_editor.xml b/Simplenote/src/main/res/layout-large-land/fragment_note_editor.xml index 8bdf02f01..1bae1afd4 100644 --- a/Simplenote/src/main/res/layout-large-land/fragment_note_editor.xml +++ b/Simplenote/src/main/res/layout-large-land/fragment_note_editor.xml @@ -2,6 +2,7 @@ - + tools:context=".NoteEditorFragment"/> @@ -75,14 +75,12 @@ android:layout_width="wrap_content" android:paddingBottom="@dimen/padding_small" android:paddingTop="@dimen/padding_small" - android:visibility="gone"> - + android:visibility="gone"/> - + android:layout_width="@dimen/padding_small"/> - + android:textSize="@dimen/text_tag"/> @@ -124,7 +121,7 @@ android:layout_height="@dimen/logo_empty" android:layout_width="@dimen/logo_empty" android:src="@drawable/ic_simplenote_24dp" - android:tint="?attr/emptyImageColor"> + app:tint="?attr/emptyImageColor"> diff --git a/Simplenote/src/main/res/layout/activity_note_editor.xml b/Simplenote/src/main/res/layout/activity_note_editor.xml index c8ebed59e..bc7c47c8c 100644 --- a/Simplenote/src/main/res/layout/activity_note_editor.xml +++ b/Simplenote/src/main/res/layout/activity_note_editor.xml @@ -78,7 +78,7 @@ android:minWidth="@dimen/minimum_target" android:padding="@dimen/padding_large" android:src="@drawable/ic_chevron_left_24dp" - android:tint="@color/toolbar_icon_alpha_40_selector" + app:tint="@color/toolbar_icon_alpha_40_selector" android:tintMode="src_in"> @@ -132,7 +132,7 @@ android:minWidth="@dimen/minimum_target" android:padding="@dimen/padding_large" android:src="@drawable/ic_chevron_right_24dp" - android:tint="@color/toolbar_icon_alpha_40_selector" + app:tint="@color/toolbar_icon_alpha_40_selector" android:tintMode="src_in"> diff --git a/Simplenote/src/main/res/layout/collaborator_row.xml b/Simplenote/src/main/res/layout/collaborator_row.xml index dd4ef5dd1..81007731e 100644 --- a/Simplenote/src/main/res/layout/collaborator_row.xml +++ b/Simplenote/src/main/res/layout/collaborator_row.xml @@ -2,6 +2,7 @@ + app:tint="?attr/notePreviewColor"> diff --git a/Simplenote/src/main/res/layout/empty_view.xml b/Simplenote/src/main/res/layout/empty_view.xml index dee1fa3c3..f20b827ce 100644 --- a/Simplenote/src/main/res/layout/empty_view.xml +++ b/Simplenote/src/main/res/layout/empty_view.xml @@ -2,6 +2,7 @@ + app:tint="?attr/emptyImageColor"> + app:tint="?attr/emptyImageColor" /> - + tools:context=".NoteEditorFragment"/> @@ -75,14 +75,12 @@ android:layout_width="wrap_content" android:paddingBottom="@dimen/padding_small" android:paddingTop="@dimen/padding_small" - android:visibility="gone"> - + android:visibility="gone"> - + android:layout_width="@dimen/padding_small"> - + android:textSize="@dimen/text_tag"> @@ -122,7 +119,7 @@ android:layout_height="@dimen/logo_empty" android:layout_width="@dimen/logo_empty" android:src="@drawable/logo_login" - android:tint="?attr/emptyImageColor"> + app:tint="?attr/emptyImageColor"> diff --git a/Simplenote/src/main/res/layout/fragment_note_error.xml b/Simplenote/src/main/res/layout/fragment_note_error.xml index 790c55262..1ba5047c1 100644 --- a/Simplenote/src/main/res/layout/fragment_note_error.xml +++ b/Simplenote/src/main/res/layout/fragment_note_error.xml @@ -2,6 +2,7 @@ + app:tint="?attr/emptyImageColor"> + app:tint="?attr/toolbarIconColor"> - + tools:text="Oct 21"/> @@ -61,8 +61,8 @@ android:layout_toEndOf="@id/note_shared" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_publish_16dp" - android:tint="?attr/notePreviewColor" android:visibility="gone" + app:tint="?attr/notePreviewColor" tools:tint="@color/text_content_light" tools:visibility="visible"> @@ -76,8 +76,8 @@ android:layout_marginStart="@dimen/padding_small" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_collaborate_16dp" - android:tint="?attr/notePreviewColor" android:visibility="gone" + app:tint="?attr/notePreviewColor" tools:tint="@color/text_content_light" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/note_list_widget_dark_black.xml b/Simplenote/src/main/res/layout/note_list_widget_dark_black.xml index 53090977c..544eae02f 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_dark_black.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_dark_black.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_dark_classic.xml b/Simplenote/src/main/res/layout/note_list_widget_dark_classic.xml index 9afec817c..4bba97cbd 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_dark_classic.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_dark_classic.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_dark_default.xml b/Simplenote/src/main/res/layout/note_list_widget_dark_default.xml index 60ecd48b7..09b908c19 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_dark_default.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_dark_default.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_dark_matrix.xml b/Simplenote/src/main/res/layout/note_list_widget_dark_matrix.xml index dee415fe2..25d8c6f81 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_dark_matrix.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_dark_matrix.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_dark_mono.xml b/Simplenote/src/main/res/layout/note_list_widget_dark_mono.xml index 7dcb30a54..c184f303c 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_dark_mono.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_dark_mono.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_dark_publication.xml b/Simplenote/src/main/res/layout/note_list_widget_dark_publication.xml index da713c9b2..67e5bb792 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_dark_publication.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_dark_publication.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_dark_sepia.xml b/Simplenote/src/main/res/layout/note_list_widget_dark_sepia.xml index c5d9881ee..99cd9a0e5 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_dark_sepia.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_dark_sepia.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_item_dark.xml b/Simplenote/src/main/res/layout/note_list_widget_item_dark.xml index 7177af09a..9bc4ad8d5 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_item_dark.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_item_dark.xml @@ -2,6 +2,7 @@ @@ -47,7 +48,7 @@ android:layout_marginStart="@dimen/padding_small" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_publish_16dp" - android:tint="@color/text_content_dark" + app:tint="@color/text_content_dark" android:visibility="gone" tools:tint="@color/text_content_dark" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/note_list_widget_item_dark_monospace.xml b/Simplenote/src/main/res/layout/note_list_widget_item_dark_monospace.xml index 9ad07f348..9ed6010c4 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_item_dark_monospace.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_item_dark_monospace.xml @@ -2,6 +2,7 @@ @@ -47,7 +48,7 @@ android:layout_marginStart="@dimen/padding_small" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_publish_16dp" - android:tint="@color/text_content_dark" + app:tint="@color/text_content_dark" android:visibility="gone" tools:tint="@color/text_content_dark" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/note_list_widget_item_dark_serif.xml b/Simplenote/src/main/res/layout/note_list_widget_item_dark_serif.xml index a856b1f73..cb04f0828 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_item_dark_serif.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_item_dark_serif.xml @@ -2,6 +2,7 @@ @@ -47,7 +48,7 @@ android:layout_marginStart="@dimen/padding_small" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_publish_16dp" - android:tint="@color/text_content_dark" + app:tint="@color/text_content_dark" android:visibility="gone" tools:tint="@color/text_content_dark" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/note_list_widget_item_light.xml b/Simplenote/src/main/res/layout/note_list_widget_item_light.xml index b644a9317..0ec00b3c8 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_item_light.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_item_light.xml @@ -2,6 +2,7 @@ @@ -47,7 +48,7 @@ android:layout_marginStart="@dimen/padding_small" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_publish_16dp" - android:tint="@color/text_content_light" + app:tint="@color/text_content_light" android:visibility="gone" tools:tint="@color/text_content_light" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/note_list_widget_item_light_monospace.xml b/Simplenote/src/main/res/layout/note_list_widget_item_light_monospace.xml index fdf1904f0..62120efaa 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_item_light_monospace.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_item_light_monospace.xml @@ -2,6 +2,7 @@ @@ -47,7 +48,7 @@ android:layout_marginStart="@dimen/padding_small" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_publish_16dp" - android:tint="@color/text_content_light" + app:tint="@color/text_content_light" android:visibility="gone" tools:tint="@color/text_content_light" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/note_list_widget_item_light_serif.xml b/Simplenote/src/main/res/layout/note_list_widget_item_light_serif.xml index 90cfaa348..e7d01160d 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_item_light_serif.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_item_light_serif.xml @@ -2,6 +2,7 @@ @@ -47,7 +48,7 @@ android:layout_marginStart="@dimen/padding_small" android:layout_width="@dimen/icon_status" android:src="@drawable/ic_publish_16dp" - android:tint="@color/text_content_light" + app:tint="@color/text_content_light" android:visibility="gone" tools:tint="@color/text_content_light" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/note_list_widget_light_black.xml b/Simplenote/src/main/res/layout/note_list_widget_light_black.xml index f852962ff..320711527 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_light_black.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_light_black.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_light_classic.xml b/Simplenote/src/main/res/layout/note_list_widget_light_classic.xml index 95c61f387..891064f3a 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_light_classic.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_light_classic.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_light_default.xml b/Simplenote/src/main/res/layout/note_list_widget_light_default.xml index 9c9af1b99..e34f62123 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_light_default.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_light_default.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_light_matrix.xml b/Simplenote/src/main/res/layout/note_list_widget_light_matrix.xml index d1627f643..d1a13b2a7 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_light_matrix.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_light_matrix.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_light_mono.xml b/Simplenote/src/main/res/layout/note_list_widget_light_mono.xml index ca71e3f30..64bf9a8e4 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_light_mono.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_light_mono.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_light_publication.xml b/Simplenote/src/main/res/layout/note_list_widget_light_publication.xml index 2d05b45da..736eb068c 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_light_publication.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_light_publication.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/note_list_widget_light_sepia.xml b/Simplenote/src/main/res/layout/note_list_widget_light_sepia.xml index d3de5b2aa..3e785900c 100644 --- a/Simplenote/src/main/res/layout/note_list_widget_light_sepia.xml +++ b/Simplenote/src/main/res/layout/note_list_widget_light_sepia.xml @@ -2,6 +2,7 @@ diff --git a/Simplenote/src/main/res/layout/search_suggestion.xml b/Simplenote/src/main/res/layout/search_suggestion.xml index 158ec31c3..8e4519297 100644 --- a/Simplenote/src/main/res/layout/search_suggestion.xml +++ b/Simplenote/src/main/res/layout/search_suggestion.xml @@ -2,6 +2,7 @@ @@ -49,7 +50,7 @@ android:minWidth="@dimen/minimum_target" android:padding="@dimen/padding_medium" android:src="@drawable/ic_cross_24dp" - android:tint="?attr/toolbarIconColor"> + app:tint="?attr/toolbarIconColor"> diff --git a/Simplenote/src/main/res/layout/style_list_row_black.xml b/Simplenote/src/main/res/layout/style_list_row_black.xml index a7941f132..f1e03256d 100644 --- a/Simplenote/src/main/res/layout/style_list_row_black.xml +++ b/Simplenote/src/main/res/layout/style_list_row_black.xml @@ -60,7 +60,7 @@ android:layout_width="@dimen/icon_locked" android:padding="@dimen/padding_medium" android:src="@drawable/ic_lock_24dp" - android:tint="@color/style_locked_icon" + app:tint="@color/style_locked_icon" android:visibility="gone" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/style_list_row_default.xml b/Simplenote/src/main/res/layout/style_list_row_default.xml index a97f8479c..726a703c0 100644 --- a/Simplenote/src/main/res/layout/style_list_row_default.xml +++ b/Simplenote/src/main/res/layout/style_list_row_default.xml @@ -60,7 +60,7 @@ android:layout_width="@dimen/icon_locked" android:padding="@dimen/padding_medium" android:src="@drawable/ic_lock_24dp" - android:tint="@color/style_locked_icon" + app:tint="@color/style_locked_icon" android:visibility="gone" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/style_list_row_matrix.xml b/Simplenote/src/main/res/layout/style_list_row_matrix.xml index c98c2754b..22b8aabbf 100644 --- a/Simplenote/src/main/res/layout/style_list_row_matrix.xml +++ b/Simplenote/src/main/res/layout/style_list_row_matrix.xml @@ -64,7 +64,7 @@ android:layout_width="@dimen/icon_locked" android:padding="@dimen/padding_medium" android:src="@drawable/ic_lock_24dp" - android:tint="@color/style_locked_icon" + app:tint="@color/style_locked_icon" android:visibility="gone" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/style_list_row_mono.xml b/Simplenote/src/main/res/layout/style_list_row_mono.xml index 91dac255f..124de3386 100644 --- a/Simplenote/src/main/res/layout/style_list_row_mono.xml +++ b/Simplenote/src/main/res/layout/style_list_row_mono.xml @@ -62,7 +62,7 @@ android:layout_width="@dimen/icon_locked" android:padding="@dimen/padding_medium" android:src="@drawable/ic_lock_24dp" - android:tint="@color/style_locked_icon" + app:tint="@color/style_locked_icon" android:visibility="gone" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/style_list_row_publication.xml b/Simplenote/src/main/res/layout/style_list_row_publication.xml index e76223907..9abd8678a 100644 --- a/Simplenote/src/main/res/layout/style_list_row_publication.xml +++ b/Simplenote/src/main/res/layout/style_list_row_publication.xml @@ -62,7 +62,7 @@ android:layout_width="@dimen/icon_locked" android:padding="@dimen/padding_medium" android:src="@drawable/ic_lock_24dp" - android:tint="@color/style_locked_icon" + app:tint="@color/style_locked_icon" android:visibility="gone" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/style_list_row_sepia.xml b/Simplenote/src/main/res/layout/style_list_row_sepia.xml index d9ce4bb18..cc84553cc 100644 --- a/Simplenote/src/main/res/layout/style_list_row_sepia.xml +++ b/Simplenote/src/main/res/layout/style_list_row_sepia.xml @@ -60,7 +60,7 @@ android:layout_width="@dimen/icon_locked" android:padding="@dimen/padding_medium" android:src="@drawable/ic_lock_24dp" - android:tint="@color/style_locked_icon" + app:tint="@color/style_locked_icon" android:visibility="gone" tools:visibility="visible"> diff --git a/Simplenote/src/main/res/layout/tags_list_row.xml b/Simplenote/src/main/res/layout/tags_list_row.xml index f05bef1c6..dbbdeaccd 100644 --- a/Simplenote/src/main/res/layout/tags_list_row.xml +++ b/Simplenote/src/main/res/layout/tags_list_row.xml @@ -2,6 +2,7 @@ + app:tint="?attr/iconTintColor"> diff --git a/Simplenote/src/main/res/values/styles.xml b/Simplenote/src/main/res/values/styles.xml index 1216389d7..baa1f5761 100644 --- a/Simplenote/src/main/res/values/styles.xml +++ b/Simplenote/src/main/res/values/styles.xml @@ -592,7 +592,7 @@ @color/background_light_sepia - diff --git a/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/CollaboratorsViewModelTest.kt b/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/CollaboratorsViewModelTest.kt index 7b35900c3..00b5e0e49 100644 --- a/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/CollaboratorsViewModelTest.kt +++ b/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/CollaboratorsViewModelTest.kt @@ -144,16 +144,26 @@ class CollaboratorsViewModelTest { @Test fun collaboratorAddedAfterStoppedListeningChangesShouldNotUpdateUiState() = runTest { + // Load collaborators and capture initial state viewModel.loadCollaborators(noteId) + val initialState = viewModel.uiState.value + + // Mock the flow to not emit anything initially + whenever(mockCollaboratorsRepository.collaboratorsChanged(noteId)).thenReturn(flow { /* no emission */ }) + + // Start and then stop listening to changes viewModel.startListeningChanges() viewModel.stopListeningChanges() + // Now mock the flow to emit changes and mock getCollaborators to return a different list + // This simulates collaborators being added after we stopped listening whenever(mockCollaboratorsRepository.collaboratorsChanged(noteId)).thenReturn(flow { emit(true) }) - val expectedList = listOf("test@emil.com", "name@example.co.jp") + val newList = listOf("test@emil.com", "name@example.co.jp", "new@email.com") whenever(mockCollaboratorsRepository.getCollaborators(noteId)) - .thenReturn(CollaboratorsActionResult.CollaboratorsList(expectedList)) + .thenReturn(CollaboratorsActionResult.CollaboratorsList(newList)) - assertEquals(UiState.CollaboratorsList(expectedList), viewModel.uiState.value) + // Since we stopped listening, the UI state should remain the same as the initial state + assertEquals(initialState, viewModel.uiState.value) } @Test diff --git a/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/TagDialogViewModelTest.kt b/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/TagDialogViewModelTest.kt index f17a24842..94a90fe6a 100644 --- a/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/TagDialogViewModelTest.kt +++ b/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/TagDialogViewModelTest.kt @@ -16,8 +16,8 @@ import org.junit.Assert.* import org.junit.Before import org.junit.Rule import org.junit.Test -import org.mockito.Mockito.`when` import org.mockito.Mockito.mock +import org.mockito.kotlin.whenever @ExperimentalCoroutinesApi class TagDialogViewModelTest { @@ -85,8 +85,8 @@ class TagDialogViewModelTest { @Test fun validateTagIsCollaborator() { val tagName = "tag1@email.com" - `when`(fakeTagsRepository.isTagValid(tagName)).thenReturn(true) - `when`(fakeTagsRepository.isTagMissing(tagName)).thenReturn(true) + whenever(fakeTagsRepository.isTagValid(tagName)).thenReturn(true) + whenever(fakeTagsRepository.isTagMissing(tagName)).thenReturn(true) viewModel.updateUiState(tagName) @@ -96,8 +96,8 @@ class TagDialogViewModelTest { @Test fun validateValidTag() { val hewTagName = "tag2" - `when`(fakeTagsRepository.isTagValid(hewTagName)).thenReturn(true) - `when`(fakeTagsRepository.isTagConflict(hewTagName, tagName)).thenReturn(false) + whenever(fakeTagsRepository.isTagValid(hewTagName)).thenReturn(true) + whenever(fakeTagsRepository.isTagConflict(hewTagName, tagName)).thenReturn(false) viewModel.updateUiState(hewTagName) @@ -117,8 +117,8 @@ class TagDialogViewModelTest { fun editTagWithNewName() { val newTagName = "tag2" viewModel.updateUiState(newTagName) - `when`(fakeTagsRepository.isTagConflict(newTagName, tagName)).thenReturn(false) - `when`(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(true) + whenever(fakeTagsRepository.isTagConflict(newTagName, tagName)).thenReturn(false) + whenever(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(true) viewModel.renameTagIfValid() @@ -130,8 +130,8 @@ class TagDialogViewModelTest { fun editTagWithConflict() { val newTagName = "tag2" viewModel.updateUiState(newTagName) - `when`(fakeTagsRepository.isTagConflict(newTagName, tagName)).thenReturn(true) - `when`(fakeTagsRepository.getCanonicalTagName(newTagName)).thenReturn(newTagName) + whenever(fakeTagsRepository.isTagConflict(newTagName, tagName)).thenReturn(true) + whenever(fakeTagsRepository.getCanonicalTagName(newTagName)).thenReturn(newTagName) viewModel.renameTagIfValid() @@ -145,8 +145,8 @@ class TagDialogViewModelTest { fun editTagWithError() { val newTagName = "tag2" viewModel.updateUiState(newTagName) - `when`(fakeTagsRepository.isTagConflict(newTagName, tagName)).thenReturn(false) - `when`(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(false) + whenever(fakeTagsRepository.isTagConflict(newTagName, tagName)).thenReturn(false) + whenever(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(false) viewModel.renameTagIfValid() @@ -158,7 +158,7 @@ class TagDialogViewModelTest { fun renameTagValid() { val newTagName = "tag2" viewModel.updateUiState(newTagName) - `when`(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(true) + whenever(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(true) viewModel.renameTag() @@ -170,7 +170,7 @@ class TagDialogViewModelTest { fun renameTagError() { val newTagName = "tag2" viewModel.updateUiState(newTagName) - `when`(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(false) + whenever(fakeTagsRepository.renameTag(newTagName, tag)).thenReturn(false) viewModel.renameTag() diff --git a/Wear/build.gradle b/Wear/build.gradle index bf22b43a7..dee8b2523 100644 --- a/Wear/build.gradle +++ b/Wear/build.gradle @@ -1,14 +1,14 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } } apply plugin: 'com.android.application' android { namespace 'com.automattic.simplenote' - compileSdk 34 + compileSdk 36 buildTypes { release { @@ -28,14 +28,14 @@ android { } dependencies { - compileOnly 'androidx.wear:wear:1.0.0' + compileOnly 'androidx.wear:wear:1.3.0' - implementation 'androidx.wear:wear:1.0.0' - implementation 'com.google.android.gms:play-services-wearable:17.0.0' + implementation 'androidx.wear:wear:1.3.0' + implementation 'com.google.android.gms:play-services-wearable:19.0.0' } repositories { - jcenter() + mavenCentral() maven { url "https://maven.google.com" } diff --git a/build.gradle b/build.gradle index 085624a1a..06d2258ef 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.9.25' - ext.google_dagger = '2.52' + ext.kotlin_version = '2.2.0' + ext.google_dagger = '2.57' repositories { maven { @@ -12,14 +12,14 @@ buildscript { } } google() - jcenter() + mavenCentral() maven { url 'https://maven.google.com' } } dependencies { - classpath 'com.android.tools.build:gradle:8.2.1' + classpath 'com.android.tools.build:gradle:8.11.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.dagger:hilt-android-gradle-plugin:$google_dagger" - classpath 'com.automattic.android:configure:0.6.1' + classpath 'com.automattic.android:configure:0.6.5' } } @@ -68,7 +68,7 @@ ext { sentryVersion = '5.8.0' automatticTracksVersion = '6.0.4' - androidxLifecycleVersion = '2.5.1' + androidxLifecycleVersion = '2.9.2' screengrabVersion = '2.1.1' } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2..1b33c55ba 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 15de90249..dbc089ed3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,8 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionSha256Sum=ed1a8d686605fd7c23bdf62c7fc7add1c5b23b2bbc3721e661934ef4a4911d7c +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c78733..23d15a936 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f93..5eed7ee84 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal