This commit is contained in:
Gangphon 2024-08-24 17:05:31 +08:00
parent 9691b7b907
commit 586583ddfd
4 changed files with 42 additions and 36 deletions

View File

@ -17,7 +17,7 @@ public class BackView extends View {
public BackView(Context context, int width, int height) { public BackView(Context context, int width, int height) {
super(context); super(context);
img = BitmapFactory.decodeResource(context.getResources(), R.drawable.back, Util.noScaled); img = BitmapFactory.decodeResource(context.getResources(), R.drawable.back, Util.noScaled);
cosImg = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/XixunPlayer/background", Util.noScaled); cosImg = BitmapFactory.decodeFile(Util.backImgFile, Util.noScaled);
rect.right = width; rect.right = width;
rect.bottom = height; rect.bottom = height;
} }

View File

@ -139,7 +139,7 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac
if(requestCode==999 && grantResults.length > 0 && grantResults[0]==PackageManager.PERMISSION_GRANTED && backView==null) init(); if(requestCode==999 && grantResults.length > 0 && grantResults[0]==PackageManager.PERMISSION_GRANTED && backView==null) init();
} }
ConnService connService; ConnService serviXy;
@SuppressLint("UnspecifiedRegisterReceiverFlag") @SuppressLint("UnspecifiedRegisterReceiverFlag")
public void init() { public void init() {
@ -156,12 +156,12 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac
var cardConn = new ServiceConnection() { var cardConn = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
Util.println("Disconnected cardsystem aidl service"); Util.println("<-<- AIDL Service cardsystem Disconnected");
} }
public void onServiceConnected(ComponentName name, IBinder iBinder) { public void onServiceConnected(ComponentName name, IBinder iBinder) {
unbindService(this); unbindService(this);
Util.println("Bind cardsystem aidl service success"); Util.println("->-> AIDL Service cardsystem aidl service Connected");
var service = CardService.Stub.asInterface(iBinder); var service = CardService.Stub.asInterface(iBinder);
try { try {
Util.isScreenOn = service.isScreenOpen(); Util.isScreenOn = service.isScreenOpen();
@ -182,17 +182,17 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac
intent.setPackage("com.xixun.joey.cardsystem"); intent.setPackage("com.xixun.joey.cardsystem");
bindService(intent, cardConn, Context.BIND_AUTO_CREATE); bindService(intent, cardConn, Context.BIND_AUTO_CREATE);
var connConn = new ServiceConnection() { var connXy = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
Util.println("Disconnected xy.conn aidl service"); Util.println("<-<- AIDL Service xy.conn Disconnected");
connService = null; serviXy = null;
} }
public void onServiceConnected(ComponentName name, IBinder iBinder) { public void onServiceConnected(ComponentName name, IBinder iBinder) {
unbindService(this); unbindService(this);
Util.println("Bind xy.conn aidl service success"); Util.println("->-> AIDL Service xy.conn Connected");
connService = ConnService.Stub.asInterface(iBinder); serviXy = ConnService.Stub.asInterface(iBinder);
try { try {
Util.serverURL = connService.getServerURL(); Util.serverURL = serviXy.getServerURL();
Util.println(" ServerURL: "+Util.serverURL); Util.println(" ServerURL: "+Util.serverURL);
if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/"; if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/";
else { else {
@ -205,9 +205,9 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac
} }
} }
}; };
intent = new Intent("xixun.intent.action.CONNECTION_INFO"); var intenXy = new Intent("xixun.intent.action.CONNECTION_INFO");
intent.setPackage("com.xixun.xy.conn"); intenXy.setPackage("com.xixun.xy.conn");
bindService(intent, connConn, Context.BIND_AUTO_CREATE); bindService(intenXy, connXy, Context.BIND_AUTO_CREATE);
reces.clear(); reces.clear();
BroadcastReceiver rece; BroadcastReceiver rece;
@ -238,21 +238,24 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Util.println("Receive CHANGE_COMPANYID"); Util.println("Receive CHANGE_COMPANYID");
if(connService!=null) {
try { try {
Util.serverURL = connService.getServerURL(); if(serviXy!=null && serviXy.asBinder().isBinderAlive()) {
Util.serverURL = serviXy.getServerURL();
Util.println(" ServerURL: "+Util.serverURL); Util.println(" ServerURL: "+Util.serverURL);
if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/"; if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/";
else { else {
if(! Util.serverURL.startsWith("http")) Util.serverURL = "http://"+Util.serverURL; if(! Util.serverURL.startsWith("http")) Util.serverURL = "http://"+Util.serverURL;
if(! Util.serverURL.endsWith("/")) Util.serverURL += "/"; if(! Util.serverURL.endsWith("/")) Util.serverURL += "/";
} }
} else {
Util.println(" bindService");
bindService(intenXy, connXy, Context.BIND_AUTO_CREATE);
}
} catch (Exception e) { } catch (Exception e) {
Util.makeText(MainActivity.this, Util.toStr(e)).show(); Util.makeText(MainActivity.this, Util.toStr(e)).show();
Util.printStackTrace(e); Util.printStackTrace(e);
} }
} }
}
}, new IntentFilter("com.xixun.joey.CHANGE_COMPANYID")); }, new IntentFilter("com.xixun.joey.CHANGE_COMPANYID"));
reces.add(rece); reces.add(rece);

View File

