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

A12 search bar related improvements #64

Open
wants to merge 2 commits into
base: r11.1
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
7 changes: 3 additions & 4 deletions res/layout/settings_homepage_container_a12.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
android:id="@+id/homepage_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/homepage_container_bg">
android:orientation="vertical">

<FrameLayout
android:id="@+id/contextual_cards_content"
Expand All @@ -47,13 +46,13 @@
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="?android:attr/windowBackground"/>
android:animateLayoutChanges="true"/>

</LinearLayout>
</androidx.core.widget.NestedScrollView>

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_a12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:touchscreenBlocksFocus="false"
Expand Down
21 changes: 20 additions & 1 deletion src/com/android/settings/homepage/SettingsHomepageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

import com.android.settingslib.drawable.CircleFramedDrawable;

import com.google.android.material.appbar.AppBarLayout;

public class SettingsHomepageActivity extends FragmentActivity {

Context context;
Expand All @@ -70,7 +72,10 @@ protected void onCreate(Bundle savedInstanceState) {
root.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);

setHomepageContainerPaddingTop();
if (useNewSearchBar)
setHomepageContainerPaddingTopA12();
else
setHomepageContainerPaddingTop();

mUserManager = context.getSystemService(UserManager.class);

Expand Down Expand Up @@ -129,6 +134,20 @@ void setHomepageContainerPaddingTop() {
view.requestFocus();
}

private void setHomepageContainerPaddingTopA12() {
final View view = findViewById(R.id.homepage_container);
final AppBarLayout appBarLayout = findViewById(R.id.appbar_layout_a12);

// use appBarLayout's current height
appBarLayout.post(() -> {
view.setPadding(0, appBarLayout.getMeasuredHeight(), 0, 0);
});

// Prevent inner RecyclerView gets focus and invokes scrolling.
view.setFocusableInTouchMode(true);
view.requestFocus();
}

private Drawable getCircularUserIcon(Context context) {
Bitmap bitmapUserIcon = mUserManager.getUserIcon(UserHandle.myUserId());

Expand Down