Use new getIcon and getMoreInfo api to show more information in Print
Settings Also fix some text color of the printer list. Bug: 24135005 Change-Id: I3c387e1277b2a7f09574d42cfe29cc03dd8ef8d5
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:fadingEdge="horizontal"
|
android:fadingEdge="horizontal"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textIsSelectable="false">
|
android:textIsSelectable="false">
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
|
@@ -22,9 +22,8 @@ import android.content.ComponentName;
|
|||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentSender.SendIntentException;
|
||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.DataSetObserver;
|
import android.database.DataSetObserver;
|
||||||
@@ -47,6 +46,7 @@ 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.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
@@ -74,6 +74,8 @@ import java.util.Map;
|
|||||||
public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
||||||
implements SwitchBar.OnSwitchChangeListener {
|
implements SwitchBar.OnSwitchChangeListener {
|
||||||
|
|
||||||
|
private static final String LOG_TAG = "PrintServiceSettingsFragment";
|
||||||
|
|
||||||
private static final int LOADER_ID_PRINTERS_LOADER = 1;
|
private static final int LOADER_ID_PRINTERS_LOADER = 1;
|
||||||
|
|
||||||
private final SettingsContentObserver mSettingsContentObserver =
|
private final SettingsContentObserver mSettingsContentObserver =
|
||||||
@@ -150,6 +152,7 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
mSettingsContentObserver.register(getContentResolver());
|
mSettingsContentObserver.register(getContentResolver());
|
||||||
|
|
||||||
updateEmptyView();
|
updateEmptyView();
|
||||||
updateUiForServiceState();
|
updateUiForServiceState();
|
||||||
}
|
}
|
||||||
@@ -283,6 +286,21 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
getBackupListView().setSelector(new ColorDrawable(Color.TRANSPARENT));
|
getBackupListView().setSelector(new ColorDrawable(Color.TRANSPARENT));
|
||||||
getBackupListView().setAdapter(mPrintersAdapter);
|
getBackupListView().setAdapter(mPrintersAdapter);
|
||||||
|
getBackupListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
PrinterInfo printer = (PrinterInfo) mPrintersAdapter.getItem(position);
|
||||||
|
|
||||||
|
if (printer.getInfoIntent() != null) {
|
||||||
|
try {
|
||||||
|
getActivity().startIntentSender(printer.getInfoIntent().getIntentSender(),
|
||||||
|
null, 0, 0, 0);
|
||||||
|
} catch (SendIntentException e) {
|
||||||
|
Log.e(LOG_TAG, "Could not execute info intent: %s", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -518,16 +536,8 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
PrinterInfo printer = (PrinterInfo) getItem(position);
|
PrinterInfo printer = (PrinterInfo) getItem(position);
|
||||||
CharSequence title = printer.getName();
|
CharSequence title = printer.getName();
|
||||||
CharSequence subtitle = null;
|
CharSequence subtitle = printer.getDescription();
|
||||||
Drawable icon = null;
|
Drawable icon = printer.loadIcon(getActivity());
|
||||||
try {
|
|
||||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(
|
|
||||||
printer.getId().getServiceName().getPackageName(), 0);
|
|
||||||
subtitle = packageInfo.applicationInfo.loadLabel(getPackageManager());
|
|
||||||
icon = packageInfo.applicationInfo.loadIcon(getPackageManager());
|
|
||||||
} catch (NameNotFoundException nnfe) {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView titleView = (TextView) convertView.findViewById(R.id.title);
|
TextView titleView = (TextView) convertView.findViewById(R.id.title);
|
||||||
titleView.setText(title);
|
titleView.setText(title);
|
||||||
@@ -552,11 +562,6 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled(int position) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<List<PrinterInfo>> onCreateLoader(int id, Bundle args) {
|
public Loader<List<PrinterInfo>> onCreateLoader(int id, Bundle args) {
|
||||||
if (id == LOADER_ID_PRINTERS_LOADER) {
|
if (id == LOADER_ID_PRINTERS_LOADER) {
|
||||||
|
Reference in New Issue
Block a user