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

Merge final release/18.2 into develop #15344

Merged
merged 31 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7e2d0c3
Refactor create_gh_release to allow unified GH release for WP+JP and …
AliSoftware Sep 2, 2021
9ad5aa9
Update YARD docs for build lanes
AliSoftware Sep 9, 2021
95c0b54
Change way to create tmpfile
AliSoftware Sep 9, 2021
9174e46
Unified GitHub Release after the 3 parallel jobs
AliSoftware Sep 13, 2021
b11e051
checkout + bundle install before create_gh_release
AliSoftware Sep 13, 2021
e7dc210
Fix attach_workspace vs checkout
AliSoftware Sep 13, 2021
ecd218b
Make create_gh_release infer the prerelease flag
AliSoftware Sep 13, 2021
1e5c779
🚧 TO REVERT: Fake-bump versionName and disable upload_to_playstore an…
AliSoftware Sep 13, 2021
d0f2c75
Revert 🚧 1e5c7795f269cb7e340bb9405dadd11839d59b4f
AliSoftware Sep 13, 2021
f2a3e70
Fix wording and variable name
AliSoftware Sep 14, 2021
556f155
Fix doc comment
AliSoftware Sep 14, 2021
f127d91
Remove legacy, unused `trigger_ci` private lane
AliSoftware Sep 14, 2021
87dd0b3
Merge pull request #15319 from wordpress-mobile/jetpack-infra/unified…
AliSoftware Sep 14, 2021
1555c4c
Add Weekly Roundup preference
renanferrari Sep 14, 2021
fdc2c2e
Add preference check to WeeklyRoundupNotifier
renanferrari Sep 14, 2021
ef9fc37
Extract method to setup setting view
renanferrari Sep 14, 2021
db7573e
Show Weekly Roundup toggle setting
renanferrari Sep 14, 2021
2509bca
Add tests
renanferrari Sep 14, 2021
d055278
Add notify method to NotificationManagerWrapper
renanferrari Sep 14, 2021
655ec08
Add option to force show Weekly Roundup notification on debug settings
renanferrari Sep 14, 2021
78e8d96
Update tests
renanferrari Sep 14, 2021
33ea1ff
Merge pull request #15325 from wordpress-mobile/feature/weekly-roundu…
ravishanker Sep 15, 2021
963c403
Release script: Update build.gradle gutenbergMobileVersion to ref
fluiddot Sep 16, 2021
70aa133
Update gutenberg-mobile reference
mkevins Sep 17, 2021
cbaf400
Merge pull request #15335 from wordpress-mobile/gutenberg/integrate_r…
mkevins Sep 17, 2021
0b8b9aa
Remove need for app: param in finalize_release prechecks call
AliSoftware Sep 17, 2021
c87600b
Update translations
AliSoftware Sep 17, 2021
a332c6a
Bump version number
AliSoftware Sep 17, 2021
ef814b2
Update WordPress metadata translations for 18.2
AliSoftware Sep 17, 2021
0a1316c
Update Jetpack metadata translations for 18.2
AliSoftware Sep 17, 2021
96d19de
Cancel Zalpha job if not a rc
AliSoftware Sep 17, 2021
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
43 changes: 35 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ jobs:
- run:
name: Init messages
command: |
echo "export SLACK_FAILURE_MESSAGE=':red_circle: Build for << parameters.app >> Android failed!'" >> $BASH_ENV
SLACKMSG_APP_NAME=$(echo "<< parameters.app >>" | sed s/wordpress/WordPress/i | sed s/jetpack/Jetpack/i)
echo "export SLACK_FAILURE_MESSAGE=':red_circle: Build for ${SLACKMSG_APP_NAME} Android failed!'" >> $BASH_ENV
- git/shallow-checkout:
init-submodules: true
- checkout-submodules
- bundle-install/bundle-install:
cache_key_prefix: release-build-v2
cache_key_prefix: &release-build-cache-key release-build-v2
- run:
name: Copy Secrets
command: FASTLANE_SKIP_UPDATE_CHECK=1 bundle exec fastlane run configure_apply
Expand All @@ -111,9 +112,11 @@ jobs:
name: Prepare build
command: |
APP_VERSION=$(./gradlew -q printVersionName | tail -1)
SLACKMSG_APP_NAME=$(echo "<< parameters.app >>" | sed s/wordpress/WordPress/i | sed s/jetpack/Jetpack/i)
SLACKMSG_APP_VERSION=<<# parameters.alpha >>$(./gradlew -q printVersionName -Palpha | tail -1)<</ parameters.alpha >><<^ parameters.alpha >>$APP_VERSION<</ parameters.alpha >>
echo "export APP_VERSION=${APP_VERSION}" >> $BASH_ENV
echo "export SLACK_FAILURE_MESSAGE=':red_circle: Build for << parameters.app >> Android $APP_VERSION failed!'" >> $BASH_ENV
echo "export SLACK_SUCCESS_MESSAGE=':tada: << parameters.app >> Android $APP_VERSION has been deployed!'" >> $BASH_ENV
echo "export SLACK_FAILURE_MESSAGE=':red_circle: Build for ${SLACKMSG_APP_NAME} Android ${SLACKMSG_APP_VERSION} failed!'" >> $BASH_ENV
echo "export SLACK_SUCCESS_MESSAGE=':tada: ${SLACKMSG_APP_NAME} Android ${SLACKMSG_APP_VERSION} has been deployed!'" >> $BASH_ENV
# Prevent fastlane from checking for updates, also removing the verbose fastlane changelog at the end of each invocation.
echo "export FASTLANE_SKIP_UPDATE_CHECK=1" >> $BASH_ENV
bundle check
Expand All @@ -124,7 +127,10 @@ jobs:
name: Build << parameters.app >> Zalpha
command: |
if [[ ${APP_VERSION} == *"-rc-"* ]]; then
bundle exec fastlane build_alpha app:<< parameters.app >> skip_confirm:true skip_prechecks:true create_release:true upload_to_play_store:true
bundle exec fastlane build_alpha app:<< parameters.app >> skip_confirm:true skip_prechecks:true upload_to_play_store:true
else
echo "Skipping and halting this job because we only build Zalpha variants for rc versions, but current version is ${APP_VERSION}"
circleci-agent step halt
Comment on lines +131 to +133
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 needed to add that change because without it, this build step will be skipped as expected… but the rest of the job would continue, and ultimately fail on the persist_to_workspace step later in that job, as the build/ directory would not exist. This is what happened in this CircleCI run.

