Skip to content

Commit efbd500

Browse files
authored
Merge pull request #558 from jorgeblacio/rate_me_add_no_thanks
Added a 'no thanks' to the rate me dialog. Also fixed a couple of bugs.
2 parents 99412a3 + a916e58 commit efbd500

File tree

11 files changed

+92
-12
lines changed

11 files changed

+92
-12
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ android {
4747
defaultConfig {
4848
minSdkVersion 21
4949
targetSdkVersion 28
50-
versionCode 94
51-
versionName "0.21.17"
50+
versionCode 95
51+
versionName "0.21.18"
5252
applicationId "com.criptext.mail"
5353
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
5454
multiDexEnabled true

src/main/kotlin/com/criptext/mail/BaseActivity.kt

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ import com.criptext.mail.utils.mailtemplates.REMailTemplate
7878
import com.criptext.mail.utils.mailtemplates.SupportMailTemplate
7979
import com.criptext.mail.utils.ui.ActivityMenu
8080
import com.criptext.mail.utils.ui.StartGuideTapped
81+
import com.criptext.mail.validation.AccountDataValidator
82+
import com.criptext.mail.validation.FormData
83+
import com.criptext.mail.validation.FormInputState
84+
import com.criptext.mail.validation.TextInput
8185
import com.github.omadahealth.lollipin.lib.PinCompatActivity
8286
import com.github.omadahealth.lollipin.lib.managers.AppLock
8387
import com.google.android.gms.auth.api.signin.GoogleSignIn
@@ -198,6 +202,25 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
198202
domain = savedInstanceState.getString("domain")!!
199203
)
200204
}
205+
SIGN_UP_MODEL -> {
206+
val signUpModel = SignUpSceneModel(
207+
isMultiple = savedInstanceState.getBoolean("isMultiple")
208+
)
209+
val username = savedInstanceState.getString("username")!!
210+
signUpModel.username.copy(value = username,
211+
state = FormInputState.Unknown())
212+
val fullName = savedInstanceState.getString("fullName")!!
213+
signUpModel.fullName.copy(value = fullName,
214+
state = FormInputState.Unknown())
215+
signUpModel.password = savedInstanceState.getString("password")!!
216+
signUpModel.confirmPassword = savedInstanceState.getString("confirmPassword")!!
217+
signUpModel.passwordState = FormInputState.Unknown()
218+
val recoveryEmail = savedInstanceState.getString("recoveryEmail")!!
219+
signUpModel.recoveryEmail.copy(value = recoveryEmail,
220+
state = FormInputState.Unknown())
221+
signUpModel.checkTermsAndConditions = savedInstanceState.getBoolean("checkTermsAndConditions")
222+
signUpModel
223+
}
201224
else -> null
202225
}
203226
}else
@@ -342,6 +365,16 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
342365
outState.putString("recipientId", currentModel.recipientId)
343366
outState.putString("domain", currentModel.domain)
344367
}
368+
is SignUpSceneModel -> {
369+
outState.putString("type", SIGN_UP_MODEL)
370+
outState.putBoolean("isMultiple", currentModel.isMultiple)
371+
outState.putString("username", currentModel.username.value)
372+
outState.putString("fullName", currentModel.fullName.value)
373+
outState.putString("password", currentModel.password)
374+
outState.putString("confirmPassword", currentModel.confirmPassword)
375+
outState.putString("recoveryEmail", currentModel.recoveryEmail.value)
376+
outState.putBoolean("checkTermsAndConditions", currentModel.checkTermsAndConditions)
377+
}
345378
}
346379
}
347380

@@ -794,7 +827,6 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
794827
// set initial state
795828
cachedModels[MailboxActivity::class.java] = MailboxSceneModel()
796829
cachedModels[SignInActivity::class.java] = SignInSceneModel()
797-
cachedModels[SignUpActivity::class.java] = SignUpSceneModel()
798830
cachedModels[SettingsActivity::class.java] = SettingsModel()
799831
cachedModels[ChangePasswordActivity::class.java] = ChangePasswordModel()
800832
}
@@ -806,12 +838,12 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
806838

