summaryrefslogtreecommitdiffstats
path: root/packages/PrintSpooler
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2013-10-17 11:11:35 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-17 11:11:35 -0700
commita225bbddeccff76b92f18e620df0a8b773d4befd (patch)
tree166a4580203de1658732cd7c40515117a89fe912 /packages/PrintSpooler
parent11c746abf3793cf122a353dbee1d73e2eddbfb82 (diff)
parent54e5575924d3abba8129268d2d0553efc9a841eb (diff)
downloadframeworks_base-a225bbddeccff76b92f18e620df0a8b773d4befd.zip
frameworks_base-a225bbddeccff76b92f18e620df0a8b773d4befd.tar.gz
frameworks_base-a225bbddeccff76b92f18e620df0a8b773d4befd.tar.bz2
am 54e55759: Merge "All printers list has incorrect padding and item height." into klp-dev
* commit '54e5575924d3abba8129268d2d0553efc9a841eb': All printers list has incorrect padding and item height.
Diffstat (limited to 'packages/PrintSpooler')
-rw-r--r--packages/PrintSpooler/res/layout/printer_list_item.xml71
-rw-r--r--packages/PrintSpooler/res/layout/select_printer_fragment.xml26
-rw-r--r--packages/PrintSpooler/res/values-land/constants.xml22
-rw-r--r--packages/PrintSpooler/res/values/constants.xml5
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java61
5 files changed, 159 insertions, 26 deletions
diff --git a/packages/PrintSpooler/res/layout/printer_list_item.xml b/packages/PrintSpooler/res/layout/printer_list_item.xml
new file mode 100644
index 0000000..47eb0b5
--- /dev/null
+++ b/packages/PrintSpooler/res/layout/printer_list_item.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:orientation="horizontal"
+ android:gravity="start|center_vertical">
+
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="32dip"
+ android:layout_height="32dip"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="8dip"
+ android:duplicateParentState="true"
+ android:contentDescription="@null"
+ android:visibility="gone">
+ </ImageView>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:duplicateParentState="true">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:textIsSelectable="false"
+ android:gravity="top|start"
+ android:textColor="@color/item_text_color"
+ android:duplicateParentState="true">
+ </TextView>
+
+ <TextView
+ android:id="@+id/subtitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:textIsSelectable="false"
+ android:visibility="gone"
+ android:textColor="@color/print_option_title"
+ android:duplicateParentState="true">
+ </TextView>
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/packages/PrintSpooler/res/layout/select_printer_fragment.xml b/packages/PrintSpooler/res/layout/select_printer_fragment.xml
new file mode 100644
index 0000000..bbd012e
--- /dev/null
+++ b/packages/PrintSpooler/res/layout/select_printer_fragment.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<ListView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/list"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:paddingStart="@dimen/printer_list_view_padding_start"
+ android:paddingEnd="@dimen/printer_list_view_padding_end"
+ android:scrollbarStyle="outsideOverlay"
+ android:cacheColorHint="@android:color/transparent"
+ android:scrollbarAlwaysDrawVerticalTrack="true" >
+</ListView>
diff --git a/packages/PrintSpooler/res/values-land/constants.xml b/packages/PrintSpooler/res/values-land/constants.xml
new file mode 100644
index 0000000..d68b77e
--- /dev/null
+++ b/packages/PrintSpooler/res/values-land/constants.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<resources>
+
+ <dimen name="printer_list_view_padding_start">48dip</dimen>
+ <dimen name="printer_list_view_padding_end">48dip</dimen>
+
+</resources>
diff --git a/packages/PrintSpooler/res/values/constants.xml b/packages/PrintSpooler/res/values/constants.xml
index e5a9d5d..e9c925c 100644
--- a/packages/PrintSpooler/res/values/constants.xml
+++ b/packages/PrintSpooler/res/values/constants.xml
@@ -26,4 +26,7 @@
<dimen name="print_dialog_frame_max_width_dip">400dip</dimen>
-</resources> \ No newline at end of file
+ <dimen name="printer_list_view_padding_start">16dip</dimen>
+ <dimen name="printer_list_view_padding_end">16dip</dimen>
+
+</resources>
diff --git a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java
index be94ba4..204c152 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java
@@ -22,7 +22,6 @@ import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
-import android.app.ListFragment;
import android.app.LoaderManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
@@ -47,12 +46,14 @@ import android.printservice.PrintServiceInfo;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
+import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Filter;
@@ -68,7 +69,7 @@ import java.util.List;
/**
* This is a fragment for selecting a printer.
*/
-public final class SelectPrinterFragment extends ListFragment {
+public final class SelectPrinterFragment extends Fragment {
private static final String LOG_TAG = "SelectPrinterFragment";
@@ -83,6 +84,8 @@ public final class SelectPrinterFragment extends ListFragment {
private final ArrayList<PrintServiceInfo> mAddPrinterServices =
new ArrayList<PrintServiceInfo>();
+ private ListView mListView;
+
private AnnounceFilterResult mAnnounceFilterResult;
public static interface OnPrinterSelectedListener {
@@ -97,8 +100,12 @@ public final class SelectPrinterFragment extends ListFragment {
}
@Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View content = inflater.inflate(R.layout.select_printer_fragment, container, false);
+
+ // Hook up the list view.
+ mListView = (ListView) content.findViewById(android.R.id.list);
final DestinationAdapter adapter = new DestinationAdapter();
adapter.registerDataSetObserver(new DataSetObserver() {
@Override
@@ -115,7 +122,23 @@ public final class SelectPrinterFragment extends ListFragment {
}
}
});
- setListAdapter(adapter);
+ mListView.setAdapter(adapter);
+
+ mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ PrinterInfo printer = (PrinterInfo) mListView.getAdapter().getItem(position);
+ Activity activity = getActivity();
+ if (activity instanceof OnPrinterSelectedListener) {
+ ((OnPrinterSelectedListener) activity).onPrinterSelected(printer.getId());
+ } else {
+ throw new IllegalStateException("the host activity must implement"
+ + " OnPrinterSelectedListener");
+ }
+ }
+ });
+
+ return content;
}
@Override
@@ -133,7 +156,7 @@ public final class SelectPrinterFragment extends ListFragment {
@Override
public boolean onQueryTextChange(String searchString) {
- ((DestinationAdapter) getListAdapter()).getFilter().filter(searchString);
+ ((DestinationAdapter) mListView.getAdapter()).getFilter().filter(searchString);
return true;
}
});
@@ -177,18 +200,6 @@ public final class SelectPrinterFragment extends ListFragment {
}
@Override
- public void onListItemClick(ListView list, View view, int position, long id) {
- PrinterInfo printer = (PrinterInfo) list.getAdapter().getItem(position);
- Activity activity = getActivity();
- if (activity instanceof OnPrinterSelectedListener) {
- ((OnPrinterSelectedListener) activity).onPrinterSelected(printer.getId());
- } else {
- throw new IllegalStateException("the host activity must implement"
- + " OnPrinterSelectedListener");
- }
- }
-
- @Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_add_printer) {
showAddPrinterSelectionDialog();
@@ -260,9 +271,9 @@ public final class SelectPrinterFragment extends ListFragment {
}
public void updateEmptyView(DestinationAdapter adapter) {
- if (getListView().getEmptyView() == null) {
+ if (mListView.getEmptyView() == null) {
View emptyView = getActivity().findViewById(R.id.empty_print_state);
- getListView().setEmptyView(emptyView);
+ mListView.setEmptyView(emptyView);
}
TextView titleView = (TextView) getActivity().findViewById(R.id.title);
View progressBar = getActivity().findViewById(R.id.progress_bar);
@@ -450,7 +461,7 @@ public final class SelectPrinterFragment extends ListFragment {
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getActivity().getLayoutInflater().inflate(
- R.layout.printer_dropdown_item, parent, false);
+ R.layout.printer_list_item, parent, false);
}
convertView.setEnabled(isEnabled(position));
@@ -539,16 +550,16 @@ public final class SelectPrinterFragment extends ListFragment {
public void post() {
remove();
- getListView().postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY);
+ mListView.postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY);
}
public void remove() {
- getListView().removeCallbacks(this);
+ mListView.removeCallbacks(this);
}
@Override
public void run() {
- final int count = getListView().getAdapter().getCount();
+ final int count = mListView.getAdapter().getCount();
final String text;
if (count <= 0) {
text = getString(R.string.print_no_printers);
@@ -556,7 +567,7 @@ public final class SelectPrinterFragment extends ListFragment {
text = getActivity().getResources().getQuantityString(
R.plurals.print_search_result_count_utterance, count, count);
}
- getListView().announceForAccessibility(text);
+ mListView.announceForAccessibility(text);
}
}
}