Skip to content

Commit 339a886

Browse files
committed
yt sign-in: improve qr code link
1 parent cd7f617 commit 339a886

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/YTSignInPresenter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
public class YTSignInPresenter extends SignInPresenter {
1515
private static final String TAG = YTSignInPresenter.class.getSimpleName();
1616
private static final String SIGN_IN_URL = "https://yt.be/activate"; // 18+, no search history
17+
private static final String QR_SIGN_IN_URL = "https://youtube.com/qr/activate/";
1718
//private static final String SIGN_IN_URL = "https://youtube.com/tv/activate"; // 18+, no search history
1819
//private static final String SIGN_IN_URL = "https://youtube.com/activate"; // age restricted, supports search history
1920
@SuppressLint("StaticFieldLeak")
@@ -64,7 +65,8 @@ public void onActionClicked() {
6465
private void updateUserCode() {
6566
mSignInAction = mService.getSignInService().signInObserve()
6667
.subscribe(
67-
userCode -> getView().showCode(userCode, SIGN_IN_URL),
68+
userCode ->
69+
getView().showCode(userCode, SIGN_IN_URL, QR_SIGN_IN_URL + userCode.replace(" ", "-")),
6870
error -> {
6971
Log.e(TAG, "Sign in error: %s", error.getMessage());
7072
if (getView() != null) {

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/views/SignInView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
public interface SignInView {
44
void showCode(String userCode, String signInUrl);
5+
void showCode(String userCode, String signInUrl, String fullSignInUrl);
56
void close();
67
}

smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/signin/SignInFragment.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,22 @@ public void onDestroy() {
5353

5454
@Override
5555
public void showCode(String userCode, String signInUrl) {
56-
setTitle(userCode, signInUrl);
56+
setTitle(userCode, signInUrl, null);
5757
}
5858

59-
private void setTitle(String userCode, String signInUrl) {
60-
if (TextUtils.isEmpty(userCode)) {
59+
@Override
60+
public void showCode(String userCode, String signInUrl, String fullSignInUrl) {
61+
setTitle(userCode, signInUrl, fullSignInUrl);
62+
}
63+
64+
private void setTitle(String userCode, String signInUrl, String fullSignInUrl) {
65+
if (getContext() == null || TextUtils.isEmpty(userCode)) {
6166
return;
6267
}
6368

6469
getGuidanceStylist().getTitleView().setText(userCode);
6570

66-
mFullSignInUrl = signInUrl + "?user_code=" + userCode.replace(" ", "-");
71+
mFullSignInUrl = fullSignInUrl != null ? fullSignInUrl : signInUrl;
6772

6873
Glide.with(getContext())
6974
.load(Utils.toQrCodeLink(mFullSignInUrl))

0 commit comments

Comments
 (0)