So instead, this halts the job gracefully, and does not run the following steps after this one for the job, avoiding to try running the persist_to_worspace one.

I didn't encounter this during my earlier tests when I did the intermediate betas because we only skip the Zalpha during the final release.

fi
no_output_timeout: 15m
- unless:
Expand All @@ -134,22 +140,41 @@ jobs:
name: Build << parameters.app >> Vanilla
command: |
if [[ ${APP_VERSION} == *"-rc-"* ]]; then
bundle exec fastlane build_beta app:<< parameters.app >> skip_confirm:true skip_prechecks:true create_release:true upload_to_play_store:true
bundle exec fastlane build_beta app:<< parameters.app >> skip_confirm:true skip_prechecks:true upload_to_play_store:true
else
bundle exec fastlane build_and_upload_release app:<< parameters.app >> skip_confirm:true skip_prechecks:true create_release:true upload_to_play_store:true
bundle exec fastlane build_and_upload_release app:<< parameters.app >> skip_confirm:true skip_prechecks:true upload_to_play_store:true
fi
no_output_timeout: 15m
- android/save-gradle-cache
- store_artifacts:
path: build
destination: Artifacts
- persist_to_workspace:
root: build
paths: ['*.aab'] # So they are made available for the "Create GitHub Release" job
- slack/status:
include_job_number_field: false
include_project_field: false
include_visit_job_action: false
webhook: '${SLACK_BUILD_WEBHOOK}'
failure_message: '${SLACK_FAILURE_MESSAGE}'
success_message: '${SLACK_SUCCESS_MESSAGE}'
Create GitHub Release:
executor:
name: android/default
api-version: "29"
steps:
- git/shallow-checkout:
init-submodules: false
- bundle-install/bundle-install:
cache_key_prefix: *release-build-cache-key
- attach_workspace:
at: build # Restore *.aab files built from "Release Build" jobs so we can attach them to the GitHub release
- run:
name: Create GitHub Release
command: |
bundle exec fastlane create_gh_release


