Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom icon preference for sustainers #1645

Merged
merged 7 commits into from
Apr 9, 2024
Merged

Conversation

roundhill
Copy link
Contributor

@roundhill roundhill commented Apr 4, 2024

Fix

This PR adds a new preference in the settings for sustainers to set a green app icon:

Changing the icon is kind of a pain on Android involving activity-alias to use a different drawable for the (gulp) main activity. From my testing it is working pretty well but does crash the app when you swap out the activities.

I also couldn't get the "New Note" shortcut to work, so just left that out when switching to the activity-alias.

Test

  • On a non-sustainer account, launch the app. You should see no sustainer icon setting in the preferences view and the app should work normally.
  • Switch to a sustainer account, you can run this code to make yourself a sustainer:
long now = System.currentTimeMillis();
try {
    Preferences preferences = mPreferencesBucket.get(Preferences.PREFERENCES_OBJECT_KEY);
    preferences.setActiveSubscription(now);
} catch (BucketObjectMissingException e) {
    throw new RuntimeException(e);
}
  • The sustainer icon preference should be in the settings.
  • Flip the switch! The app should close and you'll see the green icon.
  • Verify tapping the icon works and that you can still share content from other apps to Simplenote.

Release

These changes do not require release notes.

@dangermattic
Copy link
Collaborator

dangermattic commented Apr 4, 2024

1 Error
🚫 Please add tests for class IntentUtils (or add unit-tests-exemption label to ignore this).
2 Warnings
⚠️ strings.xml files should only be updated on release branches, when the translations are downloaded by our automation.
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@roundhill roundhill requested a review from khaykov April 4, 2024 16:25
@roundhill roundhill changed the title Add custom icon preference for susta Add custom icon preference for sustainers Apr 4, 2024
@roundhill roundhill changed the base branch from trunk to remove/sustainer-ui April 4, 2024 16:26
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Apr 4, 2024

📲 You can test the changes from this Pull Request in Simplenote Android by scanning the QR code below to install the corresponding build.

App Name Simplenote Android
Build TypeDebug
Commit783b4bd
Direct Downloadsimplenote-android-prototype-build-pr1645-783b4bd-018ebf72-8f5e-4628-9180-38ef7c5b036f.apk

@roundhill roundhill added the [Type] Enhancement Improve existing functionality. label Apr 4, 2024
@khaykov
Copy link
Member

khaykov commented Apr 4, 2024

Thanks, @roundhill ! It mostly works well, but I found a couple of issues :)

  • After you toggle the switch, app does not restart automatically on devices with API 26 (and maybe other).
  • After switching to sustainer icon, if you open a note from widget and press Up Arrow, the app closes instead of navigating to main activity.

Base automatically changed from remove/sustainer-ui to trunk April 8, 2024 19:45
Intent intent = new Intent();
intent.setComponent(new ComponentName(packageName, getMainActivityClassName(context)));

return intent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this function to get the proper main activity, if it is the alias or not. This fixes the back button crash and probably some other scenarios where we were referring directly to the NotesActivity class which may or may not exist depending on if the activity alias for the sustainer icon is active.

@roundhill
Copy link
Contributor Author

  • After you toggle the switch, app does not restart automatically on devices with API 26 (and maybe other).

I think it does do it but it takes a while (at least on the emulator it does). I've updated the requirement to show the switch to API 28 because I was getting an exception that I couldn't track down: Unexpected null component name or activity info: ComponentInfo{com.automattic.simplenote.debug/com.automattic.simplenote.NotesActivity}, null. The exception went away on API 28 and above.

  • After switching to sustainer icon, if you open a note from widget and press Up Arrow, the app closes instead of navigating to main activity.

This should be fixed now.

Copy link
Member

@khaykov khaykov left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes, @roundhill ! Works great now 👍

@roundhill roundhill merged commit 3d41b68 into trunk Apr 9, 2024
8 of 10 checks passed
@roundhill roundhill deleted the add/sustainer-icon branch April 9, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement Improve existing functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants