Coalescing multiple print job notifications (Settings)

We used to show a single notificaiton for every print job but
this is against th UX guidelines. Since we have to lead by
example, this change adds coalescing of multiple notifications.

bug:11155212

Change-Id: I865450495e7e85bd6620c1f42aeef07d2f83a01a
This commit is contained in:
Svetoslav
2013-10-09 21:59:04 -07:00
committed by Svetoslav Ganov
parent 16ad57483d
commit d9f156ddf0
4 changed files with 27 additions and 31 deletions

View File

@@ -1165,6 +1165,21 @@
android:resource="@id/print_settings" /> android:resource="@id/print_settings" />
</activity> </activity>
<activity android:name="Settings$PrintJobSettingsActivity"
android:label="@string/print_print_job"
android:taskAffinity="com.android.settings"
android:parentActivityName="Settings$PrintSettingsActivity">
<intent-filter>
<action android:name="android.settings.ACTION_PRINT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="printjob" android:pathPattern="*" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.print.PrintJobSettingsFragment" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/print_settings" />
</activity>
<!-- Keep compatibility with old shortcuts. --> <!-- Keep compatibility with old shortcuts. -->
<activity-alias android:name="DevelopmentSettings" <activity-alias android:name="DevelopmentSettings"
android:exported="true" android:exported="true"

View File

@@ -81,6 +81,7 @@ import com.android.settings.inputmethod.UserDictionaryList;
import com.android.settings.location.LocationSettings; import com.android.settings.location.LocationSettings;
import com.android.settings.nfc.AndroidBeam; import com.android.settings.nfc.AndroidBeam;
import com.android.settings.nfc.PaymentSettings; import com.android.settings.nfc.PaymentSettings;
import com.android.settings.print.PrintJobSettingsFragment;
import com.android.settings.print.PrintServiceSettingsFragment; import com.android.settings.print.PrintServiceSettingsFragment;
import com.android.settings.print.PrintSettingsFragment; import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.tts.TextToSpeechSettings; import com.android.settings.tts.TextToSpeechSettings;
@@ -347,6 +348,7 @@ public class Settings extends PreferenceActivity
NotificationAccessSettings.class.getName(), NotificationAccessSettings.class.getName(),
ManageAccountsSettings.class.getName(), ManageAccountsSettings.class.getName(),
PrintSettingsFragment.class.getName(), PrintSettingsFragment.class.getName(),
PrintJobSettingsFragment.class.getName(),
TrustedCredentialsSettings.class.getName(), TrustedCredentialsSettings.class.getName(),
PaymentSettings.class.getName(), PaymentSettings.class.getName(),
KeyboardLayoutPickerFragment.class.getName() KeyboardLayoutPickerFragment.class.getName()
@@ -1108,4 +1110,5 @@ public class Settings extends PreferenceActivity
public static class TrustedCredentialsSettingsActivity extends Settings { /* empty */ } public static class TrustedCredentialsSettingsActivity extends Settings { /* empty */ }
public static class PaymentSettingsActivity extends Settings { /* empty */ } public static class PaymentSettingsActivity extends Settings { /* empty */ }
public static class PrintSettingsActivity extends Settings { /* empty */ } public static class PrintSettingsActivity extends Settings { /* empty */ }
public static class PrintJobSettingsActivity extends Settings { /* empty */ }
} }

View File

@@ -19,6 +19,7 @@ package com.android.settings.print;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.print.PrintJob; import android.print.PrintJob;
@@ -45,6 +46,8 @@ public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
private static final int MENU_ITEM_ID_CANCEL = 1; private static final int MENU_ITEM_ID_CANCEL = 1;
private static final int MENU_ITEM_ID_RESTART = 2; private static final int MENU_ITEM_ID_RESTART = 2;
private static final String EXTRA_PRINT_JOB_ID = "EXTRA_PRINT_JOB_ID";
private static final String PRINT_JOB_PREFERENCE = "print_job_preference"; private static final String PRINT_JOB_PREFERENCE = "print_job_preference";
private static final String PRINT_JOB_MESSAGE_PREFERENCE = "print_job_message_preference"; private static final String PRINT_JOB_MESSAGE_PREFERENCE = "print_job_message_preference";
@@ -53,7 +56,7 @@ public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
private final PrintJobStateChangeListener mPrintJobStateChangeListener = private final PrintJobStateChangeListener mPrintJobStateChangeListener =
new PrintJobStateChangeListener() { new PrintJobStateChangeListener() {
@Override @Override
public void onPrintJobsStateChanged(PrintJobId printJobId) { public void onPrintJobStateChanged(PrintJobId printJobId) {
updateUi(); updateUi();
} }
}; };
@@ -141,8 +144,8 @@ public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
} }
private void processArguments() { private void processArguments() {
mPrintJobId = (PrintJobId) getArguments().getParcelable( String printJobId = getArguments().getString(EXTRA_PRINT_JOB_ID);
PrintSettingsFragment.EXTRA_PRINT_JOB_ID); mPrintJobId = PrintJobId.unflattenFromString(printJobId);
if (mPrintJobId == null) { if (mPrintJobId == null) {
finish(); finish();
} }

View File

@@ -112,8 +112,6 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment implements
private PrintJobsController mPrintJobsController; private PrintJobsController mPrintJobsController;
private String mPrintJobPreferenceToActivate;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@@ -268,19 +266,6 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment implements
if (prereference != null) { if (prereference != null) {
prereference.performClick(getPreferenceScreen()); prereference.performClick(getPreferenceScreen());
} }
} else {
String printJobId = getArguments().getString(EXTRA_PRINT_JOB_ID);
if (printJobId != null) {
getArguments().remove(EXTRA_PRINT_JOB_ID);
Preference preference = findPreference(printJobId);
if (preference != null) {
preference.performClick(getPreferenceScreen());
} else {
// The preference not being present may mean the the print job
// loader has not completed so make a note and wait for the load.
mPrintJobPreferenceToActivate = printJobId;
}
}
} }
} }
@@ -427,20 +412,10 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment implements
} }
Bundle extras = preference.getExtras(); Bundle extras = preference.getExtras();
extras.putParcelable(EXTRA_PRINT_JOB_ID, printJob.getId()); extras.putString(EXTRA_PRINT_JOB_ID, printJob.getId().flattenToString());
mActivePrintJobsCategory.addPreference(preference); mActivePrintJobsCategory.addPreference(preference);
} }
// If were waiting for creating a preference for a print
// job so we can start it - do that.
if (mPrintJobPreferenceToActivate != null) {
Preference preference = findPreference(mPrintJobPreferenceToActivate);
mPrintJobPreferenceToActivate = null;
if (preference != null) {
preference.performClick(getPreferenceScreen());
}
}
} }
} }
@@ -454,7 +429,7 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment implements
private static final String LOG_TAG = "PrintJobsLoader"; private static final String LOG_TAG = "PrintJobsLoader";
private static final boolean DEBUG = true; private static final boolean DEBUG = false;
private List <PrintJobInfo> mPrintJobs = new ArrayList<PrintJobInfo>(); private List <PrintJobInfo> mPrintJobs = new ArrayList<PrintJobInfo>();
@@ -489,7 +464,7 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment implements
if (mPrintJobStateChangeListener == null) { if (mPrintJobStateChangeListener == null) {
mPrintJobStateChangeListener = new PrintJobStateChangeListener() { mPrintJobStateChangeListener = new PrintJobStateChangeListener() {
@Override @Override
public void onPrintJobsStateChanged(PrintJobId printJobId) { public void onPrintJobStateChanged(PrintJobId printJobId) {
onForceLoad(); onForceLoad();
} }
}; };