@ -179,6 +179,15 @@ public class Prog extends AbsLayout {
} }
if(src.exitDur!=0) src.exitStart = dur*60/1000 - src.exitDur; if(src.exitDur!=0) src.exitStart = dur*60/1000 - src.exitDur;
src.alpha = (float) source.dbl("opacity", 1);
var breathe = source.dbl("breathe");
if(breathe > 0) src.breathe = (int) Math.round(60 / breathe);
var blink = source.dbl("blink");
if(blink > 0) src.blinkHalf = (int) Math.round(30 / blink);
src.rotate = (float) source.dbl("rotate");
src.scaleX = (float) source.dbl("scaleX", 1);
src.scaleY = (float) source.dbl("scaleY", 1);
var id = source.str("id"); var id = source.str("id");
var fileExt = source.stnn("fileExt"); var fileExt = source.stnn("fileExt");
if(id!=null && fileExt.startsWith(".") && new File(Util.programDir + "/" + id + fileExt).exists()) id += fileExt; if(id!=null && fileExt.startsWith(".") && new File(Util.programDir + "/" + id + fileExt).exists()) id += fileExt;
@ -266,6 +275,12 @@ public class Prog extends AbsLayout {
src.exitStart = ele0.exitStart; src.exitStart = ele0.exitStart;
src.isEntryRand = ele0.isEntryRand; src.isEntryRand = ele0.isEntryRand;
src.isExitRand = ele0.isExitRand; src.isExitRand = ele0.isExitRand;
src.alpha = ele0.alpha;
src.breathe = ele0.breathe;
src.blinkHalf = ele0.blinkHalf;
src.rotate = ele0.rotate;
src.scaleX = ele0.scaleX;
src.scaleY = ele0.scaleY;
} }
src.endTime = src.startTime + picDur; src.endTime = src.startTime + picDur;
if(hasTTS) { if(hasTTS) {
@ -352,14 +367,6 @@ public class Prog extends AbsLayout {
if(src.view==null) continue; if(src.view==null) continue;
src.view.setVisibility(GONE); src.view.setVisibility(GONE);
src.view.setLayoutParams(geo); src.view.setLayoutParams(geo);
src.alpha = (float) source.dbl("opacity", 1);
var breathe = source.dbl("breathe");
if(breathe > 0) src.breathe = (int) Math.round(60 / breathe);
var blink = source.dbl("blink");
if(blink > 0) src.blinkHalf = (int) Math.round(30 / blink);
src.rotate = (float) source.dbl("rotate");
src.scaleX = (float) source.dbl("scaleX", 1);
src.scaleY = (float) source.dbl("scaleY", 1);
box.addView(src.view); box.addView(src.view);
layer.srcs.add(src); layer.srcs.add(src);
src = new Source(); src = new Source();

View File

@ -19,7 +19,7 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer.
static String directs[] = {"NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N"}; static String directs[] = {"NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N"};
MainActivity act; MainActivity act;
ArrayList<String> htmls; ArrayList<String> htmls;
String prefix, suffix, url, text; String prefix, url, text;
int interval, pageDur, cur; int interval, pageDur, cur;
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
@ -34,7 +34,6 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer.
var html = json.stnn("html").replace("%Co2", "%CO2").trim(); var html = json.stnn("html").replace("%Co2", "%CO2").trim();
htmls = Txts.split(html, "</p>", 1); htmls = Txts.split(html, "</p>", 1);
for(int i=0; i<htmls.size(); i++) htmls.set(i, htmls.get(i)+"</p>");
pageDur = json.intg("speed")*1000; pageDur = json.intg("speed")*1000;
if(pageDur==0) pageDur = json.intg("timeSpan")*1000 / htmls.size(); if(pageDur==0) pageDur = json.intg("timeSpan")*1000 / htmls.size();
url = json.str("sUrl"); url = json.str("sUrl");
@ -52,11 +51,8 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer.
prefix = "<body style=\"color:#fff; margin:0;padding:0;"; prefix = "<body style=\"color:#fff; margin:0;padding:0;";
var lineHeight = json.str("lineHeight"); var lineHeight = json.str("lineHeight");
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";"; if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
prefix += "width:"+width+"; height:"+height+"; position:relative;\"><div id=\"ppp\" style=\"position:absolute;\">"; if(json.bool("center")) prefix += "display:flex; align-items:center;";
suffix = "</div></body>"; prefix += "\">";
if(json.bool("center")) suffix += "<script>window.onload = function() { var ppp = document.getElementById(\"ppp\");\n" +
" ppp.style.top = ("+height+"-ppp.offsetHeight)/2+'px';\n" +
"};</script>";
prog.calls.add(this); prog.calls.add(this);
} }
@ -116,7 +112,7 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer.
.replace("%radiation", (radiation == -1 ? "--" : String.valueOf(radiation))+"W/m²") .replace("%radiation", (radiation == -1 ? "--" : String.valueOf(radiation))+"W/m²")
.replace("%bm", (beam == -1 ? "--" : String.valueOf(beam))+"lux"); .replace("%bm", (beam == -1 ? "--" : String.valueOf(beam))+"lux");
loadDataWithBaseURL(null, prefix+htm+suffix, "text/html", "UTF-8", null); loadDataWithBaseURL(null, prefix+htm+"</p></body>", "text/html", "UTF-8", null);
} catch (Exception e) { } catch (Exception e) {
Util.printStackTrace(e); Util.printStackTrace(e);
} }