Update widget previews
@@ -33,6 +33,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.isoron.uhabits.R;
|
||||
import org.isoron.uhabits.helpers.UIHelper;
|
||||
@@ -123,23 +124,27 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
|
||||
|
||||
protected abstract void refreshCustomViewData(View widgetView);
|
||||
|
||||
private void savePreview(Context context, int widgetId, Bitmap widgetCache)
|
||||
private void savePreview(Context context, int widgetId, Bitmap widgetCache, int width,
|
||||
int height, String label)
|
||||
{
|
||||
try
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate(getLayoutId(), null);
|
||||
|
||||
ImageView iv = (ImageView) view.findViewById(R.id.imageView);
|
||||
iv.setImageBitmap(widgetCache);
|
||||
TextView tvLabel = (TextView) view.findViewById(R.id.label);
|
||||
if(tvLabel != null) tvLabel.setText(label);
|
||||
|
||||
view.measure(portraitWidth, portraitHeight);
|
||||
ImageView iv = (ImageView) view.findViewById(R.id.imageView);
|
||||
if(iv != null) iv.setImageBitmap(widgetCache);
|
||||
|
||||
view.measure(width, height);
|
||||
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
|
||||
view.setDrawingCacheEnabled(true);
|
||||
view.buildDrawingCache();
|
||||
Bitmap previewCache = view.getDrawingCache();
|
||||
|
||||
String filename = String.format("%s/%d.png", context.getExternalCacheDir(), widgetId);
|
||||
String filename = String.format("%s/%d_%d.png", context.getExternalCacheDir(), widgetId, width);
|
||||
Log.d("BaseWidgetProvider", String.format("Writing %s", filename));
|
||||
FileOutputStream out = new FileOutputStream(filename);
|
||||
|
||||
@@ -285,7 +290,7 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
|
||||
remoteViews.setViewPadding(R.id.buttonOverlay, p[0], p[1], p[2], p[3]);
|
||||
}
|
||||
|
||||
//savePreview(context, widgetId, drawingCache);
|
||||
//savePreview(context, widgetId, drawingCache, width, height, habit.name);
|
||||
|
||||
PendingIntent onClickIntent = getOnClickPendingIntent(context, habit);
|
||||
if (onClickIntent != null) remoteViews.setOnClickPendingIntent(R.id.button,
|
||||
|
||||
BIN
app/src/main/res/drawable-nodpi/widget_preview_checkmark.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
app/src/main/res/drawable-nodpi/widget_preview_frequency.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
app/src/main/res/drawable-nodpi/widget_preview_history.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
app/src/main/res/drawable-nodpi/widget_preview_score.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
app/src/main/res/drawable-nodpi/widget_preview_streaks.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 34 KiB |