Skip to content

Commit

Permalink
Added privacy setting redirection from launcher screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Jun 29, 2023
1 parent 5b03821 commit cc25315
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +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.LoginPrivacySettingsActivity;
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 @@ -593,7 +593,7 @@ public void setPrivacyPolicyAction(int userAction) {

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

@Override
Expand Down
40 changes: 29 additions & 11 deletions app/src/main/java/com/nmc/android/ui/LauncherActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ package com.nmc.android.ui
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.View
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.BuildConfig
import com.owncloud.android.R
import com.owncloud.android.authentication.AuthenticatorActivity
import com.owncloud.android.databinding.ActivitySplashBinding
Expand All @@ -41,6 +43,25 @@ class LauncherActivity : BaseActivity() {
@Inject
lateinit var appPreferences: AppPreferences

private val handler = Handler(Looper.getMainLooper())
private val runnable = Runnable {
// if user is null then go to authenticator activity
if (!user.isPresent) {
startActivity(Intent(this, AuthenticatorActivity::class.java))
}
//if user is logged in but did not accepted the privacy policy then take him there
//show him the privacy policy screen again
//check if app has been updated, if yes then also we have to show the privacy policy screen
else if (user.isPresent && (appPreferences.privacyPolicyAction == PrivacyUserAction.NO_ACTION
|| appPreferences.lastSeenVersionCode < BuildConfig.VERSION_CODE)
) {
LoginPrivacySettingsActivity.openPrivacySettingsActivity(this)
} else {
startActivity(Intent(this, FileDisplayActivity::class.java))
}
finish()
}

override fun onCreate(savedInstanceState: Bundle?) {
// Mandatory to call this before super method to show system launch screen for api level 31+
installSplashScreen()
Expand All @@ -64,21 +85,18 @@ class LauncherActivity : BaseActivity() {
}

private fun scheduleSplashScreen() {
Handler().postDelayed(
{
// if user is null then go to authenticator activity
if (!user.isPresent) {
startActivity(Intent(this, AuthenticatorActivity::class.java))
} else {
startActivity(Intent(this, FileDisplayActivity::class.java))
}
finish()
},
handler.postDelayed(
runnable,
SPLASH_DURATION
)
}

override fun onPause() {
super.onPause()
handler.removeCallbacks(runnable)
}

companion object {
const val SPLASH_DURATION = 1500L
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ import javax.inject.Inject
class LoginPrivacySettingsActivity : ToolbarActivity() {

companion object {
//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

@JvmStatic
fun openPrivacySettingsActivity(context: Context) {
val intent = Intent(context, LoginPrivacySettingsActivity::class.java)
Expand All @@ -47,14 +42,14 @@ class LoginPrivacySettingsActivity : ToolbarActivity() {
binding.privacyAcceptBtn.setOnClickListener {
//on accept finish the activity
//update the accept privacy action to preferences
preferences.privacyPolicyAction = ACCEPT_ACTION
preferences.privacyPolicyAction = PrivacyUserAction.ACCEPT_ACTION
openFileDisplayActivity()
}
}

private fun resetPreferenceForPrivacy() {
preferences.setDataAnalysis(false)
preferences.privacyPolicyAction = NO_ACTION
preferences.privacyPolicyAction = PrivacyUserAction.NO_ACTION
}

private fun setUpPrivacyText() {
Expand Down Expand Up @@ -84,7 +79,7 @@ class LoginPrivacySettingsActivity : ToolbarActivity() {
//disable data analysis option and close the activity
preferences.setDataAnalysis(false)
//update the reject privacy action to preferences
preferences.privacyPolicyAction = REJECT_ACTION
preferences.privacyPolicyAction = PrivacyUserAction.REJECT_ACTION
openFileDisplayActivity()
}), Pair(resources
.getString(R.string.login_privacy_settings), View.OnClickListener {
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
}
3 changes: 0 additions & 3 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="splash_image_size">116dp</dimen>
<dimen name="grid_recyclerview_padding">4dp</dimen>
<dimen name="list_item_icons_size">16dp</dimen>
<dimen name="grid_item_icons_size">24dp</dimen>
<dimen name="media_grid_item_rv_spacing">6dp</dimen>
<dimen name="txt_size_14sp">14sp</dimen>
<dimen name="txt_size_16sp">16sp</dimen>
<dimen name="txt_size_18sp">18sp</dimen>
<dimen name="txt_size_15sp">15sp</dimen>
<dimen name="crop_corner_size">15dp</dimen>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,12 @@
<string name="e2e_offline">Not possible without internet connection</string>
<string name="scan_page">Scan page</string>
<string name="done">Done</string>
<string name="prefs_category_info">Info</string>
<string name="prefs_category_data_privacy">Data Privacy</string>
<string name="privacy_settings">Privacy Settings</string>
<string name="privacy_policy">Privacy Policy</string>
<string name="prefs_open_source">Used OpenSource Software</string>
<string name="prefs_category_service">Service</string>
<string name="document_scan_pdf_generation_in_progress">Generating PDF…</string>
<string name="error_starting_doc_scan">Error starting document scan</string>
<string name="document_scan_pdf_generation_failed">PDF generation failed</string>
Expand Down

0 comments on commit cc25315

Please sign in to comment.