forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This CL shapes the role of a KeyboardAccessoryData.Tab element: It is an element that provides a specific benefit to the Manual UI by... ... providing data that is used by the bar to render a tab (upcoming) ... providing the content for a separate tab in the bottom sheet. This means, that the bottom sheet provides space for tabs and manages the general visibility and active states of tabs. The exact content of a tab doesn't matter to the AccessorySheetComponent. That way, it should become fairly straight forward to implement a new tab that is rendered into bottom sheet and accessory. The first concrete instance of a bottom sheet will follow soon: a bottom sheet that contains password related actions and data. (It's important to not mix this specific data into the AccessorySheet component as other upcoming sheets are already planned, like one for payments and one for address data.) Bug: 811747 Change-Id: Id8bd8c389496246166d26a6c298056a142c36566 Reviewed-on: https://chromium-review.googlesource.com/1047285 Commit-Queue: Friedrich Horschig <fhorschig@chromium.org> Reviewed-by: Bernhard Bauer <bauerb@chromium.org> Cr-Commit-Position: refs/heads/master@{#559180}
- Loading branch information
Showing
23 changed files
with
618 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?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. --> | ||
|
||
<!-- This Layout is mainly used in tests. Therefore use possible UnusedResource warnings. --> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:ignore="UnusedResources" | ||
android:orientation="vertical" | ||
android:layout_height="match_parent" | ||
android:layout_width="match_parent"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...va/src/org/chromium/chrome/browser/autofill/keyboard_accessory/AccessoryPagerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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. | ||
|
||
package org.chromium.chrome.browser.autofill.keyboard_accessory; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.view.PagerAdapter; | ||
import android.support.v4.view.ViewPager; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import org.chromium.chrome.browser.modelutil.SimpleListObservable; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* This {@link PagerAdapter} renders an observable list of {@link KeyboardAccessoryData.Tab}s into a | ||
* {@link ViewPager}. It instantiates the tab views based on the layout they provide. | ||
*/ | ||
class AccessoryPagerAdapter extends PagerAdapter { | ||
private final SimpleListObservable<KeyboardAccessoryData.Tab> mTabList; | ||
private final Map<KeyboardAccessoryData.Tab, ViewGroup> mViews; | ||
|
||
/** | ||
* Creates the PagerAdapter that populates a ViewPager based on a held list of tabs. | ||
* @param tabList The list that contains the tabs to instantiate. | ||
*/ | ||
public AccessoryPagerAdapter(SimpleListObservable<KeyboardAccessoryData.Tab> tabList) { | ||
mTabList = tabList; | ||
mViews = new HashMap<>(mTabList.getItemCount()); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Object instantiateItem(@NonNull ViewGroup container, int position) { | ||
KeyboardAccessoryData.Tab tab = mTabList.get(position); | ||
ViewGroup layout = mViews.get(tab); | ||
if (layout == null) { | ||
layout = (ViewGroup) LayoutInflater.from(container.getContext()) | ||
.inflate(tab.getTabLayout(), container, false); | ||
mViews.put(tab, layout); | ||
if (container.indexOfChild(layout) == -1) container.addView(layout); | ||
if (tab.getListener() != null) { | ||
tab.getListener().onTabCreated(layout); | ||
} | ||
} | ||
return layout; | ||
} | ||
|
||
@Override | ||
public void destroyItem(@NonNull ViewGroup container, int position, @Nullable Object object) { | ||
if (mViews.get(mTabList.get(position)) == null) return; | ||
ViewGroup layout = mViews.get(mTabList.get(position)); | ||
if (container.indexOfChild(layout) != -1) container.removeView(layout); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return mTabList.getItemCount(); | ||
} | ||
|
||
@Override | ||
public boolean isViewFromObject(@NonNull View view, @NonNull Object o) { | ||
return view == o; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.