Bug 697803 - Show page titles in Awesome screen history [r=blassey]

When the page title updates, propagate the update to the
system history as well, so that the AwesomeScreen shows
page titles on the history tab.
This commit is contained in:
Kartikaya Gupta 2011-10-31 15:29:49 -04:00
parent 12b7b53c2b
commit 28bc25ad4f
2 changed files with 23 additions and 11 deletions

View File

@ -43,6 +43,7 @@ import java.util.Queue;
import java.util.Set;
import java.lang.ref.SoftReference;
import android.content.ContentValues;
import android.database.Cursor;
import android.os.Handler;
import android.provider.Browser;
@ -117,6 +118,16 @@ class GlobalHistory {
GeckoAppShell.notifyUriVisited(uri);
}
public void update(String uri, String title) {
ContentValues values = new ContentValues();
values.put(Browser.BookmarkColumns.TITLE, title);
GeckoApp.mAppContext.getContentResolver().update(
Browser.BOOKMARKS_URI,
values,
Browser.BookmarkColumns.URL + " = ?",
new String[] { uri });
}
public void checkUriVisited(final String uri) {
mHandler.post(new Runnable() {
public void run() {

View File

@ -127,9 +127,14 @@ public class Tab {
mTitle = new String(title);
Log.i(LOG_NAME, "Updated title: " + title + " for tab with id: " + mId);
}
HistoryEntry he = getLastHistoryEntry();
final HistoryEntry he = getLastHistoryEntry();
if (he != null) {
he.mTitle = title;
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
GlobalHistory.getInstance().update(he.mUri, he.mTitle);
}
});
} else {
Log.e(LOG_NAME, "Requested title update on empty history stack");
}
@ -198,14 +203,18 @@ public class Tab {
void handleSessionHistoryMessage(String event, JSONObject message) throws JSONException {
if (event.equals("New")) {
String uri = message.getString("uri");
final String uri = message.getString("uri");
mHistoryIndex++;
while (mHistory.size() > mHistoryIndex) {
mHistory.remove(mHistoryIndex);
}
HistoryEntry he = new HistoryEntry(uri, null);
mHistory.add(he);
new HistoryEntryTask().execute(he);
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
GlobalHistory.getInstance().add(uri);
}
});
} else if (event.equals("Back")) {
if (mHistoryIndex - 1 < 0) {
Log.e(LOG_NAME, "Received unexpected back notification");
@ -231,14 +240,6 @@ public class Tab {
}
}
private class HistoryEntryTask extends AsyncTask<HistoryEntry, Void, Void> {
protected Void doInBackground(HistoryEntry... entries) {
HistoryEntry entry = entries[0];
GlobalHistory.getInstance().add(entry.mUri);
return null;
}
}
private class CheckBookmarkTask extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... unused) {