Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into merge/24.1-rc-3-to-t…
Browse files Browse the repository at this point in the history
…runk
  • Loading branch information
oguzkocer committed Jan 26, 2024
2 parents a5b16a5 + 9796d17 commit 8048b80
Show file tree
Hide file tree
Showing 39 changed files with 516 additions and 83 deletions.
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ updates:
# dependapot.
- dependency-name: "org.wordpress:fluxc"
- dependency-name: "org.wordpress:utils"
# org.wordpress-mobile.gutenberg-mobile is deprecated and org.wordpress.gutenberg-mobile is used instead.
# Temporarily leaving this declaration during transition, but this should be removed soon.
- dependency-name: "org.wordpress-mobile.gutenberg-mobile:react-native-gutenberg-bridge"
- dependency-name: "org.wordpress.gutenberg-mobile:react-native-gutenberg-bridge"
- dependency-name: "org.wordpress:login"
- dependency-name: "com.automattic:stories"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# built application files
*.apk
*.ap_
*.aab

# files for the dex VM
*.dex
Expand Down
7 changes: 1 addition & 6 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import se.bjurr.violations.comments.github.plugin.gradle.ViolationCommentsToGitHubTask
import se.bjurr.violations.lib.model.SEVERITY
import io.sentry.android.gradle.extensions.InstrumentationFeature

