Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into upgrade-gradle-to-7.…
Browse files Browse the repository at this point in the history
…4.2-agp-to-7.2.1
  • Loading branch information
oguzkocer committed Jul 7, 2022
2 parents 968a1bd + b4ca154 commit 7551671
Show file tree
Hide file tree
Showing 233 changed files with 3,449 additions and 1,425 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ updates:
- dependency-name: "org.wordpress.fluxc.plugins:woocommerce"
- dependency-name: "org.wordpress:login"
- dependency-name: "com.automattic:Automattic-Tracks-Android"
- dependency-name: "com.automattic.tracks:experimentation"
5 changes: 3 additions & 2 deletions WooCommerce/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ dependencies {
// Support library
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.core:core-ktx:$coreKtxVersion"
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"
implementation "androidx.appcompat:appcompat:$appCompatVersion"
Expand All @@ -204,6 +204,7 @@ dependencies {
exclude group: "com.android.support"
}

implementation "com.automattic.tracks:experimentation:trunk-f25f5b5e77df8313f19d47d07e7411256d18df79"
implementation 'com.automattic:Automattic-Tracks-Android:2.2.0'

implementation("${gradle.ext.fluxCBinaryPath}:$fluxCVersion") {
Expand Down Expand Up @@ -263,7 +264,7 @@ dependencies {
// See https://github.com/wordpress-mobile/WordPress-FluxC-Android/issues/919
exclude group: 'com.squareup.okhttp3'
}
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android-core:2.9.1'

// Dependencies for local unit tests
testImplementation "junit:junit:$jUnitVersion"
Expand Down
17 changes: 9 additions & 8 deletions WooCommerce/metadata/PlayStoreStrings.pot
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ msgstr ""
"Project-Id-Version: Release Notes & Play Store Descriptions\n"

#. translators: Release notes for this version to be displayed in the Play Store. Limit to 500 characters including spaces and commas!
msgctxt "release_note_094"
msgctxt "release_note_095"
msgid ""
"9.4:\n"
"Even though this release doesn’t have any new features, we still put a lot of love into it! In product details, some third-party extensions were causing the app to crash when viewing variable products. We’ve fixed this crash and made a handful of minor improvements to make your experience smoother.\n"
"9.5:\n"
"We keep adding new functionality to our experimental Coupon Management feature! This release includes editing and deleting coupons along with several improvements on viewing. Turn this feature on for early access in the More tab, Settings, Beta Features.\n"
"\n"
"We also fixed a bug that was making it hard for some of you to search orders. Thanks to everyone who reported this! Your feedback is vital to us!\n"
"\n"
msgstr ""

msgctxt "release_note_093"
msgctxt "release_note_094"
msgid ""
"9.3:\n"
"Canada, say hello to in-person payments! We are thrilled to announce that in-person payments are now available to Canadian merchants currently using WooCommerce Payments.\n"
"\n"
"This release also contains a few minor improvements. Thank you all again for your amazing feedback. Keep it coming!\n"
"9.4:\n"
"Even though this release doesn’t have any new features, we still put a lot of love into it! In product details, some third-party extensions were causing the app to crash when viewing variable products. We’ve fixed this crash and made a handful of minor improvements to make your experience smoother.\n"
msgstr ""

#. translators: Short description of the app to be displayed in the Play Store. Limit to 80 characters including spaces and commas!
Expand Down
2 changes: 2 additions & 0 deletions WooCommerce/metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
We keep adding new functionality to our experimental Coupon Management feature! This release includes editing and deleting coupons along with several improvements on viewing. Turn this feature on for early access in the More tab, Settings, Beta Features.

We also fixed a bug that was making it hard for some of you to search orders. Thanks to everyone who reported this! Your feedback is vital to us!

Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,40 @@ class AppPrefsTest {
)
).isNull()
}

@Test
fun givenIsPluginExplicitlySelectedIsFalseThenReturnFalse() {
AppPrefs.setIsCardReaderPluginExplicitlySelectedFlag(
localSiteId = 0,
remoteSiteId = 0L,
selfHostedSiteId = 0L,
isPluginExplicitlySelected = false
)

assertThat(
AppPrefs.isCardReaderPluginExplicitlySelected(
localSiteId = 0,
remoteSiteId = 0L,
selfHostedSiteId = 0L,
)
).isFalse
}

