Skip to content

Commit f8c7114

Browse files
authored
YiR: Login dialog in the onboarding screen. (#5965)
1 parent 1aff666 commit f8c7114

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

app/src/main/java/org/wikipedia/login/LoginActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class LoginActivity : BaseActivity() {
298298
const val SOURCE_SUGGESTED_EDITS = "suggestededits"
299299
const val SOURCE_TALK = "talk"
300300
const val SOURCE_ACTIVITY_TAB = "activity_tab"
301+
const val SOURCE_YEAR_IN_REVIEW = "yir"
301302

302303
fun newIntent(context: Context, source: String, createAccountFirst: Boolean = true): Intent {
303304
return Intent(context, LoginActivity::class.java)

app/src/main/java/org/wikipedia/yearinreview/YearInReviewOnboardingActivity.kt

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,72 @@ import android.content.Context
44
import android.content.Intent
55
import android.os.Bundle
66
import androidx.activity.compose.setContent
7+
import androidx.activity.result.contract.ActivityResultContracts
8+
import androidx.compose.runtime.getValue
9+
import androidx.compose.runtime.mutableStateOf
10+
import androidx.compose.runtime.remember
11+
import androidx.compose.runtime.setValue
12+
import androidx.compose.ui.res.stringResource
13+
import org.wikipedia.R
714
import org.wikipedia.activity.BaseActivity
15+
import org.wikipedia.auth.AccountUtil
16+
import org.wikipedia.compose.components.WikipediaAlertDialog
817
import org.wikipedia.compose.theme.BaseTheme
18+
import org.wikipedia.login.LoginActivity
919

1020
class YearInReviewOnboardingActivity : BaseActivity() {
1121

22+
private val loginLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
23+
if (it.resultCode == LoginActivity.RESULT_LOGIN_SUCCESS) {
24+
proceed()
25+
}
26+
}
27+
1228
override fun onCreate(savedInstanceState: Bundle?) {
1329
super.onCreate(savedInstanceState)
1430
setContent {
1531
BaseTheme {
32+
var showLoginDialog by remember { mutableStateOf(false) }
33+
if (showLoginDialog) {
34+
WikipediaAlertDialog(
35+
title = stringResource(R.string.year_in_review_login_dialog_title),
36+
message = stringResource(R.string.year_in_review_login_dialog_body),
37+
confirmButtonText = stringResource(R.string.year_in_review_login_dialog_positive),
38+
dismissButtonText = stringResource(R.string.year_in_review_login_dialog_negative),
39+
onDismissRequest = {
40+
showLoginDialog = false
41+
},
42+
onConfirmButtonClick = {
43+
loginLauncher.launch(LoginActivity.newIntent(this, LoginActivity.SOURCE_YEAR_IN_REVIEW))
44+
showLoginDialog = false
45+
},
46+
onDismissButtonClick = {
47+
proceed()
48+
}
49+
)
50+
}
51+
1652
YearInReviewOnboardingScreen(
1753
onBackButtonClick = {
1854
finish()
1955
},
2056
onGetStartedClick = {
21-
startActivity(YearInReviewActivity.newIntent(this))
22-
finish()
57+
if (!AccountUtil.isLoggedIn) {
58+
showLoginDialog = true
59+
} else {
60+
proceed()
61+
}
2362
}
2463
)
2564
}
2665
}
2766
}
2867

68+
private fun proceed() {
69+
startActivity(YearInReviewActivity.newIntent(this))
70+
finish()
71+
}
72+
2973
companion object {
3074
fun newIntent(context: Context): Intent {
3175
return Intent(context, YearInReviewOnboardingActivity::class.java)

app/src/main/res/values-qq/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,10 @@
18871887
<string name="year_in_review_screenshot_error">A generic error idicator with \"%s\" representing the actual error thrown</string>
18881888
<string name="year_in_review_share_subject">The subject line for sharing the year in review</string>
18891889
<string name="year_in_review_globe_icon">Content description for the year in review globe icon</string>
1890+
<string name="year_in_review_login_dialog_title">Title of a dialog asking the user to log in before accessing the Year in Review feature.</string>
1891+
<string name="year_in_review_login_dialog_body">Body text of a dialog asking the user to log in before accessing the Year in Review feature.</string>
1892+
<string name="year_in_review_login_dialog_positive">Positive button label for a dialog asking the user to log in before accessing the Year in Review feature.</string>
1893+
<string name="year_in_review_login_dialog_negative">Negative button label for a dialog asking the user to log in before accessing the Year in Review feature.</string>
18901894
<string name="recommended_reading_list_title">Title for the recommended reading list feature.</string>
18911895
<string name="recommended_reading_list_onboarding_card_title">Title of the onboarding card for the recommended reading list.</string>
18921896
<string name="recommended_reading_list_onboarding_card_message">Message on the onboarding card for the recommended reading list.</string>

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,10 @@
20072007
<string name="year_in_review_screenshot_error">Could not generate screenshot: %s</string>
20082008
<string name="year_in_review_share_subject">Year In Review Image and Link</string>
20092009
<string name="year_in_review_globe_icon">Globe Icon</string>
2010+
<string name="year_in_review_login_dialog_title">Log in for personalization?</string>
2011+
<string name="year_in_review_login_dialog_body">Logging in gives you access to personalized insights. You can still see collective insights without logging in.</string>
2012+
<string name="year_in_review_login_dialog_positive">Log in / join Wikipedia</string>
2013+
<string name="year_in_review_login_dialog_negative">Continue without logging in</string>
20102014

20112015

20122016
<!--Recommended Reading list -->

0 commit comments

Comments
 (0)