Skip to content

Commit

Permalink
Merge branch 'trunk' into issue/add-credential-manager-support
Browse files Browse the repository at this point in the history
  • Loading branch information
zwarm authored Feb 14, 2024
2 parents 419b555 + 2271079 commit 357e3b1
Show file tree
Hide file tree
Showing 24 changed files with 348 additions and 187 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/validate-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 📝 Validate Issues

on:
issues:
types: [opened, labeled, unlabeled]

jobs:
check-labels-on-issues:
uses: Automattic/dangermattic/.github/workflows/[email protected]
with:
label-format-list: '[
"^\[.+\]",
"^[[:alnum:]]"
]'
label-error-message: '🚫 Please add a type label (e.g. **[Type] Enhancement**) and a feature label (e.g. **Stats**) to this issue.'
label-success-message: 'Thanks for reporting! 👍'
secrets:
github-token: ${{ secrets.DANGERMATTIC_GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

24.3
-----
- [**] Added support to use third-party passkey providers and other devices passkeys as a WordPress.com login option [https://github.com/wordpress-mobile/WordPress-Android/pull/20174]

* [**] Added support to use third-party passkey providers and other devices passkeys as a WordPress.com login option [https://github.com/wordpress-mobile/WordPress-Android/pull/20174]
* [*] [Jetpack-only] Fix the visibility issue with the menu button on the stats [https://github.com/wordpress-mobile/WordPress-Android/pull/20175]

24.2
-----
Expand All @@ -12,6 +12,7 @@
* [**] Prevent images from temporarily disappearing when uploading media [https://github.com/WordPress/gutenberg/pull/57869]
* [***] [Jetpack-only] Reader: introduced new UI/UX for content navigation and filtering [https://github.com/wordpress-mobile/WordPress-Android/pull/19978]
* [**] Prevents crashes when the webview state is too big [https://github.com/wordpress-mobile/WordPress-Android/pull/20139]
* [*] [WordPress-only] Prevents a crash occurring when uploading videos under certain conditions [https://github.com/wordpress-mobile/WordPress-Android/pull/20168]

24.1
-----
Expand Down
2 changes: 1 addition & 1 deletion WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ kapt {
}

dependencies {
implementation 'androidx.webkit:webkit:1.7.0'
implementation 'androidx.webkit:webkit:1.10.0'
implementation "androidx.navigation:navigation-compose:$androidxComposeNavigationVersion"
compileOnly project(path: ':libs:annotations')
kapt project(':libs:processors')
Expand Down
132 changes: 77 additions & 55 deletions WordPress/src/main/java/org/wordpress/android/AppInitializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -464,65 +464,78 @@ class AppInitializer @Inject constructor(
credentialsClient.connect()
}

private fun createNotificationChannelsOnSdk26() {
private fun createNotificationChannelsOnSdk26(
normal: Boolean = true,
important: Boolean = true,
reminder: Boolean = true,
transient: Boolean = true,
weeklyRoundup: Boolean = true
) {
// create Notification channels introduced in Android Oreo
if (Build.VERSION.SDK_INT >= VERSION_CODES.O) {
// Create the NORMAL channel (used for likes, comments, replies, etc.)
val normalChannel = NotificationChannel(
application.getString(R.string.notification_channel_normal_id),
application.getString(R.string.notification_channel_general_title),
NotificationManager.IMPORTANCE_DEFAULT
)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
val notificationManager = application.getSystemService(
Context.NOTIFICATION_SERVICE
) as NotificationManager
notificationManager.createNotificationChannel(normalChannel)
if (normal) {
// Create the NORMAL channel (used for likes, comments, replies, etc.)
val normalChannel = NotificationChannel(
application.getString(R.string.notification_channel_normal_id),
application.getString(R.string.notification_channel_general_title),
NotificationManager.IMPORTANCE_DEFAULT
)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this

// Create the IMPORTANT channel (used for 2fa auth, for example)
val importantChannel = NotificationChannel(
application.getString(R.string.notification_channel_important_id),
application.getString(R.string.notification_channel_important_title),
NotificationManager.IMPORTANCE_HIGH
)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
notificationManager.createNotificationChannel(importantChannel)

// Create the REMINDER channel (used for various reminders, like Quick Start, etc.)
val reminderChannel = NotificationChannel(
application.getString(R.string.notification_channel_reminder_id),
application.getString(R.string.notification_channel_reminder_title),
NotificationManager.IMPORTANCE_LOW
)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
notificationManager.createNotificationChannel(reminderChannel)

// Create the TRANSIENT channel (used for short-lived notifications such as processing a Like/Approve,
// or media upload)
val transientChannel = NotificationChannel(
application.getString(R.string.notification_channel_transient_id),
application.getString(R.string.notification_channel_transient_title),
NotificationManager.IMPORTANCE_DEFAULT
)
transientChannel.setSound(null, null)
transientChannel.enableVibration(false)
transientChannel.enableLights(false)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
notificationManager.createNotificationChannel(transientChannel)

// Create the WEEKLY ROUNDUP channel (used for weekly roundup notification containing weekly stats)
val weeklyRoundupChannel = NotificationChannel(
application.getString(R.string.notification_channel_weekly_roundup_id),
application.getString(R.string.notification_channel_weekly_roundup_title),
NotificationManager.IMPORTANCE_LOW
)
// Register the channel with the system; you can't change the importance or other notification behaviors
// after this
notificationManager.createNotificationChannel(weeklyRoundupChannel)
notificationManager.createNotificationChannel(normalChannel)
}
if (important) {
// Create the IMPORTANT channel (used for 2fa auth, for example)
val importantChannel = NotificationChannel(
application.getString(R.string.notification_channel_important_id),
application.getString(R.string.notification_channel_important_title),
NotificationManager.IMPORTANCE_HIGH
)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
notificationManager.createNotificationChannel(importantChannel)
}
if (reminder) {
// Create the REMINDER channel (used for various reminders, like Quick Start, etc.)
val reminderChannel = NotificationChannel(
application.getString(R.string.notification_channel_reminder_id),
application.getString(R.string.notification_channel_reminder_title),
NotificationManager.IMPORTANCE_LOW
)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
notificationManager.createNotificationChannel(reminderChannel)
}
if (transient) {
// Create the TRANSIENT channel (used for short-lived notifications such as processing a Like/Approve,
// or media upload)
val transientChannel = NotificationChannel(
application.getString(R.string.notification_channel_transient_id),
application.getString(R.string.notification_channel_transient_title),
NotificationManager.IMPORTANCE_DEFAULT
)
transientChannel.setSound(null, null)
transientChannel.enableVibration(false)
transientChannel.enableLights(false)
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
notificationManager.createNotificationChannel(transientChannel)
}
if (weeklyRoundup) {
// Create the WEEKLY ROUNDUP channel (used for weekly roundup notification containing weekly stats)
val weeklyRoundupChannel = NotificationChannel(
application.getString(R.string.notification_channel_weekly_roundup_id),
application.getString(R.string.notification_channel_weekly_roundup_title),
NotificationManager.IMPORTANCE_LOW
)
// Register the channel with the system; you can't change the importance or other notification behaviors
// after this
notificationManager.createNotificationChannel(weeklyRoundupChannel)
}
}
}

Expand Down Expand Up @@ -980,10 +993,19 @@ class AppInitializer @Inject constructor(
}

private fun updateNotificationSettings() {
if(!jetpackFeatureRemovalPhaseHelper.shouldShowNotifications())
if (!jetpackFeatureRemovalPhaseHelper.shouldShowNotifications()) {
NotificationsUtils.cancelAllNotifications(application)
else
// Only create the transient notification channel to handle upload notifications
createNotificationChannelsOnSdk26(
normal = false,
important = false,
reminder = false,
transient = true,
weeklyRoundup = false,
)
} else {
createNotificationChannelsOnSdk26()
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -21,6 +22,8 @@
import org.wordpress.android.ui.main.WPMainActivity;
import org.wordpress.android.ui.media.MediaBrowserActivity;
import org.wordpress.android.ui.media.MediaBrowserType;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.FluxCUtils;
import org.wordpress.android.util.MediaUtils;
import org.wordpress.android.util.ToastUtils;
Expand Down Expand Up @@ -94,23 +97,33 @@ private void refreshContent() {
}

private void downloadExternalMedia() {
if (Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())) {
ArrayList<Uri> externalUris = getIntent().getParcelableArrayListExtra((Intent.EXTRA_STREAM));
for (Uri uri : externalUris) {
if (uri != null && isAllowedMediaType(uri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, uri));
try {
if (Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())) {
ArrayList<Uri> externalUris = getIntent().getParcelableArrayListExtra((Intent.EXTRA_STREAM));
for (Uri uri : externalUris) {
if (uri != null && isAllowedMediaType(uri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, uri));
}
}
} else if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
Uri externalUri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
if (externalUri != null && isAllowedMediaType(externalUri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, externalUri));
}
}
} else if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
Uri externalUri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
if (externalUri != null && isAllowedMediaType(externalUri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, externalUri));
}
} catch (Exception e) {
ToastUtils.showToast(this,
R.string.error_media_could_not_share_media_from_device, ToastUtils.Duration.LONG);
AppLog.e(T.MEDIA, "ShareIntentReceiver failed to download media ", e);
}
}

private boolean isAllowedMediaType(@NonNull Uri uri) {
String filePath = MediaUtils.getRealPathFromURI(this, uri);
// For cases when getRealPathFromURI returns an empty string
if (TextUtils.isEmpty(filePath)) {
filePath = String.valueOf(uri);
}
return MediaUtils.isValidImage(filePath) || MediaUtils.isVideo(filePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ private void initSubFilterViewModel(@Nullable Bundle savedInstanceState) {
BottomSheetVisible visibleState = (BottomSheetVisible) uiState;
bottomSheet = SubfilterBottomSheetFragment.newInstance(
SubFilterViewModel.getViewModelKeyForTag(mTagFragmentStartedWith),
visibleState.getCategories(),
visibleState.getCategory(),
mUiHelpers.getTextOfUiString(requireContext(), visibleState.getTitle())
);
bottomSheet.show(getChildFragmentManager(), SUBFILTER_BOTTOM_SHEET_TAG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
* followed tags and followed blogs
*/
public class ReaderSubsActivity extends LocaleAwareActivity
implements ReaderTagAdapter.TagDeletedListener {
implements ReaderTagAdapter.TagDeletedListener, ReaderTagAdapter.TagAddedListener {
private EditText mEditAdd;
private FloatingActionButton mFabButton;
private ReaderFollowButton mBtnAdd;
Expand Down Expand Up @@ -176,8 +176,7 @@ private void setResult() {
boolean shouldRefreshSubscriptions = false;
if (mPageAdapter != null) {
final ReaderTagFragment readerTagFragment = mPageAdapter.getReaderTagFragment();
final ReaderBlogFragment readerBlogFragment = mPageAdapter.getReaderBlogFragment();
if (readerTagFragment != null && readerBlogFragment != null) {
if (readerTagFragment != null) {
shouldRefreshSubscriptions = readerTagFragment.hasChangedSelectedTags();
}
}
Expand Down Expand Up @@ -497,8 +496,14 @@ public void onTagDeleted(ReaderTag tag) {
if (mLastAddedTagName != null && mLastAddedTagName.equalsIgnoreCase(tag.getTagSlug())) {
mLastAddedTagName = null;
}
String labelRemovedTag = getString(R.string.reader_label_removed_tag);
showInfoSnackbar(String.format(labelRemovedTag, tag.getLabel()));
}

@Override public void onTagAdded(@NonNull ReaderTag readerTag) {
mReaderTracker.trackTag(
AnalyticsTracker.Stat.READER_TAG_FOLLOWED,
readerTag.getTagSlug(),
ReaderTracker.SOURCE_SETTINGS
);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
/*
* fragment hosted by ReaderSubsActivity which shows followed tags
*/
public class ReaderTagFragment extends Fragment implements ReaderTagAdapter.TagDeletedListener {
public class ReaderTagFragment extends Fragment
implements ReaderTagAdapter.TagDeletedListener, ReaderTagAdapter.TagAddedListener {
private ReaderRecyclerView mRecyclerView;
private ReaderTagAdapter mTagAdapter;

Expand All @@ -49,10 +50,10 @@ public boolean hasChangedSelectedTags() {
for (final ReaderTag readerTag : mInitialReaderTagList) {
initialTagsSlugs.add(readerTag.getTagSlug());
}
final List<ReaderTag> currentReaderTagList = getTagAdapter().getItems();
final List<ReaderTag> currentlySubscribedReaderTagList = getTagAdapter().getSubscribedItems();
final Set<String> currentTagsSlugs = new HashSet<>();
if (currentReaderTagList != null) {
for (final ReaderTag readerTag : currentReaderTagList) {
if (currentlySubscribedReaderTagList != null) {
for (final ReaderTag readerTag : currentlySubscribedReaderTagList) {
currentTagsSlugs.add(readerTag.getTagSlug());
}
}
Expand Down Expand Up @@ -103,6 +104,7 @@ private ReaderTagAdapter getTagAdapter() {
Context context = WPActivityUtils.getThemedContext(getActivity());
mTagAdapter = new ReaderTagAdapter(context);
mTagAdapter.setTagDeletedListener(this);
mTagAdapter.setTagAddedListener(this);
mTagAdapter.setDataLoadedListener(isEmpty -> {
checkEmptyView();
if (mIsFirstDataLoaded) {
Expand Down Expand Up @@ -133,4 +135,10 @@ public void onTagDeleted(ReaderTag tag) {
((ReaderTagAdapter.TagDeletedListener) getActivity()).onTagDeleted(tag);
}
}

@Override public void onTagAdded(@NonNull ReaderTag readerTag) {
if (getActivity() instanceof ReaderTagAdapter.TagDeletedListener) {
((ReaderTagAdapter.TagAddedListener) getActivity()).onTagAdded(readerTag);
}
}
}
Loading

0 comments on commit 357e3b1

Please sign in to comment.