summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/EdgeSwipeModel.java
diff options
context:
space:
mode:
authorPankaj Garg <pgarg@codeaurora.org>2015-09-14 11:21:19 -0700
committerjrizzoli <joey@cyanogenmoditalia.it>2015-11-05 14:22:56 +0100
commit036365be068b993cb63322ca2540873507941095 (patch)
tree14e725e77f7b3ffebd880ee24f14288183de29c6 /src/com/android/browser/EdgeSwipeModel.java
parentf5e6af684d2dc16d150561290aabdd2cfc45e583 (diff)
downloadandroid_packages_apps_Gello-036365be068b993cb63322ca2540873507941095.tar.gz
android_packages_apps_Gello-036365be068b993cb63322ca2540873507941095.tar.bz2
android_packages_apps_Gello-036365be068b993cb63322ca2540873507941095.zip
Fixes to Edge Navigation for missing bitmaps
- Show prominent color from favicon when bitmap capture of a navigation entry is missing - More active purging of bitmaps on navigation Change-Id: I2c137385bd1b1179dbbb16c0c3e933783d499c34
Diffstat (limited to 'src/com/android/browser/EdgeSwipeModel.java')
-rw-r--r--src/com/android/browser/EdgeSwipeModel.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/browser/EdgeSwipeModel.java b/src/com/android/browser/EdgeSwipeModel.java
index 51a5dc9c..2d8517bf 100644
--- a/src/com/android/browser/EdgeSwipeModel.java
+++ b/src/com/android/browser/EdgeSwipeModel.java
@@ -30,11 +30,15 @@
package com.android.browser;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.util.SparseArray;
import android.webkit.ValueCallback;
+import org.codeaurora.swe.WebHistoryItem;
+
public class EdgeSwipeModel {
private SparseArray<Bitmap> mBitmaps;
+ private SparseArray<Integer> mColors;
private Tab mTab;
private TitleBar mBar;
@@ -46,6 +50,7 @@ public class EdgeSwipeModel {
mTab = tab;
mBar = bar;
mBitmaps = new SparseArray<>();
+ mColors = new SparseArray<>();
}
public void updateSnapshot(final int index) {
@@ -80,6 +85,17 @@ public class EdgeSwipeModel {
}
public void fetchSnapshot(final int index) {
+ if (mColors.get(index) == null && mTab.getWebView() != null) {
+ WebHistoryItem item = mTab.getWebView().copyBackForwardList().getItemAtIndex(index);
+ if (item != null) {
+ String url = item.getUrl();
+ int color = NavigationBarBase.getSiteIconColor(url);
+ if (color != 0) {
+ mColors.put(index, color);
+ }
+ }
+ }
+
if (mBitmaps.get(index) != null) {
return;
}
@@ -108,11 +124,29 @@ public class EdgeSwipeModel {
return mBitmaps.get(index);
}
+ public int getColor(int index) {
+ if (index < 0) {
+ return Color.DKGRAY;
+ }
+
+ if (index > (mTab.getWebView().copyBackForwardList().getSize() - 1)) {
+ return Color.DKGRAY;
+ }
+
+ Integer color = mColors.get(index);
+ if (color != null) {
+ return color.intValue();
+ }
+
+ return Color.DKGRAY;
+ }
+
public void deleteSnapshot(int index) {
mBitmaps.delete(index);
}
public void cleanup() {
mBitmaps.clear();
+ mColors.clear();
}
}