mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 833942 - Add 'remove' to about:home topsites r=mfinkle
This commit is contained in:
parent
76720ddfa7
commit
5783458882
@ -79,6 +79,11 @@ public class AboutHomeContent extends ScrollView
|
||||
private static int mNumberOfTopSites;
|
||||
private static int mNumberOfCols;
|
||||
|
||||
public static enum UnpinFlags {
|
||||
REMOVE_PIN,
|
||||
REMOVE_HISTORY
|
||||
}
|
||||
|
||||
static enum UpdateFlags {
|
||||
TOP_SITES,
|
||||
PREVIOUS_TABS,
|
||||
@ -210,11 +215,13 @@ public class AboutHomeContent extends ScrollView
|
||||
// force all items to be visible all the time
|
||||
View view = mTopSitesGrid.getChildAt(info.position);
|
||||
TopSitesViewHolder holder = (TopSitesViewHolder) view.getTag();
|
||||
if (holder.isPinned()) {
|
||||
if (TextUtils.isEmpty(holder.getUrl())) {
|
||||
menu.findItem(R.id.abouthome_topsites_pin).setVisible(false);
|
||||
menu.findItem(R.id.abouthome_topsites_unpin).setVisible(false);
|
||||
menu.findItem(R.id.abouthome_topsites_remove).setVisible(false);
|
||||
} else if (holder.isPinned()) {
|
||||
menu.findItem(R.id.abouthome_topsites_pin).setVisible(false);
|
||||
} else {
|
||||
if (TextUtils.isEmpty(holder.getUrl()))
|
||||
menu.findItem(R.id.abouthome_topsites_pin).setVisible(false);
|
||||
menu.findItem(R.id.abouthome_topsites_unpin).setVisible(false);
|
||||
}
|
||||
}
|
||||
@ -1013,18 +1020,21 @@ public class AboutHomeContent extends ScrollView
|
||||
holder.setPinned(false);
|
||||
}
|
||||
|
||||
public void unpinSite() {
|
||||
public void unpinSite(final UnpinFlags flags) {
|
||||
final int position = mTopSitesGrid.getSelectedPosition();
|
||||
View v = mTopSitesGrid.getChildAt(position);
|
||||
TopSitesViewHolder holder = (TopSitesViewHolder) v.getTag();
|
||||
|
||||
final View v = mTopSitesGrid.getChildAt(position);
|
||||
final TopSitesViewHolder holder = (TopSitesViewHolder) v.getTag();
|
||||
final String url = holder.getUrl();
|
||||
// Quickly update the view so that there isn't as much lag between the request and response
|
||||
clearThumbnail(holder);
|
||||
(new GeckoAsyncTask<Void, Void, Void>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
|
||||
@Override
|
||||
public Void doInBackground(Void... params) {
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
final ContentResolver resolver = mActivity.getContentResolver();
|
||||
BrowserDB.unpinSite(resolver, position);
|
||||
if (flags == UnpinFlags.REMOVE_HISTORY) {
|
||||
BrowserDB.removeHistoryEntry(resolver, url);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}).execute();
|
||||
|
@ -1050,12 +1050,17 @@ abstract public class BrowserApp extends GeckoApp
|
||||
return true;
|
||||
|
||||
case R.id.abouthome_topsites_unpin:
|
||||
mAboutHomeContent.unpinSite();
|
||||
mAboutHomeContent.unpinSite(AboutHomeContent.UnpinFlags.REMOVE_PIN);
|
||||
return true;
|
||||
|
||||
case R.id.abouthome_topsites_pin:
|
||||
mAboutHomeContent.pinSite();
|
||||
return true;
|
||||
|
||||
case R.id.abouthome_topsites_remove:
|
||||
mAboutHomeContent.unpinSite(AboutHomeContent.UnpinFlags.REMOVE_HISTORY);
|
||||
return true;
|
||||
|
||||
}
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ public class BrowserDB {
|
||||
|
||||
public void removeHistoryEntry(ContentResolver cr, int id);
|
||||
|
||||
public void removeHistoryEntry(ContentResolver cr, String url);
|
||||
|
||||
public void clearHistory(ContentResolver cr);
|
||||
|
||||
public Cursor getBookmarksInFolder(ContentResolver cr, long folderId);
|
||||
@ -169,6 +171,10 @@ public class BrowserDB {
|
||||
sDb.removeHistoryEntry(cr, id);
|
||||
}
|
||||
|
||||
public static void removeHistoryEntry(ContentResolver cr, String url) {
|
||||
sDb.removeHistoryEntry(cr, url);
|
||||
}
|
||||
|
||||
public static void clearHistory(ContentResolver cr) {
|
||||
sDb.clearHistory(cr);
|
||||
}
|
||||
|
@ -339,6 +339,12 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
new String[] { String.valueOf(id) });
|
||||
}
|
||||
|
||||
public void removeHistoryEntry(ContentResolver cr, String url) {
|
||||
int deleted = cr.delete(mHistoryUriWithProfile,
|
||||
History.URL + " = ?",
|
||||
new String[] { url });
|
||||
}
|
||||
|
||||
public void clearHistory(ContentResolver cr) {
|
||||
cr.delete(mHistoryUriWithProfile, null, null);
|
||||
}
|
||||
|
@ -203,6 +203,7 @@ size. -->
|
||||
<!ENTITY abouthome_topsites_edit "Edit">
|
||||
<!ENTITY abouthome_topsites_pin "Pin Site">
|
||||
<!ENTITY abouthome_topsites_unpin "Unpin Site">
|
||||
<!ENTITY abouthome_topsites_remove "Remove">
|
||||
|
||||
<!-- Localization note (abouthome_about_sync3, abouthome_about_apps2): The
|
||||
chevron (ex: "»"; unicode= U+00BB) is used as an arrow to show that
|
||||
|
@ -14,4 +14,6 @@
|
||||
<item android:id="@+id/abouthome_topsites_unpin"
|
||||
android:title="@string/abouthome_topsites_unpin"/>
|
||||
|
||||
<item android:id="@+id/abouthome_topsites_remove"
|
||||
android:title="@string/abouthome_topsites_remove"/>
|
||||
</menu>
|
||||
|
@ -205,6 +205,7 @@
|
||||
<string name="abouthome_topsites_edit">&abouthome_topsites_edit;</string>
|
||||
<string name="abouthome_topsites_pin">&abouthome_topsites_pin;</string>
|
||||
<string name="abouthome_topsites_unpin">&abouthome_topsites_unpin;</string>
|
||||
<string name="abouthome_topsites_remove">&abouthome_topsites_remove;</string>
|
||||
|
||||
<string name="filepicker_title">&filepicker_title;</string>
|
||||
<string name="filepicker_audio_title">&filepicker_audio_title;</string>
|
||||
|
Loading…
Reference in New Issue
Block a user