use of android.print.PrintJob in project android_packages_apps_Settings by SudaMod.
the class PrintJobSettingsFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
PrintJob printJob = getPrintJob();
if (printJob == null) {
return;
}
if (!printJob.getInfo().isCancelling()) {
MenuItem cancel = menu.add(0, MENU_ITEM_ID_CANCEL, Menu.NONE, getString(R.string.print_cancel));
cancel.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
if (printJob.isFailed()) {
MenuItem restart = menu.add(0, MENU_ITEM_ID_RESTART, Menu.NONE, getString(R.string.print_restart));
restart.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
}
use of android.print.PrintJob in project android_packages_apps_Settings by SudaMod.
the class PrintJobSettingsFragment method updateUi.
private void updateUi() {
PrintJob printJob = getPrintJob();
if (printJob == null) {
finish();
return;
}
if (printJob.isCancelled() || printJob.isCompleted()) {
finish();
return;
}
PrintJobInfo info = printJob.getInfo();
switch(info.getState()) {
case PrintJobInfo.STATE_QUEUED:
case PrintJobInfo.STATE_STARTED:
{
if (!printJob.getInfo().isCancelling()) {
mPrintJobPreference.setTitle(getString(R.string.print_printing_state_title_template, info.getLabel()));
} else {
mPrintJobPreference.setTitle(getString(R.string.print_cancelling_state_title_template, info.getLabel()));
}
}
break;
case PrintJobInfo.STATE_FAILED:
{
mPrintJobPreference.setTitle(getString(R.string.print_failed_state_title_template, info.getLabel()));
}
break;
case PrintJobInfo.STATE_BLOCKED:
{
if (!printJob.getInfo().isCancelling()) {
mPrintJobPreference.setTitle(getString(R.string.print_blocked_state_title_template, info.getLabel()));
} else {
mPrintJobPreference.setTitle(getString(R.string.print_cancelling_state_title_template, info.getLabel()));
}
}
break;
}
mPrintJobPreference.setSummary(getString(R.string.print_job_summary, info.getPrinterName(), DateUtils.formatSameDayTime(info.getCreationTime(), info.getCreationTime(), DateFormat.SHORT, DateFormat.SHORT)));
switch(info.getState()) {
case PrintJobInfo.STATE_QUEUED:
case PrintJobInfo.STATE_STARTED:
{
mPrintJobPreference.setIcon(R.drawable.ic_print);
}
break;
case PrintJobInfo.STATE_FAILED:
case PrintJobInfo.STATE_BLOCKED:
{
mPrintJobPreference.setIcon(R.drawable.ic_print_error);
}
break;
}
CharSequence status = info.getStatus(getPackageManager());
if (!TextUtils.isEmpty(status)) {
if (getPreferenceScreen().findPreference(PRINT_JOB_MESSAGE_PREFERENCE) == null) {
getPreferenceScreen().addPreference(mMessagePreference);
}
mMessagePreference.setSummary(status);
} else {
getPreferenceScreen().removePreference(mMessagePreference);
}
getActivity().invalidateOptionsMenu();
}
use of android.print.PrintJob in project android_packages_apps_Settings by DirtyUnicorns.
the class PrintJobSettingsFragment method updateUi.
private void updateUi() {
PrintJob printJob = getPrintJob();
if (printJob == null) {
finish();
return;
}
if (printJob.isCancelled() || printJob.isCompleted()) {
finish();
return;
}
PrintJobInfo info = printJob.getInfo();
switch(info.getState()) {
case PrintJobInfo.STATE_QUEUED:
case PrintJobInfo.STATE_STARTED:
{
if (!printJob.getInfo().isCancelling()) {
mPrintJobPreference.setTitle(getString(R.string.print_printing_state_title_template, info.getLabel()));
} else {
mPrintJobPreference.setTitle(getString(R.string.print_cancelling_state_title_template, info.getLabel()));
}
}
break;
case PrintJobInfo.STATE_FAILED:
{
mPrintJobPreference.setTitle(getString(R.string.print_failed_state_title_template, info.getLabel()));
}
break;
case PrintJobInfo.STATE_BLOCKED:
{
if (!printJob.getInfo().isCancelling()) {
mPrintJobPreference.setTitle(getString(R.string.print_blocked_state_title_template, info.getLabel()));
} else {
mPrintJobPreference.setTitle(getString(R.string.print_cancelling_state_title_template, info.getLabel()));
}
}
break;
}
mPrintJobPreference.setSummary(getString(R.string.print_job_summary, info.getPrinterName(), DateUtils.formatSameDayTime(info.getCreationTime(), info.getCreationTime(), DateFormat.SHORT, DateFormat.SHORT)));
switch(info.getState()) {
case PrintJobInfo.STATE_QUEUED:
case PrintJobInfo.STATE_STARTED:
{
mPrintJobPreference.setIcon(R.drawable.ic_print);
}
break;
case PrintJobInfo.STATE_FAILED:
case PrintJobInfo.STATE_BLOCKED:
{
mPrintJobPreference.setIcon(R.drawable.ic_print_error);
}
break;
}
CharSequence status = info.getStatus(getPackageManager());
if (!TextUtils.isEmpty(status)) {
if (getPreferenceScreen().findPreference(PRINT_JOB_MESSAGE_PREFERENCE) == null) {
getPreferenceScreen().addPreference(mMessagePreference);
}
mMessagePreference.setSummary(status);
} else {
getPreferenceScreen().removePreference(mMessagePreference);
}
getActivity().invalidateOptionsMenu();
}
use of android.print.PrintJob in project Osmand by osmandapp.
the class PrintDialogActivity method createWebPrintJob.
@SuppressLint("NewApi")
private void createWebPrintJob(WebView webView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
String jobName = "OsmAnd route info";
PrintJob printJob = printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
printJobId = printJob.getId();
}
}
use of android.print.PrintJob in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PrintJobPreferenceController method updateUi.
@Override
protected void updateUi() {
final PrintJob printJob = getPrintJob();
if (printJob == null) {
mFragment.finish();
return;
}
if (printJob.isCancelled() || printJob.isCompleted()) {
mFragment.finish();
return;
}
PrintJobInfo info = printJob.getInfo();
switch(info.getState()) {
case PrintJobInfo.STATE_CREATED:
{
mPreference.setTitle(mContext.getString(R.string.print_configuring_state_title_template, info.getLabel()));
}
break;
case PrintJobInfo.STATE_QUEUED:
case PrintJobInfo.STATE_STARTED:
{
if (!printJob.getInfo().isCancelling()) {
mPreference.setTitle(mContext.getString(R.string.print_printing_state_title_template, info.getLabel()));
} else {
mPreference.setTitle(mContext.getString(R.string.print_cancelling_state_title_template, info.getLabel()));
}
}
break;
case PrintJobInfo.STATE_FAILED:
{
mPreference.setTitle(mContext.getString(R.string.print_failed_state_title_template, info.getLabel()));
}
break;
case PrintJobInfo.STATE_BLOCKED:
{
if (!printJob.getInfo().isCancelling()) {
mPreference.setTitle(mContext.getString(R.string.print_blocked_state_title_template, info.getLabel()));
} else {
mPreference.setTitle(mContext.getString(R.string.print_cancelling_state_title_template, info.getLabel()));
}
}
break;
}
mPreference.setSummary(mContext.getString(R.string.print_job_summary, info.getPrinterName(), DateUtils.formatSameDayTime(info.getCreationTime(), info.getCreationTime(), DateFormat.SHORT, DateFormat.SHORT)));
TypedArray a = mContext.obtainStyledAttributes(new int[] { android.R.attr.colorControlNormal });
int tintColor = a.getColor(0, 0);
a.recycle();
switch(info.getState()) {
case PrintJobInfo.STATE_QUEUED:
case PrintJobInfo.STATE_STARTED:
{
Drawable icon = mContext.getDrawable(com.android.internal.R.drawable.ic_print);
icon.setTint(tintColor);
mPreference.setIcon(icon);
break;
}
case PrintJobInfo.STATE_FAILED:
case PrintJobInfo.STATE_BLOCKED:
{
Drawable icon = mContext.getDrawable(com.android.internal.R.drawable.ic_print_error);
icon.setTint(tintColor);
mPreference.setIcon(icon);
break;
}
}
}
Aggregations