807839
private const val EMAIL_DETAIL_MODEL = "EmailDetailModel"
808840
private const val COMPOSER_MODEL = "ComposerModel"
809-
private const val PIN_LOCK_MODEL = "PinLockModel"
810841
private const val PRIVACY_MODEL = "PrivacyModel"
811842
private const val PROFILE_MODEL = "ProfileModel"
812843
private const val RECOVERY_EMAIL_MODEL = "RecoveryEmailModel"
813844
private const val REPLY_TO_MODEL = "ReplyToModel"
814845
private const val SIGNATURE_MODEL = "SignatureModel"
846+
private const val SIGN_UP_MODEL = "SignUpModel"
815847
}
816848

817849
enum class RequestCode {

src/main/kotlin/com/criptext/mail/scenes/signup/SignUpSceneController.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,10 @@ class SignUpSceneController(
224224
private fun onCheckedUsernameAvailability(result: SignUpResult.CheckUsernameAvailability) {
225225
when (result) {
226226
is SignUpResult.CheckUsernameAvailability.Success -> {
227-
if (result.isAvailable)
227+
if (result.isAvailable) {
228228
scene.setUsernameState(FormInputState.Valid())
229-
else {
229+
toggleCreateAccountButton()
230+
} else {
230231
val newState = FormInputState.Error(UIMessage(R.string.taken_username_error))
231232
model.username = model.username.copy(state = newState)
232233
scene.setUsernameState(newState)
@@ -319,6 +320,16 @@ class SignUpSceneController(
319320
override fun onStart(activityMessage: ActivityMessage?): Boolean {
320321
dataSource.listener = dataSourceListener
321322
scene.showFormHolder()
323+
if(model.username.value.isNotEmpty()) {
324+
scene.resetSceneWidgetsFromModel(model.username, model.fullName, model.password,
325+
model.confirmPassword, model.recoveryEmail, model.checkTermsAndConditions)
326+
uiObserver.onUsernameChangedListener(model.username.value)
327+
uiObserver.onFullNameTextChangeListener(model.fullName.value)
328+
uiObserver.onPasswordChangedListener(model.password)
329+
uiObserver.onConfirmPasswordChangedListener(model.confirmPassword)
330+
uiObserver.onCheckedOptionChanged(model.checkTermsAndConditions)
331+
toggleCreateAccountButton()
332+
}
322333
scene.initListeners(
323334
uiObserver = uiObserver
324335
)

src/main/kotlin/com/criptext/mail/scenes/signup/data/RegisterUserWorker.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class RegisterUserWorker(
7979
}
8080

8181
override fun work(reporter: ProgressReporter<RegisterUser>): RegisterUser? {
82+
if(!isMultiple){
83+
db.clearAllTables()
84+
keyValueStorage.clearAll()
85+
}
8286
val registrationBundle = signalKeyGenerator.register(
8387
recipientId = incompleteAccount.username,
8488
deviceId = 1)

src/main/kotlin/com/criptext/mail/utils/apputils/AppRater.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object AppRater {
1717
private const val APP_NAME = "com.criptext.mail"// Package Name
1818

1919
private const val DAYS_UNTIL_PROMPT = 3//Min number of days
20-
private const val LAUNCHES_UNTIL_PROMPT = 3//Min number of launches
20+
private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches
2121

2222
fun appLaunched(ctx: Context, storage: KeyValueStorage) {
2323
if (storage.getBool(KeyValueStorage.StringKey.RateDontShowAgain, false)) {
@@ -52,12 +52,16 @@ object AppRater {
5252
generalDialogConfirmation.showDialog(null)
5353
generalDialogConfirmation.btnOk.text = mContext.getLocalizedUIMessage(UIMessage(R.string.rate_us))
5454
generalDialogConfirmation.btnCancel.text = mContext.getLocalizedUIMessage(UIMessage(R.string.rate_remind_later))
55+
generalDialogConfirmation.btnNoThanks.visibility = View.VISIBLE
5556
generalDialogConfirmation.btnOk.setOnClickListener {
5657
mContext.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$APP_NAME")))
5758
storage.putBool(KeyValueStorage.StringKey.RateDontShowAgain, true)
5859
generalDialogConfirmation.dismissDialog()
5960
}
60-
61+
generalDialogConfirmation.btnNoThanks.setOnClickListener {
62+
storage.putBool(KeyValueStorage.StringKey.RateDontShowAgain, true)
63+
generalDialogConfirmation.dismissDialog()
64+
}
6165
generalDialogConfirmation.btnCancel.setOnClickListener {
6266
generalDialogConfirmation.dismissDialog()
6367
}

src/main/kotlin/com/criptext/mail/utils/ui/GeneralDialogConfirmation.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class GeneralDialogConfirmation(val context: Context, val data: DialogData.Dialo
2323
private val res = context.resources
2424
lateinit var btnOk: Button
2525
lateinit var btnCancel: Button
26+
lateinit var btnNoThanks: Button
2627

2728
private lateinit var view: View
2829

@@ -65,6 +66,7 @@ class GeneralDialogConfirmation(val context: Context, val data: DialogData.Dialo
6566

6667
btnOk = view.findViewById(R.id.btn_ok) as Button
6768
btnCancel = view.findViewById(R.id.btn_cancel) as Button
69+
btnNoThanks = view.findViewById(R.id.btn_no_thanks) as Button
6870

6971
if(!btnOk.hasOnClickListeners()) {
7072
btnOk.setOnClickListener {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
>
4+
<solid
5+
android:color="?attr/criptextDialogButtonBg"/>
6+
<padding
7+
android:left="10dp"
8+
android:top="10dp"
9+
android:right="10dp"
10+
android:bottom="10dp" />
11+
</shape>

src/main/res/layout/general_confirmation_dialog.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@
5151
android:layout_weight="0.5"
5252
android:layout_height="wrap_content"
5353
android:text="@string/cancel" />
54+
<Button
55+
android:textColor="@color/button_text_color"
56+
fontPath="fonts/NunitoSans-Bold.ttf"
57+
android:textSize="15sp"
58+
android:textAllCaps="false"
59+
android:id="@+id/btn_no_thanks"
60+
android:stateListAnimator="@null"
61+
android:background="@drawable/label_button_center_bg"
62+
android:layout_width="0dp"
63+
android:layout_weight="0.5"
64+
android:layout_height="wrap_content"
65+
android:visibility="gone"
66+
android:text="@string/rate_no_thanks" />
5467

5568
<Button
5669
android:textColor="@color/button_text_color"

src/main/res/values-es/strings.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@
583583
<string name="open_email_notification_text">📩 El correo \"%1$s\" fue abierto</string>
584584
<string name="rate_us_title">¿Estás disfrutando Criptext?</string>
585585
<string name="rate_us_message">Si es así, ayúdanos con una calificación. ¡Gracias por tu apoyo!</string>
586-
<string name="rate_us">Calificar</string>
587-
<string name="rate_remind_later">Recordar Luego</string>
586+
<string name="rate_us">\nCalificar</string>
587+
<string name="rate_remind_later">Recordar\nLuego</string>
588+
<string name="rate_no_thanks">No\nGracias</string>
588589
<string name="username_is_not_criptext">El usuario o dirección de correo no pertenece a Criptext.</string>
589590
</resources>

src/main/res/values/strings.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@
583583
<string name="open_email_notification_text">📩 Email \"%1$s\" was opened</string>
584584
<string name="rate_us_title">Enjoying Criptext?</string>
585585
<string name="rate_us_message">If you do, please take a moment to rate it. Thanks for your support!</string>
586-
<string name="rate_us">Rate Us</string>
587-
<string name="rate_remind_later">Remind Later</string>
586+
<string name="rate_us">Rate\nUs</string>
587+
<string name="rate_remind_later">Remind\nLater</string>
588+
<string name="rate_no_thanks">No\nThanks</string>
588589
<string name="username_is_not_criptext">Not a valid Criptext address or username.</string>
589590
</resources>

0 commit comments

Comments
 (0)