Commit b26009e4 authored by Tommy Martino's avatar Tommy Martino Committed by Commit Bot

[AF Android] Creating Structure for Footer

This CL lays out the scaffolding for adding a footer to the Android
Autofill dropdown. The general goal is to wrap the ListView used by the
existing dropdown in new XML, which will later be expanded to
contain the footer items.

This is accomplished by adding a new XML layout to define the
relationship between the existing list and its footer, and by adding a
new setFooterView method to the popup interface which injects a View
into the designated spot in the layout.


Change-Id: I144580c15be4b204b86b85b3d6e44d11fc9f9acf
Bug: 874077
Reviewed-on: https://chromium-review.googlesource.com/1195894
Commit-Queue: Tommy Martino <tmartino@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593716}
parent 0b1fc9b7
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dropdown_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_horizontal"
android:orientation="vertical" >
<ListView
android:id="@+id/dropdown_body_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<View style="@style/HorizontalDivider"
android:id="@+id/dropdown_body_footer_divider"
android:layout_height="@dimen/divider_height"
android:layout_width="match_parent"
android:visibility="gone" />
<FrameLayout
android:id="@+id/dropdown_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
......@@ -128,4 +128,11 @@ public class DropdownPopupWindow {
public boolean isShowing() {
return mPopup.isShowing();
}
/**
* See {@link DropdownPopupWindowInterface#setFooterView(View)}.
*/
protected void setFooterView(View footerItem) {
mPopup.setFooterView(footerItem);
}
}
......@@ -7,10 +7,13 @@ package org.chromium.ui;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
......@@ -33,7 +36,10 @@ class DropdownPopupWindowImpl
private CharSequence mDescription;
private AnchoredPopupWindow mAnchoredPopupWindow;
ListAdapter mAdapter;
private ListView mListView;
private final LinearLayout mContentView;
private final ListView mListView;
private final FrameLayout mFooterView;
private Drawable mBackground;
private int mHorizontalPadding;
......@@ -66,13 +72,18 @@ class DropdownPopupWindowImpl
mAnchorView.setTag(null);
}
};
mListView = new ListView(context);
mContentView =
(LinearLayout) LayoutInflater.from(context).inflate(R.layout.dropdown_window, null);
mListView = (ListView) mContentView.findViewById(R.id.dropdown_body_list);
mFooterView = (FrameLayout) mContentView.findViewById(R.id.dropdown_footer);
ViewRectProvider rectProvider = new ViewRectProvider(mAnchorView);
rectProvider.setIncludePadding(true);
mBackground = ApiCompatibilityUtils.getDrawable(
context.getResources(), R.drawable.dropdown_popup_background);
mAnchoredPopupWindow =
new AnchoredPopupWindow(context, mAnchorView, mBackground, mListView, rectProvider);
mAnchoredPopupWindow = new AnchoredPopupWindow(
context, mAnchorView, mBackground, mContentView, rectProvider);
mAnchoredPopupWindow.addOnDismissListener(onDismissLitener);
mAnchoredPopupWindow.setLayoutObserver(this);
Rect paddingRect = new Rect();
......@@ -196,6 +207,18 @@ class DropdownPopupWindowImpl
mListView.setOnItemClickListener(clickListener);
}
@Override
public void setFooterView(View footerView) {
boolean hasFooter = footerView != null;
View divider = mContentView.findViewById(R.id.dropdown_body_footer_divider);
divider.setVisibility(hasFooter ? View.VISIBLE : View.GONE);
mFooterView.removeAllViews();
if (hasFooter) {
mFooterView.addView(footerView);
}
}
/**
* Show the popup. Will have no effect if the popup is already showing.
* Post a {@link #show()} call to the UI thread.
......
......@@ -4,6 +4,7 @@
package org.chromium.ui;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
......@@ -69,6 +70,12 @@ public interface DropdownPopupWindowInterface {
*/
void setOnItemClickListener(AdapterView.OnItemClickListener clickListener);
/**
* Adds a non-scrolling View beneath the list. This View will be separated from the main list
* by a single divider. Passing null will remove any existing footer.
*/
void setFooterView(View footerView);
/**
* Show the popup. Will have no effect if the popup is already showing.
* Post a {@link #show()} call to the UI thread.
......
......@@ -191,6 +191,11 @@ class DropdownPopupWindowJellyBean implements DropdownPopupWindowInterface {
mListPopupWindow.setOnItemClickListener(clickListener);
}
@Override
public void setFooterView(View footerView) {
// TODO(crbug.com/874077): Implement this before using footer views.
}
/**
* Show the popup. Will have no effect if the popup is already showing.
* Post a {@link #show()} call to the UI thread.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment