Loading packages/PrintSpooler/res/layout/printer_list_item.xml 0 → 100644 +71 −0 Original line number Original line Diff line number Diff line <?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> packages/PrintSpooler/res/layout/select_printer_fragment.xml 0 → 100644 +26 −0 Original line number Original line Diff line number Diff line <?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> packages/PrintSpooler/res/values-land/constants.xml 0 → 100644 +22 −0 Original line number Original line Diff line number Diff line <?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> packages/PrintSpooler/res/values/constants.xml +4 −1 Original line number Original line Diff line number Diff line Loading @@ -26,4 +26,7 @@ <dimen name="print_dialog_frame_max_width_dip">400dip</dimen> <dimen name="print_dialog_frame_max_width_dip">400dip</dimen> <dimen name="printer_list_view_padding_start">16dip</dimen> <dimen name="printer_list_view_padding_end">16dip</dimen> </resources> </resources> packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java +36 −25 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.Dialog; import android.app.DialogFragment; import android.app.DialogFragment; import android.app.Fragment; import android.app.Fragment; import android.app.FragmentTransaction; import android.app.FragmentTransaction; import android.app.ListFragment; import android.app.LoaderManager; import android.app.LoaderManager; import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.ComponentName; Loading @@ -47,12 +46,14 @@ import android.printservice.PrintServiceInfo; import android.provider.Settings; import android.provider.Settings; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuInflater; import android.view.MenuItem; import android.view.MenuItem; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.BaseAdapter; import android.widget.Filter; import android.widget.Filter; Loading @@ -68,7 +69,7 @@ import java.util.List; /** /** * This is a fragment for selecting a printer. * 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"; private static final String LOG_TAG = "SelectPrinterFragment"; Loading @@ -83,6 +84,8 @@ public final class SelectPrinterFragment extends ListFragment { private final ArrayList<PrintServiceInfo> mAddPrinterServices = private final ArrayList<PrintServiceInfo> mAddPrinterServices = new ArrayList<PrintServiceInfo>(); new ArrayList<PrintServiceInfo>(); private ListView mListView; private AnnounceFilterResult mAnnounceFilterResult; private AnnounceFilterResult mAnnounceFilterResult; public static interface OnPrinterSelectedListener { public static interface OnPrinterSelectedListener { Loading @@ -97,8 +100,12 @@ public final class SelectPrinterFragment extends ListFragment { } } @Override @Override public void onActivityCreated(Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, super.onActivityCreated(savedInstanceState); 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(); final DestinationAdapter adapter = new DestinationAdapter(); adapter.registerDataSetObserver(new DataSetObserver() { adapter.registerDataSetObserver(new DataSetObserver() { @Override @Override Loading @@ -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 @Override Loading @@ -133,7 +156,7 @@ public final class SelectPrinterFragment extends ListFragment { @Override @Override public boolean onQueryTextChange(String searchString) { public boolean onQueryTextChange(String searchString) { ((DestinationAdapter) getListAdapter()).getFilter().filter(searchString); ((DestinationAdapter) mListView.getAdapter()).getFilter().filter(searchString); return true; return true; } } }); }); Loading Loading @@ -176,18 +199,6 @@ public final class SelectPrinterFragment extends ListFragment { super.onPause(); super.onPause(); } } @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 @Override public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_add_printer) { if (item.getItemId() == R.id.action_add_printer) { Loading Loading @@ -260,9 +271,9 @@ public final class SelectPrinterFragment extends ListFragment { } } public void updateEmptyView(DestinationAdapter adapter) { public void updateEmptyView(DestinationAdapter adapter) { if (getListView().getEmptyView() == null) { if (mListView.getEmptyView() == null) { View emptyView = getActivity().findViewById(R.id.empty_print_state); View emptyView = getActivity().findViewById(R.id.empty_print_state); getListView().setEmptyView(emptyView); mListView.setEmptyView(emptyView); } } TextView titleView = (TextView) getActivity().findViewById(R.id.title); TextView titleView = (TextView) getActivity().findViewById(R.id.title); View progressBar = getActivity().findViewById(R.id.progress_bar); View progressBar = getActivity().findViewById(R.id.progress_bar); Loading Loading @@ -450,7 +461,7 @@ public final class SelectPrinterFragment extends ListFragment { public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { if (convertView == null) { convertView = getActivity().getLayoutInflater().inflate( convertView = getActivity().getLayoutInflater().inflate( R.layout.printer_dropdown_item, parent, false); R.layout.printer_list_item, parent, false); } } convertView.setEnabled(isEnabled(position)); convertView.setEnabled(isEnabled(position)); Loading Loading @@ -539,16 +550,16 @@ public final class SelectPrinterFragment extends ListFragment { public void post() { public void post() { remove(); remove(); getListView().postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY); mListView.postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY); } } public void remove() { public void remove() { getListView().removeCallbacks(this); mListView.removeCallbacks(this); } } @Override @Override public void run() { public void run() { final int count = getListView().getAdapter().getCount(); final int count = mListView.getAdapter().getCount(); final String text; final String text; if (count <= 0) { if (count <= 0) { text = getString(R.string.print_no_printers); text = getString(R.string.print_no_printers); Loading @@ -556,7 +567,7 @@ public final class SelectPrinterFragment extends ListFragment { text = getActivity().getResources().getQuantityString( text = getActivity().getResources().getQuantityString( R.plurals.print_search_result_count_utterance, count, count); R.plurals.print_search_result_count_utterance, count, count); } } getListView().announceForAccessibility(text); mListView.announceForAccessibility(text); } } } } } } Loading
packages/PrintSpooler/res/layout/printer_list_item.xml 0 → 100644 +71 −0 Original line number Original line Diff line number Diff line <?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>
packages/PrintSpooler/res/layout/select_printer_fragment.xml 0 → 100644 +26 −0 Original line number Original line Diff line number Diff line <?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>
packages/PrintSpooler/res/values-land/constants.xml 0 → 100644 +22 −0 Original line number Original line Diff line number Diff line <?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>
packages/PrintSpooler/res/values/constants.xml +4 −1 Original line number Original line Diff line number Diff line Loading @@ -26,4 +26,7 @@ <dimen name="print_dialog_frame_max_width_dip">400dip</dimen> <dimen name="print_dialog_frame_max_width_dip">400dip</dimen> <dimen name="printer_list_view_padding_start">16dip</dimen> <dimen name="printer_list_view_padding_end">16dip</dimen> </resources> </resources>
packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java +36 −25 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.Dialog; import android.app.DialogFragment; import android.app.DialogFragment; import android.app.Fragment; import android.app.Fragment; import android.app.FragmentTransaction; import android.app.FragmentTransaction; import android.app.ListFragment; import android.app.LoaderManager; import android.app.LoaderManager; import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.ComponentName; Loading @@ -47,12 +46,14 @@ import android.printservice.PrintServiceInfo; import android.provider.Settings; import android.provider.Settings; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuInflater; import android.view.MenuItem; import android.view.MenuItem; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.BaseAdapter; import android.widget.Filter; import android.widget.Filter; Loading @@ -68,7 +69,7 @@ import java.util.List; /** /** * This is a fragment for selecting a printer. * 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"; private static final String LOG_TAG = "SelectPrinterFragment"; Loading @@ -83,6 +84,8 @@ public final class SelectPrinterFragment extends ListFragment { private final ArrayList<PrintServiceInfo> mAddPrinterServices = private final ArrayList<PrintServiceInfo> mAddPrinterServices = new ArrayList<PrintServiceInfo>(); new ArrayList<PrintServiceInfo>(); private ListView mListView; private AnnounceFilterResult mAnnounceFilterResult; private AnnounceFilterResult mAnnounceFilterResult; public static interface OnPrinterSelectedListener { public static interface OnPrinterSelectedListener { Loading @@ -97,8 +100,12 @@ public final class SelectPrinterFragment extends ListFragment { } } @Override @Override public void onActivityCreated(Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, super.onActivityCreated(savedInstanceState); 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(); final DestinationAdapter adapter = new DestinationAdapter(); adapter.registerDataSetObserver(new DataSetObserver() { adapter.registerDataSetObserver(new DataSetObserver() { @Override @Override Loading @@ -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 @Override Loading @@ -133,7 +156,7 @@ public final class SelectPrinterFragment extends ListFragment { @Override @Override public boolean onQueryTextChange(String searchString) { public boolean onQueryTextChange(String searchString) { ((DestinationAdapter) getListAdapter()).getFilter().filter(searchString); ((DestinationAdapter) mListView.getAdapter()).getFilter().filter(searchString); return true; return true; } } }); }); Loading Loading @@ -176,18 +199,6 @@ public final class SelectPrinterFragment extends ListFragment { super.onPause(); super.onPause(); } } @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 @Override public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_add_printer) { if (item.getItemId() == R.id.action_add_printer) { Loading Loading @@ -260,9 +271,9 @@ public final class SelectPrinterFragment extends ListFragment { } } public void updateEmptyView(DestinationAdapter adapter) { public void updateEmptyView(DestinationAdapter adapter) { if (getListView().getEmptyView() == null) { if (mListView.getEmptyView() == null) { View emptyView = getActivity().findViewById(R.id.empty_print_state); View emptyView = getActivity().findViewById(R.id.empty_print_state); getListView().setEmptyView(emptyView); mListView.setEmptyView(emptyView); } } TextView titleView = (TextView) getActivity().findViewById(R.id.title); TextView titleView = (TextView) getActivity().findViewById(R.id.title); View progressBar = getActivity().findViewById(R.id.progress_bar); View progressBar = getActivity().findViewById(R.id.progress_bar); Loading Loading @@ -450,7 +461,7 @@ public final class SelectPrinterFragment extends ListFragment { public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { if (convertView == null) { convertView = getActivity().getLayoutInflater().inflate( convertView = getActivity().getLayoutInflater().inflate( R.layout.printer_dropdown_item, parent, false); R.layout.printer_list_item, parent, false); } } convertView.setEnabled(isEnabled(position)); convertView.setEnabled(isEnabled(position)); Loading Loading @@ -539,16 +550,16 @@ public final class SelectPrinterFragment extends ListFragment { public void post() { public void post() { remove(); remove(); getListView().postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY); mListView.postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY); } } public void remove() { public void remove() { getListView().removeCallbacks(this); mListView.removeCallbacks(this); } } @Override @Override public void run() { public void run() { final int count = getListView().getAdapter().getCount(); final int count = mListView.getAdapter().getCount(); final String text; final String text; if (count <= 0) { if (count <= 0) { text = getString(R.string.print_no_printers); text = getString(R.string.print_no_printers); Loading @@ -556,7 +567,7 @@ public final class SelectPrinterFragment extends ListFragment { text = getActivity().getResources().getQuantityString( text = getActivity().getResources().getQuantityString( R.plurals.print_search_result_count_utterance, count, count); R.plurals.print_search_result_count_utterance, count, count); } } getListView().announceForAccessibility(text); mListView.announceForAccessibility(text); } } } } } }