Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
10 changes: 5 additions & 5 deletions PasscodeLock/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

android {
namespace 'org.wordpress.passcodelock'
compileSdk 34
compileSdk 36

defaultConfig {
minSdk 23
Expand All @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,9 +25,11 @@ public abstract class AbstractPasscodeKeyboardActivity extends Activity {
protected InputFilter[] filters = null;
protected TextView topMessage = null;

@SuppressLint("RestrictedApi")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to avoid linter complaining for now, but tracking separately here #1734

protected FingerprintManagerCompat mFingerprintManager;
protected CancellationSignal mCancel;

@SuppressLint("RestrictedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -36,21 +39,21 @@ 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);
if (message != null) {
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
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.passcodelock;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
Expand All @@ -23,7 +24,8 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

@Override
@SuppressLint("RestrictedApi")
@Override
public void onResume() {
super.onResume();

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.wordpress.passcodelock;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;

import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
import androidx.core.os.CancellationSignal;

public class PasscodeUnlockActivity extends AbstractPasscodeKeyboardActivity {
@SuppressLint("RestrictedApi")
@Override
public void onResume() {
super.onResume();
Expand Down Expand Up @@ -39,6 +41,7 @@ protected void onPinLockInserted() {
}
}

@SuppressLint("RestrictedApi")
@Override
protected FingerprintManagerCompat.AuthenticationCallback getFingerprintCallback() {
return new FingerprintManagerCompat.AuthenticationCallback() {
Expand All @@ -59,6 +62,7 @@ public void onAuthenticationFailed() {
};
}

@SuppressLint("RestrictedApi")
private boolean isFingerprintSupportedAndEnabled() {
return mFingerprintManager.isHardwareDetected() &&
mFingerprintManager.hasEnrolledFingerprints() &&
Expand Down
66 changes: 33 additions & 33 deletions Simplenote/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def versionProperties = loadPropertiesFromFile(file("${rootDir}/version.properti

android {
namespace 'com.automattic.simplenote'
compileSdk 34
compileSdk 36

buildTypes {
debug {
Expand Down Expand Up @@ -46,9 +46,6 @@ android {
testInstrumentationRunner 'com.automattic.simplenote.SimplenoteAppRunner'
}

lintOptions {
checkReleaseBuilds false
}

testOptions {
unitTests.returnDefaultValues = true
Expand All @@ -59,16 +56,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 {
Expand All @@ -83,26 +83,26 @@ buildscript {
}

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'
exclude group: 'androidx', module: 'support-annotations'
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
Expand All @@ -116,32 +116,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"
Expand Down
13 changes: 7 additions & 6 deletions Simplenote/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
</activity>

<activity
android:name=".NotesActivity"
android:name="com.automattic.simplenote.NotesActivity"
android:configChanges="screenSize|smallestScreenSize|orientation|screenLayout"
android:label="@string/app_launcher_name"
android:resizeableActivity="true"
android:exported="true"
android:windowSoftInputMode="adjustResize|stateHidden">
android:windowSoftInputMode="adjustResize|stateHidden"
android:theme="@style/Theme.Simplestyle">

<intent-filter>

Expand Down Expand Up @@ -85,7 +86,7 @@

<data
android:host="app.simplenote.com"
android:pathPattern="/account/.*/reset?redirect=simplenote://launch"
android:pathPattern="/account/.*/reset"
android:scheme="https">
</data>

Expand Down Expand Up @@ -121,7 +122,7 @@
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="app.simplenote.com"
android:pathPattern="/account/.*/reset?redirect=simplenote://launch"
android:pathPattern="/account/.*/reset"
android:scheme="https">
</data>
</intent-filter>
Expand Down Expand Up @@ -180,11 +181,11 @@
<activity
android:name="com.automattic.simplenote.StyleActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:parentActivityName=".PreferencesActivity"></activity>
android:parentActivityName=".PreferencesActivity" />

<activity
android:name="com.automattic.simplenote.TagsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"></activity>
android:configChanges="orientation|keyboardHidden|screenSize" />

<activity
android:name="com.automattic.simplenote.DeepLinkActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ class DeepLinkActivity : AppCompatActivity() {
startActivity(intent)
}
VERIFIED_WEB_SCHEME -> {
// New MagicLink
startMagicLinkConfirmation(uri)
// Check if this is a password reset URL
if (uri.path?.contains("/account/") == true && uri.path?.contains("/reset") == true) {
handlePasswordReset(uri)
} else {
// New MagicLink
startMagicLinkConfirmation(uri)
}
}
LOGIN_SCHEME -> {
if (queryParamContainsData(uri.query, USERNAME_KEY_QUERY) && queryParamContainsData(uri.query, AUTH_CODE_QUERY)) {
Expand Down Expand Up @@ -88,6 +93,21 @@ class DeepLinkActivity : AppCompatActivity() {
}
}

private fun handlePasswordReset(uri: Uri) {
val redirectParam = uri.getQueryParameter("redirect")
if (redirectParam == "simplenote://launch") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (❓): The logic within both if/else seems the same to me, what that done on purpose? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof good catch, fixed in 2589709 - it should just launch the app when capturing a password reset link and the app is installed (this to do the same thing it was doing before, no behavior change)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the fix @mzorz , so in the end, no query parameters no nothing needed here, right? 😊

// Handle the redirect to launch the app
val intent = IntentUtils.maybeAliasedIntent(applicationContext)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
} else {
// Default behavior for reset URLs without redirect
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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ public void onPageScrollStateChanged(int state) {

@Override
public void onBackPressed() {
handleBackPressed();
super.onBackPressed();
handleBackPressed();
}

private void handleBackPressed() {
Expand All @@ -249,7 +250,7 @@ private void handleBackPressed() {

finish();
} else {
super.onBackPressed();
getOnBackPressedDispatcher().onBackPressed();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading