am 1b881bcc: Merge "Show appropriate empty state if not printers are found." into klp-dev

* commit '1b881bcc4181c240007a1d6d7a3e224b4f018933':
  Show appropriate empty state if not printers are found.
This commit is contained in:
Svetoslav
2013-10-01 22:21:57 -07:00
committed by Android Git Automerger
3 changed files with 25 additions and 4 deletions

View File

@@ -15,7 +15,7 @@
--> -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/empty_printers_list_service_disabled" android:id="@+id/empty_print_state"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:visibility="gone"> android:visibility="gone">
@@ -28,11 +28,12 @@
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="12dip" android:layout_marginBottom="12dip"
android:src="@drawable/ic_grayedout_printer" android:src="@drawable/ic_grayedout_printer"
android:contentDescription="@string/print_service_disabled"> android:contentDescription="@null">
</ImageView> </ImageView>
<TextView <TextView

View File

@@ -3430,6 +3430,9 @@
<!-- Title for the prompt shown as a placeholder if no print serivices are installed. [CHAR LIMIT=50] --> <!-- Title for the prompt shown as a placeholder if no print serivices are installed. [CHAR LIMIT=50] -->
<string name="print_no_services_installed">No services installed</string> <string name="print_no_services_installed">No services installed</string>
<!-- Title for the prompt shown as a placeholder if no printers are found while searching. [CHAR LIMIT=50] -->
<string name="print_no_printers_found">No printers found</string>
<!-- Title for print menu item to launch a settings activity. [CHAR LIMIT=25] --> <!-- Title for print menu item to launch a settings activity. [CHAR LIMIT=25] -->
<string name="print_menu_item_settings">Settings</string> <string name="print_menu_item_settings">Settings</string>

View File

@@ -95,6 +95,7 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
@Override @Override
public void onChanged() { public void onChanged() {
invalidateOptionsMenuIfNeeded(); invalidateOptionsMenuIfNeeded();
updateEmptyView();
} }
@Override @Override
@@ -227,14 +228,15 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
ViewGroup contentRoot = (ViewGroup) listView.getParent(); ViewGroup contentRoot = (ViewGroup) listView.getParent();
View emptyView = listView.getEmptyView(); View emptyView = listView.getEmptyView();
if (!mToggleSwitch.isChecked()) { if (!mToggleSwitch.isChecked()) {
if (emptyView != null if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
&& emptyView.getId() != R.id.empty_printers_list_service_disabled) {
contentRoot.removeView(emptyView); contentRoot.removeView(emptyView);
emptyView = null; emptyView = null;
} }
if (emptyView == null) { if (emptyView == null) {
emptyView = getActivity().getLayoutInflater().inflate( emptyView = getActivity().getLayoutInflater().inflate(
R.layout.empty_print_state, contentRoot, false); R.layout.empty_print_state, contentRoot, false);
ImageView iconView = (ImageView) emptyView.findViewById(R.id.icon);
iconView.setContentDescription(getString(R.string.print_service_disabled));
TextView textView = (TextView) emptyView.findViewById(R.id.message); TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_service_disabled); textView.setText(R.string.print_service_disabled);
contentRoot.addView(emptyView); contentRoot.addView(emptyView);
@@ -252,6 +254,21 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
contentRoot.addView(emptyView); contentRoot.addView(emptyView);
listView.setEmptyView(emptyView); listView.setEmptyView(emptyView);
} }
} else if (mPrintersAdapter.getCount() <= 0) {
if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
contentRoot.removeView(emptyView);
emptyView = null;
}
if (emptyView == null) {
emptyView = getActivity().getLayoutInflater().inflate(
R.layout.empty_print_state, contentRoot, false);
ImageView iconView = (ImageView) emptyView.findViewById(R.id.icon);
iconView.setContentDescription(getString(R.string.print_no_printers_found));
TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_no_printers_found);
contentRoot.addView(emptyView);
listView.setEmptyView(emptyView);
}
} }
} }