Skip to content

Commit

Permalink
Merge pull request #558 from jorgeblacio/rate_me_add_no_thanks
Browse files Browse the repository at this point in the history
Added a 'no thanks' to the rate me dialog. Also fixed a couple of bugs.
  • Loading branch information
danieltigse authored Oct 22, 2019
2 parents 99412a3 + a916e58 commit efbd500
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 12 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 94
versionName "0.21.17"
versionCode 95
versionName "0.21.18"
applicationId "com.criptext.mail"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
Expand Down
36 changes: 34 additions & 2 deletions src/main/kotlin/com/criptext/mail/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ import com.criptext.mail.utils.mailtemplates.REMailTemplate
import com.criptext.mail.utils.mailtemplates.SupportMailTemplate
import com.criptext.mail.utils.ui.ActivityMenu
import com.criptext.mail.utils.ui.StartGuideTapped
import com.criptext.mail.validation.AccountDataValidator
import com.criptext.mail.validation.FormData
import com.criptext.mail.validation.FormInputState
import com.criptext.mail.validation.TextInput
import com.github.omadahealth.lollipin.lib.PinCompatActivity
import com.github.omadahealth.lollipin.lib.managers.AppLock
import com.google.android.gms.auth.api.signin.GoogleSignIn
Expand Down Expand Up @@ -198,6 +202,25 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
domain = savedInstanceState.getString("domain")!!
)
}
SIGN_UP_MODEL -> {
val signUpModel = SignUpSceneModel(
isMultiple = savedInstanceState.getBoolean("isMultiple")
)
val username = savedInstanceState.getString("username")!!
signUpModel.username.copy(value = username,
state = FormInputState.Unknown())
val fullName = savedInstanceState.getString("fullName")!!
signUpModel.fullName.copy(value = fullName,
state = FormInputState.Unknown())
signUpModel.password = savedInstanceState.getString("password")!!
signUpModel.confirmPassword = savedInstanceState.getString("confirmPassword")!!
signUpModel.passwordState = FormInputState.Unknown()
val recoveryEmail = savedInstanceState.getString("recoveryEmail")!!
signUpModel.recoveryEmail.copy(value = recoveryEmail,
state = FormInputState.Unknown())
signUpModel.checkTermsAndConditions = savedInstanceState.getBoolean("checkTermsAndConditions")
signUpModel
}
else -> null
}
}else
Expand Down Expand Up @@ -342,6 +365,16 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
outState.putString("recipientId", currentModel.recipientId)
outState.putString("domain", currentModel.domain)
}
is SignUpSceneModel -> {
outState.putString("type", SIGN_UP_MODEL)
outState.putBoolean("isMultiple", currentModel.isMultiple)
outState.putString("username", currentModel.username.value)
outState.putString("fullName", currentModel.fullName.value)
outState.putString("password", currentModel.password)
outState.putString("confirmPassword", currentModel.confirmPassword)
outState.putString("recoveryEmail", currentModel.recoveryEmail.value)
outState.putBoolean("checkTermsAndConditions", currentModel.checkTermsAndConditions)
}
}
}

Expand Down Expand Up @@ -794,7 +827,6 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
// set initial state
cachedModels[MailboxActivity::class.java] = MailboxSceneModel()
cachedModels[SignInActivity::class.java] = SignInSceneModel()
cachedModels[SignUpActivity::class.java] = SignUpSceneModel()
cachedModels[SettingsActivity::class.java] = SettingsModel()
cachedModels[ChangePasswordActivity::class.java] = ChangePasswordModel()
}
Expand All @@ -806,12 +838,12 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {

private const val EMAIL_DETAIL_MODEL = "EmailDetailModel"
private const val COMPOSER_MODEL = "ComposerModel"
private const val PIN_LOCK_MODEL = "PinLockModel"
private const val PRIVACY_MODEL = "PrivacyModel"
private const val PROFILE_MODEL = "ProfileModel"
private const val RECOVERY_EMAIL_MODEL = "RecoveryEmailModel"
private const val REPLY_TO_MODEL = "ReplyToModel"
private const val SIGNATURE_MODEL = "SignatureModel"
private const val SIGN_UP_MODEL = "SignUpModel"
}