plugins {
id "com.android.application"
Expand Down Expand Up @@ -41,11 +40,6 @@ repositories {
includeGroup "com.automattic"
includeGroup "com.automattic.stories"
includeGroup "com.automattic.tracks"
// 'org.wordpress-mobile' group is deprecated. It's kept for now for smoother transition
// but it should be removed soon (within couple weeks)
includeGroup "org.wordpress-mobile"
includeGroup "org.wordpress-mobile.gutenberg-mobile"
includeGroupByRegex "org.wordpress-mobile.react-native-libraries.*"
}
}
maven {
Expand Down Expand Up @@ -164,6 +158,7 @@ android {
buildConfigField "boolean", "ENABLE_OPEN_WEB_LINKS_WITH_JP_FLOW", "true"
buildConfigField "boolean", "BLAZE_MANAGE_CAMPAIGNS", "false"
buildConfigField "boolean", "DASHBOARD_PERSONALIZATION", "false"
buildConfigField "boolean", "ENABLE_SITE_MONITORING", "false"

manifestPlaceholders = [magicLinkScheme:"wordpress"]
}
Expand Down
Binary file not shown.
12 changes: 10 additions & 2 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

<!-- GCM all build types configuration -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
Expand Down Expand Up @@ -828,11 +829,13 @@
<!-- Services -->
<service
android:name=".ui.uploads.UploadService"
android:label="Upload Service" />
android:label="Upload Service"
android:foregroundServiceType="dataSync"/>
<service
android:name=".ui.media.services.MediaDeleteService"
android:label="Media Delete Service"
android:exported="false"
android:foregroundServiceType="dataSync"
/>

<service
Expand Down Expand Up @@ -1053,7 +1056,7 @@

<service
android:name=".push.GCMMessageService"
android:exported="false">
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
Expand Down Expand Up @@ -1120,6 +1123,11 @@
android:label="@string/stats"
android:theme="@style/WordPress.NoActionBar"/>

<activity android:name=".ui.sitemonitor.SiteMonitorParentActivity"
android:exported="false"
android:label="@string/site_monitoring"
android:theme="@style/WordPress.NoActionBar"/>

<meta-data android:name="io.sentry.traces.activity.enable" android:value="false" />

</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.wordpress.android.ui.stats.refresh.lists.TotalCommentsDetailListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.TotalFollowersDetailListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.TotalLikesDetailListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.TrafficListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.WeeksListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.YearsListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.detail.DetailListViewModel;
Expand Down Expand Up @@ -158,6 +159,11 @@ abstract class ViewModelModule {
@ViewModelKey(InsightsListViewModel.class)
abstract ViewModel insightsTabViewModel(InsightsListViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(TrafficListViewModel.class)
abstract ViewModel trafficTabViewModel(TrafficListViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(DaysListViewModel.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.wordpress.android.ui.mysite.menu.KEY_QUICK_START_EVENT
import org.wordpress.android.ui.mysite.menu.MenuActivity
import org.wordpress.android.ui.mysite.personalization.PersonalizationActivity
import org.wordpress.android.ui.quickstart.QuickStartEvent
import org.wordpress.android.ui.sitemonitor.SiteMonitorParentActivity
import org.wordpress.android.util.ToastUtils
import org.wordpress.android.util.analytics.AnalyticsUtils
import javax.inject.Inject
Expand Down Expand Up @@ -156,5 +157,11 @@ class ActivityNavigator @Inject constructor() {
mainActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
return mainActivityIntent
}

fun navigateToSiteMonitoring(context: Context, site: SiteModel) {
val intent = Intent(context, SiteMonitorParentActivity::class.java)
intent.putExtra(WordPress.SITE, site)
context.startActivity(intent)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
Expand Down Expand Up @@ -467,7 +469,15 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
@SuppressLint("UnspecifiedRegisterReceiverFlag")
public void onStart() {
super.onStart();
registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
if (Build.VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
registerReceiver(
mDownloadReceiver,
new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
ContextWrapper.RECEIVER_NOT_EXPORTED
);
} else {
registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
mDispatcher.register(this);

// we only register with EventBus the first time - necessary since we don't unregister in onStop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DeviceListBuilder(
// This item sets the threshold for the visible items in all the list
val lastShownTimestamp = results.fold(0L) { timestamp, (_, result) ->
val nextTimestamp = result?.nextTimestamp
if (nextTimestamp != null && nextTimestamp > timestamp) {
if (result?.items?.isNotEmpty() == true && nextTimestamp != null && nextTimestamp > timestamp) {
nextTimestamp
} else {
timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment),
.newInstance(action.isPromptsEnabled)
.show(requireActivity().supportFragmentManager, BloganuaryNudgeLearnMoreOverlayFragment.TAG)
}

is SiteNavigationAction.OpenSiteMonitoring -> activityNavigator.navigateToSiteMonitoring(
requireActivity(),
action.site
)
}

private fun handleNavigation(action: BloggingPromptCardNavigationAction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ sealed class SiteNavigationAction {
object OpenDashboardPersonalization : SiteNavigationAction()

data class OpenBloganuaryNudgeOverlay(val isPromptsEnabled: Boolean): SiteNavigationAction()
data class OpenSiteMonitoring(val site: SiteModel) : SiteNavigationAction()
}

sealed class BloggingPromptCardNavigationAction: SiteNavigationAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ListItemActionHandler @Inject constructor(
ListItemAction.COMMENTS -> SiteNavigationAction.OpenUnifiedComments(selectedSite)
ListItemAction.BLAZE -> onBlazeMenuItemClick()
ListItemAction.MORE -> SiteNavigationAction.OpenMore(selectedSite, quickStartEvent)
ListItemAction.SITE_MONITORING -> SiteNavigationAction.OpenSiteMonitoring(selectedSite)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ enum class ListItemAction (val trackingLabel: String) {
BLAZE("blaze"),
ME("me"),
MORE("more"),
SITE_MONITORING("site_monitoring"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class SiteItemsBuilder @Inject constructor(
private fun getManageSiteItems(
params: SiteItemsBuilderParams
): List<MySiteCardAndItem> {
val siteMonitoring = buildSiteMonitoringOptionsIfNeeded(params)
val manageSiteItems = buildManageSiteItems(params)

val emptyHeaderItem1 = CategoryEmptyHeaderItem(UiString.UiStringText(""))
Expand All @@ -101,6 +102,7 @@ class SiteItemsBuilder @Inject constructor(
val emptyHeaderItem2 = CategoryEmptyHeaderItem(UiString.UiStringText(""))
val admin = siteListItemBuilder.buildAdminItemIfAvailable(params.site, params.onClick)
return listOf(manageHeader) +
siteMonitoring +
manageSiteItems +
emptyHeaderItem1 +
jetpackConfiguration +
Expand All @@ -126,6 +128,12 @@ class SiteItemsBuilder @Inject constructor(
)
}

private fun buildSiteMonitoringOptionsIfNeeded(params: SiteItemsBuilderParams): List<MySiteCardAndItem> {
return listOfNotNull(
siteListItemBuilder.buildSiteMonitoringItemIfAvailable(params.site, params.onClick)
)
}

private fun buildManageSiteItems(params: SiteItemsBuilderParams): List<MySiteCardAndItem>{
if(jetpackFeatureRemovalOverlayUtil.shouldHideJetpackFeatures())
return emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.wordpress.android.ui.utils.UiString.UiStringText
import org.wordpress.android.util.BuildConfigWrapper
import org.wordpress.android.util.DateTimeUtils
import org.wordpress.android.util.SiteUtilsWrapper
import org.wordpress.android.util.config.SiteMonitoringFeatureConfig
import java.util.GregorianCalendar
import java.util.TimeZone
import javax.inject.Inject
Expand All @@ -39,7 +40,8 @@ class SiteListItemBuilder @Inject constructor(
private val siteUtilsWrapper: SiteUtilsWrapper,
private val buildConfigWrapper: BuildConfigWrapper,
private val themeBrowserUtils: ThemeBrowserUtils,
private val jetpackFeatureRemovalPhaseHelper: JetpackFeatureRemovalPhaseHelper
private val jetpackFeatureRemovalPhaseHelper: JetpackFeatureRemovalPhaseHelper,
private val siteMonitoringFeatureConfig: SiteMonitoringFeatureConfig
) {
fun buildActivityLogItemIfAvailable(site: SiteModel, onClick: (ListItemAction) -> Unit): ListItem? {
val isWpComOrJetpack = siteUtilsWrapper.isAccessedViaWPComRest(
Expand Down Expand Up @@ -245,6 +247,22 @@ class SiteListItemBuilder @Inject constructor(
} else null
}

@Suppress("ComplexCondition")
fun buildSiteMonitoringItemIfAvailable(site: SiteModel, onClick: (ListItemAction) -> Unit): MySiteCardAndItem? {
return if (buildConfigWrapper.isJetpackApp
&& site.isWPComAtomic
&& site.isAdmin
&& siteMonitoringFeatureConfig.isEnabled()
) {
ListItem(
R.drawable.gb_ic_tool,
UiStringRes(R.string.site_monitoring),
onClick = ListItemInteraction.create(ListItemAction.SITE_MONITORING, onClick),
listItemAction = ListItemAction.SITE_MONITORING
)
} else null
}

companion object {
const val HIDE_WP_ADMIN_YEAR = 2015
const val HIDE_WP_ADMIN_MONTH = 9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class MenuActivity : AppCompatActivity() {
this,
action.campaignListingPageSource
)
is SiteNavigationAction.OpenSiteMonitoring -> activityNavigator.navigateToSiteMonitoring(this, action.site)
else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package org.wordpress.android.ui.sitemonitor

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.TabRow
import androidx.compose.material.Text
import androidx.compose.material3.Tab
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import dagger.hilt.android.AndroidEntryPoint
import org.wordpress.android.R
import org.wordpress.android.WordPress
import org.wordpress.android.fluxc.model.SiteModel
import org.wordpress.android.ui.compose.components.MainTopAppBar
import org.wordpress.android.ui.compose.components.NavigationIcons
import org.wordpress.android.ui.compose.theme.AppTheme
import org.wordpress.android.util.extensions.getSerializableExtraCompat

@AndroidEntryPoint
class SiteMonitorParentActivity: AppCompatActivity() {
val viewModel:SiteMonitorParentViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AppTheme {
viewModel.start(getSite())
SiteMonitorScreen()
}
}
}

private fun getSite(): SiteModel {
return requireNotNull(intent.getSerializableExtraCompat(WordPress.SITE)) as SiteModel
}

@Composable
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
fun SiteMonitorScreen(modifier: Modifier = Modifier) {
Scaffold(
topBar = {
MainTopAppBar(
title = stringResource(id = R.string.site_monitoring),
navigationIcon = NavigationIcons.BackIcon,
onNavigationIconClick = onBackPressedDispatcher::onBackPressed,
)
},
content = {
TabScreen(modifier = modifier)
}
)
}

@Composable
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
fun TabScreen(modifier: Modifier = Modifier) {
var tabIndex by remember { mutableStateOf(0) }

val tabs = listOf(
R.string.site_monitoring_tab_title_metrics,
R.string.site_monitoring_tab_title_php_logs,
R.string.site_monitoring_tab_title_web_server_logs
)

Column(modifier = modifier.fillMaxWidth()) {
TabRow(
selectedTabIndex = tabIndex,
backgroundColor = MaterialTheme.colors.surface,
contentColor = MaterialTheme.colors.onSurface,
) {
tabs.forEachIndexed { index, title ->
Tab(text = { Text(stringResource(id = title)) },
selected = tabIndex == index,
onClick = { tabIndex = index }
)
}
}
when (tabIndex) {
0 -> SiteMonitoringWebView()
1 -> SiteMonitoringWebView()
2 -> SiteMonitoringWebView()
}
}
}

@Composable
fun SiteMonitoringWebView(){
Text(text = "SiteMonitoringWebView")
}
}
Loading

0 comments on commit 8048b80

Please sign in to comment.