From 75b76c3b1e3061a1ed70bea80b3f3525282e19c4 Mon Sep 17 00:00:00 2001 From: A117870935 Date: Mon, 12 Jun 2023 14:24:37 +0530 Subject: [PATCH 1/2] Progress and seek bar customized. --- .../client/logger/ui/LogsActivity.kt | 4 ++- .../android/ui/utils/ProgressBarThemeUtils.kt | 28 +++++++++++++++++++ .../android/media/MediaControlView.kt | 4 ++- .../android/ui/adapter/UploadListAdapter.java | 5 +++- .../ui/fragment/FileDetailFragment.java | 4 ++- .../ui/preview/FileDownloadFragment.java | 4 ++- 6 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/nmc/android/ui/utils/ProgressBarThemeUtils.kt diff --git a/app/src/main/java/com/nextcloud/client/logger/ui/LogsActivity.kt b/app/src/main/java/com/nextcloud/client/logger/ui/LogsActivity.kt index 642d22ba0fcc..d5174144bc1c 100644 --- a/app/src/main/java/com/nextcloud/client/logger/ui/LogsActivity.kt +++ b/app/src/main/java/com/nextcloud/client/logger/ui/LogsActivity.kt @@ -21,6 +21,7 @@ import com.owncloud.android.R import com.owncloud.android.databinding.LogsActivityBinding import com.owncloud.android.ui.activity.ToolbarActivity import com.owncloud.android.utils.theme.ViewThemeUtils +import com.nmc.android.ui.utils.ProgressBarThemeUtils import javax.inject.Inject class LogsActivity : ToolbarActivity() { @@ -55,7 +56,8 @@ class LogsActivity : ToolbarActivity() { } findViewById(R.id.logs_loading_progress).apply { - viewThemeUtils.platform.themeHorizontalProgressBar(this) + //NMC Customization + ProgressBarThemeUtils.themeHorizontalProgressBar(this, resources.getColor(R.color.primary, null)) } logsAdapter = LogsAdapter(this) diff --git a/app/src/main/java/com/nmc/android/ui/utils/ProgressBarThemeUtils.kt b/app/src/main/java/com/nmc/android/ui/utils/ProgressBarThemeUtils.kt new file mode 100644 index 000000000000..ea274bb68c3a --- /dev/null +++ b/app/src/main/java/com/nmc/android/ui/utils/ProgressBarThemeUtils.kt @@ -0,0 +1,28 @@ +package com.nmc.android.ui.utils + +import android.widget.ProgressBar +import android.widget.SeekBar +import androidx.annotation.ColorInt +import androidx.core.graphics.BlendModeColorFilterCompat +import androidx.core.graphics.BlendModeCompat + +/** + * theming progress and seek bar for NMC + */ +object ProgressBarThemeUtils { + + @JvmStatic + fun themeHorizontalSeekBar(seekBar: SeekBar, @ColorInt color: Int) { + themeHorizontalProgressBar(seekBar, color) + seekBar.thumb.colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC_IN) + } + + @JvmStatic + fun themeHorizontalProgressBar(progressBar: ProgressBar?, @ColorInt color: Int) { + progressBar?.indeterminateDrawable?.colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC_IN) + progressBar?.progressDrawable?.colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC_IN) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/owncloud/android/media/MediaControlView.kt b/app/src/main/java/com/owncloud/android/media/MediaControlView.kt index 25747c3f1bd0..1b7eb5081e0b 100644 --- a/app/src/main/java/com/owncloud/android/media/MediaControlView.kt +++ b/app/src/main/java/com/owncloud/android/media/MediaControlView.kt @@ -27,6 +27,7 @@ import android.widget.MediaController.MediaPlayerControl import android.widget.SeekBar import android.widget.SeekBar.OnSeekBarChangeListener import androidx.core.content.ContextCompat +import com.nmc.android.ui.utils.ProgressBarThemeUtils import com.owncloud.android.MainApp import com.owncloud.android.R import com.owncloud.android.databinding.MediaControlBinding @@ -85,7 +86,8 @@ class MediaControlView(context: Context, attrs: AttributeSet?) : binding.rewindBtn.setOnClickListener(this) binding.progressBar.run { - viewThemeUtils.platform.themeHorizontalSeekBar(this) + // NMC Customization + ProgressBarThemeUtils.themeHorizontalSeekBar(this, resources.getColor(R.color.primary, null)) setMax(1000) } diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index 80fdcb89a5c0..5bff6ac85d21 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -30,6 +30,7 @@ import com.nextcloud.client.jobs.upload.FileUploadHelper; import com.nextcloud.client.jobs.upload.FileUploadWorker; import com.nextcloud.client.network.ConnectivityService; +import com.nmc.android.ui.utils.ProgressBarThemeUtils; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.databinding.UploadListHeaderBinding; @@ -345,7 +346,9 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati String status = getStatusText(item); switch (item.getUploadStatus()) { case UPLOAD_IN_PROGRESS -> { - viewThemeUtils.platform.themeHorizontalProgressBar(itemViewHolder.binding.uploadProgressBar); + // NMC Customization + ProgressBarThemeUtils.themeHorizontalProgressBar(itemViewHolder.binding.uploadProgressBar, + holder.itemView.getContext().getResources().getColor(R.color.primary, null)); itemViewHolder.binding.uploadProgressBar.setProgress(0); itemViewHolder.binding.uploadProgressBar.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index b02a85ae5022..06d987bde32a 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -58,6 +58,7 @@ import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.EncryptionUtils; import com.owncloud.android.utils.MimeTypeUtil; +import com.nmc.android.ui.utils.ProgressBarThemeUtils; import com.owncloud.android.utils.theme.ViewThemeUtils; import org.greenrobot.eventbus.EventBus; @@ -255,7 +256,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { if (getFile() != null && user != null) { - viewThemeUtils.platform.themeHorizontalProgressBar(binding.progressBar); + //NMC Customization + ProgressBarThemeUtils.themeHorizontalProgressBar(binding.progressBar, getResources().getColor(R.color.primary, null)); progressListener = new ProgressListener(binding.progressBar); binding.cancelBtn.setOnClickListener(this); binding.favorite.setOnClickListener(this); diff --git a/app/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java b/app/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java index 3004dce0fd36..2bdae76f8f30 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java @@ -25,6 +25,7 @@ import com.nextcloud.client.jobs.download.FileDownloadHelper; import com.nextcloud.utils.extensions.BundleExtensionsKt; import com.nextcloud.utils.extensions.FileExtensionsKt; +import com.nmc.android.ui.utils.ProgressBarThemeUtils; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; @@ -139,7 +140,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mView = inflater.inflate(R.layout.file_download_fragment, container, false); ProgressBar progressBar = mView.findViewById(R.id.progressBar); - viewThemeUtils.platform.themeHorizontalProgressBar(progressBar); + //NMC Customization + ProgressBarThemeUtils.themeHorizontalProgressBar(progressBar, getResources().getColor(R.color.primary, null)); mProgressListener = new ProgressListener(progressBar); (mView.findViewById(R.id.cancelBtn)).setOnClickListener(this); From 869917c67360181afb9800b5774502d45a8f427d Mon Sep 17 00:00:00 2001 From: A117870935 Date: Thu, 18 May 2023 18:03:56 +0530 Subject: [PATCH 2/2] Tealium and Adjust SDKs added from following branches: feature/NMCLOUD-339 feature/NMCLOUD-428 --- app/build.gradle | 6 +- app/src/main/AndroidManifest.xml | 11 ++ .../nextcloud/client/di/ActivityInjector.kt | 7 +- .../client/preferences/AppPreferences.java | 18 +++ .../preferences/AppPreferencesImpl.java | 25 +++ .../android/marketTracking/AdjustSdkUtils.kt | 67 ++++++++ .../android/marketTracking/TealiumSdkUtils.kt | 107 +++++++++++++ .../marketTracking/TrackingScanInterface.kt | 14 ++ .../TrackingScanInterfaceImpl.kt | 18 +++ .../com/nmc/android/ui/PrivacyUserAction.kt | 9 ++ .../java/com/owncloud/android/MainApp.java | 13 ++ .../authentication/AuthenticatorActivity.java | 13 ++ .../ui/activity/FileDisplayActivity.java | 4 + .../android/ui/activity/SettingsActivity.java | 8 + .../ui/activity/SyncedFoldersActivity.kt | 13 ++ .../android/ui/dialog/AccountRemovalDialog.kt | 148 +++--------------- .../ui/fragment/FileDetailFragment.java | 3 + .../fragment/FileDetailSharingFragment.java | 8 + .../fragment/OCFileListBottomSheetDialog.java | 8 + .../ui/fragment/OCFileListFragment.java | 39 +++++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + gradle.properties | 2 +- nmc_marketing-dependencies.gradle | 23 +++ 24 files changed, 436 insertions(+), 130 deletions(-) create mode 100644 app/src/main/java/com/nmc/android/marketTracking/AdjustSdkUtils.kt create mode 100644 app/src/main/java/com/nmc/android/marketTracking/TealiumSdkUtils.kt create mode 100644 app/src/main/java/com/nmc/android/marketTracking/TrackingScanInterface.kt create mode 100644 app/src/main/java/com/nmc/android/marketTracking/TrackingScanInterfaceImpl.kt create mode 100644 app/src/main/java/com/nmc/android/ui/PrivacyUserAction.kt create mode 100644 nmc_marketing-dependencies.gradle diff --git a/app/build.gradle b/app/build.gradle index d89b137e29fb..42abf0e87d18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,7 +50,8 @@ if (shotTest) { apply plugin: 'shot' } apply plugin: 'com.google.devtools.ksp' - +// apply marketing SDK for NMC +apply from: "$rootProject.projectDir/nmc_marketing-dependencies.gradle" println "Gradle uses Java ${Jvm.current()}" @@ -427,6 +428,9 @@ dependencies { // splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate implementation 'androidx.core:core-splashscreen:1.0.1' + + // NMC: dependency required to capture Advertising ID for Adjust & MoEngage SDK + implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' } configurations.configureEach { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6f89c63ac939..c69fbec4e95c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -606,6 +606,17 @@ android:name="com.nextcloud.client.etm.EtmActivity" android:exported="false" android:theme="@style/Theme.ownCloud.Toolbar" /> + + + + + + + + androidInjector() { return dispatchingAndroidInjector; } + //NMC Customization + private void initMarketTrackingSdks(){ + TealiumSdkUtils.initialiseTealiumSDK(this); + AdjustSdkUtils.initialiseAdjustSDK(this); + } + public static void setAppTheme(DarkMode mode) { switch (mode) { case LIGHT -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); diff --git a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java index 727f514ca66d..855413123046 100644 --- a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -66,6 +66,8 @@ import com.nextcloud.common.PlainClient; import com.nextcloud.operations.PostMethod; import com.nextcloud.utils.extensions.BundleExtensionsKt; +import com.nmc.android.marketTracking.AdjustSdkUtils; +import com.nmc.android.marketTracking.TealiumSdkUtils; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.databinding.AccountSetupBinding; @@ -1333,6 +1335,10 @@ public void onAuthenticatorTaskCallback(RemoteOperationResult result) } private void endSuccess() { + //track successful login event + AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_SUCCESSFUL_LOGIN, preferences); + TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_SUCCESSFUL_LOGIN, preferences); + if (onlyAdd) { finish(); } else { @@ -1735,4 +1741,11 @@ public void onSavedCertificate() { public void onFailedSavingCertificate() { DisplayUtils.showSnackMessage(this, R.string.ssl_validator_not_saved); } + + @Override + protected void onStart() { + super.onStart(); + //track screen view when activity is visible + TealiumSdkUtils.trackView(TealiumSdkUtils.SCREEN_VIEW_LOGIN, preferences); + } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 868513da42f2..0e5f5fa1bc9e 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -63,6 +63,7 @@ import com.nextcloud.client.network.ConnectivityService; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.utils.IntentUtil; +import com.nmc.android.marketTracking.TealiumSdkUtils; import com.nextcloud.model.WorkerState; import com.nextcloud.model.WorkerStateLiveData; import com.nextcloud.utils.extensions.ActivityExtensionsKt; @@ -2327,6 +2328,9 @@ public void onStart() { EventBus.getDefault().post(new TokenPushEvent()); checkForNewDevVersionNecessary(getApplicationContext()); + + //track screen view when activity is visible + TealiumSdkUtils.trackView(TealiumSdkUtils.SCREEN_VIEW_FILE_BROWSER, preferences); } private void registerRefreshFolderEventReceiver() { diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java index 0dbf9ca99e92..949601a2421a 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java @@ -47,6 +47,7 @@ import com.nextcloud.client.network.ClientFactory; import com.nextcloud.client.network.ConnectivityService; import com.nextcloud.client.preferences.AppPreferences; +import com.nmc.android.marketTracking.TealiumSdkUtils; import com.nextcloud.client.preferences.AppPreferencesImpl; import com.nextcloud.client.preferences.DarkMode; import com.owncloud.android.BuildConfig; @@ -1067,6 +1068,13 @@ protected void onPostCreate(Bundle savedInstanceState) { getDelegate().onPostCreate(savedInstanceState); } + @Override + protected void onStart() { + super.onStart(); + //track screen view when activity is visible + TealiumSdkUtils.trackView(TealiumSdkUtils.SCREEN_VIEW_SETTINGS, preferences); + } + @Override protected void onDestroy() { super.onDestroy(); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt index 23486394a2ca..cdc265f63ae8 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt @@ -35,6 +35,8 @@ import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.SubFolderRule import com.nextcloud.utils.extensions.getParcelableArgument import com.nextcloud.utils.extensions.isDialogFragmentReady +import com.nmc.android.marketTracking.AdjustSdkUtils +import com.nmc.android.marketTracking.TealiumSdkUtils import com.owncloud.android.BuildConfig import com.owncloud.android.MainApp import com.owncloud.android.R @@ -583,6 +585,9 @@ class SyncedFoldersActivity : backgroundJobManager.startImmediateFilesSyncJob(syncedFolderDisplayItem.id, overridePowerSaving = false) showBatteryOptimizationInfo() } + + //track event when user enable/disable auto upload on/off + trackAutoUploadEvent(syncedFolderDisplayItem.isEnabled) } override fun onSyncFolderSettingsClick(section: Int, syncedFolderDisplayItem: SyncedFolderDisplayItem?) { @@ -710,6 +715,14 @@ class SyncedFoldersActivity : if (syncedFolder.isEnabled) { showBatteryOptimizationInfo() } + + //track event when user enable/disable auto upload on/off + trackAutoUploadEvent(syncedFolder.isEnabled) + } + + private fun trackAutoUploadEvent(enabled: Boolean) { + AdjustSdkUtils.trackEvent(if (enabled) AdjustSdkUtils.EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_ON else AdjustSdkUtils.EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_OFF, preferences) + TealiumSdkUtils.trackEvent(if (enabled) TealiumSdkUtils.EVENT_SETTINGS_AUTO_UPLOAD_ON else TealiumSdkUtils.EVENT_SETTINGS_AUTO_UPLOAD_OFF, preferences) } private fun saveOrUpdateSyncedFolder(item: SyncedFolderDisplayItem) { diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt index e42f1b7c626f..f07de12e475f 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalDialog.kt @@ -9,27 +9,23 @@ package com.owncloud.android.ui.dialog import android.app.Dialog -import android.graphics.drawable.Drawable +import android.content.DialogInterface import android.os.Bundle -import android.view.View -import androidx.appcompat.app.AlertDialog import androidx.fragment.app.DialogFragment -import com.google.android.material.button.MaterialButton import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.nextcloud.client.account.User -import com.nextcloud.client.account.UserAccountManager import com.nextcloud.client.di.Injectable import com.nextcloud.client.jobs.BackgroundJobManager +import com.nextcloud.client.preferences.AppPreferences +import com.nmc.android.marketTracking.AdjustSdkUtils +import com.nmc.android.marketTracking.TealiumSdkUtils import com.nextcloud.utils.extensions.getParcelableArgument import com.owncloud.android.R -import com.owncloud.android.databinding.AccountRemovalDialogBinding -import com.owncloud.android.datamodel.FileDataStorageManager -import com.owncloud.android.utils.DisplayUtils -import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener import com.owncloud.android.utils.theme.ViewThemeUtils import javax.inject.Inject -class AccountRemovalDialog : DialogFragment(), AvatarGenerationListener, Injectable { +// NMC Customization: We don't need two option for logout. On logout directly logout the user locally from the app +class AccountRemovalDialog : DialogFragment(), Injectable { @Inject lateinit var backgroundJobManager: BackgroundJobManager @@ -37,137 +33,37 @@ class AccountRemovalDialog : DialogFragment(), AvatarGenerationListener, Injecta @Inject lateinit var viewThemeUtils: ViewThemeUtils + @Inject + lateinit var appPreferences: AppPreferences + private var user: User? = null - private lateinit var alertDialog: AlertDialog - private var _binding: AccountRemovalDialogBinding? = null - val binding get() = _binding!! override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) user = requireArguments().getParcelableArgument(KEY_USER, User::class.java) } - override fun onStart() { - super.onStart() - - // disable positive button and apply theming - alertDialog = dialog as AlertDialog - alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false - - viewThemeUtils.platform.themeRadioButton(binding.radioLocalRemove) - viewThemeUtils.platform.themeRadioButton(binding.radioRequestDeletion) - viewThemeUtils.material.colorMaterialButtonPrimaryTonal( - alertDialog.getButton(AlertDialog.BUTTON_POSITIVE) as MaterialButton - ) - viewThemeUtils.material.colorMaterialButtonPrimaryBorderless( - alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE) as MaterialButton - ) - - binding.userName.text = UserAccountManager.getDisplayName(user) - binding.account.text = user?.let { DisplayUtils.convertIdn(it.accountName, false) } - } - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - _binding = AccountRemovalDialogBinding.inflate(layoutInflater) - - // start avatar generation - setAvatar() - - // hide second option when plug-in isn't installed - if (hasDropAccount()) { - binding.requestDeletion.visibility = View.VISIBLE - } - - val builder = - MaterialAlertDialogBuilder(requireActivity()) - .setTitle(R.string.delete_account) - .setView(binding.root) - .setNegativeButton(R.string.common_cancel) { _, _ -> } - .setPositiveButton(R.string.delete_account) { _, _ -> removeAccount() } - - // allow selection by clicking on list element - binding.localRemove.setOnClickListener { - binding.radioLocalRemove.performClick() - } - binding.requestDeletion.setOnClickListener { - binding.radioRequestDeletion.performClick() - } - - // set listeners for custom radio button list - binding.radioLocalRemove.setOnClickListener { - binding.radioRequestDeletion.isChecked = false - alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).apply { - text = getText(R.string.delete_account) - isEnabled = true - } - } - binding.radioRequestDeletion.setOnClickListener { - binding.radioLocalRemove.isChecked = false - alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).apply { - text = getString(R.string.request_account_deletion_button) - isEnabled = true + val builder = MaterialAlertDialogBuilder(requireActivity()) + .setTitle(R.string.delete_account) + .setMessage(resources.getString(R.string.delete_account_warning, user!!.accountName)) + .setIcon(R.drawable.ic_warning) + .setPositiveButton(R.string.common_ok) { _: DialogInterface?, _: Int -> + // track adjust and tealium events on logout confirmed + AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_SETTINGS_LOGOUT, appPreferences) + TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_SETTINGS_LOGOUT, appPreferences) + backgroundJobManager.startAccountRemovalJob( + user!!.accountName, + false + ) } - } - - viewThemeUtils.dialog.colorMaterialAlertDialogBackground(requireActivity(), builder) + .setNegativeButton(R.string.common_cancel, null) return builder.create() } - /** - * Get value of `drop-account` capability. - */ - private fun hasDropAccount(): Boolean { - val capability = FileDataStorageManager(user, context?.contentResolver).getCapability(user) - return capability.dropAccount.isTrue - } - - /** - * Start removal of account. Depending on which option is checked, either a browser will open to request deletion, - * or the local account will be removed immediately. - */ - private fun removeAccount() { - user?.let { user -> - if (binding.radioRequestDeletion.isChecked) { - DisplayUtils.startLinkIntent(activity, user.server.uri.toString() + DROP_ACCOUNT_URI) - } else { - backgroundJobManager.startAccountRemovalJob(user.accountName, false) - } - } - } - - /** - * Start avatar generation. - */ - private fun setAvatar() { - try { - val imageView = binding.userIcon - imageView.tag = user!!.accountName - DisplayUtils.setAvatar( - user!!, - this, - resources.getDimension(R.dimen.list_item_avatar_icon_radius), - resources, - imageView, - context - ) - } catch (_: Exception) { - } - } - - override fun avatarGenerated(avatarDrawable: Drawable?, callContext: Any?) { - avatarDrawable?.let { - binding.userIcon.setImageDrawable(it) - } - } - - override fun shouldCallGeneratedCallback(tag: String?, callContext: Any?): Boolean { - return binding.userIcon.tag == tag - } - companion object { private const val KEY_USER = "USER" - private const val DROP_ACCOUNT_URI = "/settings/user/drop_account" @JvmStatic fun newInstance(user: User) = AccountRemovalDialog().apply { diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index 06d987bde32a..d0c2711e6baa 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -36,6 +36,7 @@ import com.nextcloud.utils.MenuUtils; import com.nextcloud.utils.extensions.BundleExtensionsKt; import com.nextcloud.utils.extensions.FileExtensionsKt; +import com.nmc.android.marketTracking.TealiumSdkUtils; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.databinding.FileDetailsFragmentBinding; @@ -373,6 +374,8 @@ public void onStart() { super.onStart(); listenForTransferProgress(); EventBus.getDefault().register(this); + //track screen view when fragment is visible + TealiumSdkUtils.trackView(TealiumSdkUtils.SCREEN_VIEW_SHARING, preferences); } @Override diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java index 071faeee4666..372fde88d28d 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java @@ -55,6 +55,9 @@ import com.owncloud.android.ui.adapter.ShareeListAdapter; import com.owncloud.android.ui.adapter.ShareeListAdapterListener; import com.owncloud.android.ui.asynctasks.RetrieveHoverCardAsyncTask; +import com.nextcloud.client.preferences.AppPreferences; +import com.nmc.android.marketTracking.AdjustSdkUtils; +import com.nmc.android.marketTracking.TealiumSdkUtils; import com.owncloud.android.ui.dialog.SharePasswordDialogFragment; import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper; import com.owncloud.android.ui.helpers.FileOperationsHelper; @@ -101,6 +104,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda @Inject ClientFactory clientFactory; @Inject ViewThemeUtils viewThemeUtils; @Inject UsersAndGroupsSearchConfig searchConfig; + @Inject AppPreferences appPreferences; public static FileDetailSharingFragment newInstance(OCFile file, User user) { FileDetailSharingFragment fragment = new FileDetailSharingFragment(); @@ -311,6 +315,10 @@ public void createPublicShareLink() { // create without password if not enforced by server or we don't know if enforced; fileOperationsHelper.shareFileViaPublicShare(file, null); } + + //track event on creating share link + AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_CREATE_SHARING_LINK, appPreferences); + TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_CREATE_SHARING_LINK, appPreferences); } @Override diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java index 2deb69e0537d..941b0530396d 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java @@ -16,7 +16,9 @@ import com.nextcloud.client.device.DeviceInfo; import com.nextcloud.client.di.Injectable; import com.nextcloud.client.documentscan.AppScanOptionalFeature; +import com.nextcloud.client.preferences.AppPreferencesImpl; import com.nextcloud.utils.EditorUtils; +import com.nmc.android.marketTracking.TealiumSdkUtils; import com.owncloud.android.R; import com.owncloud.android.databinding.FileListActionsBottomSheetCreatorBinding; import com.owncloud.android.databinding.FileListActionsBottomSheetFragmentBinding; @@ -157,6 +159,12 @@ protected void onCreate(Bundle savedInstanceState) { } setupClickListener(); + + //track screen view when fragment is visible + TealiumSdkUtils.trackView(TealiumSdkUtils.SCREEN_VIEW_FAB_PLUS, + //Need to create direct instance of AppPreferences as Injection doesn't work in Dialogs + //If we take AppPreferences as parameter in constructor it will affect the other NMC PRs test cases + AppPreferencesImpl.fromContext(fileActivity)); } private void setupClickListener() { diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index d6725c51d7ef..54aacc0d7dc2 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -61,7 +61,11 @@ import com.nextcloud.utils.extensions.FileExtensionsKt; import com.nextcloud.utils.extensions.IntentExtensionsKt; import com.nextcloud.utils.fileNameValidator.FileNameValidator; +import com.nmc.android.marketTracking.TrackingScanInterface; import com.nextcloud.utils.view.FastScrollUtils; +import com.nmc.android.marketTracking.AdjustSdkUtils; +import com.nmc.android.marketTracking.TrackingScanInterfaceImpl; +import com.nmc.android.marketTracking.TealiumSdkUtils; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.ArbitraryDataProvider; @@ -233,6 +237,13 @@ public class OCFileListFragment extends ExtendedListFragment implements @Inject DeviceInfo deviceInfo; + /** + * Things to note about both the branches. 1. nmc/1867-scanbot branch: --> interface won't be initialised --> + * calling of interface method will be done here 2. nmc/1925-market_tracking --> interface will be initialised --> + * calling of interface method won't be done here + */ + private TrackingScanInterface trackingScanInterface; + protected enum MenuItemAddRemove { DO_NOTHING, REMOVE_SORT, @@ -257,6 +268,9 @@ public void onCreate(Bundle savedInstanceState) { } searchFragment = currentSearchType != null && isSearchEventSet(searchEvent); + + //NMC customization will be initialised in nmc/1925-market_tracking + trackingScanInterface = new TrackingScanInterfaceImpl(); } @Override @@ -520,6 +534,10 @@ public void uploadFromApp() { Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS ); + + //track event photo/video/any upload button click + AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_FAB_BOTTOM_PHOTO_VIDEO_UPLOAD, preferences); + TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_FAB_BOTTOM_PHOTO_VIDEO_UPLOAD, preferences); } @Override @@ -537,6 +555,10 @@ public void directCameraUpload() { } showDirectCameraUploadAlertDialog(fileDisplayActivity); + + // NMC: track event for camera upload button click + AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_FAB_BOTTOM_CAMERA_UPLOAD, preferences); + TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_FAB_BOTTOM_CAMERA_UPLOAD, preferences); } private void showDirectCameraUploadAlertDialog(FileDisplayActivity fileDisplayActivity) { @@ -579,6 +601,10 @@ public void uploadFiles() { ((FileActivity) getActivity()).getUser().orElseThrow(RuntimeException::new), FileDisplayActivity.REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM, getCurrentFile().isEncrypted()); + + // track event for uploading files button click + AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_FAB_BOTTOM_FILE_UPLOAD, preferences); + TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_FAB_BOTTOM_FILE_UPLOAD, preferences); } @Override @@ -607,6 +633,14 @@ public void onShareIconClick(OCFile file) { mContainerActivity.getFileOperationsHelper().sendShareFile(file); }); } + + //track event on click of Share button + trackSharingClickEvent(); + } + + private void trackSharingClickEvent() { + AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_FILE_BROWSER_SHARING, preferences); + TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_FILE_BROWSER_SHARING, preferences); } @Override @@ -1193,6 +1227,8 @@ public boolean onFileActionChosen(@IdRes final int itemId, Set checkedFi if (itemId == R.id.action_send_share_file) { mContainerActivity.getFileOperationsHelper().sendShareFile(singleFile); + //track event on click of Share button + trackSharingClickEvent(); return true; } else if (itemId == R.id.action_open_file_with) { mContainerActivity.getFileOperationsHelper().openFile(singleFile); @@ -1223,6 +1259,9 @@ public boolean onFileActionChosen(@IdRes final int itemId, Set checkedFi mContainerActivity.showDetails(singleFile); mContainerActivity.showSortListGroup(false); + + //track event on click of Share button + trackSharingClickEvent(); return true; } else if (itemId == R.id.action_set_as_wallpaper) { mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile, getView()); diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 947a61daeb76..102179c9092a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -219,6 +219,7 @@ Zu sichernde Daten Zugangsdaten falsch Benutzerkonto löschen + Konto %s und alle lokalen Dateien löschen?\n\nLöschung kann nicht rückgängig gemacht werden. Einträgen entfernen Link löschen Auswahl aufheben diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5cdc8b30bd8d..6b4c2b4ff14d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -185,6 +185,7 @@ Request deletion Request permanent deletion of account by service provider Remove account + Remove account %s and delete all local files?\n\nDeletion cannot be undone. Avatar Active user Upload from… diff --git a/gradle.properties b/gradle.properties index 8a056693e8ea..9d5ed622fef4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ android.useAndroidX=true android.nonTransitiveRClass=false android.nonFinalResIds=false #android.debug.obsoleteApi=true - +ADJUST_APP_TOKEN="54qd7rraqav4" # JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 diff --git a/nmc_marketing-dependencies.gradle b/nmc_marketing-dependencies.gradle new file mode 100644 index 000000000000..79cc28d01fb6 --- /dev/null +++ b/nmc_marketing-dependencies.gradle @@ -0,0 +1,23 @@ +allprojects { + repositories { + jcenter() + maven { + url "https://maven.tealiumiq.com/android/releases/" + } + } +} + +android { + buildTypes.each { + it.buildConfigField "String", "ADJUST_APP_TOKEN", "${ADJUST_APP_TOKEN}" + } +} + +dependencies { + //Adjust SDK --> https://github.com/adjust/android_sdk + implementation 'com.adjust.sdk:adjust-android:4.28.1' + implementation 'com.android.installreferrer:installreferrer:2.2' + + //tealium sdk + implementation 'com.tealium:library:5.8.0' +} \ No newline at end of file