comment it
This commit is contained in:
parent
7018143aaf
commit
5400a0d42d
|
@ -1,12 +1,19 @@
|
|||
package org.er2.fireplace;
|
||||
|
||||
import android.service.dreams.DreamService;
|
||||
import android.widget.TextView;
|
||||
|
||||
/* Dream service to show fireplace on device
|
||||
* instead of just black screen (useful for TVs).
|
||||
*
|
||||
* (c) Er2 2022 <er2@dismail.de>
|
||||
* Zlib License
|
||||
*/
|
||||
|
||||
public class Dream extends DreamService {
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
setInteractive(false);
|
||||
setFullscreen(true);
|
||||
setContentView(R.layout.dream);
|
||||
|
|
|
@ -3,24 +3,34 @@ package org.er2.fireplace;
|
|||
import java.util.Random;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* This file is a model and some controller in MVC pattern
|
||||
*
|
||||
* (c) Er2 <er2@dismail.de>
|
||||
* Zlib License
|
||||
*/
|
||||
|
||||
public class Fireplace {
|
||||
/* Characters and colors to use */
|
||||
/* (yes I like comments in C style) */
|
||||
private static String chr = "!\"#$%&*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`~ ";
|
||||
private static int[] cols = {
|
||||
/* 0x OPACITY hex
|
||||
Because Android uses opacity before hex
|
||||
*/
|
||||
0xFFfdcf58,
|
||||
0xFFf27d0c,
|
||||
0xFFf07f13,
|
||||
0xFF800909,
|
||||
};
|
||||
|
||||
int fsize;
|
||||
public int w, h, col;
|
||||
ArrayList<Integer> fire;
|
||||
Random rand;
|
||||
int fsize; /* Font size */
|
||||
public int w, h, col; /* width, height, columns */
|
||||
ArrayList<Integer> fire; /* ArrayList is to allow resize */
|
||||
Random rand; /* Some random :) */
|
||||
|
||||
int ind;
|
||||
int cid;
|
||||
int hid;
|
||||
int ind, cid, hid; /* column INDex, Color InDex, cHaracter InDex */
|
||||
|
||||
/* Pls no comments */
|
||||
public Fireplace() {
|
||||
fire = new ArrayList<Integer>();
|
||||
rand = new Random();
|
||||
|
|
|
@ -9,10 +9,17 @@ import android.util.AttributeSet;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
/* Fireplace frontend
|
||||
* TODO: Optimize this..
|
||||
*
|
||||
* (c) Er2 2022 <er2@dismail.de>
|
||||
* Zlib License
|
||||
*/
|
||||
|
||||
public class FireplaceView extends View {
|
||||
Paint paint;
|
||||
Fireplace fpl;
|
||||
Bitmap bmp;
|
||||
Paint paint; /* Android paint */
|
||||
Fireplace fpl; /* Our backend */
|
||||
Bitmap bmp; /* Screenshot of previous frame (thing to be optimized) */
|
||||
|
||||
public FireplaceView(Context ctx, AttributeSet attrs) {
|
||||
super(ctx, attrs);
|
||||
|
@ -22,9 +29,14 @@ public class FireplaceView extends View {
|
|||
}
|
||||
|
||||
public void drawFire(Canvas canv) {
|
||||
/* draw previous frame and apply transparency
|
||||
thing to be optimized
|
||||
*/
|
||||
canv.drawBitmap(bmp, 0, 0, null);
|
||||
paint.setColor(0x1E000000);
|
||||
canv.drawRect(0, 0, getWidth(), getHeight(), paint);
|
||||
|
||||
/* going through columns */
|
||||
for(int i = 0; i < fpl.col; i++) {
|
||||
fpl.next();
|
||||
paint.setColor(fpl.getCol());
|
||||
|
@ -39,6 +51,7 @@ public class FireplaceView extends View {
|
|||
|
||||
@Override
|
||||
public void onDraw(Canvas c) {
|
||||
/* TODO: To be optimized */
|
||||
Bitmap bip = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canv = new Canvas(bip);
|
||||
drawFire(canv);
|
||||
|
@ -49,6 +62,7 @@ public class FireplaceView extends View {
|
|||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int ow, int oh) {
|
||||
/* Set size directly */
|
||||
fpl.setSize(w, h);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,12 @@ package org.er2.fireplace;
|
|||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
/* Typical main activity file
|
||||
*
|
||||
* (c) Er2 2022 <er2@dismail.de>
|
||||
* Zlib License
|
||||
*/
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
Loading…
Reference in New Issue