Skip to content

Commit e7941f2

Browse files
committed
Layout improvements
1 parent 8562050 commit e7941f2

File tree

48 files changed

+301
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+301
-258
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ buildscript {
1515
ext.fragmentVersion = '1.8.9'
1616
ext.lifecycleVersion = '2.9.2'
1717
ext.loaderVersion = '1.1.0'
18-
ext.materialVersion = '1.14.0-alpha03'
18+
ext.materialVersion = '1.14.0-alpha04'
1919
ext.mediarouterVersion = '1.8.1'
2020
ext.multidexVersion = '2.0.1'
2121
ext.navigationVersion = '2.9.3'

play-services-base/core/src/main/res/layout/preference_app_heading.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
android:ellipsize="marquee"
4747
android:gravity="center"
4848
android:singleLine="false"
49-
android:textAppearance="?attr/textAppearanceTitleLarge"
49+
android:textAppearance="?attr/textAppearanceTitleLargeEmphasized"
5050
app:layout_constraintEnd_toEndOf="parent"
5151
app:layout_constraintStart_toStartOf="parent"
5252
app:layout_constraintTop_toBottomOf="@android:id/icon"

play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractAboutFragment.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import android.widget.ArrayAdapter;
2828
import android.widget.Button;
2929
import android.widget.ImageView;
30-
import android.widget.LinearLayout;
3130
import android.widget.TextView;
3231

3332
import androidx.annotation.NonNull;
@@ -134,11 +133,21 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
134133
collectLibraries(libraries);
135134
Collections.sort(libraries);
136135

137-
LinearLayout libraryContainer = aboutRoot.findViewById(R.id.library_container);
138-
for (Library library : libraries) {
136+
ViewGroup libraryContainer = aboutRoot.findViewById(R.id.library_container);
137+
for (int i = 0; i < libraries.size(); i++) {
138+
Library library = libraries.get(i);
139+
139140
View libraryView = inflater.inflate(R.layout.library_item, libraryContainer, false);
140-
((TextView) libraryView.findViewById(android.R.id.text1)).setText(getString(R.string.about_name_version_str, library.name, getLibVersion(library.packageName)));
141-
((TextView) libraryView.findViewById(android.R.id.text2)).setText(library.copyright != null ? library.copyright : getString(R.string.about_default_license));
141+
142+
TextView title = libraryView.findViewById(android.R.id.text1);
143+
TextView subtitle = libraryView.findViewById(android.R.id.text2);
144+
145+
title.setText(getString(R.string.about_name_version_str, library.name, getLibVersion(library.packageName)));
146+
subtitle.setText(library.copyright != null ? library.copyright : getString(R.string.about_default_license));
147+
148+
com.google.android.material.listitem.ListItemLayout listItemLayout = libraryView.findViewById(R.id.list_item_library);
149+
listItemLayout.updateAppearance(i, libraries.size());
150+
142151
libraryContainer.addView(libraryView);
143152
}
144153

play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSelfCheckFragment.java

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
package org.microg.tools.ui;
1818

1919
import android.os.Bundle;
20+
import android.view.MotionEvent;
2021
import android.util.Log;
2122
import android.view.LayoutInflater;
22-
import android.view.MotionEvent;
2323
import android.view.View;
2424
import android.view.ViewGroup;
2525
import android.widget.CheckBox;
@@ -48,22 +48,22 @@ public abstract class AbstractSelfCheckFragment extends Fragment {
4848
@Override
4949
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
5050
View scrollRoot = inflater.inflate(R.layout.self_check, container, false);
51-
root = (ViewGroup) scrollRoot.findViewById(R.id.self_check_root);
51+
root = scrollRoot.findViewById(R.id.self_check_root);
5252
reset(inflater);
5353
return scrollRoot;
5454
}
5555

5656
protected abstract void prepareSelfCheckList(List<SelfCheckGroup> checks);
5757

5858
protected void reset(LayoutInflater inflater) {
59-
List<SelfCheckGroup> selfCheckGroupList = new ArrayList<SelfCheckGroup>();
59+
List<SelfCheckGroup> selfCheckGroupList = new ArrayList<>();
6060
prepareSelfCheckList(selfCheckGroupList);
6161

6262
root.removeAllViews();
6363
for (SelfCheckGroup group : selfCheckGroupList) {
6464
View groupView = inflater.inflate(R.layout.self_check_group, root, false);
6565
((TextView) groupView.findViewById(android.R.id.title)).setText(group.getGroupName(getContext()));
66-
final ViewGroup viewGroup = (ViewGroup) groupView.findViewById(R.id.group_content);
66+
final ViewGroup viewGroup = groupView.findViewById(R.id.group_content);
6767
final SelfCheckGroup.ResultCollector collector = new GroupResultCollector(viewGroup);
6868
try {
6969
group.doChecks(getContext(), collector);
@@ -88,41 +88,51 @@ public void addResult(final String name, final SelfCheckGroup.Result result, fin
8888
}
8989

9090
@Override
91-
public void addResult(final String name, final SelfCheckGroup.Result result, final String resolution,
92-
final SelfCheckGroup.CheckResolver resolver) {
91+
public void addResult(final String name, final SelfCheckGroup.Result result, final String resolution, final SelfCheckGroup.CheckResolver resolver) {
9392
if (result == null || getActivity() == null) return;
94-
getActivity().runOnUiThread(new Runnable() {
95-
@Override
96-
public void run() {
97-
View resultEntry = LayoutInflater.from(getContext()).inflate(R.layout.self_check_entry, viewGroup, false);
98-
((TextView) resultEntry.findViewById(R.id.self_check_name)).setText(name);
99-
resultEntry.findViewById(R.id.self_check_result).setOnTouchListener(new View.OnTouchListener() {
100-
@Override
101-
public boolean onTouch(View v, MotionEvent event) {
102-
return true;
103-
}
104-
});
105-
if (result == Positive) {
106-
((CheckBox) resultEntry.findViewById(R.id.self_check_result)).setChecked(true);
107-
resultEntry.findViewById(R.id.self_check_resolution).setVisibility(GONE);
108-
} else {
109-
((TextView) resultEntry.findViewById(R.id.self_check_resolution)).setText(resolution);
110-
if (result == Unknown) {
111-
resultEntry.findViewById(R.id.self_check_result).setVisibility(INVISIBLE);
112-
}
113-
if (resolver != null) {
114-
resultEntry.setClickable(true);
115-
resultEntry.setOnClickListener(new View.OnClickListener() {
116-
@Override
117-
public void onClick(View v) {
118-
resolver.tryResolve(AbstractSelfCheckFragment.this);
119-
}
120-
});
93+
getActivity().runOnUiThread(() -> {
94+
View resultEntry = LayoutInflater.from(getContext()).inflate(R.layout.self_check_entry, viewGroup, false);
95+
96+
TextView nameView = resultEntry.findViewById(R.id.self_check_name);
97+
TextView resolutionView = resultEntry.findViewById(R.id.self_check_resolution);
98+
CheckBox checkBox = resultEntry.findViewById(R.id.self_check_result);
99+
resultEntry.findViewById(R.id.list_item_check);
100+
101+
nameView.setText(name);
102+
103+
resultEntry.findViewById(R.id.self_check_result).setOnTouchListener((v, event) -> {
104+
if (event.getAction() == MotionEvent.ACTION_UP) {
105+
if (event.getX() >= 0 && event.getX() <= v.getWidth() && event.getY() >= 0 && event.getY() <= v.getHeight()) {
106+
v.performClick();
121107
}
122108
}
123-
viewGroup.addView(resultEntry);
109+
return true;
110+
});
111+
112+
if (result == Positive) {
113+
checkBox.setChecked(true);
114+
resolutionView.setVisibility(GONE);
115+
} else {
116+
resolutionView.setText(resolution);
117+
if (result == Unknown) {
118+
checkBox.setVisibility(INVISIBLE);
119+
}
120+
if (resolver != null) {
121+
resultEntry.setClickable(true);
122+
resultEntry.setOnClickListener(v -> resolver.tryResolve(AbstractSelfCheckFragment.this));
123+
}
124+
}
125+
126+
viewGroup.addView(resultEntry);
127+
128+
for (int i = 0; i < viewGroup.getChildCount(); i++) {
129+
View child = viewGroup.getChildAt(i);
130+
com.google.android.material.listitem.ListItemLayout layout = child.findViewById(R.id.list_item_check);
131+
if (layout != null) {
132+
layout.updateAppearance(i, viewGroup.getChildCount());
133+
}
124134
}
125135
});
126136
}
127137
}
128-
}
138+
}

play-services-core/microg-ui-tools/src/main/res/drawable/preference_background_libraries.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

play-services-core/microg-ui-tools/src/main/res/layout/about_root.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
android:layout_height="wrap_content"
4646
android:layout_marginTop="12dp"
4747
android:text="@string/about_root_title"
48-
android:textAppearance="?attr/textAppearanceTitleLarge"
48+
android:textAppearance="?attr/textAppearanceTitleLargeEmphasized"
4949
app:layout_constraintEnd_toEndOf="parent"
5050
app:layout_constraintStart_toStartOf="parent"
5151
app:layout_constraintTop_toBottomOf="@android:id/icon" />
@@ -111,7 +111,6 @@
111111
android:id="@+id/library_container"
112112
android:layout_width="0dp"
113113
android:layout_height="wrap_content"
114-
android:background="@drawable/preference_background_libraries"
115114
android:orientation="vertical"
116115
app:layout_constraintEnd_toEndOf="parent"
117116
app:layout_constraintStart_toStartOf="parent"
Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,58 @@
1-
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
1+
<com.google.android.material.listitem.ListItemLayout xmlns:android="http://schemas.android.com/apk/res/android"
22
xmlns:app="http://schemas.android.com/apk/res-auto"
33
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/list_item_library"
5+
style="?attr/listItemLayoutSegmentedStyle"
46
android:layout_width="match_parent"
57
android:layout_height="wrap_content"
6-
android:layout_marginStart="14dp"
7-
android:layout_marginTop="16dp"
8-
android:layout_marginEnd="14dp"
9-
android:layout_marginBottom="16dp">
8+
android:layout_marginBottom="2dp"
9+
android:background="@android:color/transparent">
1010

11-
<com.google.android.material.imageview.ShapeableImageView
12-
android:id="@+id/icon"
13-
android:layout_width="wrap_content"
11+
<com.google.android.material.card.MaterialCardView
12+
android:layout_width="match_parent"
1413
android:layout_height="wrap_content"
15-
android:importantForAccessibility="no"
16-
android:src="@drawable/ic_license"
17-
app:layout_constraintBottom_toBottomOf="parent"
18-
app:layout_constraintStart_toStartOf="parent"
19-
app:layout_constraintTop_toTopOf="parent" />
14+
android:checkable="false"
15+
app:cardBackgroundColor="?attr/colorSurfaceContainer">
2016

21-
<com.google.android.material.textview.MaterialTextView
22-
android:id="@android:id/text1"
23-
android:layout_width="0dp"
24-
android:layout_height="wrap_content"
25-
android:layout_marginStart="12dp"
26-
android:textAppearance="?attr/textAppearanceLabelLarge"
27-
app:layout_constraintBottom_toTopOf="@android:id/text2"
28-
app:layout_constraintEnd_toEndOf="parent"
29-
app:layout_constraintStart_toEndOf="@id/icon"
30-
app:layout_constraintTop_toTopOf="parent"
31-
app:layout_constraintVertical_chainStyle="packed"
32-
tools:text="Android Jetpack" />
17+
<androidx.constraintlayout.widget.ConstraintLayout
18+
android:layout_width="match_parent"
19+
android:layout_height="wrap_content"
20+
android:padding="12dp">
3321

34-
<com.google.android.material.textview.MaterialTextView
35-
android:id="@android:id/text2"
36-
android:layout_width="0dp"
37-
android:layout_height="wrap_content"
38-
android:textAppearance="?attr/textAppearanceBodySmall"
39-
android:textColor="?android:textColorSecondary"
40-
app:layout_constraintBottom_toBottomOf="parent"
41-
app:layout_constraintEnd_toEndOf="parent"
42-
app:layout_constraintStart_toStartOf="@android:id/text1"
43-
app:layout_constraintTop_toBottomOf="@android:id/text1"
44-
tools:text="Apache License 2.0, The Android Open Source Project." />
45-
</androidx.constraintlayout.widget.ConstraintLayout>
22+
<com.google.android.material.imageview.ShapeableImageView
23+
android:id="@+id/icon"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:importantForAccessibility="no"
27+
android:src="@drawable/ic_license"
28+
app:layout_constraintBottom_toBottomOf="parent"
29+
app:layout_constraintStart_toStartOf="parent"
30+
app:layout_constraintTop_toTopOf="parent" />
31+
32+
<com.google.android.material.textview.MaterialTextView
33+
android:id="@android:id/text1"
34+
android:layout_width="0dp"
35+
android:layout_height="wrap_content"
36+
android:layout_marginStart="12dp"
37+
android:textAppearance="?attr/textAppearanceLabelLarge"
38+
app:layout_constraintBottom_toTopOf="@android:id/text2"
39+
app:layout_constraintEnd_toEndOf="parent"
40+
app:layout_constraintStart_toEndOf="@id/icon"
41+
app:layout_constraintTop_toTopOf="parent"
42+
app:layout_constraintVertical_chainStyle="packed"
43+
tools:text="Android Jetpack" />
44+
45+
<com.google.android.material.textview.MaterialTextView
46+
android:id="@android:id/text2"
47+
android:layout_width="0dp"
48+
android:layout_height="wrap_content"
49+
android:textAppearance="?attr/textAppearanceBodySmall"
50+
android:textColor="?android:textColorSecondary"
51+
app:layout_constraintBottom_toBottomOf="parent"
52+
app:layout_constraintEnd_toEndOf="parent"
53+
app:layout_constraintStart_toStartOf="@android:id/text1"
54+
app:layout_constraintTop_toBottomOf="@android:id/text1"
55+
tools:text="Apache License 2.0, The Android Open Source Project." />
56+
</androidx.constraintlayout.widget.ConstraintLayout>
57+
</com.google.android.material.card.MaterialCardView>
58+
</com.google.android.material.listitem.ListItemLayout>

play-services-core/microg-ui-tools/src/main/res/layout/self_check.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
1818
android:layout_width="match_parent"
19-
android:layout_height="wrap_content">
19+
android:layout_height="match_parent"
20+
android:layout_marginStart="?attr/listPreferredItemPaddingStart"
21+
android:layout_marginEnd="?attr/listPreferredItemPaddingEnd">
2022

2123
<androidx.appcompat.widget.LinearLayoutCompat
2224
android:id="@+id/self_check_root"
23-
android:layout_width="wrap_content"
24-
android:layout_height="wrap_content"
25+
android:layout_width="fill_parent"
26+
android:layout_height="fill_parent"
2527
android:orientation="vertical" />
2628
</androidx.core.widget.NestedScrollView>

0 commit comments

Comments
 (0)