Skip to content

Commit

Permalink
Code refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Jun 29, 2023
1 parent 4a21a5b commit 0c48982
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.device.DeviceInfo;
import com.nextcloud.client.documentscan.AppScanOptionalFeature;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.nextcloud.ui.ChooseAccountDialogFragment;
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
import com.nextcloud.utils.EditorUtils;
Expand Down Expand Up @@ -469,8 +468,7 @@ public MaterialSchemes getMaterialSchemesForPrimaryBackground() {
fda.themeUtils,
viewThemeUtils,
editorUtils,
appScanOptionalFeature,
AppPreferencesImpl.fromContext(targetContext));
appScanOptionalFeature);

fda.runOnUiThread(sut::show);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ default void onDarkThemeModeChanged(DarkMode mode) {
void setDataAnalysis(boolean enableDataAnalysis);
boolean isDataAnalysisEnabled();

/**
* Saves the privacy policy action taken by user
* this will maintain the state of current privacy policy action taken
* @see com.nmc.android.ui.LoginPrivacySettingsActivity for actions
* @param userAction taken by user
*/
void setPrivacyPolicyAction(int userAction);
int getPrivacyPolicyAction();

/**
* Gets status of migration to user id, default false
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.account.UserAccountManagerImpl;
import com.nmc.android.ui.PrivacyUserAction;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
import com.owncloud.android.datamodel.FileDataStorageManager;
Expand Down Expand Up @@ -104,6 +105,7 @@ public final class AppPreferencesImpl implements AppPreferences {
private static final String PREF__IN_APP_REVIEW_DATA = "in_app_review_data";

private static final String PREF__DATA_ANALYSIS = "data_analysis";
private static final String PREF__PRIVACY_POLICY_ACTION = "privacy_policy_action";

private final Context context;
private final SharedPreferences preferences;
Expand Down Expand Up @@ -584,6 +586,16 @@ public boolean isDataAnalysisEnabled() {
return preferences.getBoolean(PREF__DATA_ANALYSIS, true);
}

@Override
public void setPrivacyPolicyAction(int userAction) {
preferences.edit().putInt(PREF__PRIVACY_POLICY_ACTION, userAction).apply();
}

@Override
public int getPrivacyPolicyAction() {
return preferences.getInt(PREF__PRIVACY_POLICY_ACTION, PrivacyUserAction.NO_ACTION);
}

@Override
public boolean isUserIdMigrated() {
return preferences.getBoolean(PREF__MIGRATED_USER_ID, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import com.owncloud.android.BuildConfig
import com.owncloud.android.R

object MoEngageSdkUtils {

//enable/disable moengage as we are not using it right now due to no proper firebase api key
private const val MOENGAGE_ENABLED = false

@JvmStatic
fun initMoEngageSDK(application: Application) {
if (application.resources.getBoolean(R.bool.moengage_enabled)) {
if (MOENGAGE_ENABLED) {
val moEngage = MoEngage.Builder(application, BuildConfig.MOENGAGE_APP_ID)
.build()
MoEngage.initialise(moEngage)
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/nmc/android/ui/PrivacyUserAction.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nmc.android.ui

//class to handle user action for privacy
object PrivacyUserAction {
//privacy user action to maintain the state of privacy policy
const val NO_ACTION = 0 //user has taken no action
const val REJECT_ACTION = 1 //user rejected the privacy policy
const val ACCEPT_ACTION = 2 //user has accepted the privacy policy
}
6 changes: 3 additions & 3 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.nextcloud.client.preferences.DarkMode;
import com.nmc.android.ui.LauncherActivity;
import com.nmc.android.utils.AdjustSdkUtils;
import com.nmc.android.utils.MoEngageSdkUtils;
import com.nmc.android.utils.TealiumSdkUtils;
import com.nmc.android.marketTracking.AdjustSdkUtils;
import com.nmc.android.marketTracking.MoEngageSdkUtils;
import com.nmc.android.marketTracking.TealiumSdkUtils;
import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.authentication.PassCodeManager;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
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.nmc.android.marketTracking.TealiumSdkUtils;
import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.nextcloud.client.device.DeviceInfo;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.documentscan.AppScanOptionalFeature;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.nextcloud.utils.EditorUtils;
import com.nmc.android.marketTracking.TealiumSdkUtils;
import com.owncloud.android.R;
Expand Down Expand Up @@ -62,7 +62,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog implements In
private final EditorUtils editorUtils;

private final AppScanOptionalFeature appScanOptionalFeature;
private final AppPreferences preferences;


public OCFileListBottomSheetDialog(FileActivity fileActivity,
OCFileListBottomSheetActions actions,
Expand All @@ -72,8 +72,7 @@ public OCFileListBottomSheetDialog(FileActivity fileActivity,
ThemeUtils themeUtils,
ViewThemeUtils viewThemeUtils,
EditorUtils editorUtils,
AppScanOptionalFeature appScanOptionalFeature,
AppPreferences preferences) {
AppScanOptionalFeature appScanOptionalFeature) {
super(fileActivity);
this.actions = actions;
this.fileActivity = fileActivity;
Expand All @@ -84,7 +83,6 @@ public OCFileListBottomSheetDialog(FileActivity fileActivity,
this.viewThemeUtils = viewThemeUtils;
this.editorUtils = editorUtils;
this.appScanOptionalFeature = appScanOptionalFeature;
this.preferences = preferences;
}

@Override
Expand Down Expand Up @@ -176,7 +174,10 @@ protected void onCreate(Bundle savedInstanceState) {
setupClickListener();

//track screen view when fragment is visible
TealiumSdkUtils.trackView(TealiumSdkUtils.SCREEN_VIEW_FAB_PLUS, preferences);
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
import com.nextcloud.utils.EditorUtils;
import com.nextcloud.utils.ShortcutUtil;
import com.nmc.android.marketTracking.TrackingScanInterface;
import com.nextcloud.utils.view.FastScrollUtils;
import com.nmc.android.marketTracking.AdjustSdkUtils;
import com.nmc.android.marketTracking.TrackingScanInterface;
import com.nmc.android.marketTracking.TrackingScanInterfaceImpl;
import com.nmc.android.marketTracking.TealiumSdkUtils;
import com.owncloud.android.MainApp;
Expand Down Expand Up @@ -507,8 +507,7 @@ public void registerFabListener() {
themeUtils,
viewThemeUtils,
editorUtils,
appScanOptionalFeature,
preferences);
appScanOptionalFeature);

dialog.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
dialog.show();
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/values/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@
<string name="dev_changelog">https://github.com/nextcloud/android/raw/dev/CHANGELOG.md</string>

<string name="buildNumber" translatable="false"></string>

<!-- NMC Note: will be used to enable/disable moengage as we are not using it right now due to no proper api key -->
<bool name="moengage_enabled">false</bool>
</resources>


0 comments on commit 0c48982

Please sign in to comment.