@Test
fun givenIsPluginExplicitlySelectedIsTrueThenReturnTrue() {
AppPrefs.setIsCardReaderPluginExplicitlySelectedFlag(
localSiteId = 0,
remoteSiteId = 0L,
selfHostedSiteId = 0L,
isPluginExplicitlySelected = true
)

assertThat(
AppPrefs.isCardReaderPluginExplicitlySelected(
localSiteId = 0,
remoteSiteId = 0L,
selfHostedSiteId = 0L,
)
).isTrue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class ScreenshotTest : TestBase() {
val composeTestRule = createComposeRule()

@get:Rule(order = 3)
var activityRule = ActivityTestRule(MainActivity::class.java)

@Rule @JvmField
val localeTestRule = LocaleTestRule()

@get:Rule(order = 4)
var activityRule = ActivityTestRule(MainActivity::class.java)

@Before
fun setUp() {
CleanStatusBar.enableWithDefaults()
Expand Down
29 changes: 20 additions & 9 deletions WooCommerce/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest package="com.woocommerce.android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.woocommerce.android">

<!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- Allows for storing and retrieving screenshots -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- Allows changing locales -->
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.CHANGE_CONFIGURATION"
tools:ignore="ProtectedPermissions" />

<!-- Clean the status bar for screenshots automation
See https://docs.fastlane.tools/actions/screengrab/#clean-status-bar -->
<!-- Indicates the use of the clean status bar feature -->
<uses-feature android:name="tools.fastlane.screengrab.cleanstatusbar" />
<!-- Allows for changing the status bar -->
<uses-permission android:name="android.permission.DUMP" tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.DUMP"
tools:ignore="ProtectedPermissions" />

<application
android:name=".WooCommerceDebug"
tools:replace="android:name" />
tools:replace="android:name">
<provider
android:name=".LeakCanaryInstaller"
android:authorities="${applicationId}.leakcanary-installer"
android:exported="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.woocommerce.android

import android.app.Application
import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri
import com.woocommerce.android.util.PackageUtils
import com.woocommerce.android.util.WooLog
import leakcanary.AppWatcher

internal class LeakCanaryInstaller : ContentProvider() {
override fun onCreate(): Boolean {
if (!PackageUtils.isTesting()) {
WooLog.v(WooLog.T.DEVICE, "Installing LeakCanary")
val application = context!!.applicationContext as Application
AppWatcher.manualInstall(application)
}
return true
}

override fun query(
uri: Uri,
projectionArg: Array<String>?,
selection: String?,
selectionArgs: Array<String>?,
sortOrder: String?
): Cursor? = null

override fun getType(uri: Uri): String? = null

override fun insert(uri: Uri, contentValues: ContentValues?): Uri? = null

override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0

override fun update(
uri: Uri,
values: ContentValues?,
selection: String?,
selectionArgs: Array<out String>?
): Int = 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class AppInitializer @Inject constructor() : ApplicationLifecycleListener {
}
}

@Suppress("DEPRECATION")
override fun onAppComesFromBackground() {
AnalyticsTracker.track(AnalyticsEvent.APPLICATION_OPENED)

Expand Down
33 changes: 33 additions & 0 deletions WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.content.SharedPreferences.Editor
import androidx.preference.PreferenceManager
import com.woocommerce.android.AppPrefs.CardReaderOnboardingStatus.CARD_READER_ONBOARDING_COMPLETED
import com.woocommerce.android.AppPrefs.CardReaderOnboardingStatus.CARD_READER_ONBOARDING_NOT_COMPLETED
import com.woocommerce.android.AppPrefs.DeletablePrefKey.CARD_READER_IS_PLUGIN_EXPLICITLY_SELECTED
import com.woocommerce.android.AppPrefs.DeletablePrefKey.CARD_READER_ONBOARDING_COMPLETED_STATUS_V2
import com.woocommerce.android.AppPrefs.DeletablePrefKey.CARD_READER_PREFERRED_PLUGIN
import com.woocommerce.android.AppPrefs.DeletablePrefKey.CARD_READER_PREFERRED_PLUGIN_VERSION
Expand Down Expand Up @@ -71,6 +72,7 @@ object AppPrefs {
USER_EMAIL,
RECEIPT_PREFIX,
CARD_READER_ONBOARDING_COMPLETED_STATUS_V2,
CARD_READER_IS_PLUGIN_EXPLICITLY_SELECTED,
CARD_READER_PREFERRED_PLUGIN,
CARD_READER_PREFERRED_PLUGIN_VERSION,
CARD_READER_STATEMENT_DESCRIPTOR,
Expand Down Expand Up @@ -475,6 +477,19 @@ object AppPrefs {

fun isCardReaderWelcomeDialogShown() = getBoolean(UndeletablePrefKey.CARD_READER_WELCOME_SHOWN, false)

fun isCardReaderPluginExplicitlySelected(
localSiteId: Int,
remoteSiteId: Long,
selfHostedSiteId: Long
) = getBoolean(
getIsPluginExplicitlySelectedKey(
localSiteId,
remoteSiteId,
selfHostedSiteId
),
false
)

fun getCardReaderPreferredPlugin(
localSiteId: Int,
remoteSiteId: Long,
Expand Down Expand Up @@ -534,12 +549,30 @@ object AppPrefs {
}
}

fun setIsCardReaderPluginExplicitlySelectedFlag(
localSiteId: Int,
remoteSiteId: Long,
selfHostedSiteId: Long,
isPluginExplicitlySelected: Boolean
) {
setBoolean(
getIsPluginExplicitlySelectedKey(localSiteId, remoteSiteId, selfHostedSiteId),
isPluginExplicitlySelected
)
}

private fun getCardReaderOnboardingStatusKey(
localSiteId: Int,
remoteSiteId: Long,
selfHostedSiteId: Long
) = PrefKeyString("$CARD_READER_ONBOARDING_COMPLETED_STATUS_V2:$localSiteId:$remoteSiteId:$selfHostedSiteId")

private fun getIsPluginExplicitlySelectedKey(
localSiteId: Int,
remoteSiteId: Long,
selfHostedSiteId: Long
) = PrefKeyString("$CARD_READER_IS_PLUGIN_EXPLICITLY_SELECTED:$localSiteId:$remoteSiteId:$selfHostedSiteId")

private fun getCardReaderPreferredPluginKey(
localSiteId: Int,
remoteSiteId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class AppPrefsWrapper @Inject constructor() {

fun isCardReaderWelcomeDialogShown() = AppPrefs.isCardReaderWelcomeDialogShown()

fun isCardReaderPluginExplicitlySelected(localSiteId: Int, remoteSiteId: Long, selfHostedSiteId: Long) =
AppPrefs.isCardReaderPluginExplicitlySelected(localSiteId, remoteSiteId, selfHostedSiteId)

fun getCardReaderPreferredPlugin(
localSiteId: Int,
remoteSiteId: Long,
Expand Down Expand Up @@ -59,6 +62,20 @@ class AppPrefsWrapper @Inject constructor() {
)
}

fun setIsCardReaderPluginExplicitlySelectedFlag(
localSiteId: Int,
remoteSiteId: Long,
selfHostedSiteId: Long,
isPluginExplicitlySelected: Boolean = false
) {
AppPrefs.setIsCardReaderPluginExplicitlySelectedFlag(
localSiteId,
remoteSiteId,
selfHostedSiteId,
isPluginExplicitlySelected
)
}

fun setCardReaderStatementDescriptor(
statementDescriptor: String?,
localSiteId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ enum class AnalyticsEvent(val siteless: Boolean = false) {
ORDER_CREATION_SUCCESS,
ORDER_CREATION_FAILED,
ORDER_SYNC_FAILED,
ORDER_CREATION_CUSTOMER_SEARCH,
ORDER_CREATION_CUSTOMER_ADDED,

// -- Refunds
CREATE_ORDER_REFUND_NEXT_BUTTON_TAPPED,
Expand Down Expand Up @@ -255,6 +257,7 @@ enum class AnalyticsEvent(val siteless: Boolean = false) {
// -- Card Present Payments - onboarding
CARD_PRESENT_ONBOARDING_LEARN_MORE_TAPPED,
CARD_PRESENT_ONBOARDING_NOT_COMPLETED,
CARD_PRESENT_PAYMENT_GATEWAY_SELECTED,

// -- Card Present Payments - collection
CARD_PRESENT_COLLECT_PAYMENT_TAPPED,
Expand Down Expand Up @@ -329,6 +332,7 @@ enum class AnalyticsEvent(val siteless: Boolean = false) {
SETTINGS_WE_ARE_HIRING_BUTTON_TAPPED,
SETTINGS_BETA_FEATURES_PRODUCTS_TOGGLED,
SETTINGS_IMAGE_OPTIMIZATION_TOGGLED,
SETTINGS_CARD_PRESENT_SELECT_PAYMENT_GATEWAY_TAPPED,
PRIVACY_SETTINGS_COLLECT_INFO_TOGGLED,
PRIVACY_SETTINGS_PRIVACY_POLICY_LINK_TAPPED,
PRIVACY_SETTINGS_SHARE_INFO_LINK_TAPPED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.woocommerce.android.util.WooLog
import com.woocommerce.android.util.WooLog.T
import org.json.JSONObject
import org.wordpress.android.fluxc.model.SiteModel
import java.util.Locale
import java.util.UUID

class AnalyticsTracker private constructor(private val context: Context) {
Expand Down Expand Up @@ -62,7 +63,7 @@ class AnalyticsTracker private constructor(private val context: Context) {
return
}

val eventName = stat.name.toLowerCase()
val eventName = stat.name.lowercase(Locale.getDefault())

val user = username ?: getAnonID() ?: generateNewAnonID()

Expand Down Expand Up @@ -296,6 +297,7 @@ class AnalyticsTracker private constructor(private val context: Context) {
const val KEY_AMOUNT = "amount"

const val KEY_PAYMENT_METHOD = "payment_method"
const val KEY_PAYMENT_GATEWAY = "payment_gateway"

const val KEY_IS_JETPACK_CP_CONNECTED = "is_jetpack_cp_conntected"
const val KEY_ACTIVE_JETPACK_CONNECTION_PLUGINS = "active_jetpack_connection_plugins"
Expand Down
Loading

0 comments on commit 7551671

Please sign in to comment.