enum class RequestCode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ class SignUpSceneController(
private fun onCheckedUsernameAvailability(result: SignUpResult.CheckUsernameAvailability) {
when (result) {
is SignUpResult.CheckUsernameAvailability.Success -> {
if (result.isAvailable)
if (result.isAvailable) {
scene.setUsernameState(FormInputState.Valid())
else {
toggleCreateAccountButton()
} else {
val newState = FormInputState.Error(UIMessage(R.string.taken_username_error))
model.username = model.username.copy(state = newState)
scene.setUsernameState(newState)
Expand Down Expand Up @@ -319,6 +320,16 @@ class SignUpSceneController(
override fun onStart(activityMessage: ActivityMessage?): Boolean {
dataSource.listener = dataSourceListener
scene.showFormHolder()
if(model.username.value.isNotEmpty()) {
scene.resetSceneWidgetsFromModel(model.username, model.fullName, model.password,
model.confirmPassword, model.recoveryEmail, model.checkTermsAndConditions)
uiObserver.onUsernameChangedListener(model.username.value)
uiObserver.onFullNameTextChangeListener(model.fullName.value)
uiObserver.onPasswordChangedListener(model.password)
uiObserver.onConfirmPasswordChangedListener(model.confirmPassword)
uiObserver.onCheckedOptionChanged(model.checkTermsAndConditions)
toggleCreateAccountButton()
}
scene.initListeners(
uiObserver = uiObserver
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class RegisterUserWorker(
}

override fun work(reporter: ProgressReporter<RegisterUser>): RegisterUser? {
if(!isMultiple){
db.clearAllTables()
keyValueStorage.clearAll()
}
val registrationBundle = signalKeyGenerator.register(
recipientId = incompleteAccount.username,
deviceId = 1)
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/com/criptext/mail/utils/apputils/AppRater.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object AppRater {
private const val APP_NAME = "com.criptext.mail"// Package Name

private const val DAYS_UNTIL_PROMPT = 3//Min number of days
private const val LAUNCHES_UNTIL_PROMPT = 3//Min number of launches
private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches

fun appLaunched(ctx: Context, storage: KeyValueStorage) {
if (storage.getBool(KeyValueStorage.StringKey.RateDontShowAgain, false)) {
Expand Down Expand Up @@ -52,12 +52,16 @@ object AppRater {
generalDialogConfirmation.showDialog(null)
generalDialogConfirmation.btnOk.text = mContext.getLocalizedUIMessage(UIMessage(R.string.rate_us))
generalDialogConfirmation.btnCancel.text = mContext.getLocalizedUIMessage(UIMessage(R.string.rate_remind_later))
generalDialogConfirmation.btnNoThanks.visibility = View.VISIBLE
generalDialogConfirmation.btnOk.setOnClickListener {
mContext.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$APP_NAME")))
storage.putBool(KeyValueStorage.StringKey.RateDontShowAgain, true)
generalDialogConfirmation.dismissDialog()
}

generalDialogConfirmation.btnNoThanks.setOnClickListener {
storage.putBool(KeyValueStorage.StringKey.RateDontShowAgain, true)
generalDialogConfirmation.dismissDialog()
}
generalDialogConfirmation.btnCancel.setOnClickListener {
generalDialogConfirmation.dismissDialog()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class GeneralDialogConfirmation(val context: Context, val data: DialogData.Dialo
private val res = context.resources
lateinit var btnOk: Button
lateinit var btnCancel: Button
lateinit var btnNoThanks: Button

private lateinit var view: View

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

btnOk = view.findViewById(R.id.btn_ok) as Button
btnCancel = view.findViewById(R.id.btn_cancel) as Button
btnNoThanks = view.findViewById(R.id.btn_no_thanks) as Button

if(!btnOk.hasOnClickListeners()) {
btnOk.setOnClickListener {
Expand Down
11 changes: 11 additions & 0 deletions src/main/res/drawable/label_button_center_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
>
<solid
android:color="?attr/criptextDialogButtonBg"/>
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
13 changes: 13 additions & 0 deletions src/main/res/layout/general_confirmation_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:text="@string/cancel" />
<Button
android:textColor="@color/button_text_color"
fontPath="fonts/NunitoSans-Bold.ttf"
android:textSize="15sp"
android:textAllCaps="false"
android:id="@+id/btn_no_thanks"
android:stateListAnimator="@null"
android:background="@drawable/label_button_center_bg"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/rate_no_thanks" />

<Button
android:textColor="@color/button_text_color"
Expand Down
5 changes: 3 additions & 2 deletions src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@
<string name="open_email_notification_text">📩 El correo \"%1$s\" fue abierto</string>
<string name="rate_us_title">¿Estás disfrutando Criptext?</string>
<string name="rate_us_message">Si es así, ayúdanos con una calificación. ¡Gracias por tu apoyo!</string>
<string name="rate_us">Calificar</string>
<string name="rate_remind_later">Recordar Luego</string>
<string name="rate_us">\nCalificar</string>
<string name="rate_remind_later">Recordar\nLuego</string>
<string name="rate_no_thanks">No\nGracias</string>
<string name="username_is_not_criptext">El usuario o dirección de correo no pertenece a Criptext.</string>
</resources>
5 changes: 3 additions & 2 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@
<string name="open_email_notification_text">📩 Email \"%1$s\" was opened</string>
<string name="rate_us_title">Enjoying Criptext?</string>
<string name="rate_us_message">If you do, please take a moment to rate it. Thanks for your support!</string>
<string name="rate_us">Rate Us</string>
<string name="rate_remind_later">Remind Later</string>
<string name="rate_us">Rate\nUs</string>
<string name="rate_remind_later">Remind\nLater</string>
<string name="rate_no_thanks">No\nThanks</string>
<string name="username_is_not_criptext">Not a valid Criptext address or username.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class RegisterUserWorkerTest {
httpClient.put("/keybundle/pushtoken", "__JWT__", any<JSONObject>()).body
} returns "OK"
every { db.clearAllTables() } just Runs
every { storage.clearAll() } just Runs

val newAccount = IncompleteAccount(username ="tester", name = "A Tester", deviceId = 1,
password = "secretPassword", recoveryEmail = "[email protected]")
Expand Down

0 comments on commit efbd500

Please sign in to comment.