Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into merge/release-7.38-in…
Browse files Browse the repository at this point in the history
…to-main

# Conflicts:
#	modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/sync/SyncManagerImpl.kt
  • Loading branch information
ashiagr committed May 5, 2023
2 parents f295461 + 80dfb36 commit 1dba064
Show file tree
Hide file tree
Showing 35 changed files with 1,003 additions and 576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal class SyncAccountTest {
syncManager.loginWithEmailAndPassword(
email = "[email protected]",
password = "password_signin",
signInSource = SignInSource.Onboarding
signInSource = SignInSource.UserInitiated.Onboarding
)
}
assert(result is LoginResult.Success)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ class AutomotiveSettingsFragment : Fragment() {
}

userView.signedInState = signInState
userView.setOnClickListener {
if (loggedIn) {
val fragment = AccountDetailsFragment.newInstance()
(activity as? AutomotiveSettingsActivity)?.addFragment(fragment)
} else {
signIn()
}
}
userView.lblUserEmail.setOnClickListener { onProfileAccountButtonClicked(loggedIn) }
userView.imgProfilePicture.setOnClickListener { onProfileAccountButtonClicked(loggedIn) }
userView.btnAccount?.setOnClickListener { onProfileAccountButtonClicked(loggedIn) }
}
}

private fun onProfileAccountButtonClicked(loggedIn: Boolean) {
if (loggedIn) {
val fragment = AccountDetailsFragment.newInstance()
(activity as? AutomotiveSettingsActivity)?.addFragment(fragment)
} else {
signIn()
}
}

fun signIn() {
val loginIntent = Intent(activity, AccountActivity::class.java)
startActivity(loginIntent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<au.com.shiftyjelly.pocketcasts.profile.UserView
android:id="@+id/userView"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package au.com.shiftyjelly.pocketcasts.account
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.LinearGradient
import android.graphics.Paint
import android.graphics.RectF
Expand All @@ -12,6 +11,7 @@ import android.graphics.drawable.Drawable
import android.net.Uri
import android.util.AttributeSet
import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.toBitmap
import androidx.core.graphics.toRect
import au.com.shiftyjelly.pocketcasts.ui.extensions.getThemeColor
Expand All @@ -36,8 +36,8 @@ class ProfileCircleView @JvmOverloads constructor(
private var plusAccount = false

private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
private var color0 = Color.parseColor("#feb525")
private var color1 = Color.parseColor("#fed745")
private var color0 = ContextCompat.getColor(context, UR.color.plus_gold_dark)
private var color1 = ContextCompat.getColor(context, UR.color.plus_gold_light)
private var colorGrey = context.getThemeColor(UR.attr.primary_icon_02)

private val inset = 2 * context.resources.displayMetrics.density
Expand All @@ -52,13 +52,18 @@ class ProfileCircleView @JvmOverloads constructor(
private var iconDrawable0: Drawable? = context.getTintedDrawable(R.drawable.ic_plus_account, iconColor)
private var iconDrawable1: Drawable? = context.getTintedDrawable(R.drawable.ic_free_account, iconColor)
private var bitmap: Bitmap? = null
private var isPatron: Boolean = false

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
update()
}

fun update() {
val color0Res = if (isPatron) UR.color.patron_purple else UR.color.plus_gold_dark
val color1Res = if (isPatron) UR.color.patron_purple else UR.color.plus_gold_light
color0 = ContextCompat.getColor(context, color0Res)
color1 = ContextCompat.getColor(context, color1Res)
// -- outer circle
val cx = width / 2f
bounds0Rect = RectF(0f, 0f, width.toFloat(), height.toFloat())
Expand Down Expand Up @@ -125,6 +130,7 @@ class ProfileCircleView @JvmOverloads constructor(
fun setup(
percent: Float,
plusOnly: Boolean,
isPatron: Boolean = false,
gravatarUrl: String? = null,
) {
drawState = DRAW_FULL
Expand All @@ -142,8 +148,11 @@ class ProfileCircleView @JvmOverloads constructor(
}
}

color0 = context.getThemeColor(UR.attr.gradient_01_a)
color1 = context.getThemeColor(UR.attr.gradient_01_e)
this.isPatron = isPatron
val color0Res = if (isPatron) UR.attr.gradient_05_e else UR.attr.gradient_01_a
val color1Res = if (isPatron) UR.attr.gradient_05_e else UR.attr.gradient_01_e
color0 = context.getThemeColor(color0Res)
color1 = context.getThemeColor(color1Res)
update()
invalidate()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package au.com.shiftyjelly.pocketcasts.account.onboarding.components

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import au.com.shiftyjelly.pocketcasts.compose.components.TextH50
import au.com.shiftyjelly.pocketcasts.images.R

private val iconSizeInDp = 14.dp
private val pillCornerRadiusInDp = 800.dp

@Composable
fun SubscriptionTierPill(
@DrawableRes iconRes: Int,
@StringRes shortNameRes: Int,
modifier: Modifier = Modifier,
iconColor: Color = Color.Unspecified,
backgroundColor: Color = Color.Black,
) {
Card(
shape = RoundedCornerShape(pillCornerRadiusInDp),
backgroundColor = backgroundColor,
) {
Row(
modifier = Modifier
.semantics(mergeDescendants = true) {}
.padding(horizontal = 8.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(iconRes),
contentDescription = null,
modifier = modifier
.size(iconSizeInDp)
.padding(end = 4.dp),
tint = iconColor,
)
TextH50(
text = stringResource(shortNameRes),
color = Color.White,
)
}
}
}

@Preview
@Composable
private fun SubscriptionTierPillPreview() {
SubscriptionTierPill(
iconRes = R.drawable.ic_patron,
shortNameRes = au.com.shiftyjelly.pocketcasts.localization.R.string.pocket_casts_patron_short,
backgroundColor = Color.Black,
)
}
Loading

0 comments on commit 1dba064

Please sign in to comment.