Use separate layout for un-selected page previews
- Make remove icon more visible by removing the translucency in icon - Replace remove and check icon by vectors - unselected pages are now not faded out by being 50% translucent to the page shadow anymore, they are explcityly faded out by being 50% translucent to a defined background color - No need for our own animations as the recyclerview does all the animations for us Fixes: 28885729 Change-Id: I70d2db89c4124bf5ef528c65b5f79d189da43857
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 783 B |
|
Before Width: | Height: | Size: 761 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
25
packages/PrintSpooler/res/drawable/ic_check_circle.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"
|
||||
android:fillColor="?android:attr/colorAccent" />
|
||||
</vector>
|
||||
25
packages/PrintSpooler/res/drawable/ic_remove_circle.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z"
|
||||
android:fillColor="?android:attr/colorAccent" />
|
||||
</vector>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:enterFadeDuration="@android:integer/config_shortAnimTime"
|
||||
android:exitFadeDuration="@android:integer/config_shortAnimTime">
|
||||
|
||||
<item
|
||||
android:state_selected="true">
|
||||
<bitmap
|
||||
android:src="@drawable/ic_check_circle"
|
||||
android:tint="?android:attr/colorAccent">
|
||||
</bitmap>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<bitmap
|
||||
android:src="@drawable/ic_remove_circle"
|
||||
android:tint="?android:attr/colorAccent">
|
||||
</bitmap>
|
||||
</item>
|
||||
|
||||
</selector>
|
||||
@@ -20,12 +20,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/preview_page_margin"
|
||||
android:orientation="vertical"
|
||||
android:background="?android:attr/colorForeground">
|
||||
android:background="@color/unselected_page_background_color"
|
||||
android:elevation="@dimen/unselected_page_elevation" >
|
||||
|
||||
<com.android.printspooler.widget.PageContentView
|
||||
android:id="@+id/page_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
android:layout_height="fill_parent"
|
||||
android:alpha="0.5">
|
||||
</com.android.printspooler.widget.PageContentView>
|
||||
|
||||
<RelativeLayout
|
||||
@@ -34,7 +36,7 @@
|
||||
android:layout_height="@dimen/preview_page_footer_height"
|
||||
android:background="@color/material_grey_500"
|
||||
android:orientation="horizontal"
|
||||
android:duplicateParentState="true">
|
||||
android:alpha="0.5">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_number"
|
||||
@@ -52,8 +54,7 @@
|
||||
android:layout_marginRight="8dip"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@drawable/page_selector_background"
|
||||
android:duplicateParentState="true">
|
||||
android:src="@drawable/ic_remove_circle">
|
||||
</ImageView>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
60
packages/PrintSpooler/res/layout/preview_page_selected.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.android.printspooler.widget.PreviewPageFrame xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/preview_page"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/preview_page_margin"
|
||||
android:orientation="vertical"
|
||||
android:background="@android:color/white"
|
||||
android:elevation="@dimen/selected_page_elevation" >
|
||||
|
||||
<com.android.printspooler.widget.PageContentView
|
||||
android:id="@+id/page_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
</com.android.printspooler.widget.PageContentView>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/page_footer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/preview_page_footer_height"
|
||||
android:background="@color/material_grey_500"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorPrimary">
|
||||
</TextView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/page_selector"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="8dip"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_check_circle">
|
||||
</ImageView>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</com.android.printspooler.widget.PreviewPageFrame>
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
<color name="print_preview_background_color">#F2F1F2</color>
|
||||
|
||||
<color name="unselected_page_background_color">#C0C0C0</color>
|
||||
|
||||
<color name="material_grey_500">#ffa3a3a3</color>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -39,9 +39,6 @@
|
||||
|
||||
<integer name="print_option_column_count">2</integer>
|
||||
|
||||
<fraction name="page_selected_alpha">100%</fraction>
|
||||
<fraction name="page_unselected_alpha">50%</fraction>
|
||||
|
||||
<dimen name="preview_page_footer_height">32dip</dimen>
|
||||
<dimen name="preview_page_min_width">128dip</dimen>
|
||||
|
||||
|
||||
@@ -297,7 +297,14 @@ public final class PageAdapter extends Adapter<ViewHolder> {
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View page = mLayoutInflater.inflate(R.layout.preview_page, parent, false);
|
||||
View page;
|
||||
|
||||
if (viewType == 0) {
|
||||
page = mLayoutInflater.inflate(R.layout.preview_page_selected, parent, false);
|
||||
} else {
|
||||
page = mLayoutInflater.inflate(R.layout.preview_page, parent, false);
|
||||
}
|
||||
|
||||
return new MyViewHolder(page);
|
||||
}
|
||||
|
||||
@@ -345,9 +352,9 @@ public final class PageAdapter extends Adapter<ViewHolder> {
|
||||
content.init(provider, mEmptyState, mErrorState, mMediaSize, mMinMargins);
|
||||
|
||||
if (mConfirmedPagesInDocument.indexOfKey(pageInDocument) >= 0) {
|
||||
page.setSelected(true, false);
|
||||
page.setSelected(true);
|
||||
} else {
|
||||
page.setSelected(false, false);
|
||||
page.setSelected(false);
|
||||
}
|
||||
|
||||
page.setContentDescription(mContext.getString(R.string.page_description_template,
|
||||
@@ -364,6 +371,15 @@ public final class PageAdapter extends Adapter<ViewHolder> {
|
||||
return mSelectedPageCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mConfirmedPagesInDocument.indexOfKey(computePageIndexInDocument(position)) >= 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return computePageIndexInDocument(position);
|
||||
@@ -821,14 +837,14 @@ public final class PageAdapter extends Adapter<ViewHolder> {
|
||||
final int pageInDocument = computePageIndexInDocument(pageInAdapter);
|
||||
if (mConfirmedPagesInDocument.indexOfKey(pageInDocument) < 0) {
|
||||
mConfirmedPagesInDocument.put(pageInDocument, null);
|
||||
page.setSelected(true, true);
|
||||
} else {
|
||||
if (mConfirmedPagesInDocument.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
mConfirmedPagesInDocument.remove(pageInDocument);
|
||||
page.setSelected(false, true);
|
||||
}
|
||||
|
||||
notifyItemChanged(pageInAdapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,29 +22,14 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import com.android.printspooler.R;
|
||||
|
||||
/**
|
||||
* This class represents the frame of page in the print preview list
|
||||
* that contains the page and a footer.
|
||||
*/
|
||||
public final class PreviewPageFrame extends LinearLayout {
|
||||
private final float mSelectedElevation;
|
||||
private final float mNotSelectedElevation;
|
||||
|
||||
private final float mSelectedPageAlpha;
|
||||
private final float mNotSelectedAlpha;
|
||||
|
||||
public PreviewPageFrame(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mSelectedElevation = mContext.getResources().getDimension(
|
||||
R.dimen.selected_page_elevation);
|
||||
mNotSelectedElevation = mContext.getResources().getDimension(
|
||||
R.dimen.unselected_page_elevation);
|
||||
mSelectedPageAlpha = mContext.getResources().getFraction(
|
||||
R.fraction.page_selected_alpha, 1, 1);
|
||||
mNotSelectedAlpha = mContext.getResources().getFraction(
|
||||
R.fraction.page_unselected_alpha, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,28 +50,4 @@ public final class PreviewPageFrame extends LinearLayout {
|
||||
info.setCheckable(true);
|
||||
info.setChecked(isSelected());
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected, boolean animate) {
|
||||
if (isSelected() == selected) {
|
||||
return;
|
||||
}
|
||||
setSelected(selected);
|
||||
if (selected) {
|
||||
if (animate) {
|
||||
animate().translationZ(mSelectedElevation)
|
||||
.alpha(mSelectedPageAlpha);
|
||||
} else {
|
||||
setTranslationZ(mSelectedElevation);
|
||||
setAlpha(mSelectedPageAlpha);
|
||||
}
|
||||
} else {
|
||||
if (animate) {
|
||||
animate().translationZ(mNotSelectedElevation)
|
||||
.alpha(mNotSelectedAlpha);
|
||||
} else {
|
||||
setTranslationZ(mNotSelectedElevation);
|
||||
setAlpha(mNotSelectedAlpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||