Skip to content

Commit

Permalink
Add horizontal layout adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
DaVinci9196 committed Nov 11, 2024
1 parent 994fdc4 commit 5466be6
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,17 @@ class AuthSignInActivity : AppCompatActivity() {

private fun openAccountPicker(packageName: String) {
val binding = SigninPickerBinding.inflate(layoutInflater)
var accountListView: ListView = binding.pickerList
binding.isLand = (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE).also {
if (it) {
accountListView = binding.pickerListLand
}
}
binding.appName = packageManager.getApplicationLabel(packageName).toString()
binding.appIcon = packageManager.getApplicationIcon(packageName)
val accounts = getSystemService<AccountManager>()!!.getAccountsByType(DEFAULT_ACCOUNT_TYPE) + Account(DEFAULT_ACCOUNT, DEFAULT_ACCOUNT_TYPE)
accountListView.adapter = object : ArrayAdapter<Account>(this, 0, accounts) {
binding.pickerList.adapter = object : ArrayAdapter<Account>(this, 0, accounts) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val v = convertView ?: layoutInflater.inflate(R.layout.signin_account_row, parent, false)
getItem(position)?.let { bindAccountRow(v, it) { _, _ -> notifyDataSetChanged() } }
return v
}
}
accountListView.setOnItemClickListener { parent, view, position, id ->
binding.pickerList.setOnItemClickListener { parent, view, position, id ->
binding.listProgressSpinner = true
if (accounts[position].name == DEFAULT_ACCOUNT) {
openAddAccount()
Expand Down
108 changes: 108 additions & 0 deletions play-services-core/src/main/res/layout-land/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>
129 changes: 47 additions & 82 deletions play-services-core/src/main/res/layout/signin_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,101 +25,56 @@
name="listProgressSpinner"
type="boolean" />

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

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

</data>

<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:orientation="vertical"
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" />

<FrameLayout
android:layout_marginTop="24dp"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
app:visibility='@{isLand ? View.GONE : View.VISIBLE}'>

<ListView
android:id="@+id/picker_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
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>

<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>
<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" />

<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:visibility='@{isLand ? View.VISIBLE : View.GONE}'>
android:layout_marginTop="24dp"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">

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

Expand All @@ -132,5 +87,15 @@

</FrameLayout>

<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>
</layout>

0 comments on commit 5466be6

Please sign in to comment.