Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues related to AuthSignIn page #2585

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.microg.gms.auth.signin
import android.accounts.Account
import android.accounts.AccountManager
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Bitmap
import android.os.Bundle
import android.util.Log
Expand All @@ -24,7 +25,6 @@ import com.google.android.gms.auth.api.identity.SignInCredential
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.auth.api.signin.SignInAccount
import com.google.android.gms.auth.api.signin.internal.SignInConfiguration
import com.google.android.gms.common.Scopes
import com.google.android.gms.common.api.CommonStatusCodes
import com.google.android.gms.common.api.Status
import com.google.android.gms.common.internal.safeparcel.SafeParcelableSerializer
Expand All @@ -36,7 +36,6 @@ import org.microg.gms.auth.AuthConstants
import org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT
import org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT_TYPE
import org.microg.gms.auth.login.LoginActivity
import org.microg.gms.people.DatabaseHelper
import org.microg.gms.people.PeopleManager
import org.microg.gms.utils.getApplicationLabel

Expand All @@ -53,8 +52,6 @@ class AuthSignInActivity : AppCompatActivity() {
intent?.extras?.also { it.classLoader = SignInConfiguration::class.java.classLoader }?.getParcelable<SignInConfiguration>("config")
}.getOrNull()

private val Int.px: Int get() = (this * resources.displayMetrics.density).toInt()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setResult(CommonStatusCodes.CANCELED)
Expand All @@ -64,8 +61,12 @@ class AuthSignInActivity : AppCompatActivity() {
val packageName = config?.packageName
if (packageName == null || (packageName != callingActivity?.packageName && callingActivity?.packageName != this.packageName))
return finishResult(CommonStatusCodes.DEVELOPER_ERROR, "package name mismatch")
val accountManager = getSystemService<AccountManager>() ?: return finishResult(CommonStatusCodes.INTERNAL_ERROR, "No account manager")

initView()
}

private fun initView() {
val accountManager = getSystemService<AccountManager>() ?: return finishResult(CommonStatusCodes.INTERNAL_ERROR, "No account manager")
val accounts = accountManager.getAccountsByType(DEFAULT_ACCOUNT_TYPE)
if (accounts.isNotEmpty()) {
val account = config?.options?.account
Expand Down Expand Up @@ -230,4 +231,9 @@ class AuthSignInActivity : AppCompatActivity() {
}
}
}

override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
initView()
}
}
108 changes: 108 additions & 0 deletions play-services-core/src/main/res/layout-w600dp/signin_picker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ SPDX-FileCopyrightText: 2023 microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="appName"
type="String" />

<variable
name="appIcon"
type="android.graphics.drawable.Drawable" />

<variable
name="policySpanned"
type="android.text.Spanned" />

<variable
name="listProgressSpinner"
type="boolean" />

<import type="android.view.View" />

</data>

<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical">

<ImageView
android:layout_marginTop="32dp"
android:layout_marginBottom="16dp"
android:layout_marginHorizontal="16dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_horizontal"
app:imageDrawable="@{appIcon}"
tools:src="@mipmap/ic_app" />

<TextView
android:layout_margin="2dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/signin_picker_title"
android:maxLines="2"
style="@style/TextAppearance.AppCompat.Title" />

<TextView
android:id="@+id/picker_subtitle"
android:layout_margin="2dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{@string/signin_picker_subtitle(appName)}"
tools:text="@string/signin_picker_subtitle"
style="@style/TextAppearance.AppCompat.Medium" />

<TextView
android:id="@+id/picker_subtext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="24dp"
android:maxLines="6"
android:text='@{@string/signin_subtext_sharing(appName) + (policySpanned != null ? " " + policySpanned : "")}'
style="@style/TextAppearance.AppCompat.Small"
tools:text="To continue, microG will share name, email address and profile picture of your Google Account with Test App. Before using this app, review its privacy policy and terms of service." />
</LinearLayout>

<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">

<ListView
android:id="@+id/picker_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:alpha="@{listProgressSpinner ? 0.6f : 1.0f}"
tools:listitem="@layout/signin_account_row" />

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:visibility="invisible"
app:visibility='@{listProgressSpinner ? View.VISIBLE : View.INVISIBLE}' />

</FrameLayout>

</LinearLayout>
</layout>