зеркало из https://github.com/mozilla/gecko-dev.git
Bug 976925 - UI after adding a Home Panel from Settings. r=lucasr
This commit is contained in:
Родитель
ad618b75de
Коммит
5335011f33
|
@ -104,7 +104,7 @@ public class HomeConfigInvalidator implements GeckoEventListener {
|
|||
try {
|
||||
if (event.equals(EVENT_HOMEPANELS_INSTALL)) {
|
||||
Log.d(LOGTAG, EVENT_HOMEPANELS_INSTALL);
|
||||
handlePanelInstall(createPanelConfigFromMessage(message));
|
||||
handlePanelInstall(createPanelConfigFromMessage(message), InvalidationMode.DELAYED);
|
||||
} else if (event.equals(EVENT_HOMEPANELS_UNINSTALL)) {
|
||||
Log.d(LOGTAG, EVENT_HOMEPANELS_UNINSTALL);
|
||||
final String panelId = message.getString(JSON_KEY_PANEL_ID);
|
||||
|
@ -126,20 +126,23 @@ public class HomeConfigInvalidator implements GeckoEventListener {
|
|||
/**
|
||||
* Adds a new PanelConfig to the HomeConfig.
|
||||
*
|
||||
* This posts the invalidation of HomeConfig immediately.
|
||||
*
|
||||
* @param panelConfig panel to add
|
||||
*/
|
||||
public void installPanel(PanelConfig panelConfig) {
|
||||
handlePanelInstall(panelConfig);
|
||||
Log.d(LOGTAG, "installPanel: " + panelConfig.getTitle());
|
||||
handlePanelInstall(panelConfig, InvalidationMode.IMMEDIATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs in the gecko thread.
|
||||
*/
|
||||
private void handlePanelInstall(PanelConfig panelConfig) {
|
||||
private void handlePanelInstall(PanelConfig panelConfig, InvalidationMode mode) {
|
||||
mPendingChanges.offer(new ConfigChange(ChangeType.INSTALL, panelConfig));
|
||||
Log.d(LOGTAG, "handlePanelInstall: " + mPendingChanges.size());
|
||||
|
||||
scheduleInvalidation(InvalidationMode.DELAYED);
|
||||
scheduleInvalidation(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -135,11 +136,20 @@ public class HomePanelPicker extends FragmentActivity {
|
|||
private void installNewPanelAndQuit(PanelInfo panelInfo) {
|
||||
final PanelConfig newPanelConfig = panelInfo.toPanelConfig();
|
||||
HomeConfigInvalidator.getInstance().installPanel(newPanelConfig);
|
||||
showToastForNewPanel(newPanelConfig);
|
||||
|
||||
setResult(Activity.RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void showToastForNewPanel(PanelConfig panelConfig) {
|
||||
String panelName = panelConfig.getTitle();
|
||||
|
||||
// Display toast.
|
||||
final String successMsg = getResources().getString(R.string.home_add_panel_installed, panelName);
|
||||
Toast.makeText(this, successMsg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
// ViewHolder for rows of the panel picker.
|
||||
private static class PanelRow {
|
||||
final TextView title;
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
<!ENTITY pref_home_add_panel "Add panel">
|
||||
<!ENTITY home_add_panel_title "Add new panel">
|
||||
<!ENTITY home_add_panel_empty "Sorry, we couldn\'t find any panels for you to add.">
|
||||
<!-- Localization note (home_add_panel_installed):
|
||||
The &formatS; will be replaced with the name of the new panel the user just
|
||||
selected to be added to the home page. -->
|
||||
<!ENTITY home_add_panel_installed "\'&formatS;\' added to homepage">
|
||||
<!ENTITY pref_category_home_content_settings "Content settings">
|
||||
<!ENTITY pref_home_updates "Automatic updates">
|
||||
<!ENTITY pref_home_updates_enabled "Enabled">
|
||||
|
|
|
@ -75,6 +75,7 @@ public class GeckoPreferences
|
|||
private static boolean sIsCharEncodingEnabled = false;
|
||||
private boolean mInitialized = false;
|
||||
private int mPrefsRequestId = 0;
|
||||
private PanelsPreferenceCategory mPanelsPreferenceCategory;
|
||||
|
||||
// These match keys in resources/xml*/preferences*.xml
|
||||
private static final String PREFS_SEARCH_RESTORE_DEFAULTS = NON_PREF_PREFIX + "search.restore_defaults";
|
||||
|
@ -279,9 +280,8 @@ public class GeckoPreferences
|
|||
case HomePanelPicker.REQUEST_CODE_ADD_PANEL:
|
||||
switch (resultCode) {
|
||||
case Activity.RESULT_OK:
|
||||
// XXX: Bug 976925 - UI after adding a panel.
|
||||
setResult(RESULT_CODE_EXIT_SETTINGS);
|
||||
finish();
|
||||
// Panel installed, refresh panels list.
|
||||
mPanelsPreferenceCategory.refresh();
|
||||
break;
|
||||
case Activity.RESULT_CANCELED:
|
||||
// Dialog was cancelled, do nothing.
|
||||
|
@ -348,6 +348,8 @@ public class GeckoPreferences
|
|||
i--;
|
||||
continue;
|
||||
}
|
||||
} else if (pref instanceof PanelsPreferenceCategory) {
|
||||
mPanelsPreferenceCategory = (PanelsPreferenceCategory) pref;
|
||||
}
|
||||
setupPreferences((PreferenceGroup) pref, prefs);
|
||||
} else {
|
||||
|
|
|
@ -69,6 +69,21 @@ public class PanelsPreferenceCategory extends CustomListCategory {
|
|||
mLoadTask.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the Home Panels list from HomeConfig.
|
||||
*/
|
||||
public void refresh() {
|
||||
// Clear all the existing home panels, but leave the
|
||||
// first item (Add panels).
|
||||
int prefCount = getPreferenceCount();
|
||||
while (prefCount > 1) {
|
||||
removePreference(getPreference(1));
|
||||
prefCount--;
|
||||
}
|
||||
|
||||
loadHomeConfig();
|
||||
}
|
||||
|
||||
private void displayHomeConfig(HomeConfig.State configState) {
|
||||
for (PanelConfig panelConfig : configState) {
|
||||
// Create and add the pref.
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
<string name="pref_home_add_panel">&pref_home_add_panel;</string>
|
||||
<string name="home_add_panel_title">&home_add_panel_title;</string>
|
||||
<string name="home_add_panel_empty">&home_add_panel_empty;</string>
|
||||
<string name="home_add_panel_installed">&home_add_panel_installed;</string>
|
||||
<string name="pref_category_home_content_settings">&pref_category_home_content_settings;</string>
|
||||
<string name="pref_home_updates">&pref_home_updates;</string>
|
||||
<string name="pref_home_updates_enabled">&pref_home_updates_enabled;</string>
|
||||
|
|
Загрузка…
Ссылка в новой задаче