Skip to content

Commit

Permalink
Merge branches 'release-3.7.0' and 'master' of github.com:kickstarter…
Browse files Browse the repository at this point in the history
…/android-oss into release-3.7.0

* 'release-3.7.0' of github.com:kickstarter/android-oss:

* 'master' of github.com:kickstarter/android-oss:
  NTV-637: Messages screen unable to load more messages (#1716)
  NTV-364: Creator dashboard not loading for release 3.7.0(#1715)
  [no-jira]: Update String translation for facebook deprecation (#1714)
  • Loading branch information
Arkariang committed Dec 8, 2022
2 parents 3baa45a + a45dc1f commit bbf8ba5
Show file tree
Hide file tree
Showing 27 changed files with 225 additions and 189 deletions.
83 changes: 59 additions & 24 deletions app/src/main/assets/json/server-config.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public final class RecyclerViewPaginator {
private final @NonNull Action0 nextPage;
private final Observable<Boolean> isLoading;
private Subscription subscription;
private static final int DIRECTION_DOWN = 1;
private Subscription retrySubscription;
private final PublishSubject<Void> retryLoadingNextPageSubject = PublishSubject.create();

Expand Down Expand Up @@ -51,7 +50,6 @@ public void start() {

final Observable<Pair<Integer, Integer>> lastVisibleAndCount = RxRecyclerView.scrollEvents(this.recyclerView)
.filter(__ -> BoolenExtKt.isFalse(Secrets.IS_OSS))
.filter(__ -> this.recyclerView.canScrollVertically(DIRECTION_DOWN))
.map(__ -> this.recyclerView.getLayoutManager())
.ofType(LinearLayoutManager.class)
.map(this::displayedItemFromLinearLayout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import com.kickstarter.models.extensions.getCreatedAndDraftProjectsCount
import com.kickstarter.services.DiscoveryParams
import com.kickstarter.ui.data.CheckoutData
import com.kickstarter.ui.data.PledgeData
import org.joda.time.DateTime
import java.util.Locale
import kotlin.math.ceil
import kotlin.math.roundToInt
Expand Down Expand Up @@ -193,7 +192,7 @@ object AnalyticEventsUtils {
val project = pledgeData.projectData().project()
val properties = HashMap<String, Any>().apply {
reward.estimatedDeliveryOn()?.let { deliveryDate ->
put("estimated_delivery_on", DateTime(deliveryDate.time))
put("estimated_delivery_on", deliveryDate)
}
put("has_items", isItemized(reward))
put("id", reward.id().toString())
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/kickstarter/libs/utils/DateTimeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.joda.time.DateTimeZone
import org.joda.time.Seconds
import org.joda.time.format.DateTimeFormat
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import kotlin.math.abs
import kotlin.math.floor
Expand All @@ -22,9 +21,9 @@ object DateTimeUtils {
* e.g.: December 2015.
*/
@JvmOverloads
fun estimatedDeliveryOn(date: Date, locale: Locale = Locale.getDefault()): String {
fun estimatedDeliveryOn(date: DateTime, locale: Locale = Locale.getDefault()): String {
val formatter = SimpleDateFormat("MMMM yyyy", locale)
return formatter.format(date)
return formatter.format(date.toDate())
}

fun isDateToday(dateTime: DateTime): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.kickstarter.models.SingleLocation
import org.joda.time.DateTime

object RewardFactory {
val ESTIMATED_DELIVERY = DateTime.parse("2019-03-26T19:26:09Z").toDate()
val ESTIMATED_DELIVERY = DateTime.parse("2019-03-26T19:26:09Z")

@JvmStatic
fun addOn(): Reward {
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/com/kickstarter/models/Reward.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.annotation.StringDef
import com.kickstarter.libs.utils.extensions.isZero
import kotlinx.parcelize.Parcelize
import org.joda.time.DateTime
import java.util.Date

@Parcelize
class Reward private constructor(
Expand All @@ -16,7 +15,7 @@ class Reward private constructor(
private val id: Long,
private val limit: Int?,
private val minimum: Double,
private val estimatedDeliveryOn: Date?,
private val estimatedDeliveryOn: DateTime?,
private val remaining: Int?,
private val rewardsItems: List<RewardsItem>?,
private val shippingPreference: String?,
Expand Down Expand Up @@ -86,7 +85,7 @@ class Reward private constructor(
private var id: Long = 0L,
private var limit: Int? = null,
private var minimum: Double = 0.0,
private var estimatedDeliveryOn: Date? = null,
private var estimatedDeliveryOn: DateTime? = null,
private var remaining: Int? = null,
private var rewardsItems: List<RewardsItem>? = emptyList(),
private var shippingPreference: String? = null,
Expand All @@ -111,7 +110,9 @@ class Reward private constructor(
fun id(id: Long?) = apply { this.id = id ?: -1L }
fun limit(limit: Int?) = apply { this.limit = limit }
fun minimum(minimum: Double?) = apply { this.minimum = minimum ?: 0.0 }
fun estimatedDeliveryOn(estimatedDeliveryOn: Date?) = apply { this.estimatedDeliveryOn = estimatedDeliveryOn }
fun estimatedDeliveryOn(estimatedDeliveryOn: DateTime?) = apply {
this.estimatedDeliveryOn = estimatedDeliveryOn
}
fun remaining(remaining: Int?) = apply { this.remaining = remaining }
fun rewardsItems(rewardsItems: List<RewardsItem>?) = apply { this.rewardsItems = rewardsItems ?: emptyList() }
fun shippingPreference(shippingPreference: String?) = apply { this.shippingPreference = shippingPreference }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fun rewardTransformer(
rewardGr.convertedAmount().fragments().amount().amount()?.toDouble() ?: 0.0
val desc = rewardGr.description()
val title = rewardGr.name()
val estimatedDelivery = rewardGr.estimatedDeliveryOn()
val estimatedDelivery = rewardGr.estimatedDeliveryOn()?.let { DateTime(it) }
val remaining = rewardGr.remainingQuantity()
val endsAt = rewardGr.endsAt()?.let { DateTime(it) }
val startsAt = rewardGr.startsAt()?.let { DateTime(it) }
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/com/kickstarter/ui/activities/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.kickstarter.libs.utils.TransitionUtils.slideInFromLeft
import com.kickstarter.libs.utils.ViewUtils
import com.kickstarter.libs.utils.extensions.getResetPasswordIntent
import com.kickstarter.ui.IntentKey
import com.kickstarter.ui.data.LoginReason
import com.kickstarter.ui.extensions.hideKeyboard
import com.kickstarter.ui.extensions.onChange
import com.kickstarter.ui.extensions.showSnackbar
Expand All @@ -31,6 +32,7 @@ class LoginActivity : BaseActivity<LoginViewModel.ViewModel>() {

private val forgotPasswordString = R.string.login_buttons_forgot_password_html
private val forgotPasswordSentEmailString = R.string.forgot_password_we_sent_an_email_to_email_address_with_instructions_to_reset_your_password
private val resetPasswordSentEmailString = R.string.forgot_password_we_sent_an_email_to_email_address_with_instructions_to_set_your_password
private val loginDoesNotMatchString = R.string.login_errors_does_not_match
private val unableToLoginString = R.string.login_errors_unable_to_log_in
private val loginString = R.string.login_buttons_log_in
Expand Down Expand Up @@ -90,9 +92,9 @@ class LoginActivity : BaseActivity<LoginViewModel.ViewModel>() {
val show = showAndEmail.first
val email = showAndEmail.second
if (show) {
resetPasswordSuccessDialog(email).show()
resetPasswordSuccessDialog(email.first, showAndEmail.second.second).show()
} else {
resetPasswordSuccessDialog(email).dismiss()
resetPasswordSuccessDialog(email.first, showAndEmail.second.second).dismiss()
}
}

Expand All @@ -114,9 +116,14 @@ class LoginActivity : BaseActivity<LoginViewModel.ViewModel>() {
/**
* Lazily creates a reset password success confirmation dialog and stores it in an instance variable.
*/
private fun resetPasswordSuccessDialog(email: String): ConfirmDialog {
private fun resetPasswordSuccessDialog(email: String, loginReason: LoginReason): ConfirmDialog {
if (this.confirmResetPasswordSuccessDialog == null) {
val message = this.ksString.format(getString(this.forgotPasswordSentEmailString), "email", email)
val message = if (loginReason == LoginReason.RESET_FACEBOOK_PASSWORD) {
this.ksString.format(getString(this.resetPasswordSentEmailString), "email", email)
} else {
this.ksString.format(getString(this.resetPasswordSentEmailString), "email", email)
}

this.confirmResetPasswordSuccessDialog = ConfirmDialog(this, null, message)

this.confirmResetPasswordSuccessDialog!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class LoginToutActivity : BaseActivity<LoginToutViewModel.ViewModel>() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
this.showAlertDialog(
message = getString(R.string.FPO_we_can_no_longer_log_you_in_through_Facebook),
positiveActionTitle = getString(R.string.FPO_Set_new_password),
message = getString(R.string.We_can_no_longer_log_you_in_through_Facebook),
positiveActionTitle = getString(R.string.Set_new_password),
negativeActionTitle = getString(R.string.accessibility_discovery_buttons_log_in),
isCancelable = false,
positiveAction = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ResetPasswordActivity : BaseActivity<ResetPasswordViewModel.ViewModel>() {

private fun navigateToLoginActivity() {
setFormEnabled(false)
val intent = Intent().getLoginActivityIntent(this, binding.resetPasswordFormView.email.text(), LoginReason.RESET_PASSWORD)
val intent = Intent().getLoginActivityIntent(this, binding.resetPasswordFormView.email.text(), LoginReason.RESET_FACEBOOK_PASSWORD)
startActivityWithTransition(intent, R.anim.fade_in_slide_in_left, R.anim.slide_out_right)
finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SetPasswordActivity : BaseActivity<SetPasswordViewModel.ViewModel>() {

setContentView(binding.root)
setSupportActionBar(binding.resetPasswordToolbar.loginToolbar)
binding.resetPasswordToolbar.loginToolbar.setTitle(getString(R.string.FPO_Set_your_password))
binding.resetPasswordToolbar.loginToolbar.setTitle(getString(R.string.Set_your_password))
binding.resetPasswordToolbar.backButton.isGone = true
binding.newPassword.onChange { this.viewModel.inputs.newPassword(it) }
binding.confirmPassword.onChange { this.viewModel.inputs.confirmPassword(it) }
Expand All @@ -44,7 +44,7 @@ class SetPasswordActivity : BaseActivity<SetPasswordViewModel.ViewModel>() {
.compose(bindToLifecycle())
.compose(Transformers.observeForUI())
.subscribe {
binding.setPasswordHint.text = getString(R.string.FPO_We_will_be_discontinuing_the_ability_to_log_in_via_Facebook, it)
binding.setPasswordHint.text = this.environment().ksString()?.format(getString(R.string.We_will_be_discontinuing_the_ability_to_log_in_via_FB), "email", it)
}

this.viewModel.outputs.passwordWarning()
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/kickstarter/ui/data/LoginReason.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum class LoginReason {
BACK_PROJECT,
MESSAGE_CREATOR,
RESET_PASSWORD,
RESET_FACEBOOK_PASSWORD,
STAR_PROJECT;

val isDefaultFlow: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ enum class ResetPasswordScreenState(
@StringRes val hint: Int?
) {
ResetPassword(
title = R.string.FPO_reset_your_password,
hint = R.string.FPO_we_re_simplifying_our_login_process_To_log_in
title = R.string.Reset_your_password,
hint = R.string.We_re_simplifying_our_login_process_To_log_in
),
ForgetPassword(
title = R.string.forgot_password_title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import com.kickstarter.ui.data.ProjectData
import com.kickstarter.ui.fragments.BackingFragment
import com.stripe.android.model.Card
import com.stripe.android.model.CardBrand
import org.joda.time.DateTime
import rx.Observable
import rx.subjects.BehaviorSubject
import rx.subjects.PublishSubject
import type.CreditCardPaymentType
import type.CreditCardTypes
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.concurrent.TimeUnit

Expand Down Expand Up @@ -473,7 +473,7 @@ interface BackingFragmentViewModel {

reward
.filter { RewardUtils.isReward(it) && ObjectUtils.isNotNull(it.estimatedDeliveryOn()) }
.map<Date> { it.estimatedDeliveryOn() }
.map<DateTime> { it.estimatedDeliveryOn() }
.map { DateTimeUtils.estimatedDeliveryOn(it) }
.compose(bindToLifecycle())
.subscribe(this.estimatedDelivery)
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/kickstarter/viewmodels/LoginViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface LoginViewModel {
fun showCreatedPasswordSnackbar(): Observable<Void>

/** Emits a boolean to determine whether reset password dialog should be shown. */
fun showResetPasswordSuccessDialog(): Observable<Pair<Boolean, String>>
fun showResetPasswordSuccessDialog(): Observable<Pair<Boolean, Pair<String, LoginReason>>>

/** Start two factor activity for result. */
fun tfaChallenge(): Observable<Void>
Expand All @@ -81,7 +81,7 @@ interface LoginViewModel {
private val prefillEmail = BehaviorSubject.create<String>()
private val showChangedPasswordSnackbar = BehaviorSubject.create<Void>()
private val showCreatedPasswordSnackbar = BehaviorSubject.create<Void>()
private val showResetPasswordSuccessDialog = BehaviorSubject.create<Pair<Boolean, String>>()
private val showResetPasswordSuccessDialog = BehaviorSubject.create<Pair<Boolean, Pair<String, LoginReason>>>()
private val tfaChallenge: Observable<Void>

private val loginError = PublishSubject.create<ErrorEnvelope>()
Expand Down Expand Up @@ -144,8 +144,12 @@ interface LoginViewModel {

emailAndReason
.filter { it.second == LoginReason.RESET_PASSWORD }
.map { it.first }
.ofType(String::class.java)
.map { e -> Pair.create(true, e) }
.compose(bindToLifecycle())
.subscribe(this.showResetPasswordSuccessDialog)

emailAndReason
.filter { it.second == LoginReason.RESET_FACEBOOK_PASSWORD }
.map { e -> Pair.create(true, e) }
.compose(bindToLifecycle())
.subscribe(this.showResetPasswordSuccessDialog)
Expand All @@ -169,7 +173,7 @@ interface LoginViewModel {
this.resetPasswordConfirmationDialogDismissed
.map<Boolean> { it.negate() }
.compose<Pair<Boolean, Pair<String, LoginReason>>>(combineLatestPair(emailAndReason))
.map { Pair.create(it.first, it.second.first) }
.map { Pair.create(it.first, it.second) }
.compose(bindToLifecycle())
.subscribe(this.showResetPasswordSuccessDialog)

Expand Down Expand Up @@ -256,7 +260,7 @@ interface LoginViewModel {

override fun showCreatedPasswordSnackbar(): Observable<Void> = this.showCreatedPasswordSnackbar

override fun showResetPasswordSuccessDialog(): BehaviorSubject<Pair<Boolean, String>> = this.showResetPasswordSuccessDialog
override fun showResetPasswordSuccessDialog(): BehaviorSubject<Pair<Boolean, Pair<String, LoginReason>>> = this.showResetPasswordSuccessDialog

override fun tfaChallenge() = this.tfaChallenge
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import com.kickstarter.ui.data.PledgeData
import com.kickstarter.ui.data.PledgeFlowContext
import com.kickstarter.ui.data.ProjectData
import com.kickstarter.ui.viewholders.RewardViewHolder
import org.joda.time.DateTime
import rx.Observable
import rx.subjects.BehaviorSubject
import rx.subjects.PublishSubject
import java.math.RoundingMode
import java.util.Date

interface RewardViewHolderViewModel {
interface Inputs {
Expand Down Expand Up @@ -423,7 +423,7 @@ interface RewardViewHolderViewModel {

reward
.filter { RewardUtils.isReward(it) && ObjectUtils.isNotNull(it.estimatedDeliveryOn()) }
.map<Date> { it.estimatedDeliveryOn() }
.map<DateTime> { it.estimatedDeliveryOn() }
.map { DateTimeUtils.estimatedDeliveryOn(it) }
.compose(bindToLifecycle())
.subscribe(this.estimatedDelivery)
Expand Down
17 changes: 2 additions & 15 deletions app/src/main/res/layout/activity_set_password.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,19 @@
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:text="@string/FPO_We_will_be_discontinuing_the_ability_to_log_in_via_Facebook"
android:text="@string/We_will_be_discontinuing_the_ability_to_log_in_via_FB"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/reset_password_toolbar" />

<TextView
android:id="@+id/set_password_hint2"
style="@style/CalloutPrimaryMaison"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:text="@string/FPO_Please_enter_a_password_that_is_at_least_6_characters_long"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/set_password_hint" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/new_password_TextInputLayout"
style="@style/SettingsPasswordTextInputLayout"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:hint="@string/New_password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/set_password_hint2">
app:layout_constraintTop_toBottomOf="@+id/set_password_hint">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/new_password"
Expand Down
Loading

0 comments on commit bbf8ba5

Please sign in to comment.