mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 783312 - Show empty rows on about:home for customization. r=mfinkle
This commit is contained in:
parent
497cb2e84e
commit
bef574b750
@ -336,8 +336,13 @@ public class AboutHomeContent extends ScrollView
|
||||
|
||||
Cursor c = (Cursor) mTopSitesAdapter.getItem(i);
|
||||
final String url = c.getString(c.getColumnIndex(URLColumns.URL));
|
||||
|
||||
displayThumbnail(view, thumbnails.get(url));
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
ImageView thumbnailView = (ImageView) view.findViewById(R.id.thumbnail);
|
||||
thumbnailView.setImageResource(R.drawable.abouthome_thumbnail_add);
|
||||
thumbnailView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
} else {
|
||||
displayThumbnail(view, thumbnails.get(url));
|
||||
}
|
||||
}
|
||||
|
||||
mTopSitesGrid.invalidate();
|
||||
@ -806,6 +811,11 @@ public class AboutHomeContent extends ScrollView
|
||||
}
|
||||
|
||||
titleView.setText(title);
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
titleView.setVisibility(View.GONE);
|
||||
} else {
|
||||
titleView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -501,6 +501,7 @@ RES_DRAWABLE_BASE = \
|
||||
res/drawable/abouthome_promo_logo_sync.png \
|
||||
res/drawable/abouthome_thumbnail.png \
|
||||
res/drawable/abouthome_thumbnail_bg.png \
|
||||
res/drawable/abouthome_thumbnail_add.png \
|
||||
res/drawable/address_bar_bg_shadow.png \
|
||||
res/drawable/alert_addon.png \
|
||||
res/drawable/alert_app.png \
|
||||
@ -592,6 +593,7 @@ RES_DRAWABLE_HDPI = \
|
||||
res/drawable-hdpi/abouthome_promo_logo_sync.png \
|
||||
res/drawable-hdpi/abouthome_thumbnail.png \
|
||||
res/drawable-hdpi/abouthome_thumbnail_bg.png \
|
||||
res/drawable-hdpi/abouthome_thumbnail_add.png \
|
||||
res/drawable-hdpi/address_bar_bg_shadow.png \
|
||||
res/drawable-hdpi/alert_addon.png \
|
||||
res/drawable-hdpi/alert_app.png \
|
||||
@ -673,6 +675,7 @@ RES_DRAWABLE_XHDPI = \
|
||||
res/drawable-xhdpi/abouthome_promo_logo_sync.png \
|
||||
res/drawable-xhdpi/abouthome_thumbnail.png \
|
||||
res/drawable-xhdpi/abouthome_thumbnail_bg.png \
|
||||
res/drawable-xhdpi/abouthome_thumbnail_add.png \
|
||||
res/drawable-xhdpi/address_bar_bg_shadow.png \
|
||||
res/drawable-xhdpi/address_bar_texture_port.png \
|
||||
res/drawable-xhdpi/address_bar_texture_port_pb.png \
|
||||
|
@ -10,6 +10,7 @@ import org.mozilla.gecko.db.BrowserContract.ExpirePriority;
|
||||
import android.content.ContentResolver;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.database.CursorWrapper;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
||||
@ -115,7 +116,7 @@ public class BrowserDB {
|
||||
}
|
||||
|
||||
public static Cursor getTopSites(ContentResolver cr, int limit) {
|
||||
return sDb.getTopSites(cr, limit);
|
||||
return new TopSitesCursorWrapper(sDb.getTopSites(cr, limit), limit);
|
||||
}
|
||||
|
||||
public static void updateVisitedHistory(ContentResolver cr, String uri) {
|
||||
@ -243,4 +244,59 @@ public class BrowserDB {
|
||||
public static int getCount(ContentResolver cr, String database) {
|
||||
return sDb.getCount(cr, database);
|
||||
}
|
||||
|
||||
/* Cursor wrapper that forces top sites to contain at least
|
||||
* mNumberOfTopSites entries. For rows outside the wrapped cursor
|
||||
* will return empty strings and zero.
|
||||
*/
|
||||
static public class TopSitesCursorWrapper extends CursorWrapper {
|
||||
int mIndex = -1;
|
||||
Cursor mCursor = null;
|
||||
int mSize = 0;
|
||||
|
||||
public TopSitesCursorWrapper(Cursor cursor, int size) {
|
||||
super(cursor);
|
||||
mCursor = cursor;
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public int getPosition() { return mIndex; }
|
||||
public int getCount() { return mSize; }
|
||||
public boolean isAfterLast() { return mIndex >= mSize; }
|
||||
public boolean isBeforeFirst() { return mIndex < 0; }
|
||||
public boolean isLast() { return mIndex == mSize - 1; }
|
||||
public boolean moveToNext() { return moveToPosition(mIndex + 1); }
|
||||
public boolean moveToPrevious() { return moveToPosition(mIndex - 1); }
|
||||
|
||||
public boolean moveToPosition(int position) {
|
||||
mIndex = position;
|
||||
if (position > -1 && position < mCursor.getCount())
|
||||
super.moveToPosition(position);
|
||||
return !(isBeforeFirst() || isAfterLast());
|
||||
}
|
||||
|
||||
public long getLong(int columnIndex) {
|
||||
if (mIndex > -1 && mIndex < mCursor.getCount())
|
||||
return super.getLong(columnIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getString(int columnIndex) {
|
||||
if (mIndex > -1 && mIndex < mCursor.getCount())
|
||||
return super.getString(columnIndex);
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean move(int offset) {
|
||||
return moveToPosition(mIndex + offset);
|
||||
}
|
||||
|
||||
public boolean moveToFirst() {
|
||||
return moveToPosition(0);
|
||||
}
|
||||
|
||||
public boolean moveToLast() {
|
||||
return moveToPosition(mSize-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 249 B |
Binary file not shown.
After Width: | Height: | Size: 296 B |
Binary file not shown.
After Width: | Height: | Size: 214 B |
Loading…
Reference in New Issue
Block a user