Connected Tests:
parameters:
Expand Down Expand Up @@ -404,4 +429,6 @@ workflows:
- Release Build:
name: "Release: JP Beta"
app: jetpack
alpha: false
alpha: false
- Create GitHub Release:
requires: ["Release: WP Alpha", "Release: WP Beta", "Release: JP Beta"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import kotlinx.coroutines.CoroutineDispatcher
import org.wordpress.android.R
import org.wordpress.android.modules.BG_THREAD
import org.wordpress.android.modules.UI_THREAD
import org.wordpress.android.ui.debug.DebugSettingsViewModel.NavigationAction.DebugCookies
import org.wordpress.android.ui.debug.DebugSettingsViewModel.UiItem.Button
Expand All @@ -18,23 +19,31 @@ import org.wordpress.android.ui.debug.DebugSettingsViewModel.UiItem.Type.BUTTON
import org.wordpress.android.ui.debug.DebugSettingsViewModel.UiItem.Type.FEATURE
import org.wordpress.android.ui.debug.DebugSettingsViewModel.UiItem.Type.HEADER
import org.wordpress.android.ui.debug.DebugSettingsViewModel.UiItem.Type.ROW
import org.wordpress.android.ui.notifications.NotificationManagerWrapper
import org.wordpress.android.ui.utils.ListItemInteraction
import org.wordpress.android.ui.utils.ListItemInteraction.Companion.create
import org.wordpress.android.util.DebugUtils
import org.wordpress.android.util.config.FeaturesInDevelopment
import org.wordpress.android.util.config.ManualFeatureConfig
import org.wordpress.android.util.config.RemoteConfig
import org.wordpress.android.util.config.RemoteConfigDefaults
import org.wordpress.android.viewmodel.ContextProvider
import org.wordpress.android.viewmodel.Event
import org.wordpress.android.viewmodel.ScopedViewModel
import org.wordpress.android.workers.weeklyroundup.WeeklyRoundupNotifier
import javax.inject.Inject
import javax.inject.Named

class DebugSettingsViewModel
@Inject constructor(
@Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher,
@Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher,
private val manualFeatureConfig: ManualFeatureConfig,
private val remoteConfig: RemoteConfig,
private val debugUtils: DebugUtils
private val debugUtils: DebugUtils,
private val weeklyRoundupNotifier: WeeklyRoundupNotifier,
private val notificationManager: NotificationManagerWrapper,
private val contextProvider: ContextProvider
) : ScopedViewModel(mainDispatcher) {
private val _uiState = MutableLiveData<UiState>()
val uiState: LiveData<UiState> = _uiState
Expand Down Expand Up @@ -65,14 +74,21 @@ class DebugSettingsViewModel
uiItems.add(Button(R.string.debug_settings_restart_app, debugUtils::restartApp))
}
uiItems.add(Header(R.string.debug_settings_tools))
uiItems.add(Row(R.string.debug_cookies_title, ListItemInteraction.create(this::onDebugCookiesClick)))
uiItems.add(Row(R.string.debug_cookies_title, create(this::onDebugCookiesClick)))
uiItems.add(Row(R.string.debug_settings_force_show_weekly_roundup, create(this::onForceShowWeeklyRoundupClick)))
_uiState.value = UiState(uiItems)
}

private fun onDebugCookiesClick() {
_onNavigation.value = Event(DebugCookies)
}

private fun onForceShowWeeklyRoundupClick() = launch(bgDispatcher) {
weeklyRoundupNotifier.buildNotifications().forEach {
notificationManager.notify(it.id, it.asNotificationCompatBuilder(contextProvider.getContext()).build())
}
}

private fun buildDevelopedFeatures(): List<Feature> {
return FeaturesInDevelopment.featuresInDevelopment.map { name ->
val value = if (manualFeatureConfig.hasManualSetup(name)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.wordpress.android.ui.notifications

import android.app.Notification
import android.content.Context
import androidx.core.app.NotificationManagerCompat
import javax.inject.Inject

class NotificationManagerWrapper
@Inject constructor(private val context: Context) {
fun areNotificationsEnabled() = NotificationManagerCompat.from(context).areNotificationsEnabled()
fun notify(id: Int, notification: Notification) = NotificationManagerCompat.from(context).notify(id, notification)
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ public enum DeletablePrefKey implements PrefKey {
REMOVED_QUICK_START_CARD_TYPE,
PINNED_DYNAMIC_CARD,
BLOGGING_REMINDERS_SHOWN,
SHOULD_SCHEDULE_CREATE_SITE_NOTIFICATION
SHOULD_SCHEDULE_CREATE_SITE_NOTIFICATION,
SHOULD_SHOW_WEEKLY_ROUNDUP_NOTIFICATION
}

/**
Expand Down Expand Up @@ -1300,6 +1301,18 @@ public static boolean shouldScheduleCreateSiteNotification() {
return getBoolean(DeletablePrefKey.SHOULD_SCHEDULE_CREATE_SITE_NOTIFICATION, true);
}

public static void setShouldShowWeeklyRoundupNotification(long remoteSiteId, boolean shouldShow) {
prefs().edit().putBoolean(getShouldShowWeeklyRoundupNotification(remoteSiteId), shouldShow).apply();
}

public static boolean shouldShowWeeklyRoundupNotification(long remoteSiteId) {
return prefs().getBoolean(getShouldShowWeeklyRoundupNotification(remoteSiteId), true);
}

@NonNull private static String getShouldShowWeeklyRoundupNotification(long siteId) {
return DeletablePrefKey.SHOULD_SHOW_WEEKLY_ROUNDUP_NOTIFICATION.name() + siteId;
}

/*
* adds a local site ID to the top of list of recently chosen sites
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ class AppPrefsWrapper @Inject constructor() {
return AppPrefs.isBloggingRemindersShown(siteId)
}

fun setShouldShowWeeklyRoundupNotification(siteId: Long, shouldShow: Boolean) {
AppPrefs.setShouldShowWeeklyRoundupNotification(siteId, shouldShow)
}

fun shouldShowWeeklyRoundupNotification(siteId: Long): Boolean {
return AppPrefs.shouldShowWeeklyRoundupNotification(siteId)
}

fun setSiteJetpackCapabilities(remoteSiteId: Long, capabilities: List<JetpackCapability>) =
AppPrefs.setSiteJetpackCapabilities(remoteSiteId, capabilities)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.preference.DialogPreference;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -16,6 +17,7 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;

Expand All @@ -25,6 +27,7 @@
import org.wordpress.android.models.NotificationsSettings;
import org.wordpress.android.models.NotificationsSettings.Channel;
import org.wordpress.android.models.NotificationsSettings.Type;
import org.wordpress.android.ui.prefs.AppPrefs;
import org.wordpress.android.ui.prefs.notifications.PrefMainSwitchToolbarView.MainSwitchToolbarListener;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
Expand Down Expand Up @@ -182,48 +185,68 @@ private View configureLayoutForView(LinearLayout view) {
continue;
}

View commentsSetting = View.inflate(getContext(), R.layout.notifications_settings_switch, null);
TextView title = commentsSetting.findViewById(R.id.notifications_switch_title);
title.setText(settingName);

// Add special summary text for the WPCOM section
String settingSummary = null;
if (mChannel == Channel.WPCOM && i < summaryArray.length) {
String summaryText = summaryArray[i];
TextView summary = commentsSetting.findViewById(R.id.notifications_switch_summary);
summary.setVisibility(View.VISIBLE);
summary.setText(summaryText);
settingSummary = summaryArray[i];
}

final SwitchCompat toggleSwitch = commentsSetting.findViewById(R.id.notifications_switch);
toggleSwitch.setChecked(JSONUtils.queryJSON(settingsJson, settingValue, true));
toggleSwitch.setTag(settingValue);
toggleSwitch.setOnCheckedChangeListener(mOnCheckedChangedListener);
boolean isSettingChecked = JSONUtils.queryJSON(settingsJson, settingValue, true);

View rowContainer = commentsSetting.findViewById(R.id.row_container);
rowContainer.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
toggleSwitch.setChecked(!toggleSwitch.isChecked());
}
});

if (mShouldDisplayMainSwitch && i == mSettingsArray.length - 1) {
View divider = commentsSetting.findViewById(R.id.notifications_list_divider);
if (divider != null) {
MarginLayoutParams mlp = (MarginLayoutParams) divider.getLayoutParams();
mlp.leftMargin = 0;
mlp.rightMargin = 0;
divider.setLayoutParams(mlp);
}
}
boolean isSettingLast = i == mSettingsArray.length - 1;

view.addView(commentsSetting);
view.addView(setupSettingView(settingName, settingValue, settingSummary, isSettingChecked,
isSettingLast, mOnCheckedChangedListener));
}
}

// Add Weekly Roundup setting
if (mChannel == Channel.BLOGS && mType == Type.DEVICE) {
String settingName = getContext().getString(R.string.weekly_roundup);
boolean isSettingChecked = AppPrefs.shouldShowWeeklyRoundupNotification(mBlogId);
View settingView = setupSettingView(settingName, null, null, isSettingChecked, true,
(compoundButton, isChecked) -> AppPrefs.setShouldShowWeeklyRoundupNotification(mBlogId, isChecked));
view.addView(settingView);
}

return view;
}

private CompoundButton.OnCheckedChangeListener mOnCheckedChangedListener =
private View setupSettingView(String settingName, @Nullable String settingValue, @Nullable String settingSummary,
boolean isSettingChecked, boolean isSettingLast,
CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
View setting = View.inflate(getContext(), R.layout.notifications_settings_switch, null);
TextView title = setting.findViewById(R.id.notifications_switch_title);
title.setText(settingName);

if (!TextUtils.isEmpty(settingSummary)) {
TextView summary = setting.findViewById(R.id.notifications_switch_summary);
summary.setVisibility(View.VISIBLE);
summary.setText(settingSummary);
}

final SwitchCompat toggleSwitch = setting.findViewById(R.id.notifications_switch);
toggleSwitch.setChecked(isSettingChecked);
toggleSwitch.setTag(settingValue);
toggleSwitch.setOnCheckedChangeListener(onCheckedChangeListener);

View rowContainer = setting.findViewById(R.id.row_container);
rowContainer.setOnClickListener(v -> toggleSwitch.setChecked(!toggleSwitch.isChecked()));

if (mShouldDisplayMainSwitch && isSettingLast) {
View divider = setting.findViewById(R.id.notifications_list_divider);
if (divider != null) {
MarginLayoutParams mlp = (MarginLayoutParams) divider.getLayoutParams();
mlp.leftMargin = 0;
mlp.rightMargin = 0;
divider.setLayoutParams(mlp);
}
}

return setting;
}

private final CompoundButton.OnCheckedChangeListener mOnCheckedChangedListener =
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
Expand Down Expand Up @@ -325,7 +348,7 @@ private void hideDisabledView(boolean isMainChecked) {
* Updates Notifications current settings switches state based on the main switch state
*
* @param isMainChecked TRUE to switch on the settings switches.
* FALSE to switch off the settings switches.
* FALSE to switch off the settings switches.
*/
private void setSettingsSwitchesChecked(boolean isMainChecked) {
for (String settingValue : mSettingsValues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.wordpress.android.push.NotificationPushIds.WEEKLY_ROUNDUP_NOTIFICATIO
import org.wordpress.android.push.NotificationType.WEEKLY_ROUNDUP
import org.wordpress.android.ui.ActivityLauncher
import org.wordpress.android.ui.notifications.SystemNotificationsTracker
import org.wordpress.android.ui.prefs.AppPrefsWrapper
import org.wordpress.android.ui.stats.StatsTimeframe.WEEK
import org.wordpress.android.util.SiteUtilsWrapper
import org.wordpress.android.viewmodel.ContextProvider
Expand All @@ -26,7 +27,8 @@ class WeeklyRoundupNotifier @Inject constructor(
private val weeklyRoundupScheduler: WeeklyRoundupScheduler,
private val notificationsTracker: SystemNotificationsTracker,
private val siteUtils: SiteUtilsWrapper,
private val weeklyRoundupRepository: WeeklyRoundupRepository
private val weeklyRoundupRepository: WeeklyRoundupRepository,
private val appPrefs: AppPrefsWrapper
) {
fun shouldShowNotifications() = accountStore.hasAccessToken() && siteStore.hasSitesAccessedViaWPComRest()

Expand All @@ -36,6 +38,7 @@ class WeeklyRoundupNotifier @Inject constructor(
.awaitAll()
.asSequence()
.filterNotNull()
.filter { appPrefs.shouldShowWeeklyRoundupNotification(it.site.siteId) }
.sortedByDescending { it.score }
.take(TOP_FIVE_SITES)
.filter { it.views >= MIN_SITE_VIEWS }
Expand Down
Loading