Compare commits
No commits in common. "bd5851a5a3b1601f578579bb0decc90712240876" and "2b3462a6412b16539764096892228df67fda611b" have entirely different histories.
bd5851a5a3
...
2b3462a641
|
@ -1,17 +1,4 @@
|
||||||
# Built application files
|
# ---> Android
|
||||||
*.apk
|
|
||||||
*.ap_
|
|
||||||
|
|
||||||
# Files for the Dalvik VM
|
|
||||||
*.dex
|
|
||||||
|
|
||||||
# Java class files
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Generated files
|
|
||||||
bin/
|
|
||||||
gen/
|
|
||||||
|
|
||||||
# Gradle files
|
# Gradle files
|
||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
|
@ -19,8 +6,30 @@ build/
|
||||||
# Local configuration file (sdk path, etc)
|
# Local configuration file (sdk path, etc)
|
||||||
local.properties
|
local.properties
|
||||||
|
|
||||||
# Proguard folder generated by Eclipse
|
# Log/OS Files
|
||||||
proguard/
|
|
||||||
|
|
||||||
#Log Files
|
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
# Android Studio generated files and folders
|
||||||
|
captures/
|
||||||
|
.externalNativeBuild/
|
||||||
|
.cxx/
|
||||||
|
*.apk
|
||||||
|
output.json
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
*.iml
|
||||||
|
.idea/
|
||||||
|
misc.xml
|
||||||
|
deploymentTargetDropDown.xml
|
||||||
|
render.experimental.xml
|
||||||
|
|
||||||
|
# Keystore files
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
|
|
||||||
|
# Google Services (e.g. APIs or Firebase)
|
||||||
|
google-services.json
|
||||||
|
|
||||||
|
# Android Profiling
|
||||||
|
*.hprof
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
*.iml
|
|
||||||
.gradle
|
|
||||||
/local.properties
|
|
||||||
/.idea/caches
|
|
||||||
/.idea/libraries
|
|
||||||
/.idea/modules.xml
|
|
||||||
/.idea/workspace.xml
|
|
||||||
/.idea/navEditor.xml
|
|
||||||
/.idea/assetWizardSettings.xml
|
|
||||||
.DS_Store
|
|
||||||
/build
|
|
||||||
/captures
|
|
||||||
.externalNativeBuild
|
|
||||||
.cxx
|
|
||||||
local.properties
|
|
|
@ -1,3 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<bytecodeTargetLevel target="17" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
||||||
<component name="GradleSettings">
|
|
||||||
<option name="linkedExternalProjectsSettings">
|
|
||||||
<GradleProjectSettings>
|
|
||||||
<option name="testRunner" value="GRADLE" />
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
|
||||||
<option name="modules">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
<option value="$PROJECT_DIR$/app" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</GradleProjectSettings>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,9 +0,0 @@
|
||||||
<project version="4">
|
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="Android" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1 +0,0 @@
|
||||||
/build
|
|
|
@ -1,62 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'com.android.application'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
namespace 'com.xixun.xixunplayer'
|
|
||||||
compileSdk 34
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.xixun.xixunplayer"
|
|
||||||
minSdk 21
|
|
||||||
targetSdk 34
|
|
||||||
versionCode 1
|
|
||||||
versionName "2.1"
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildFeatures {
|
|
||||||
aidl true
|
|
||||||
}
|
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_11
|
|
||||||
targetCompatibility JavaVersion.VERSION_11
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
||||||
implementation 'androidx.media3:media3-exoplayer:1.2.0'
|
|
||||||
// implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
|
|
||||||
// implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
|
|
||||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
|
|
||||||
implementation files('libs/gnph.jar')
|
|
||||||
implementation files('libs/zip4j-2.10.0.jar')
|
|
||||||
implementation files('libs/xixun_card_settings_1.2.4.jar')
|
|
||||||
implementation files('libs/ijkplayer-java-0.8.8.aar')
|
|
||||||
implementation files('libs/ijkplayer-armv7a-0.8.8.aar')
|
|
||||||
implementation files('libs/ijkplayer-arm64-0.8.8.aar')
|
|
||||||
implementation files('libs/connService2.jar')
|
|
||||||
}
|
|
||||||
|
|
||||||
def getAppName() {
|
|
||||||
def stringsFile = android.sourceSets.main.res.sourceFiles.find { it.name.equals 'strings.xml' }
|
|
||||||
String s = new XmlParser().parse(stringsFile).string.find { it.@name.equals 'app_name' }.text();
|
|
||||||
return s.replaceAll("\"", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改 Apk 名
|
|
||||||
android.applicationVariants.configureEach { variant ->
|
|
||||||
variant.outputs.configureEach {
|
|
||||||
def fileName = "${getAppName()}-${versionName}.apk"
|
|
||||||
outputFileName = fileName
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
|
@ -1,58 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools" >
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
|
||||||
tools:ignore="ScopedStorage" />
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
|
||||||
android:usesCleartextTraffic="true"
|
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
|
||||||
android:supportsRtl="true"
|
|
||||||
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
|
|
||||||
<service
|
|
||||||
android:name=".RestartService"
|
|
||||||
android:exported="false" >
|
|
||||||
<intent-filter>
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".MainActivity"
|
|
||||||
android:exported="true"
|
|
||||||
android:label="@string/app_name" >
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<service
|
|
||||||
android:name=".Server"
|
|
||||||
android:exported="true" >
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="com.xixun.action.PlayerInfo" />
|
|
||||||
</intent-filter>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<receiver
|
|
||||||
android:name=".BootCompletedReceiver"
|
|
||||||
android:exported="true" >
|
|
||||||
<intent-filter android:priority="999" >
|
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
<meta-data android:name="android.max_aspect" android:value="2.1" />
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
|
@ -1,47 +0,0 @@
|
||||||
// PlayerInfo.aidl
|
|
||||||
package com.xixun.util;
|
|
||||||
|
|
||||||
// Declare any non-default types here with import statements
|
|
||||||
|
|
||||||
interface PlayerInfo {
|
|
||||||
//***需要实现,用于外部接口获取当前播放的节目名
|
|
||||||
String getProgramName();
|
|
||||||
//不需要实现
|
|
||||||
String getVersion();
|
|
||||||
//外部接口通知播放器屏幕宽高发生变化
|
|
||||||
void setScreenWidth(int w);
|
|
||||||
void setScreenHeight(int h);
|
|
||||||
//不需要
|
|
||||||
void taskScreenshot(String cmdId);
|
|
||||||
//不需要
|
|
||||||
void setExternalTemperature(float t);
|
|
||||||
void setInternalTemperature(float t);
|
|
||||||
void setHumidity(float h);
|
|
||||||
//暂时不需要
|
|
||||||
boolean forcePlayProgram(String pid);
|
|
||||||
boolean finishForcePlay();
|
|
||||||
//需要实现,让其他进程获取到当前播放的节目id
|
|
||||||
String getCurProgramId();
|
|
||||||
//需要,外部进程设置播放器的USB节目解压密码
|
|
||||||
void setUSBProgramPwd(String pwd);
|
|
||||||
//***需要,接收平台节目接口
|
|
||||||
String executeJosnCommand(String josn);
|
|
||||||
//暂停播放,以前的版本没有实现
|
|
||||||
void pausePlayer(boolean b);
|
|
||||||
//查询节目是否暂停播放
|
|
||||||
boolean isPause();
|
|
||||||
//***需要,清空节目和下载的素材
|
|
||||||
boolean clearTasks();
|
|
||||||
//需要,返回当前已有的节目数量
|
|
||||||
int countOfPrograms(int type);
|
|
||||||
//需要,指定id播放插播节目
|
|
||||||
void playInsertTask(String pid);
|
|
||||||
//需要,指定id停止播放插播节目
|
|
||||||
void stopInsertTask(String pid);
|
|
||||||
//***需要,回读当前节目json
|
|
||||||
String getProgramTask();
|
|
||||||
//不需要
|
|
||||||
void setUploadLogUrl(String playLog);
|
|
||||||
//不需要
|
|
||||||
String getUploadLogUrl();
|
|
||||||
}
|
|
Before Width: | Height: | Size: 680 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 929 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 748 B |
Before Width: | Height: | Size: 877 B |
Before Width: | Height: | Size: 923 B |
Before Width: | Height: | Size: 866 B |
Before Width: | Height: | Size: 698 B |
Before Width: | Height: | Size: 878 B |
Before Width: | Height: | Size: 647 B |
Before Width: | Height: | Size: 937 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 669 B |
Before Width: | Height: | Size: 966 B |
Before Width: | Height: | Size: 569 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 964 B |
Before Width: | Height: | Size: 971 B |
Before Width: | Height: | Size: 937 B |
Before Width: | Height: | Size: 833 B |
Before Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1003 B |
Before Width: | Height: | Size: 964 B |
Before Width: | Height: | Size: 787 B |
Before Width: | Height: | Size: 829 B |
Before Width: | Height: | Size: 904 B |
Before Width: | Height: | Size: 2.2 KiB |
|
@ -1,107 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
public class AbsLayout extends ViewGroup {
|
|
||||||
|
|
||||||
public AbsLayout(Context context) {
|
|
||||||
this(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbsLayout(Context context, AttributeSet attrs) {
|
|
||||||
this(context, attrs, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbsLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
this(context, attrs, defStyleAttr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbsLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
int count = getChildCount();
|
|
||||||
int maxHeight = 0;
|
|
||||||
int maxWidth = 0;
|
|
||||||
measureChildren(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
for(int i = 0; i < count; i++) {
|
|
||||||
View child = getChildAt(i);
|
|
||||||
if(child.getVisibility() != GONE) {
|
|
||||||
int childRight;
|
|
||||||
int childBottom;
|
|
||||||
var lp = (LayoutParams) child.getLayoutParams();
|
|
||||||
childRight = lp.x + child.getMeasuredWidth();
|
|
||||||
childBottom = lp.y + child.getMeasuredHeight();
|
|
||||||
maxWidth = Math.max(maxWidth, childRight);
|
|
||||||
maxHeight = Math.max(maxHeight, childBottom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maxWidth += getPaddingLeft() + getPaddingRight();
|
|
||||||
maxHeight += getPaddingTop() + getPaddingBottom();
|
|
||||||
maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
|
|
||||||
maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
|
|
||||||
setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, 0), resolveSizeAndState(maxHeight, heightMeasureSpec, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
|
||||||
return new LayoutParams(0, 0, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
||||||
int count = getChildCount();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
View child = getChildAt(i);
|
|
||||||
if(child.getVisibility() != GONE) {
|
|
||||||
var lp = (LayoutParams) child.getLayoutParams();
|
|
||||||
int childLeft = getPaddingLeft() + lp.x;
|
|
||||||
int childTop = getPaddingTop() + lp.y;
|
|
||||||
child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
|
|
||||||
return new LayoutParams(getContext(), attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
|
|
||||||
return p instanceof LayoutParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
|
|
||||||
return new LayoutParams(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldDelayChildPressedState() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class LayoutParams extends ViewGroup.LayoutParams {
|
|
||||||
|
|
||||||
public int x;
|
|
||||||
public int y;
|
|
||||||
|
|
||||||
public LayoutParams(int x, int y, int width, int height) {
|
|
||||||
super(width, height);
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
public LayoutParams(Context c, AttributeSet attrs) {
|
|
||||||
super(c, attrs);
|
|
||||||
}
|
|
||||||
public LayoutParams(ViewGroup.LayoutParams source) {
|
|
||||||
super(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
public class BackView extends View {
|
|
||||||
|
|
||||||
public Bitmap img, cosImg;
|
|
||||||
Rect rect = new Rect();
|
|
||||||
|
|
||||||
public BackView(Context context, int width, int height) {
|
|
||||||
super(context);
|
|
||||||
img = BitmapFactory.decodeResource(context.getResources(), R.drawable.back);
|
|
||||||
cosImg = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/XixunPlayer/background");
|
|
||||||
rect.right = width;
|
|
||||||
rect.bottom = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
if(cosImg!=null) canvas.drawBitmap(cosImg, null, rect, null);
|
|
||||||
else if(img!=null) for(int y=0; y<rect.bottom; y+=img.getHeight()) for(int x=0; x<rect.right; x+=img.getWidth()) canvas.drawBitmap(img, x, y, null);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
Util.println("BootCompletedReceiver onReceive ---- "+intent.getAction());
|
|
||||||
if(MainActivity.ins!=null) return;
|
|
||||||
intent = new Intent(context, MainActivity.class);
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,106 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.widget.VideoView;
|
|
||||||
|
|
||||||
public class EleVideo2 extends VideoView implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
float vol = 1;
|
|
||||||
|
|
||||||
public EleVideo2(String path, Context context) {
|
|
||||||
super(context);
|
|
||||||
setVideoPath(path);
|
|
||||||
setOnPreparedListener((MediaPlayer player)->{
|
|
||||||
player.setLooping(true);
|
|
||||||
if(! isShown()) {
|
|
||||||
player.seekTo(0);
|
|
||||||
player.pause();
|
|
||||||
}
|
|
||||||
if(vol!=1) player.setVolume(vol, vol);
|
|
||||||
setOnPreparedListener(null);
|
|
||||||
});
|
|
||||||
setOnErrorListener((MediaPlayer mp, int what, int extra)->{
|
|
||||||
var err = "Media Error: "+getErrorName(what)+". "+getErrorName(extra);
|
|
||||||
Util.makeText(getContext(), err).show();
|
|
||||||
Util.println(err);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVisibilityAggregated(boolean isVisible) {
|
|
||||||
super.onVisibilityAggregated(isVisible);
|
|
||||||
if(isVisible) {
|
|
||||||
Util.println("Video Show");
|
|
||||||
if(! isPlaying()) {
|
|
||||||
seekTo(0);
|
|
||||||
start();
|
|
||||||
seekTo(0);
|
|
||||||
if(! isPlaying()) Util.println("Video isn't Playing on Show");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Util.println("Video Hide");
|
|
||||||
seekTo(0);
|
|
||||||
pause();
|
|
||||||
seekTo(0);
|
|
||||||
showCnt = 3;
|
|
||||||
if(canAdd) {
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Choreographer choreographer = Choreographer.getInstance();
|
|
||||||
int showCnt;
|
|
||||||
boolean canAdd = true;
|
|
||||||
@Override
|
|
||||||
public void doFrame(long frameTimeNanos) {
|
|
||||||
if(isShown()) {
|
|
||||||
seekTo(0);
|
|
||||||
if(! isPlaying()) {
|
|
||||||
start();
|
|
||||||
seekTo(0);
|
|
||||||
if(! isPlaying()) {
|
|
||||||
Util.println("Video isn't Playing on doFrame "+showCnt);
|
|
||||||
if(showCnt==0) {
|
|
||||||
suspend();
|
|
||||||
resume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(showCnt>0) showCnt--;
|
|
||||||
else {
|
|
||||||
canAdd = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if(isPlaying()) {
|
|
||||||
seekTo(0);
|
|
||||||
pause();
|
|
||||||
seekTo(0);
|
|
||||||
Util.println("pause in doFrame()");
|
|
||||||
}
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getErrorName(int code) {
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_UNKNOWN) return "UNKNOWN";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_SERVER_DIED) return "SERVER_DIED";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) return "NOT_VALID_FOR_PROGRESSIVE_PLAYBACK";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_IO) return "IO";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_MALFORMED) return "MALFORMED";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_UNSUPPORTED) return "UNSUPPORTED";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_TIMED_OUT) return "TIMED_OUT";
|
|
||||||
if(code==-2147483648) return "SYSTEM";
|
|
||||||
return "Unknown ("+code+")";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
public interface IntentReceiver {
|
|
||||||
void onReceive(Intent intent);
|
|
||||||
}
|
|
|
@ -1,592 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.StrictMode;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.RequiresApi;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.xixun.joey.aidlset.CardService;
|
|
||||||
import com.xixun.xy.conn.aidl.ConnService;
|
|
||||||
|
|
||||||
import net.lingala.zip4j.ZipFile;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.net.ServerSocket;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import gnph.util.Chsets;
|
|
||||||
import gnph.util.IOs;
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity implements Choreographer.FrameCallback, Runnable {
|
|
||||||
|
|
||||||
public static MainActivity ins;
|
|
||||||
public Intent environIntent = new Intent();
|
|
||||||
HashSet<IntentReceiver> environs = new HashSet<>();
|
|
||||||
BackView backView;
|
|
||||||
Prog progView, insView;
|
|
||||||
long launchMilli = System.currentTimeMillis();
|
|
||||||
long syncMs;
|
|
||||||
int state;
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.R)
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
var msg = "==== MainActivity onCreate ==== UI Thread: "+Thread.currentThread().getId();
|
|
||||||
Util.println(msg);
|
|
||||||
ins = this;
|
|
||||||
startService(new Intent(this, RestartService.class));
|
|
||||||
|
|
||||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
|
|
||||||
|
|
||||||
if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) init();
|
|
||||||
else {
|
|
||||||
Util.println("---- No permission, Try again ...");
|
|
||||||
ActivityCompat.requestPermissions(this, new String[]{
|
|
||||||
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
||||||
android.Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
||||||
android.Manifest.permission.MANAGE_EXTERNAL_STORAGE,
|
|
||||||
android.Manifest.permission.RECEIVE_BOOT_COMPLETED,
|
|
||||||
android.Manifest.permission.INTERNET
|
|
||||||
}, 999);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
if(requestCode==999 && grantResults.length > 0 && grantResults[0]==PackageManager.PERMISSION_GRANTED && backView==null) init();
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnService connService;
|
|
||||||
|
|
||||||
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
|
||||||
public void init() {
|
|
||||||
var dir = Build.VERSION.SDK_INT < Build.VERSION_CODES.R ? Environment.getExternalStorageDirectory().getAbsolutePath() + "/XixunPlayer" : getExternalFilesDir(null).getAbsolutePath();
|
|
||||||
var msg = "---- dir "+dir;
|
|
||||||
Util.println(msg);
|
|
||||||
Util.programDir = dir + "/program";
|
|
||||||
Util.backImgFile = dir + "/background";
|
|
||||||
|
|
||||||
var program = new File(Util.programDir);
|
|
||||||
if(program.isFile()) program.delete();
|
|
||||||
msg = "---- mkdir: "+program.mkdirs();
|
|
||||||
Util.println(msg);
|
|
||||||
|
|
||||||
var cardConn = new ServiceConnection() {
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
|
||||||
Util.println("Disconnected cardsystem aidl service");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onServiceConnected(ComponentName name, IBinder iBinder) {
|
|
||||||
unbindService(this);
|
|
||||||
Util.println("Bind cardsystem aidl service success");
|
|
||||||
var service = CardService.Stub.asInterface(iBinder);
|
|
||||||
try {
|
|
||||||
Util.isScreenOn = service.isScreenOpen();
|
|
||||||
Util.screenWidth = service.getScreenWidth();
|
|
||||||
Util.screenHeight = service.getScreenHeight();
|
|
||||||
Util.println(" IsScreenOn: "+Util.isScreenOn+" screen: "+Util.screenWidth+" x "+Util.screenHeight);
|
|
||||||
setContentView(backView = new BackView(MainActivity.this, Util.screenWidth, Util.screenHeight));
|
|
||||||
state = 5;
|
|
||||||
if(Util.isScreenOn) initProg();
|
|
||||||
else state = 8;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.makeText(MainActivity.this, Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var intent = new Intent("com.xixun.joey.aidlset.SettingsService");
|
|
||||||
intent.setPackage("com.xixun.joey.cardsystem");
|
|
||||||
bindService(intent, cardConn, Context.BIND_AUTO_CREATE);
|
|
||||||
|
|
||||||
var connConn = new ServiceConnection() {
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
|
||||||
Util.println("Disconnected xy.conn aidl service");
|
|
||||||
connService = null;
|
|
||||||
}
|
|
||||||
public void onServiceConnected(ComponentName name, IBinder iBinder) {
|
|
||||||
unbindService(this);
|
|
||||||
Util.println("Bind xy.conn aidl service success");
|
|
||||||
connService = ConnService.Stub.asInterface(iBinder);
|
|
||||||
try {
|
|
||||||
Util.serverURL = connService.getServerURL();
|
|
||||||
Util.println(" ServerURL: "+Util.serverURL);
|
|
||||||
if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/";
|
|
||||||
else {
|
|
||||||
if(! Util.serverURL.startsWith("http")) Util.serverURL = "http://"+Util.serverURL;
|
|
||||||
if(! Util.serverURL.endsWith("/")) Util.serverURL += "/";
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.makeText(MainActivity.this, Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
intent = new Intent("xixun.intent.action.CONNECTION_INFO");
|
|
||||||
intent.setPackage("com.xixun.xy.conn");
|
|
||||||
bindService(intent, connConn, Context.BIND_AUTO_CREATE);
|
|
||||||
|
|
||||||
registerReceiver(new BroadcastReceiver(){
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
Util.println("Receive PAUSE_PLAYER");
|
|
||||||
Util.isScreenOn = ! intent.getBooleanExtra("pause", false);
|
|
||||||
Util.println(" IsScreenOn: "+Util.isScreenOn);
|
|
||||||
if(! Util.isScreenOn) {
|
|
||||||
state = 8;
|
|
||||||
if(insView!=null) {
|
|
||||||
insView.release();
|
|
||||||
insView = null;
|
|
||||||
}
|
|
||||||
if(progView!=null) {
|
|
||||||
progView.release();
|
|
||||||
progView = null;
|
|
||||||
}
|
|
||||||
setContentView(backView);
|
|
||||||
} else if(progView==null && insView==null) initProg();
|
|
||||||
}
|
|
||||||
}, new IntentFilter("com.xixun.action.PAUSE_PLAYER"));
|
|
||||||
|
|
||||||
registerReceiver(new BroadcastReceiver(){
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
Util.println("Receive CHANGE_COMPANYID");
|
|
||||||
if(connService!=null) {
|
|
||||||
try {
|
|
||||||
Util.serverURL = connService.getServerURL();
|
|
||||||
Util.println(" ServerURL: "+Util.serverURL);
|
|
||||||
if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/";
|
|
||||||
else {
|
|
||||||
if(! Util.serverURL.startsWith("http")) Util.serverURL = "http://"+Util.serverURL;
|
|
||||||
if(! Util.serverURL.endsWith("/")) Util.serverURL += "/";
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.makeText(MainActivity.this, Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, new IntentFilter("com.xixun.joey.CHANGE_COMPANYID"));
|
|
||||||
|
|
||||||
registerReceiver(new BroadcastReceiver(){
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
MainActivity.this.environIntent = intent;
|
|
||||||
for(var environ : environs) {
|
|
||||||
environ.onReceive(intent);
|
|
||||||
((View)environ).invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, new IntentFilter("xixun.intent.action.TEMPERATURE_HUMIDITY"));
|
|
||||||
|
|
||||||
registerReceiver(new BroadcastReceiver(){
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
try {
|
|
||||||
var code = intent.getIntExtra("code", 0);
|
|
||||||
Util.println(" remote_control "+code);
|
|
||||||
if(progView == null || ! progView.isShown() || code > progView.pages.size()) return;
|
|
||||||
if(! progView.avas.isEmpty()) progView.curAva().hide();
|
|
||||||
var millis = (System.currentTimeMillis()+999)/1000*1000;
|
|
||||||
if(code > 0) {
|
|
||||||
progView.avas.clear();
|
|
||||||
progView.avas.add(code-1);
|
|
||||||
progView.curAva = 0;
|
|
||||||
progView.curTimes = 1;
|
|
||||||
progView.waitTo = 0; //点播
|
|
||||||
var page = progView.curAva();
|
|
||||||
page.setMillis(millis);
|
|
||||||
if(state != 6) {
|
|
||||||
setContentView(progView);
|
|
||||||
state = 6;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
progView.waitTo = Long.MAX_VALUE;
|
|
||||||
syncProg(millis);
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Util.makeText(MainActivity.this, Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, new IntentFilter("com.xixun.yzd.REMOTE_CONTROL"));
|
|
||||||
|
|
||||||
var intentFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
|
|
||||||
intentFilter.addDataScheme("file");
|
|
||||||
registerReceiver(new BroadcastReceiver(){
|
|
||||||
long lastMs;
|
|
||||||
final char[] pass = {'8','8','8'};
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
var path = intent.getData().getPath();
|
|
||||||
Util.println("\nMEDIA_MOUNTED path: "+path);
|
|
||||||
var ms = System.currentTimeMillis();
|
|
||||||
if(ms-lastMs<1000) return;
|
|
||||||
lastMs = ms;
|
|
||||||
Util.makeText(MainActivity.this, "MEDIA_MOUNTED path: "+path+"\nImporting 正在导入 ...").show();
|
|
||||||
new Thread(()->{
|
|
||||||
try {
|
|
||||||
var zip = new ZipFile(path+"/program.zip");
|
|
||||||
if(zip.isEncrypted()) zip.setPassword(pass);
|
|
||||||
long size = 0;
|
|
||||||
ByteArrayOutputStream progJson = null;
|
|
||||||
var headers = zip.getFileHeaders();
|
|
||||||
for(var header : headers) {
|
|
||||||
size += header.getUncompressedSize();
|
|
||||||
if("program".equals(header.getFileName())) {
|
|
||||||
progJson = new ByteArrayOutputStream();
|
|
||||||
IOs.writeClose(progJson, zip.getInputStream(header));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(progJson==null) {
|
|
||||||
Util.println("No program File");
|
|
||||||
runOnUiThread(() -> Util.makeText(MainActivity.this, "No program File").show());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(size==0) {
|
|
||||||
Util.println("zip size is 0");
|
|
||||||
runOnUiThread(() -> Util.makeText(MainActivity.this, "zip size is 0").show());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Util.deleteFiles(size, null);
|
|
||||||
for(var header : headers) if(! "program".equals(header.getFileName())) {
|
|
||||||
Util.println(" name: " + header.getFileName());
|
|
||||||
var fOut = new FileOutputStream(Util.programDir + "/" + header.getFileName());
|
|
||||||
IOs.writeCloseIn(fOut, zip.getInputStream(header));
|
|
||||||
fOut.flush();
|
|
||||||
fOut.getFD().sync();
|
|
||||||
fOut.close();
|
|
||||||
}
|
|
||||||
var json = progJson.toByteArray();
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
Util.println("Import Succeed");
|
|
||||||
Util.makeText(MainActivity.this, "Import Succeed 导入成功\nDon't shut down within 1 minute, otherwise the program may be lost\n不要在 1 分钟内关机,否则节目可能丢失").show();
|
|
||||||
initProg(json);
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
runOnUiThread(() -> Util.makeText(MainActivity.this, Util.toStr(e)).show());
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
}, intentFilter);
|
|
||||||
|
|
||||||
new Thread(this).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopProg() {
|
|
||||||
if(insView!=null) {
|
|
||||||
insView.release();
|
|
||||||
insView = null;
|
|
||||||
}
|
|
||||||
if(progView!=null) {
|
|
||||||
progView.release();
|
|
||||||
progView = null;
|
|
||||||
}
|
|
||||||
setContentView(backView);
|
|
||||||
}
|
|
||||||
public boolean delProgFile() {
|
|
||||||
stopProg();
|
|
||||||
var files = new File(Util.programDir).listFiles();
|
|
||||||
var ok = true;
|
|
||||||
if(files != null) for(var file : files) if(! file.delete()) ok = false;
|
|
||||||
state = 4;
|
|
||||||
try {
|
|
||||||
var out = new FileOutputStream(Util.programDir+"/program");
|
|
||||||
out.write("{}".getBytes());
|
|
||||||
out.flush();
|
|
||||||
out.getFD().sync();
|
|
||||||
out.close();
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
public void initProg() {
|
|
||||||
state = 1;
|
|
||||||
try {
|
|
||||||
Util.println("\nParse Insert Prog Json");
|
|
||||||
var root = JSMap.fromClose(new BufferedInputStream(new FileInputStream(Util.programDir + "/insert")));
|
|
||||||
var task = root.jsmap("task");
|
|
||||||
if(task==null && root.containsKey("layers")) task = new JSMap("items", new JSList<>(new JSMap("_program", root)));
|
|
||||||
if(task!=null) {
|
|
||||||
var view = new Prog(task, this);
|
|
||||||
if(view.getChildCount()!=0) setContentView(insView = view);
|
|
||||||
}
|
|
||||||
} catch(FileNotFoundException ignored) {
|
|
||||||
} catch(Throwable e) {
|
|
||||||
state = 7;
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Util.println("\nParse Prog Json");
|
|
||||||
var root = JSMap.fromClose(new BufferedInputStream(new FileInputStream(Util.programDir + "/program")));
|
|
||||||
var task = root.jsmap("task");
|
|
||||||
if(task==null && root.containsKey("layers")) task = new JSMap("items", new JSList<>(new JSMap("_program", root)));
|
|
||||||
if(task==null) Util.println(root.isEmpty() ? " Empty program JSON\n" : " Error: task==null\n");
|
|
||||||
else {
|
|
||||||
var view = new Prog(task, this);
|
|
||||||
if(view.getChildCount()==0) Util.println(" Error: ChildCount==0\n");
|
|
||||||
else setContentView(progView = view);
|
|
||||||
}
|
|
||||||
} catch(FileNotFoundException e) {
|
|
||||||
Util.println(""+e);
|
|
||||||
} catch(Throwable e) {
|
|
||||||
state = 7;
|
|
||||||
Util.makeText(this, Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
if(insView!=null || progView!=null) {
|
|
||||||
state = 5;
|
|
||||||
Util.println("Init Sync");
|
|
||||||
syncProg((System.currentTimeMillis()+999)/1000*1000);
|
|
||||||
if(canAdd) {
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
}
|
|
||||||
} else if(state != 7) state = 3;
|
|
||||||
}
|
|
||||||
public void initProg(byte[] json) {
|
|
||||||
try {
|
|
||||||
Util.println("\nParse Prog Json");
|
|
||||||
var root = JSMap.from(json);
|
|
||||||
var task = root.jsmap("task");
|
|
||||||
if(task==null) {
|
|
||||||
if(! root.containsKey("layers")) {
|
|
||||||
state = 7;
|
|
||||||
Util.println(" Error: task==null\n");
|
|
||||||
Util.println(new String(json, Chsets.UTF8));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
task = new JSMap("items", new JSList<>(new JSMap("_program", root)));
|
|
||||||
}
|
|
||||||
var view = new Prog(task, this);
|
|
||||||
if(view.getChildCount()==0) {
|
|
||||||
if(! view.isInsert) state = 7;
|
|
||||||
Util.println(" Error: ChildCount==0\n");
|
|
||||||
Util.println(new String(json, Chsets.UTF8));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(view.isInsert) {
|
|
||||||
if(insView!=null) insView.release();
|
|
||||||
insView = view;
|
|
||||||
setContentView(insView);
|
|
||||||
} else {
|
|
||||||
if(progView!=null) progView.release();
|
|
||||||
progView = view;
|
|
||||||
setContentView(progView);
|
|
||||||
}
|
|
||||||
var fOut = new FileOutputStream(Util.programDir + (view.isInsert?"/insert":"/program"));
|
|
||||||
fOut.write(json);
|
|
||||||
fOut.flush();
|
|
||||||
fOut.getFD().sync();
|
|
||||||
fOut.close();
|
|
||||||
state = 5;
|
|
||||||
Util.println("Init Sync");
|
|
||||||
syncProg((System.currentTimeMillis()+999)/1000*1000);
|
|
||||||
if(canAdd) {
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
state = 7;
|
|
||||||
Util.makeText(this, Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
Util.println(new String(json, Chsets.UTF8));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Choreographer choreographer = Choreographer.getInstance();
|
|
||||||
boolean canAdd = true;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long frameTimeNanos) {
|
|
||||||
if(progView == null && insView==null) {
|
|
||||||
canAdd = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var milli = System.currentTimeMillis();
|
|
||||||
if(insView!=null && ! insView.avas.isEmpty()) {
|
|
||||||
var lastPage = insView.curAva();
|
|
||||||
if(milli >= lastPage.endMilli) {
|
|
||||||
lastPage.hide();
|
|
||||||
if(--lastPage.repeatTimes<=0 && ++insView.curAva >= insView.avas.size()) {
|
|
||||||
var isDiff = milli-lastPage.endMilli>=1000;
|
|
||||||
Util.println("isDiff: "+isDiff+" endMs: "+lastPage.endMilli+" millis:"+milli);
|
|
||||||
syncProg(isDiff ? milli : lastPage.endMilli);
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
if(insView!=null) for(var call : insView.calls) call.doFrame(milli);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
insView.curAva().setMillis(lastPage.endMilli);
|
|
||||||
Util.println("curAva: "+insView.curAva+" endMs: "+insView.curAva().endMilli);
|
|
||||||
} else lastPage.showHideSrcs(milli);
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
for(var call : insView.calls) call.doFrame(milli);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(progView.avas.isEmpty()) {
|
|
||||||
if(milli >= progView.waitTo) {
|
|
||||||
progView.waitTo = Long.MAX_VALUE;
|
|
||||||
Util.println("wait sync");
|
|
||||||
syncProg(milli);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var lastPage = progView.curAva();
|
|
||||||
if(milli >= lastPage.endMilli) {
|
|
||||||
lastPage.hide();
|
|
||||||
if(progView.waitTo > 0) { //waitTo==0 为点播,不换页
|
|
||||||
if(progView.curTimes < lastPage.repeatTimes) progView.curTimes++;
|
|
||||||
else {
|
|
||||||
progView.curTimes = 1;
|
|
||||||
if(++progView.curAva >= progView.avas.size()) {
|
|
||||||
var isDiff = milli-lastPage.endMilli>=1000;
|
|
||||||
if(Util.buf.length()>1000000) Util.buf.replace(0, 100000, "");
|
|
||||||
Util.println("isDiff: "+isDiff+" endMs: "+lastPage.endMilli+" millis:"+milli);
|
|
||||||
syncProg(isDiff ? milli : lastPage.endMilli);
|
|
||||||
if(! progView.isShown() || progView.avas.isEmpty()) Util.println("after. No Avas");
|
|
||||||
else Util.println("after. curAva: "+progView.curAva+" endMs: "+progView.curAva().endMilli);
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
for(var call : progView.calls) call.doFrame(milli);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
progView.curAva().setMillis(lastPage.endMilli);
|
|
||||||
Util.println("curAva: "+progView.curAva+" endMs: "+progView.curAva().endMilli);
|
|
||||||
} else lastPage.showHideSrcs(milli);
|
|
||||||
}
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
for(var call : progView.calls) call.doFrame(milli);
|
|
||||||
}
|
|
||||||
|
|
||||||
void syncProg(long milli) {
|
|
||||||
if(insView!=null) {
|
|
||||||
insView.avas.clear();
|
|
||||||
for(int i=0; i<insView.pages.size(); i++) if(insView.pages.get(i).repeatTimes <= 0) {
|
|
||||||
for(var layer : insView.pages.get(i).layers) for(var src : layer.srcs) {
|
|
||||||
insView.removeView(src.view);
|
|
||||||
insView.calls.remove(src);
|
|
||||||
}
|
|
||||||
insView.pages.remove(i--);
|
|
||||||
}
|
|
||||||
if(insView.pages.isEmpty()) {
|
|
||||||
insView.release();
|
|
||||||
insView = null;
|
|
||||||
try {
|
|
||||||
var fOut = new FileOutputStream(Util.programDir + "/insert");
|
|
||||||
fOut.write("{}".getBytes());
|
|
||||||
fOut.flush();
|
|
||||||
fOut.getFD().sync();
|
|
||||||
fOut.close();
|
|
||||||
} catch(Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var dur = 0;
|
|
||||||
for(int i=0; i<insView.pages.size(); i++) if(insView.pages.get(i).isScheOn(milli+dur)) {
|
|
||||||
insView.avas.add(i);
|
|
||||||
dur += insView.pages.get(i).tDur;
|
|
||||||
}
|
|
||||||
if(dur==0) for(int i=0; i<insView.pages.size(); i++) if(insView.pages.get(i).sches==null) {
|
|
||||||
insView.avas.add(i);
|
|
||||||
dur += insView.pages.get(i).tDur;
|
|
||||||
}
|
|
||||||
if(dur!=0) {
|
|
||||||
insView.curAva = 0;
|
|
||||||
insView.curAva().setMillis(milli);
|
|
||||||
if(! insView.isShown()) setContentView(insView);
|
|
||||||
state = 6;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(progView!=null) {
|
|
||||||
progView.curTimes = 1;
|
|
||||||
progView.avas.clear();
|
|
||||||
var dur = 0;
|
|
||||||
for(int i=0; i<progView.pages.size(); i++) if(progView.pages.get(i).isScheOn(milli+dur)) {
|
|
||||||
progView.avas.add(i);
|
|
||||||
dur += progView.pages.get(i).tDur;
|
|
||||||
}
|
|
||||||
if(dur==0) {
|
|
||||||
for(int i=0; i<progView.pages.size(); i++) if(progView.pages.get(i).sches==null) {
|
|
||||||
progView.avas.add(i);
|
|
||||||
dur += progView.pages.get(i).tDur;
|
|
||||||
}
|
|
||||||
if(dur==0) {
|
|
||||||
progView.waitTo = milli + 1000;
|
|
||||||
if(state!=2) {
|
|
||||||
setContentView(backView);
|
|
||||||
state = 2;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var start = milli / dur * dur;
|
|
||||||
progView.curAva = 0;
|
|
||||||
if(start < milli) {
|
|
||||||
do {
|
|
||||||
start += progView.curAva().tDur;
|
|
||||||
progView.curAva++;
|
|
||||||
} while(progView.curAva < progView.avas.size() && start<=milli);
|
|
||||||
progView.curAva--;
|
|
||||||
start -= progView.curAva().tDur;
|
|
||||||
syncMs = milli;
|
|
||||||
Util.println("Sync. dur: "+dur+" milli: "+milli+" start: "+start+" diff: "+(milli - start));
|
|
||||||
}
|
|
||||||
progView.curAva().setMillis(start);
|
|
||||||
if(! progView.isShown()) setContentView(progView);
|
|
||||||
state = 6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
var serverSocket = new ServerSocket(3333);
|
|
||||||
while(true) {
|
|
||||||
try {
|
|
||||||
Util.println("\nAccepting ...");
|
|
||||||
var socket = serverSocket.accept();
|
|
||||||
new SocketThread(this, socket).start();
|
|
||||||
Util.println("\nAccepted");
|
|
||||||
} catch (Throwable e) {
|
|
||||||
MainActivity.ins.runOnUiThread(() -> Util.makeText(MainActivity.this, Util.toStr(e)).show());
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
MainActivity.ins.runOnUiThread(() -> Util.makeText(MainActivity.this, Util.toStr(e)).show());
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,693 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.speech.tts.TextToSpeech;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
import android.webkit.JavascriptInterface;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import gnph.util.Dates;
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class Prog extends AbsLayout {
|
|
||||||
|
|
||||||
ArrayList<Page> pages = new ArrayList<>();
|
|
||||||
ArrayList<Integer> avas = new ArrayList<>();
|
|
||||||
ArrayList<Choreographer.FrameCallback> calls = new ArrayList<>();
|
|
||||||
int curAva, curTimes = 1;
|
|
||||||
long waitTo = Long.MAX_VALUE;
|
|
||||||
boolean isInsert;
|
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
|
||||||
public Prog(JSMap task, Context context) {
|
|
||||||
super(context);
|
|
||||||
isInsert = task.bool("insert");
|
|
||||||
JSList<JSMap> jpages = task.jslist("items");
|
|
||||||
JSList<Long> partLengths = task.jslist("partLengths");
|
|
||||||
var isVertical = task.bool("isVertical");
|
|
||||||
var partObj = task;
|
|
||||||
if(partLengths==null) {
|
|
||||||
try {
|
|
||||||
var _program = jpages.get(0).jsmap("_program");
|
|
||||||
partLengths = _program.jslist("splitWidths");
|
|
||||||
isVertical = _program.bool("isVer");
|
|
||||||
partObj = _program;
|
|
||||||
} catch (Throwable ignored){}
|
|
||||||
}
|
|
||||||
var width = partObj.intg("width");
|
|
||||||
var height = partObj.intg("height");
|
|
||||||
AbsLayout box;
|
|
||||||
if(partLengths==null || partLengths.size() <= 1) box = this;
|
|
||||||
else {
|
|
||||||
box = new AbsLayout(context);
|
|
||||||
addView(box, new AbsLayout.LayoutParams(0, 0, width, height));
|
|
||||||
var mask = new View(context);
|
|
||||||
mask.setBackgroundColor(0xff000000);
|
|
||||||
var len0 = partLengths.get(0).intValue();
|
|
||||||
addView(mask, isVertical ? new AbsLayout.LayoutParams(0, len0, width, height - len0) : new AbsLayout.LayoutParams(len0, 0, width - len0, height));
|
|
||||||
int x = 0, y = 0;
|
|
||||||
for(int i=1; i<partLengths.size(); i++) {
|
|
||||||
var part = new SrcCopy(context, box);
|
|
||||||
if(isVertical) {
|
|
||||||
y -= partLengths.get(i-1);
|
|
||||||
x += width;
|
|
||||||
addView(part, new AbsLayout.LayoutParams(x, y, width, partLengths.get(i).intValue() - y));
|
|
||||||
} else {
|
|
||||||
x -= partLengths.get(i-1);
|
|
||||||
y += height;
|
|
||||||
addView(part, new AbsLayout.LayoutParams(x, y, partLengths.get(i).intValue() - x, height));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(var pageMap : jpages) {
|
|
||||||
var _program = pageMap.jsmap("_program");
|
|
||||||
JSList<JSMap> layers = _program.jslist("layers");
|
|
||||||
var isSimple = _program.intg("version")==2;
|
|
||||||
if(layers==null || layers.isEmpty()) continue;
|
|
||||||
if(isSimple) {
|
|
||||||
width = _program.intg("width", Util.screenWidth);
|
|
||||||
height = _program.intg("height", Util.screenHeight);
|
|
||||||
}
|
|
||||||
var page = new Page();
|
|
||||||
page.name = _program.str("name");
|
|
||||||
page.repeatTimes = pageMap.intg("repeatTimes", 1);
|
|
||||||
page.parse(pageMap.jslist("schedules"));
|
|
||||||
HashMap<String, View> videoMap = new HashMap<>();
|
|
||||||
for(int ll=layers.size()-1; ll>=0; ll--) {
|
|
||||||
var layer = new Layer();
|
|
||||||
layer.isLoop = layers.get(ll).bool("repeat");
|
|
||||||
JSList<JSMap> sources = layers.get(ll).jslist("sources");
|
|
||||||
var border = layers.get(ll).jsmap("border");
|
|
||||||
SrcBorder bdEle = null;
|
|
||||||
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
|
|
||||||
if(border!=null) {
|
|
||||||
bdEle = new SrcBorder(this, Util.programDir+"/"+border.stnn("img"), border.stnn("eff"), border.intg("speed"));
|
|
||||||
bdWidth = bdEle.img.getHeight();
|
|
||||||
}
|
|
||||||
var src = new Source();
|
|
||||||
for(var source : sources) {
|
|
||||||
src.type = source.stnn("_type");
|
|
||||||
if(src.type.isEmpty()) continue;
|
|
||||||
var timeSpan = source.intg("timeSpan")*1000;
|
|
||||||
if(timeSpan==0) {
|
|
||||||
Util.println("\nError: timeSpan is 0. _type: "+src.type);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var geo = isSimple ? new AbsLayout.LayoutParams(0, 0, width, height) : new AbsLayout.LayoutParams(source.intg("left")+bdWidth, source.intg("top")+bdWidth, source.intg("width")-bdWidth-bdWidth, source.intg("height")-bdWidth-bdWidth);
|
|
||||||
var notAudio = ! src.type.equals("Audio");
|
|
||||||
if(notAudio) {
|
|
||||||
if(geo.width<=0 || geo.height<=0) {
|
|
||||||
Util.println("\nError: width or height is 0. _type: "+src.type+" width: "+geo.width+" height: "+geo.height);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(box != this && ((geo.y>=height && height>0) || (geo.x>=width && width>0))) {
|
|
||||||
Util.println("\nError: y>=height or x>=width. _type: "+src.type+" width: "+width+" height: "+height+" x: "+geo.x+" y: "+geo.y);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
src.startTime = isSimple ? (layer.srcs.isEmpty() ? 0 : layer.srcs.get(layer.srcs.size()-1).endTime) : source.intg("playTime")*1000;
|
|
||||||
if(bdStart > src.startTime) bdStart = src.startTime;
|
|
||||||
src.endTime = src.startTime + timeSpan;
|
|
||||||
if(bdEnd < src.endTime) bdEnd = src.endTime;
|
|
||||||
if(layer.dur < src.endTime) layer.dur = src.endTime;
|
|
||||||
if(notAudio) {
|
|
||||||
if(page.sDur < src.endTime) page.sDur = src.endTime;
|
|
||||||
} else if(page.audioDur < src.endTime) page.audioDur = src.endTime;
|
|
||||||
|
|
||||||
src.entryDur = source.intg("entryEffectTimeSpan")*60;
|
|
||||||
if(src.entryDur > 0) {
|
|
||||||
var effect = source.str("entryEffect");
|
|
||||||
if(effect == null || effect.equalsIgnoreCase("None")) src.entryDur = 0;
|
|
||||||
else if(effect.equalsIgnoreCase("Random")) src.isEntryRand = true;
|
|
||||||
else {
|
|
||||||
effect = effect.replace("MOVING", "MOVE");
|
|
||||||
effect = effect.replace("LEFT_TOP", "TL");
|
|
||||||
effect = effect.replace("RIGHT_TOP", "TR");
|
|
||||||
effect = effect.replace("RIGHT_BOTTOM", "BR");
|
|
||||||
effect = effect.replace("LEFT_BOTTOM", "BL");
|
|
||||||
effect = effect.replace("ALPHA", "FADE");
|
|
||||||
effect = effect.replace("_IN", "");
|
|
||||||
effect = effect.replace("_OUT", "");
|
|
||||||
try {
|
|
||||||
src.entryEff = Effect.valueOf(effect);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
if(effect.equalsIgnoreCase("ROTATE_RIGHT")) src.entryEff = Effect.ROTATE;
|
|
||||||
else if(effect.equalsIgnoreCase("ROTATE_LEFT")) src.entryEff = Effect.ROTATE_R;
|
|
||||||
else src.entryDur = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
src.exitDur = source.intg("exitEffectTimeSpan")*60;
|
|
||||||
if(src.exitDur > 0) {
|
|
||||||
var effect = source.str("exitEffect");
|
|
||||||
if(effect == null || effect.equalsIgnoreCase("None")) src.exitDur = 0;
|
|
||||||
else if(effect.equalsIgnoreCase("Random")) src.isExitRand = true;
|
|
||||||
else {
|
|
||||||
effect = effect.replace("MOVING", "MOVE");
|
|
||||||
effect = effect.replace("LEFT_TOP", "TL");
|
|
||||||
effect = effect.replace("RIGHT_TOP", "TR");
|
|
||||||
effect = effect.replace("RIGHT_BOTTOM", "BR");
|
|
||||||
effect = effect.replace("LEFT_BOTTOM", "BL");
|
|
||||||
effect = effect.replace("ALPHA", "FADE");
|
|
||||||
effect = effect.replace("_IN", "");
|
|
||||||
effect = effect.replace("_OUT", "");
|
|
||||||
try {
|
|
||||||
src.exitEff = Effect.valueOf(effect);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
if(effect.equalsIgnoreCase("ROTATE_RIGHT")) src.exitEff = Effect.ROTATE;
|
|
||||||
else if(effect.equalsIgnoreCase("ROTATE_LEFT")) src.exitEff = Effect.ROTATE_R;
|
|
||||||
else src.exitDur = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(src.exitDur!=0) src.exitStart = timeSpan*60/1000 - src.exitDur;
|
|
||||||
|
|
||||||
var id = source.str("id");
|
|
||||||
var fileExt = source.stnn("fileExt");
|
|
||||||
if(id!=null && fileExt.startsWith(".") && new File(Util.programDir + "/" + id + fileExt).exists()) id += fileExt;
|
|
||||||
src.view = null;
|
|
||||||
if(src.type.equals("Image")) {
|
|
||||||
if(id==null) continue;
|
|
||||||
var isGif = fileExt.toLowerCase().endsWith("gif");
|
|
||||||
if(isGif) {
|
|
||||||
var imgView = new GifImageView(context);
|
|
||||||
imgView.setImageURI(src.uri = Uri.fromFile(new File(Util.programDir + "/" + id)));
|
|
||||||
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
|
|
||||||
src.view = imgView;
|
|
||||||
} else {
|
|
||||||
var imgView = new ImageView(context);
|
|
||||||
imgView.setImageURI(Uri.fromFile(new File(Util.programDir + "/" + id)));
|
|
||||||
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
|
|
||||||
src.view = imgView;
|
|
||||||
}
|
|
||||||
} else if(src.type.endsWith("Video")) {
|
|
||||||
var isLive = src.type.startsWith("Live");
|
|
||||||
var url = source.str("url");
|
|
||||||
if(isLive) {
|
|
||||||
if(url==null) continue;
|
|
||||||
} else if(id==null) continue;
|
|
||||||
var key = isLive ? url : id + src.startTime + src.endTime;
|
|
||||||
var exist = videoMap.get(key);
|
|
||||||
if(exist!=null) {
|
|
||||||
var geoOld = (AbsLayout.LayoutParams) exist.getLayoutParams();
|
|
||||||
if(geo.width*geo.height > geoOld.width*geoOld.height) {
|
|
||||||
exist.setLayoutParams(geo);
|
|
||||||
geo = geoOld;
|
|
||||||
}
|
|
||||||
src.view = new SrcCopy(context, exist);
|
|
||||||
((SrcCopy) src.view).scaleX = 0;
|
|
||||||
} else {
|
|
||||||
src.view = new SrcVideo(context, isLive ? url : Util.programDir+"/"+id, source.intg("vol", 100) / 100.0f, isLive);
|
|
||||||
videoMap.put(key, src.view);
|
|
||||||
}
|
|
||||||
} else if(src.type.equals("Audio")) {
|
|
||||||
if(id==null) continue;
|
|
||||||
src.view = new SrcVideo(context, Util.programDir + "/" +id, source.intg("vol", 100) / 100.0f, false);
|
|
||||||
} else if(src.type.startsWith("MultiPng") || src.type.equals("SplitText")) {
|
|
||||||
JSList<JSMap> imgs = source.jslist("arrayPics");
|
|
||||||
if(imgs.isEmpty()) continue;
|
|
||||||
var mode = source.str("curchange");
|
|
||||||
var hasTTS = src.type.endsWith("Audio");
|
|
||||||
var speechRate = (float) source.dbl("voiceRate");
|
|
||||||
if(mode!=null ? mode.endsWith("roll") : (imgs.size()==1 && imgs.get(0).intg("picDuration")==0)) {
|
|
||||||
var img = imgs.get(0);
|
|
||||||
src.view = new SrcScroll(this, img, null);
|
|
||||||
if(hasTTS) {
|
|
||||||
src.text = img.str("text");
|
|
||||||
if(src.text!=null) {
|
|
||||||
src.tts = new TextToSpeech(context, (int status)->{
|
|
||||||
Util.println("status: "+status+" "+(status==TextToSpeech.SUCCESS));
|
|
||||||
}, "com.iflytek.speechcloud");
|
|
||||||
src.tts.setSpeechRate(speechRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var ele0 = src;
|
|
||||||
for(var map : imgs) {
|
|
||||||
var picDur = map.intg("picDuration")*1000;
|
|
||||||
if(picDur==0) picDur = timeSpan / imgs.size();
|
|
||||||
src.type = "Image";
|
|
||||||
if(src!=ele0) {
|
|
||||||
src.startTime = layer.srcs.get(layer.srcs.size()-1).endTime;
|
|
||||||
src.entryEff = ele0.entryEff;
|
|
||||||
src.exitEff = ele0.exitEff;
|
|
||||||
src.entryDur = ele0.entryDur;
|
|
||||||
src.exitDur = ele0.exitDur;
|
|
||||||
src.exitStart = ele0.exitStart;
|
|
||||||
src.isEntryRand = ele0.isEntryRand;
|
|
||||||
src.isExitRand = ele0.isExitRand;
|
|
||||||
}
|
|
||||||
src.endTime = src.startTime + picDur;
|
|
||||||
if(hasTTS) {
|
|
||||||
src.text = map.str("text");
|
|
||||||
if(src.text!=null) {
|
|
||||||
src.tts = new TextToSpeech(context, (int status)->{
|
|
||||||
Util.println("status: "+status+" "+(status==TextToSpeech.SUCCESS));
|
|
||||||
}, "com.iflytek.speechcloud");
|
|
||||||
src.tts.setSpeechRate(speechRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var imgView = new ImageView(context);
|
|
||||||
imgView.setImageURI(Uri.fromFile(new File(Util.programDir + "/" + map.stnn("id"))));
|
|
||||||
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
|
|
||||||
src.view = imgView;
|
|
||||||
src.view.setVisibility(GONE);
|
|
||||||
src.view.setLayoutParams(geo);
|
|
||||||
box.addView(src.view);
|
|
||||||
layer.srcs.add(src);
|
|
||||||
src = new Source();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(src.type.equals("DigitalClock")) src.view = new SrcDigitalClock(this, source);
|
|
||||||
else if(src.type.startsWith("DigitalClock")) src.view = new SrcDigiClock(this, source);
|
|
||||||
else if(src.type.equals("AnalogClock")) src.view = new SrcAnaClock(this, geo.width, geo.height, Util.programDir + "/" + id, source);
|
|
||||||
else if(src.type.equals("WebURL")) {
|
|
||||||
var webView = new WebView(context);
|
|
||||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
webView.setVerticalScrollBarEnabled(false);
|
|
||||||
webView.setHorizontalScrollBarEnabled(false);
|
|
||||||
webView.setInitialScale(source.intg("zoom", 100));
|
|
||||||
webView.getSettings().setJavaScriptEnabled(true);
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
@Override
|
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
|
||||||
view.loadUrl("javascript:window.scrollTo("+source.str("offX", "0")+", "+source.str("offY", "0")+")");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
webView.loadUrl(source.stnn("url"));
|
|
||||||
src.view = webView;
|
|
||||||
}
|
|
||||||
else if(src.type.equals("Timer")) src.view = new SrcTimer(this, source);
|
|
||||||
else if(src.type.equals("Countdown")) src.view = new SrcCountdown(this, source);
|
|
||||||
else if(src.type.startsWith("Environ")) src.view = new SrcEnviron(this, source);
|
|
||||||
else if(src.type.startsWith("Weather")) src.view = new SrcWeather(context, source);
|
|
||||||
else if(src.type.startsWith("VistorSource")) src.view = new SrcVisitor(this, source);
|
|
||||||
else if(src.type.startsWith("MultiLineText")) src.view = new SrcSensor(this, source, geo.width, geo.height);
|
|
||||||
else if(src.type.startsWith("SingleLineText")) {
|
|
||||||
var webView = new WebView(context);
|
|
||||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
webView.setVerticalScrollBarEnabled(false);
|
|
||||||
webView.setHorizontalScrollBarEnabled(false);
|
|
||||||
webView.setInitialScale(100);
|
|
||||||
webView.getSettings().setJavaScriptEnabled(true);
|
|
||||||
webView.setLayoutParams(new AbsLayout.LayoutParams(0, -geo.height, geo.width, geo.height));
|
|
||||||
var html = source.stnn("html");
|
|
||||||
var prefix = "<body style=\"color:#fff; margin:0; padding:0; white-space:nowrap; ";
|
|
||||||
var lineHeight = source.get("lineHeight");
|
|
||||||
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
|
|
||||||
var fontSize = lineHeight instanceof Number ? geo.height / ((Number)lineHeight).doubleValue() : geo.height;
|
|
||||||
prefix += "height:"+geo.height+"; font-size:"+fontSize+"px;\">";
|
|
||||||
var suffix = "</body><script>window.onload = function() {\n" +
|
|
||||||
"window.java.setWidth(document.body.scrollWidth);};</script>";
|
|
||||||
source.put("effect", "to left");
|
|
||||||
source.put("effectSpeed", source.intg("speed"));
|
|
||||||
var view = new SrcScroll(this, source, Bitmap.createBitmap(geo.width, geo.height, Bitmap.Config.ARGB_8888));
|
|
||||||
src.view = view;
|
|
||||||
webView.addJavascriptInterface(new Object() {
|
|
||||||
@JavascriptInterface
|
|
||||||
public void setWidth(int width) {
|
|
||||||
MainActivity.ins.runOnUiThread(() -> {
|
|
||||||
var hhh = view.imgs.get(0).getHeight();
|
|
||||||
var www = width + hhh;
|
|
||||||
webView.getLayoutParams().width = www;
|
|
||||||
view.imgs.set(0, Bitmap.createBitmap(www, hhh, Bitmap.Config.ARGB_8888));
|
|
||||||
box.addView(webView);
|
|
||||||
view.webView = webView;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, "java");
|
|
||||||
webView.loadDataWithBaseURL(null, prefix+html+suffix, "text/html", "UTF-8", null);
|
|
||||||
}
|
|
||||||
else continue;
|
|
||||||
if(src.view==null) continue;
|
|
||||||
src.view.setVisibility(GONE);
|
|
||||||
src.view.setLayoutParams(geo);
|
|
||||||
box.addView(src.view);
|
|
||||||
layer.srcs.add(src);
|
|
||||||
src = new Source();
|
|
||||||
}
|
|
||||||
if(bdEle!=null && ! sources.isEmpty()) {
|
|
||||||
JSList<Long> geometry = border.jslist("geometry");
|
|
||||||
src.startTime = bdStart;
|
|
||||||
src.endTime = bdEnd;
|
|
||||||
src.view = bdEle;
|
|
||||||
src.view.setVisibility(GONE);
|
|
||||||
box.addView(src.view, new AbsLayout.LayoutParams(geometry.get(0).intValue(), geometry.get(1).intValue(), geometry.get(2).intValue(), geometry.get(3).intValue()));
|
|
||||||
layer.srcs.add(src);
|
|
||||||
}
|
|
||||||
if(! layer.srcs.isEmpty()) page.layers.add(layer);
|
|
||||||
}
|
|
||||||
if(page.sDur==0) {
|
|
||||||
if(page.audioDur > 0) page.sDur = page.audioDur;
|
|
||||||
else continue;
|
|
||||||
}
|
|
||||||
page.tDur = page.sDur * page.repeatTimes;
|
|
||||||
for_layer: for(int ll=0; ll<page.layers.size(); ll++) {
|
|
||||||
var layer = page.layers.get(ll);
|
|
||||||
for(int ss=0; ss<layer.srcs.size(); ss++) {
|
|
||||||
var src = layer.srcs.get(ss);
|
|
||||||
if(src.startTime >= page.sDur) {
|
|
||||||
if(layer.srcs.size() > 1) layer.srcs.remove(ss--);
|
|
||||||
else {
|
|
||||||
page.layers.remove(ll--);
|
|
||||||
continue for_layer;
|
|
||||||
}
|
|
||||||
} else if(src.endTime > page.sDur) src.endTime = page.sDur;
|
|
||||||
}
|
|
||||||
if(layer.dur > page.sDur) layer.dur = page.sDur;
|
|
||||||
if(layer.dur == page.sDur) layer.isLoop = false;
|
|
||||||
}
|
|
||||||
pages.add(page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Page curAva() {
|
|
||||||
return pages.get(avas.get(curAva));
|
|
||||||
}
|
|
||||||
void release() {
|
|
||||||
try {
|
|
||||||
setVisibility(GONE);
|
|
||||||
View view;
|
|
||||||
for(int cc=0; cc<getChildCount(); cc++) if((view = getChildAt(cc)) instanceof SrcVideo) ((SrcVideo) view).release();
|
|
||||||
for(var page : pages) for(var layer : page.layers) for(var src : layer.srcs) if(src.tts!=null) src.tts.shutdown();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class Source {
|
|
||||||
View view;
|
|
||||||
long startMilli, endMilli = Long.MAX_VALUE;
|
|
||||||
int startTime, entryDur, exitStart = Integer.MAX_VALUE, exitDur, endTime, ff;
|
|
||||||
Effect entryEff, exitEff;
|
|
||||||
String type;
|
|
||||||
Uri uri;
|
|
||||||
TextToSpeech tts;
|
|
||||||
String text;
|
|
||||||
boolean isEntryRand, isExitRand;
|
|
||||||
|
|
||||||
void show() {
|
|
||||||
if(view.getVisibility()==VISIBLE) return;
|
|
||||||
view.setVisibility(VISIBLE);
|
|
||||||
ff = 0;
|
|
||||||
if(isEntryRand) entryEff = Effect.values()[Util.rand.nextInt(Effect.values().length)];
|
|
||||||
if(isExitRand) exitEff = Effect.values()[Util.rand.nextInt(Effect.values().length)];
|
|
||||||
resetEff();
|
|
||||||
doEff();
|
|
||||||
if(tts!=null) tts.speak(text, TextToSpeech.QUEUE_FLUSH, null, null);
|
|
||||||
}
|
|
||||||
void hide() {
|
|
||||||
if(view.getVisibility()!=VISIBLE) return;
|
|
||||||
view.setVisibility(GONE);
|
|
||||||
if(uri!=null) ((GifImageView) view).setImageURI(uri);
|
|
||||||
if(tts!=null && tts.isSpeaking()) tts.stop();
|
|
||||||
}
|
|
||||||
void doEff() {
|
|
||||||
var w = view.getLayoutParams().width;
|
|
||||||
var h = view.getLayoutParams().height;
|
|
||||||
if(ff < entryDur) {
|
|
||||||
if(entryEff == Effect.EXPAND_HOR) view.setScaleX(ff / (float) entryDur);
|
|
||||||
else if(entryEff == Effect.EXPAND_VER) view.setScaleY(ff / (float) entryDur);
|
|
||||||
else if(entryEff == Effect.EXPAND_LEFT) {
|
|
||||||
view.setScaleX(ff / (float) entryDur);
|
|
||||||
view.setTranslationX((1 - view.getScaleX()) * w / 2);
|
|
||||||
} else if(entryEff == Effect.EXPAND_TOP) {
|
|
||||||
view.setScaleY(ff / (float) entryDur);
|
|
||||||
view.setTranslationY((1 - view.getScaleY()) * h / 2);
|
|
||||||
} else if(entryEff == Effect.EXPAND_RIGHT) {
|
|
||||||
view.setScaleX(ff / (float) entryDur);
|
|
||||||
view.setTranslationX((view.getScaleX() - 1) * w / 2);
|
|
||||||
} else if(entryEff == Effect.EXPAND_BOTTOM) {
|
|
||||||
view.setScaleY(ff / (float) entryDur);
|
|
||||||
view.setTranslationY((view.getScaleY() - 1) * h / 2);
|
|
||||||
}
|
|
||||||
else if(entryEff == Effect.MOVE_LEFT) view.setTranslationX(w - ff*w/(float) entryDur);
|
|
||||||
else if(entryEff == Effect.MOVE_TOP) view.setTranslationY(h - ff*h/(float) entryDur);
|
|
||||||
else if(entryEff == Effect.MOVE_RIGHT) view.setTranslationX(ff*w/(float) entryDur - w);
|
|
||||||
else if(entryEff == Effect.MOVE_BOTTOM) view.setTranslationY(ff*h/(float) entryDur - h);
|
|
||||||
else if(entryEff == Effect.FADE) view.setAlpha(ff / (float) entryDur);
|
|
||||||
else if(entryEff == Effect.ZOOM) {
|
|
||||||
view.setScaleX(ff / (float) entryDur);
|
|
||||||
view.setScaleY(view.getScaleX());
|
|
||||||
} else if(entryEff == Effect.ZOOM_TL) {
|
|
||||||
var rate = ff / (float) entryDur;
|
|
||||||
view.setTranslationX((rate - 1) * w / 2);
|
|
||||||
view.setTranslationY((rate - 1) * h / 2);
|
|
||||||
view.setScaleX(rate);
|
|
||||||
view.setScaleY(rate);
|
|
||||||
} else if(entryEff == Effect.ZOOM_BR) {
|
|
||||||
var rate = ff / (float) entryDur;
|
|
||||||
view.setTranslationX((1 - rate) * w / 2);
|
|
||||||
view.setTranslationY((1 - rate) * h / 2);
|
|
||||||
view.setScaleX(rate);
|
|
||||||
view.setScaleY(rate);
|
|
||||||
} else if(entryEff == Effect.ZOOM_TR) {
|
|
||||||
var rate = ff / (float) entryDur;
|
|
||||||
view.setTranslationX((1 - rate) * w / 2);
|
|
||||||
view.setTranslationY((rate - 1) * h / 2);
|
|
||||||
view.setScaleX(rate);
|
|
||||||
view.setScaleY(rate);
|
|
||||||
} else if(entryEff == Effect.ZOOM_BL) {
|
|
||||||
var rate = ff / (float) entryDur;
|
|
||||||
view.setTranslationX((rate - 1) * w / 2);
|
|
||||||
view.setTranslationY((1 - rate) * h / 2);
|
|
||||||
view.setScaleX(rate);
|
|
||||||
view.setScaleY(rate);
|
|
||||||
} else if(entryEff == Effect.ROTATE) {
|
|
||||||
view.setScaleX(ff / (float) entryDur);
|
|
||||||
view.setScaleY(view.getScaleX());
|
|
||||||
view.setRotation(view.getScaleX() * 360);
|
|
||||||
} else if(entryEff == Effect.ROTATE_R) {
|
|
||||||
view.setScaleX(ff / (float) entryDur);
|
|
||||||
view.setScaleY(view.getScaleX());
|
|
||||||
view.setRotation(- view.getScaleX() * 360);
|
|
||||||
}
|
|
||||||
} else if(ff>=exitStart) {
|
|
||||||
var fff = ff - exitStart;
|
|
||||||
if(fff > exitDur) fff = exitDur;
|
|
||||||
if(exitEff == Effect.EXPAND_HOR) view.setScaleX(1 - fff / (float) exitDur);
|
|
||||||
else if(exitEff == Effect.EXPAND_VER) view.setScaleY(1 - fff / (float) exitDur);
|
|
||||||
else if(exitEff == Effect.EXPAND_LEFT) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setTranslationX(rate * w / 2);
|
|
||||||
} else if(exitEff == Effect.EXPAND_TOP) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setScaleY(1 - rate);
|
|
||||||
view.setTranslationY(rate * h / 2);
|
|
||||||
} else if(exitEff == Effect.EXPAND_RIGHT) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setTranslationX(- rate * w / 2);
|
|
||||||
} else if(exitEff == Effect.EXPAND_BOTTOM) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setScaleY(1 - rate);
|
|
||||||
view.setTranslationY(- rate * h / 2);
|
|
||||||
}
|
|
||||||
else if(exitEff == Effect.MOVE_LEFT) view.setTranslationX(- fff*w / (float) exitDur);
|
|
||||||
else if(exitEff == Effect.MOVE_RIGHT) view.setTranslationX(fff*w / (float) exitDur);
|
|
||||||
else if(exitEff == Effect.MOVE_TOP) view.setTranslationY(- fff*h / (float) exitDur);
|
|
||||||
else if(exitEff == Effect.MOVE_BOTTOM) view.setTranslationY(fff*h / (float) exitDur);
|
|
||||||
else if(exitEff == Effect.FADE) view.setAlpha(1 - fff / (float) exitDur);
|
|
||||||
else if(exitEff == Effect.ZOOM) {
|
|
||||||
view.setScaleX(1 - fff / (float) exitDur);
|
|
||||||
view.setScaleY(view.getScaleX());
|
|
||||||
} else if(exitEff == Effect.ZOOM_TL) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setTranslationX(- rate * w / 2);
|
|
||||||
view.setTranslationY(- rate * h / 2);
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setScaleY(1 - rate);
|
|
||||||
} else if(exitEff == Effect.ZOOM_BR) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setTranslationX(rate * w / 2);
|
|
||||||
view.setTranslationY(rate * h / 2);
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setScaleY(1 - rate);
|
|
||||||
} else if(exitEff == Effect.ZOOM_TR) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setTranslationX(rate * w / 2);
|
|
||||||
view.setTranslationY(- rate * h / 2);
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setScaleY(1 - rate);
|
|
||||||
} else if(exitEff == Effect.ZOOM_BL) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setTranslationX(- rate * w / 2);
|
|
||||||
view.setTranslationY(rate * h / 2);
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setScaleY(1 - rate);
|
|
||||||
} else if(exitEff == Effect.ROTATE) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setScaleY(view.getScaleX());
|
|
||||||
view.setRotation(rate * 360);
|
|
||||||
} else if(exitEff == Effect.ROTATE_R) {
|
|
||||||
var rate = fff / (float) exitDur;
|
|
||||||
view.setScaleX(1 - rate);
|
|
||||||
view.setScaleY(view.getScaleX());
|
|
||||||
view.setRotation(- rate * 360);
|
|
||||||
}
|
|
||||||
} else resetEff();
|
|
||||||
ff++;
|
|
||||||
}
|
|
||||||
void resetEff() {
|
|
||||||
view.setTranslationX(0);
|
|
||||||
view.setTranslationY(0);
|
|
||||||
view.setAlpha(1);
|
|
||||||
view.setScaleX(1);
|
|
||||||
view.setScaleY(1);
|
|
||||||
view.setRotation(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class Layer {
|
|
||||||
ArrayList<Source> srcs = new ArrayList<>();
|
|
||||||
long endMilli = Long.MAX_VALUE;
|
|
||||||
int dur;
|
|
||||||
boolean isLoop;
|
|
||||||
}
|
|
||||||
public enum Effect {
|
|
||||||
EXPAND_HOR, EXPAND_VER, EXPAND_LEFT, EXPAND_TOP, EXPAND_RIGHT, EXPAND_BOTTOM,
|
|
||||||
ZOOM, ZOOM_TL, ZOOM_TR, ZOOM_BR, ZOOM_BL,
|
|
||||||
ROTATE, ROTATE_R,
|
|
||||||
FADE,
|
|
||||||
MOVE_LEFT, MOVE_TOP, MOVE_RIGHT, MOVE_BOTTOM,
|
|
||||||
}
|
|
||||||
public static class Sche {
|
|
||||||
long startDate = -1, endDate = -1;
|
|
||||||
int startTime = -1, endTime = -1;
|
|
||||||
HashSet<Integer> weeks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Page {
|
|
||||||
String name;
|
|
||||||
ArrayList<Layer> layers = new ArrayList<>();
|
|
||||||
ArrayList<Sche> sches;
|
|
||||||
long endMilli = Long.MAX_VALUE;
|
|
||||||
int sDur, tDur, repeatTimes, audioDur;
|
|
||||||
|
|
||||||
void hide() {
|
|
||||||
for(var layer : layers) for(var src : layer.srcs) src.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMillis(long milli) {
|
|
||||||
endMilli = milli + sDur;
|
|
||||||
for(var layer : layers) {
|
|
||||||
if(layer.isLoop) layer.endMilli = milli + layer.dur;
|
|
||||||
for(var src : layer.srcs) {
|
|
||||||
src.endMilli = milli + src.endTime;
|
|
||||||
src.startMilli = milli + src.startTime;
|
|
||||||
if(src.startTime == 0) src.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void showHideSrcs(long milli) {
|
|
||||||
for(var layer : layers) {
|
|
||||||
for(var src : layer.srcs) {
|
|
||||||
if(src.view.getVisibility()==VISIBLE) {
|
|
||||||
if(milli >= src.endMilli) src.hide();
|
|
||||||
else src.doEff();
|
|
||||||
} else if(milli < src.endMilli && milli >= src.startMilli) src.show();
|
|
||||||
}
|
|
||||||
if(milli >= layer.endMilli) {
|
|
||||||
layer.endMilli += layer.dur;
|
|
||||||
for(var src : layer.srcs) {
|
|
||||||
src.endMilli += layer.dur;
|
|
||||||
src.startMilli += layer.dur;
|
|
||||||
if(src.startTime > 0) src.hide();
|
|
||||||
else src.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean isScheOn(long milli) {
|
|
||||||
if(sches==null) return false;
|
|
||||||
var local = milli + Dates.zoneOff;
|
|
||||||
var time = local % 86400000L;
|
|
||||||
int week = -1;
|
|
||||||
for(var sche : sches) {
|
|
||||||
if(notInRange(sche.startDate, local, sche.endDate)) continue;
|
|
||||||
if(notInRange(sche.startTime, time, sche.endTime)) continue;
|
|
||||||
if(sche.weeks==null) return true;
|
|
||||||
if(week==-1) week = ((int)(local / 86400000L) + 4) % 7;
|
|
||||||
if(sche.weeks.contains(week)) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public boolean notInRange(long start, long val, long end) {
|
|
||||||
if(end==-1) return false;
|
|
||||||
return start <= end ? !(val >= start && val < end) : val >= end && val < start;
|
|
||||||
}
|
|
||||||
SimpleDateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
SimpleDateFormat timeFmt = new SimpleDateFormat("HH:mm:ss");
|
|
||||||
public void parse(JSList<JSMap> schedules) {
|
|
||||||
if(schedules!=null) for(var schedule : schedules) {
|
|
||||||
var sche = new Sche();
|
|
||||||
var startTime = schedule.str("startTime");
|
|
||||||
if(startTime!=null) {
|
|
||||||
if(startTime.length()==5) startTime += ":00";
|
|
||||||
try {
|
|
||||||
sche.startTime = (int)timeFmt.parse(startTime).getTime()+Dates.zoneOff;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var endTime = schedule.str("endTime");
|
|
||||||
if(endTime!=null) {
|
|
||||||
if(endTime.length()==5) endTime += ":00";
|
|
||||||
try {
|
|
||||||
sche.endTime = (int)timeFmt.parse(endTime).getTime()+Dates.zoneOff;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(sche.startTime==sche.endTime) sche.startTime = sche.endTime = -1;
|
|
||||||
var startDate = schedule.str("startDate");
|
|
||||||
if(startDate!=null) {
|
|
||||||
try {
|
|
||||||
sche.startDate = dateFmt.parse(startDate).getTime() + Dates.zoneOff;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var endDate = schedule.str("endDate");
|
|
||||||
if(endDate!=null) {
|
|
||||||
try {
|
|
||||||
sche.endDate = dateFmt.parse(endDate).getTime() + Dates.zoneOff + 86400000L;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(sche.startDate==sche.endDate) sche.startDate = sche.endDate = -1;
|
|
||||||
JSList<Long> weekFilter = schedule.jslist("weekFilter");
|
|
||||||
if(weekFilter!=null && ! weekFilter.isEmpty() && weekFilter.size() < 7) {
|
|
||||||
sche.weeks = new HashSet<>();
|
|
||||||
for(var week : weekFilter) sche.weeks.add(week.intValue() % 7);
|
|
||||||
}
|
|
||||||
if(sches==null) sches = new ArrayList<>();
|
|
||||||
sches.add(sche);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.IBinder;
|
|
||||||
|
|
||||||
public class RestartService extends Service {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
Util.println("---- RestartService onCreate");
|
|
||||||
if(MainActivity.ins!=null) return;
|
|
||||||
var intent = new Intent(this, MainActivity.class);
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
throw new UnsupportedOperationException("Not yet implemented");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,351 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.RemoteException;
|
|
||||||
|
|
||||||
import com.xixun.util.PlayerInfo;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import gnph.util.IOs;
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.URLConn;
|
|
||||||
|
|
||||||
public class Server extends Service {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return binder;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerInfo.Stub binder = new PlayerInfo.Stub() {
|
|
||||||
@Override
|
|
||||||
public String getProgramName() throws RemoteException {
|
|
||||||
try {
|
|
||||||
var name = MainActivity.ins!=null && MainActivity.ins.progView!=null && ! MainActivity.ins.progView.avas.isEmpty() ? MainActivity.ins.progView.curAva().name : null;
|
|
||||||
Util.println("Server getProgramName. <-"+name);
|
|
||||||
return name;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion() throws RemoteException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setScreenWidth(int w) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setScreenHeight(int h) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void taskScreenshot(String cmdId) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExternalTemperature(float t) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInternalTemperature(float t) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHumidity(float h) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean forcePlayProgram(String pid) throws RemoteException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean finishForcePlay() throws RemoteException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCurProgramId() throws RemoteException {
|
|
||||||
Util.println("Server getCurProgramId ...");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUSBProgramPwd(String pwd) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ResourceType")
|
|
||||||
@Override
|
|
||||||
public String executeJosnCommand(String jsonstr) throws RemoteException {
|
|
||||||
Util.println("Server executeJsonCommand ..."+jsonstr);//{"_type":"DeleteTask","id":"652522a0e81d1e000009201a","sendTo":"yzd-player"}
|
|
||||||
String commandId = null;
|
|
||||||
try {
|
|
||||||
var jsonBytes = jsonstr.getBytes(StandardCharsets.UTF_8);
|
|
||||||
var json = JSMap.from(jsonBytes);
|
|
||||||
var _type = json.stnn("_type");
|
|
||||||
commandId = json.stnn("id");
|
|
||||||
if(_type.equals("PlayXixunTask") || _type.equals("PlayProgramTask")) {
|
|
||||||
var preDownloadURL = json.str("preDownloadURL");
|
|
||||||
if(preDownloadURL==null) preDownloadURL = Util.serverURL+"file/download?id=";
|
|
||||||
var task = json.jsmap("task");
|
|
||||||
JSList<JSMap> jpages = task.jslist("items");
|
|
||||||
int proSize = 0;
|
|
||||||
var needDowns = new ArrayList<NeedDowns>();
|
|
||||||
var hases = new HashSet<String>();
|
|
||||||
for(var pageMap : jpages) {
|
|
||||||
var _program = pageMap.jsmap("_program");
|
|
||||||
if(_program==null) continue;
|
|
||||||
proSize += _program.intg("totalSize");
|
|
||||||
var needDown = new NeedDowns();
|
|
||||||
needDown.prog = pageMap.stnn("_id");
|
|
||||||
needDowns.add(needDown);
|
|
||||||
JSList<JSMap> layers = _program.jslist("layers");
|
|
||||||
if(layers==null || layers.isEmpty()) continue;
|
|
||||||
for(int ll=layers.size()-1; ll>=0; ll--) {
|
|
||||||
var layer = new Prog.Layer();
|
|
||||||
JSList<JSMap> sources = layers.get(ll).jslist("sources");
|
|
||||||
// var border = layers.get(ll).jsmap("border");
|
|
||||||
// if(border!=null) {
|
|
||||||
// }
|
|
||||||
for(var source : sources) {
|
|
||||||
var type = source.stnn("_type");
|
|
||||||
if(type.equals("Video") || type.equals("Audio") || type.equals("Image") || type.startsWith("DigitalClock") || type.equals("Timer") || type.startsWith("Environ")) {
|
|
||||||
var filename = source.str("id");
|
|
||||||
if(filename==null) continue;
|
|
||||||
var url = source.stnn("url");
|
|
||||||
if(! url.startsWith("http")) url = preDownloadURL + filename;
|
|
||||||
var file = new File(Util.programDir+"/"+filename);
|
|
||||||
if(file.exists() && file.length() > 0) {
|
|
||||||
proSize -= file.length();
|
|
||||||
hases.add(filename);
|
|
||||||
} else needDown.srcs.add(new Src(filename, url));
|
|
||||||
} else if(type.startsWith("MultiPng") || type.equals("SplitText")) {
|
|
||||||
JSList<JSMap> imgs = source.jslist("arrayPics");
|
|
||||||
if(imgs.isEmpty()) continue;
|
|
||||||
for(var img : imgs) {
|
|
||||||
var filename = img.str("id");
|
|
||||||
if(filename==null) continue;
|
|
||||||
var url = img.stnn("url");
|
|
||||||
if(! url.startsWith("http")) url = preDownloadURL + filename;
|
|
||||||
var file = new File(Util.programDir+"/"+filename);
|
|
||||||
if(file.exists() && file.length() > 0) {
|
|
||||||
proSize -= file.length();
|
|
||||||
hases.add(filename);
|
|
||||||
} else needDown.srcs.add(new Src(filename, url));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int finalProSize = proSize;
|
|
||||||
String finalCommandId = commandId;
|
|
||||||
var notificationURL = json.str("notificationURL");
|
|
||||||
new Thread(()->{
|
|
||||||
Util.deleteFiles(finalProSize, hases);
|
|
||||||
for(var needDown : needDowns) {
|
|
||||||
int cnt = 0;
|
|
||||||
for(var src : needDown.srcs) {
|
|
||||||
try {
|
|
||||||
var in = new URLConn(src.url).in();
|
|
||||||
var fout = new FileOutputStream(Util.programDir+"/"+src.filename);
|
|
||||||
IOs.writeCloseIn(fout, in);
|
|
||||||
fout.flush();
|
|
||||||
fout.getFD().sync();
|
|
||||||
fout.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
cnt++;
|
|
||||||
if(notificationURL!=null && cnt!=needDown.srcs.size()) {
|
|
||||||
try {
|
|
||||||
new URLConn(notificationURL).timeout(5000).writeJson(new JSMap(
|
|
||||||
"commandId", finalCommandId,
|
|
||||||
"taskItemId", needDown.prog,
|
|
||||||
"progress", cnt*100/needDown.srcs.size()).toStr()).read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(notificationURL!=null) {
|
|
||||||
try {
|
|
||||||
new URLConn(notificationURL).timeout(5000).writeJson(new JSMap(
|
|
||||||
"commandId", finalCommandId,
|
|
||||||
"taskItemId", needDown.prog,
|
|
||||||
"progress", 100).toStr()).read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MainActivity.ins.runOnUiThread(() -> MainActivity.ins.initProg(jsonBytes));
|
|
||||||
}).start();
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "Success",
|
|
||||||
"result", "received command",
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId
|
|
||||||
).toString();
|
|
||||||
} else if(_type.equals("DeleteTask")) {
|
|
||||||
MainActivity.ins.runOnUiThread(() -> MainActivity.ins.delProgFile());
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "DataCallback",
|
|
||||||
"result", "received command",
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId
|
|
||||||
).toString();
|
|
||||||
} else if(_type.equals("PlayerStateCommand")) {
|
|
||||||
var descs = Util.getState(MainActivity.ins.state);
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "Success",
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId,
|
|
||||||
"code", MainActivity.ins.state,
|
|
||||||
"des_en", descs[0],
|
|
||||||
"des", descs[1]
|
|
||||||
).toString();
|
|
||||||
} else if(_type.equals("SetPlayerBackground")) {
|
|
||||||
var url = json.str("url");
|
|
||||||
if(url==null) new File(Util.backImgFile).delete();
|
|
||||||
else {
|
|
||||||
var fout = new FileOutputStream(Util.backImgFile);
|
|
||||||
IOs.write(fout, new URLConn(url).in());
|
|
||||||
fout.flush();
|
|
||||||
fout.getFD().sync();
|
|
||||||
fout.close();
|
|
||||||
}
|
|
||||||
MainActivity.ins.runOnUiThread(() -> {
|
|
||||||
MainActivity.ins.backView.cosImg = url==null ? null : BitmapFactory.decodeFile(Util.backImgFile);
|
|
||||||
MainActivity.ins.backView.invalidate();
|
|
||||||
});
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "Success",
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId
|
|
||||||
).toString();
|
|
||||||
} else if(_type.equals("GetPlayerBackground")) {
|
|
||||||
var backImg = new File(Util.backImgFile);
|
|
||||||
var img = Base64.getEncoder().encodeToString(IOs.readBytesClose(backImg.exists() ? new FileInputStream(backImg) : MainActivity.ins.getResources().openRawResource(R.drawable.back)));
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "DataCallback",
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId,
|
|
||||||
"img", img
|
|
||||||
).toString();
|
|
||||||
} else if(_type.equalsIgnoreCase("getProgramTask")) {
|
|
||||||
var task = JSMap.fromClose(new FileInputStream(Util.programDir+"/program")).jsmap("task");
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "ProgramTaskCallback",
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId,
|
|
||||||
"task", task
|
|
||||||
).toString();
|
|
||||||
}
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "Error",
|
|
||||||
"errorMessage", "Unknown Type: "+_type,
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId
|
|
||||||
).toString();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
return new JSMap(
|
|
||||||
"_type", "Error",
|
|
||||||
"errorMessage", Util.toStr(e),
|
|
||||||
"cardId", Util.getCardId(),
|
|
||||||
"commandId", commandId
|
|
||||||
).toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pausePlayer(boolean b) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPause() throws RemoteException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean clearTasks() throws RemoteException {
|
|
||||||
MainActivity.ins.runOnUiThread(() -> MainActivity.ins.delProgFile());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int countOfPrograms(int type) throws RemoteException {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playInsertTask(String pid) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stopInsertTask(String pid) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProgramTask() throws RemoteException {
|
|
||||||
try {
|
|
||||||
return IOs.readStrClose(new FileInputStream(Util.programDir+"/program"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
return Util.toStr(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUploadLogUrl(String playLog) throws RemoteException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUploadLogUrl() throws RemoteException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static class Src {
|
|
||||||
String filename;
|
|
||||||
String url;
|
|
||||||
|
|
||||||
public Src(String filename, String url) {
|
|
||||||
this.filename = filename;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static class NeedDowns {
|
|
||||||
String prog;
|
|
||||||
ArrayList<Src> srcs = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,235 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import static android.view.View.VISIBLE;
|
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.StatFs;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
import androidx.annotation.OptIn;
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import gnph.util.IOs;
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.NumFmts;
|
|
||||||
import gnph.util.O;
|
|
||||||
|
|
||||||
public class SocketThread extends Thread {
|
|
||||||
MainActivity main;
|
|
||||||
Socket socket;
|
|
||||||
InputStream in;
|
|
||||||
OutputStream out;
|
|
||||||
public SocketThread(MainActivity main, Socket socket) {
|
|
||||||
this.main = main;
|
|
||||||
this.socket = socket;
|
|
||||||
}
|
|
||||||
@OptIn(markerClass = UnstableApi.class) @Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
socket.setSoTimeout(600000);
|
|
||||||
Util.socketThreads.add(this);
|
|
||||||
in = socket.getInputStream();
|
|
||||||
out = socket.getOutputStream();
|
|
||||||
HashSet<String> hases = null;
|
|
||||||
ByteArrayOutputStream progJson = null;
|
|
||||||
while(true) {
|
|
||||||
var obj = JSMap.from(in);
|
|
||||||
var _type = obj.stnn("_type");
|
|
||||||
Util.println("_type: "+_type);
|
|
||||||
if("consult".equals(_type)) {
|
|
||||||
JSList<String> ids = obj.jslist("idList");
|
|
||||||
hases = new HashSet<>();
|
|
||||||
if(ids!=null) for(int i=0; i<ids.size(); i++) {
|
|
||||||
if(new File(Util.programDir + "/" + ids.get(i)).exists()) ids.remove(i--);
|
|
||||||
else hases.add(ids.get(i));
|
|
||||||
}
|
|
||||||
new JSMap("_type", _type, "idList", ids).write(out);
|
|
||||||
} else if("proStart".equals(_type)) {
|
|
||||||
Util.deleteFiles(obj.intg("proSize"), hases);
|
|
||||||
} else if("fileStart".equals(_type)) {
|
|
||||||
var size = obj.intg("size");
|
|
||||||
var name = obj.stnn("id");
|
|
||||||
Util.println(" size: " + size + " name: " + name);
|
|
||||||
if(name.equals("program")) {
|
|
||||||
progJson = new ByteArrayOutputStream();
|
|
||||||
IOs.writeCloseOut(progJson, in, size);
|
|
||||||
} else {
|
|
||||||
var fOut = new FileOutputStream(Util.programDir + "/" + name);
|
|
||||||
IOs.write(fOut, in, size);
|
|
||||||
fOut.flush();
|
|
||||||
fOut.getFD().sync();
|
|
||||||
fOut.close();
|
|
||||||
}
|
|
||||||
} else if("imgFileStart".equals(_type)) {
|
|
||||||
var size = obj.intg("size");
|
|
||||||
var fout = new FileOutputStream(Util.backImgFile);
|
|
||||||
IOs.write(fout, in, size);
|
|
||||||
fout.flush();
|
|
||||||
fout.getFD().sync();
|
|
||||||
fout.close();
|
|
||||||
main.runOnUiThread(() -> {
|
|
||||||
main.backView.cosImg = BitmapFactory.decodeFile(Util.backImgFile);
|
|
||||||
main.backView.invalidate();
|
|
||||||
});
|
|
||||||
} else if("imgFileEnd".equals(_type)) {
|
|
||||||
new JSMap("success", true).write(out);
|
|
||||||
} else if("proEnd".equals(_type)) {
|
|
||||||
new JSMap("success", progJson!=null).write(out);
|
|
||||||
if(progJson!=null) {
|
|
||||||
var json = progJson.toByteArray();
|
|
||||||
progJson = null;
|
|
||||||
main.runOnUiThread(() -> main.initProg(json));
|
|
||||||
}
|
|
||||||
} else if("DelPrograms".equals(_type)) {
|
|
||||||
var latch = new CountDownLatch(1);
|
|
||||||
var ok = new AtomicBoolean(false);
|
|
||||||
main.runOnUiThread(() -> {
|
|
||||||
ok.set(main.delProgFile());
|
|
||||||
latch.countDown();
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch (InterruptedException ignored) {}
|
|
||||||
new JSMap("success", ok.get()).write(out);
|
|
||||||
} else if("DelBackImg".equals(_type)) {
|
|
||||||
MainActivity.ins.runOnUiThread(() -> {
|
|
||||||
MainActivity.ins.backView.cosImg = null;
|
|
||||||
MainActivity.ins.backView.invalidate();
|
|
||||||
});
|
|
||||||
new JSMap("success", new File(Util.backImgFile).delete()).write(out);
|
|
||||||
} else if("getPlayerState".equals(_type)) {
|
|
||||||
var descs = Util.getState(main.state);
|
|
||||||
new JSMap(
|
|
||||||
"code", main.state,
|
|
||||||
"des_en", descs[0],
|
|
||||||
"des", descs[1]
|
|
||||||
).write(out);
|
|
||||||
} else if("GetInfo".equals(_type)) {
|
|
||||||
var writer = new OutputStreamWriter(out);
|
|
||||||
var Fmt = new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS");
|
|
||||||
var dur = 0;
|
|
||||||
if(main.progView!=null) for(var page : main.progView.pages) dur += page.tDur;
|
|
||||||
writer.append("ProgSend: ").append(Fmt.format(new File(Util.programDir + "/program").lastModified())).append(" ProgDur: ").append(String.valueOf(dur));
|
|
||||||
if(main.progView!=null) writer.append(" Pages: ").append(String.valueOf(main.progView.avas.size())).append(" / ").append(String.valueOf(main.progView.pages.size()));
|
|
||||||
writer.append("\n");
|
|
||||||
writer.append(" Launch: ").append(Fmt.format(main.launchMilli)).append("\n");
|
|
||||||
writer.append(" Sync: ").append(Fmt.format(main.syncMs)).append("\n");
|
|
||||||
if(main.progView==null) writer.append(" ProgView is Null\n");
|
|
||||||
else if(main.progView.avas.isEmpty()) writer.append(" No Avas\n");
|
|
||||||
else writer.append("Page End: ").append(Fmt.format(main.progView.curAva().endMilli)).append(" CurPage: ").append(String.valueOf(main.progView.curAva)).append(" / ").append(String.valueOf(main.progView.avas.get(main.progView.curAva))).append("\n");
|
|
||||||
writer.append(" Current: ").append(Fmt.format(System.currentTimeMillis())).append("\n");
|
|
||||||
var statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
|
||||||
writer.append(" Disk: ").append(String.valueOf(statFs.getTotalBytes()/1000000)).append(" ").append(String.valueOf(statFs.getAvailableBytes()/1000000)).append(" ").append(String.valueOf(statFs.getFreeBytes()/1000000)).append(" (total avail free)\n");
|
|
||||||
var actManager = (ActivityManager) main.getSystemService(main.ACTIVITY_SERVICE);
|
|
||||||
var memoryInfo = new ActivityManager.MemoryInfo();
|
|
||||||
actManager.getMemoryInfo(memoryInfo);
|
|
||||||
writer.append(" Memory: ").append(String.valueOf(memoryInfo.totalMem/1000000)).append(" ").append(String.valueOf(memoryInfo.availMem/1000000)).append(" ").append(String.valueOf(memoryInfo.threshold/1000000)).append(" ").append(String.valueOf(memoryInfo.lowMemory)).append(" (total avail threshold low)\n");
|
|
||||||
var runtime = Runtime.getRuntime();
|
|
||||||
writer.append("Runtime: ").append(String.valueOf(runtime.maxMemory()/1000000)).append(" ").append(String.valueOf(runtime.totalMemory()/1000000)).append(" ").append(NumFmts.cfix2().format(runtime.freeMemory()*0.000001)).append(" (max total free)\n");
|
|
||||||
// writer.append("/proc/stat\n");
|
|
||||||
// IOs.writeCloseIn(writer, new FileReader("/proc/stat"));
|
|
||||||
writer.append("\nSockets ").append(String.valueOf(Util.socketThreads.size())).append("\n");
|
|
||||||
for(var socket : Util.socketThreads) writer.append(" ").append(String.valueOf(socket.socket.getInetAddress())).append(":").append(String.valueOf(socket.socket.getPort())).append(" Buf:").append(String.valueOf(socket.socket.getReceiveBufferSize()/1000)).append("k SoLinger:").append(String.valueOf(socket.socket.getSoLinger())).append("\n");
|
|
||||||
|
|
||||||
writer.append("\n");
|
|
||||||
var latch = new CountDownLatch(1);
|
|
||||||
main.runOnUiThread(() -> {
|
|
||||||
if(main.progView!=null && ! main.progView.avas.isEmpty()) {
|
|
||||||
var page = main.progView.curAva();
|
|
||||||
for(var layer : page.layers) for(var src : layer.srcs) if(src.view.getVisibility()==VISIBLE) {
|
|
||||||
try {
|
|
||||||
if(src.view instanceof SrcVideo) {
|
|
||||||
var view = (SrcVideo) src.view;
|
|
||||||
if(view.ijkPlayer!=null) {
|
|
||||||
writer.append("VideoPlaying: ").append(String.valueOf(view.ijkPlayer.isPlaying())).append("\tCur/Dur: ").append(String.valueOf(view.ijkPlayer.getCurrentPosition())).append("/").append(String.valueOf(view.ijkPlayer.getDuration())).append("\n");
|
|
||||||
var mediaInfo = view.ijkPlayer.getMediaInfo();
|
|
||||||
var vStream = mediaInfo.mMeta.mVideoStream;
|
|
||||||
writer.append(" BitRate: ").append(String.valueOf(view.ijkPlayer.getBitRate()/1000)).append("k\tFPS: ").append(String.valueOf(vStream.mFpsNum/(float)vStream.mFpsDen)).append(" (").append(String.valueOf(vStream.mFpsNum)).append("/").append(String.valueOf(vStream.mFpsDen)).append(")\n");
|
|
||||||
var tracks = view.ijkPlayer.getTrackInfo();
|
|
||||||
for(var track : tracks) writer.append(" ").append(track.getInfoInline()).append("\n");
|
|
||||||
writer.append(" Format: ").append(mediaInfo.mMeta.mFormat).append("\n");
|
|
||||||
writer.append("VideoDecoder: ").append(mediaInfo.mVideoDecoder).append(" ").append(mediaInfo.mVideoDecoderImpl).append(" (").append(String.valueOf(view.ijkPlayer.getVideoDecoder())).append(")\n");
|
|
||||||
writer.append("AudioDecoder: ").append(mediaInfo.mAudioDecoder).append(" ").append(mediaInfo.mAudioDecoderImpl).append("\n");
|
|
||||||
//writer.append("PROFILE: ").append(mediaInfo.mMeta.getString(IjkMediaMeta.IJKM_KEY_CODEC_PROFILE)).append("\n");
|
|
||||||
} else if(view.exoPlayer!=null) {
|
|
||||||
writer.append("VideoPlaying: ").append(String.valueOf(view.exoPlayer.isPlaying())).append(" ").append(String.valueOf(view.exoPlayer.getCurrentPosition())).append("/").append(String.valueOf(view.exoPlayer.getDuration())).append("\n");
|
|
||||||
writer.append(" BitRate: ").append(String.valueOf(view.bitRate/1000)).append("k\n");
|
|
||||||
writer.append("PlaybackStat: ").append(view.getState()).append("\n");
|
|
||||||
writer.append(" PlayerError: ").append(String.valueOf(view.exoPlayer.getPlayerError())).append("\n");
|
|
||||||
writer.append(" VideoFormat: ").append(String.valueOf(view.exoPlayer.getVideoFormat())).append("\n");
|
|
||||||
var cnt = view.exoPlayer.getRendererCount();
|
|
||||||
for(int rr=0; rr<cnt; rr++) writer.append(" Renderer: ").append(String.valueOf(view.exoPlayer.getRendererType(rr))).append(" ").append(String.valueOf(view.exoPlayer.getRenderer(rr))).append("\n");
|
|
||||||
writer.append("getPlaybackParameters: ").append(String.valueOf(view.exoPlayer.getPlaybackParameters())).append("\n");
|
|
||||||
}
|
|
||||||
writer.append("\n");
|
|
||||||
} else if(src.view instanceof SrcWeather) {
|
|
||||||
var view = (SrcWeather) src.view;
|
|
||||||
writer.append("SrcWeather html: ").append(view.html).append("\n");
|
|
||||||
} else if(src.view instanceof WebView) {
|
|
||||||
var view = (WebView) src.view;
|
|
||||||
writer.append("Title: ").append(view.getTitle()).append("\n");
|
|
||||||
writer.append(" Url: ").append(view.getUrl()).append("\n");
|
|
||||||
writer.append("OrUrl: ").append(view.getOriginalUrl()).append("\n");
|
|
||||||
writer.append("Progress: ").append(String.valueOf(view.getProgress())).append("\n");
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
latch.countDown();
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch (InterruptedException ignored) {}
|
|
||||||
writer.flush();
|
|
||||||
} else if("GetLog".equals(_type)) {
|
|
||||||
out.write(Util.buf.toString().getBytes());
|
|
||||||
} else if("ListProgFiles".equals(_type)) {
|
|
||||||
var files = new File(Util.programDir).listFiles();
|
|
||||||
if(files == null) return;
|
|
||||||
Arrays.sort(files, (f1, f2) -> (int) (f2.lastModified() - f1.lastModified()));
|
|
||||||
var writer = new OutputStreamWriter(out);
|
|
||||||
for(var file : files) writer.append(file.getName()).append(' ').append(String.valueOf(file.length())).append('\n');
|
|
||||||
writer.append('\n');
|
|
||||||
writer.flush();
|
|
||||||
} else if("GetFile".equals(_type)) {
|
|
||||||
var name = obj.str("name");
|
|
||||||
if(name!=null) IOs.writeCloseIn(out, new FileInputStream(Util.programDir+"/"+name));
|
|
||||||
else new JSMap("code", 1, "msg", "name is null").write(out);
|
|
||||||
}
|
|
||||||
out.flush();
|
|
||||||
Util.println("cmd end");
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
var emsg = e.getMessage();
|
|
||||||
if(emsg!=null && ("Socket closed".equals(emsg) || emsg.endsWith("end-of-input"))) {
|
|
||||||
Util.println(emsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
main.runOnUiThread(() -> Util.makeText(main, Util.toStr(e)).show());
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
} finally {
|
|
||||||
Util.socketThreads.remove(this);
|
|
||||||
O.close(in, out, socket);
|
|
||||||
Util.println("conn end\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,166 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Path;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcAnaClock extends View implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
Calendar calendar;
|
|
||||||
Bitmap img;
|
|
||||||
int pinHourColor, pinMinColor, pinSecColor;
|
|
||||||
Path hPath, mPath, sPath;
|
|
||||||
float hAngle, mAngle, sAngle;
|
|
||||||
Paint paintPin = new Paint(), paint = new Paint();
|
|
||||||
boolean showSecHand;
|
|
||||||
|
|
||||||
public SrcAnaClock(Prog prog, float w, float h, String path, JSMap source) {
|
|
||||||
super(prog.getContext());
|
|
||||||
var timeZoneStr = source.str("timeZone");
|
|
||||||
//if(timeZoneStr!=null) timeZone = ZoneId.of(timeZoneStr);
|
|
||||||
var timeZone = timeZoneStr==null ? null : TimeZone.getTimeZone(timeZoneStr);
|
|
||||||
calendar = timeZone==null ? Calendar.getInstance() : Calendar.getInstance(timeZone);
|
|
||||||
|
|
||||||
var sideLen = Math.min(w, h);
|
|
||||||
var halfSide = sideLen / 2;
|
|
||||||
var lineWidth = sideLen / 128;
|
|
||||||
if(lineWidth < 1) lineWidth = 1;
|
|
||||||
|
|
||||||
paintPin.setAntiAlias(true);
|
|
||||||
paintPin.setStyle(Paint.Style.FILL_AND_STROKE);
|
|
||||||
paintPin.setStrokeWidth(lineWidth);
|
|
||||||
paintPin.setStrokeJoin(Paint.Join.ROUND);
|
|
||||||
paint.setAntiAlias(true);
|
|
||||||
paint.setStyle(Paint.Style.FILL);
|
|
||||||
var fontSize = sideLen / 11;
|
|
||||||
paint.setTextSize(fontSize);
|
|
||||||
|
|
||||||
img = BitmapFactory.decodeFile(path);
|
|
||||||
if(img==null) {
|
|
||||||
img = Bitmap.createBitmap((int)w, (int)h, Bitmap.Config.ARGB_8888);
|
|
||||||
var canvas = new Canvas(img);
|
|
||||||
canvas.translate(w / 2, h / 2);
|
|
||||||
if(source.bool("showBg")) {
|
|
||||||
var bgColor = Color.parseColor(source.stnn("bgColor"));
|
|
||||||
var opacity = source.dbl("opacity", -1);
|
|
||||||
if(opacity!=-1) bgColor = bgColor & 0x00ffffff | ((int)opacity*255)<<24;
|
|
||||||
paint.setColor(bgColor);
|
|
||||||
canvas.drawOval(-halfSide, -halfSide, halfSide, halfSide, paint);
|
|
||||||
}
|
|
||||||
var minMarkSize = sideLen/48;
|
|
||||||
var hourMarkSize = sideLen/32;
|
|
||||||
var scaleHourColor = Color.parseColor(source.stnn("scaleHourColor"));
|
|
||||||
var scaleMinColor = Color.parseColor(source.stnn("scaleMinColor"));
|
|
||||||
var showScaleNum = source.bool("showScaleNum");
|
|
||||||
var rScale = (sideLen - Math.max(minMarkSize, hourMarkSize)) / 2;
|
|
||||||
var rNum = halfSide * 0.83;
|
|
||||||
for(int i=0; i<60; i++) {
|
|
||||||
var k = i * Math.PI / 30;
|
|
||||||
var x = (float) (Math.sin(k) * rScale);
|
|
||||||
var y = (float) (-Math.cos(k) * rScale);
|
|
||||||
if(i % 5 > 0) {
|
|
||||||
var rr = minMarkSize / 2f;
|
|
||||||
paint.setColor(scaleMinColor);
|
|
||||||
canvas.drawOval(x-rr, y-rr, x+rr, y+rr, paint);
|
|
||||||
} else {
|
|
||||||
var rr = hourMarkSize / 2f;
|
|
||||||
paint.setColor(scaleHourColor);
|
|
||||||
canvas.drawOval(x-rr, y-rr, x+rr, y+rr, paint);
|
|
||||||
if(showScaleNum) {
|
|
||||||
var hour = i/5;
|
|
||||||
if(hour==0) hour = 12;
|
|
||||||
x = (float) (Math.sin(k) * rNum);
|
|
||||||
y = (float) (-Math.cos(k) * rNum);
|
|
||||||
canvas.drawText(String.valueOf(hour), x - fontSize*(hour<10 ? 0.28f : 0.6f), y + fontSize*0.355f, paint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pinHourColor = Color.parseColor(source.stnn("pinHourColor"));
|
|
||||||
pinMinColor = Color.parseColor(source.stnn("pinMinColor"));
|
|
||||||
pinSecColor = Color.parseColor(source.stnn("pinSecColor"));
|
|
||||||
var hhLen = (float) source.dbl("pinHourLen", 50);
|
|
||||||
var mhLen = (float) source.dbl("pinMinLen", 75);
|
|
||||||
var shLen = (float) source.dbl("pinSecLen", 100);
|
|
||||||
var hhWidth = (float) source.dbl("pinHourWidth", 15);
|
|
||||||
var mhWidth = (float) source.dbl("pinMinWidth", 10);
|
|
||||||
var shWidth = (float) source.dbl("pinSecWidth", 5);
|
|
||||||
showSecHand = source.bool("showSecond");
|
|
||||||
|
|
||||||
var rx = hhWidth*sideLen/400;
|
|
||||||
hPath = new Path();
|
|
||||||
hPath.moveTo(rx, 0);
|
|
||||||
hPath.lineTo(0, hhLen*sideLen/-200);
|
|
||||||
hPath.lineTo(-rx, 0);
|
|
||||||
hPath.close();
|
|
||||||
|
|
||||||
rx = mhWidth*sideLen/400;
|
|
||||||
mPath = new Path();
|
|
||||||
mPath.moveTo(rx, 0);
|
|
||||||
mPath.lineTo(0, mhLen*sideLen/-200);
|
|
||||||
mPath.lineTo(-rx, 0);
|
|
||||||
mPath.close();
|
|
||||||
rx = shWidth*sideLen/400;
|
|
||||||
sPath = new Path();
|
|
||||||
sPath.moveTo(rx, 0);
|
|
||||||
sPath.lineTo(0, shLen*sideLen/-200);
|
|
||||||
sPath.lineTo(-rx, 0);
|
|
||||||
sPath.close();
|
|
||||||
prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cal() {
|
|
||||||
//var time = timeZone==null ? LocalTime.now() : LocalTime.now(timeZone);
|
|
||||||
calendar.setTimeInMillis(lastSec*1000);
|
|
||||||
sAngle = calendar.get(Calendar.SECOND) * 6;
|
|
||||||
mAngle = calendar.get(Calendar.MINUTE) * 6 + sAngle/60;
|
|
||||||
hAngle = calendar.get(Calendar.HOUR_OF_DAY) * 30 + mAngle/12;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onDraw(@NonNull Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
if(img != null) canvas.drawBitmap(img, null, new RectF(0,0, getWidth(), getHeight()), null);
|
|
||||||
canvas.translate(getWidth()/2f, getHeight()/2f);
|
|
||||||
|
|
||||||
paintPin.setColor(pinHourColor);
|
|
||||||
canvas.rotate(hAngle);
|
|
||||||
canvas.drawPath(hPath, paintPin);
|
|
||||||
|
|
||||||
paintPin.setColor(pinMinColor);
|
|
||||||
canvas.rotate(mAngle-hAngle);
|
|
||||||
canvas.drawPath(mPath, paintPin);
|
|
||||||
if(showSecHand) {
|
|
||||||
paintPin.setColor(pinSecColor);
|
|
||||||
canvas.rotate(sAngle-mAngle);
|
|
||||||
canvas.drawPath(sPath, paintPin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long lastSec;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) return;
|
|
||||||
var sec = ms / 1000;
|
|
||||||
if(sec != lastSec) {
|
|
||||||
lastSec = sec;
|
|
||||||
cal();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Path;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcBorder extends View implements Choreographer.FrameCallback {
|
|
||||||
Bitmap img;
|
|
||||||
int[] lens = new int[4];
|
|
||||||
Path[] paths = new Path[4];
|
|
||||||
int[] offs = new int[]{0,0,0,0};
|
|
||||||
byte eff;
|
|
||||||
int interval;
|
|
||||||
|
|
||||||
public SrcBorder(Prog prog, String path, String effStr, int speed) {
|
|
||||||
super(prog.getContext());
|
|
||||||
img = BitmapFactory.decodeFile(path);
|
|
||||||
if(effStr.startsWith("ro")) eff = 'r';
|
|
||||||
else if(effStr.startsWith("bl")) eff = 'b';
|
|
||||||
if(eff=='r') interval = speed==1 ? 4 : (speed==2 ? 2 : 1);
|
|
||||||
else interval = speed==1 ? 30 : (speed==2 ? 15 : 4);
|
|
||||||
if(eff!=0) prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
||||||
super.onSizeChanged(w, h, oldw, oldh);
|
|
||||||
lens[0] = lens[2] = w;
|
|
||||||
lens[1] = lens[3] = h;
|
|
||||||
int bdWidth = img.getHeight();
|
|
||||||
for(int i=0; i<2; i++) {
|
|
||||||
Path path = new Path();
|
|
||||||
path.moveTo(0,0);
|
|
||||||
path.lineTo(lens[i], 0);
|
|
||||||
path.lineTo(lens[i] - bdWidth, bdWidth);
|
|
||||||
path.lineTo(bdWidth, bdWidth);
|
|
||||||
path.close();
|
|
||||||
paths[i] = paths[i+2] = path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
if(eff!='b' || offs[0] <= 0) {
|
|
||||||
int bdWidth = img.getHeight();
|
|
||||||
int bdLen = img.getWidth();
|
|
||||||
offs[1] = (offs[0] + lens[0]-bdWidth)%bdLen;
|
|
||||||
offs[2] = (offs[0] + lens[0]+lens[1]-bdWidth*2)%bdLen;
|
|
||||||
offs[3] = (offs[0] + lens[0]*2+lens[1]-bdWidth*3)%bdLen;
|
|
||||||
for(int ll=0; ll<4; ll++) {
|
|
||||||
canvas.save();
|
|
||||||
canvas.clipPath(paths[ll]);
|
|
||||||
for(int x=-offs[ll]; x<lens[ll]; x+=bdLen) canvas.drawBitmap(img, x, 0, null);
|
|
||||||
canvas.restore();
|
|
||||||
if(ll<3) {
|
|
||||||
canvas.translate(lens[ll], 0);
|
|
||||||
canvas.rotate(90);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int freshCnt;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) {
|
|
||||||
freshCnt = offs[0] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(freshCnt < interval) freshCnt++;
|
|
||||||
else {
|
|
||||||
freshCnt = 1;
|
|
||||||
if(eff=='r') {
|
|
||||||
if(offs[0] <= 0) offs[0] = img.getWidth()-1;
|
|
||||||
else offs[0]--;
|
|
||||||
} else offs[0] = offs[0]==0 ? 1 : 0;
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
public class SrcCopy extends View {
|
|
||||||
|
|
||||||
View view;
|
|
||||||
float scaleX = 1, scaleY = 1;
|
|
||||||
|
|
||||||
public SrcCopy(Context context, View view) {
|
|
||||||
super(context);
|
|
||||||
this.view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(@NonNull Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
if(view==null) return;
|
|
||||||
if(scaleX==0) {
|
|
||||||
if(view.getWidth()!=0&&getWidth()!=0) {
|
|
||||||
scaleX = getWidth() / (float) view.getWidth();
|
|
||||||
scaleY = getHeight() / (float) view.getHeight();
|
|
||||||
} else {
|
|
||||||
invalidate();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(scaleX!=1 || scaleY!=1) canvas.scale(scaleX, scaleY);
|
|
||||||
view.draw(canvas);
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.NumFmts;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcCountdown extends WebView implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
long targetTime;
|
|
||||||
String html, lineHeight, prefix;
|
|
||||||
boolean hasDay, hasHour, hasMin, hasSec;
|
|
||||||
|
|
||||||
public SrcCountdown(Prog prog, JSMap json) {
|
|
||||||
super(prog.getContext());
|
|
||||||
setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
setVerticalScrollBarEnabled(false);
|
|
||||||
setHorizontalScrollBarEnabled(false);
|
|
||||||
setInitialScale(100);
|
|
||||||
html = json.stnn("html");
|
|
||||||
lineHeight = json.str("lineHeight");
|
|
||||||
prefix = "<body style=\"color:#fff;margin:0;padding:0;";
|
|
||||||
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
|
|
||||||
prefix += "\">";
|
|
||||||
hasDay = html.contains("%d");
|
|
||||||
hasHour = html.contains("%h");
|
|
||||||
hasMin = html.contains("%m");
|
|
||||||
hasSec = html.contains("%s");
|
|
||||||
var time = json.stnn("time");
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
targetTime = new SimpleDateFormat("y-M-d H:m:s").parse(time).getTime() / 1000;
|
|
||||||
} catch (Exception e) {
|
|
||||||
targetTime = new SimpleDateFormat("y-M-d H:m").parse(time).getTime() / 1000;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
Util.makeText(prog.getContext(), Util.toStr(e)).show();
|
|
||||||
}
|
|
||||||
prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cal() {
|
|
||||||
var secs = targetTime - lastSec;
|
|
||||||
if(secs < 0) secs = 0;
|
|
||||||
var htm = html;
|
|
||||||
if(hasDay) {
|
|
||||||
htm = htm.replace("%d", Long.toString(secs/86400));
|
|
||||||
secs %= 86400;
|
|
||||||
}
|
|
||||||
if(hasHour) {
|
|
||||||
htm = htm.replace("%h", NumFmts.zz().format(secs/3600));
|
|
||||||
secs %= 3600;
|
|
||||||
}
|
|
||||||
if(hasMin) {
|
|
||||||
htm = htm.replace("%m", NumFmts.zz().format(secs/60));
|
|
||||||
secs %= 60;
|
|
||||||
}
|
|
||||||
if(hasSec) htm = htm.replace("%s", NumFmts.zz().format(secs));
|
|
||||||
loadDataWithBaseURL(null, prefix+htm+"</body>", "text/html", "UTF-8", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
long lastSec;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) return;
|
|
||||||
var sec = ms / 1000;
|
|
||||||
if(sec != lastSec) {
|
|
||||||
lastSec = sec;
|
|
||||||
cal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,275 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
import gnph.android.LinearBox;
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcDigiClock extends LinearBox implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
static final String[] weeks = {"SUN", "MON","TUE","WED","THU","FRI","SAT"};
|
|
||||||
HashMap<String, Bitmap> imgs = new HashMap<>();
|
|
||||||
ImageView[] yearComps = {new ImageView(getContext()), new ImageView(getContext()), new ImageView(getContext()), new ImageView(getContext())};
|
|
||||||
ImageView[] monthComps = {new ImageView(getContext()), new ImageView(getContext())};
|
|
||||||
ImageView[] dayComps = {new ImageView(getContext()), new ImageView(getContext())};
|
|
||||||
ImageView weekComp = new ImageView(getContext()), ampmComp = new ImageView(getContext());
|
|
||||||
ImageView[] hourComps = {new ImageView(getContext()), new ImageView(getContext())};
|
|
||||||
ImageView[] minComps = {new ImageView(getContext()), new ImageView(getContext())};
|
|
||||||
ImageView[] secComps = {new ImageView(getContext()), new ImageView(getContext())};
|
|
||||||
|
|
||||||
Calendar calendar;
|
|
||||||
SimpleDateFormat timeptn, dataFmt = new SimpleDateFormat("yyyyMMdd");
|
|
||||||
boolean multiline, weekly, isSingleMonth;
|
|
||||||
|
|
||||||
public SrcDigiClock(Prog prog, JSMap json) {
|
|
||||||
super(prog.getContext());
|
|
||||||
setGravity(Gravity.CENTER);
|
|
||||||
var timeZoneStr = json.str("timeZone");
|
|
||||||
//if(timeZoneStr!=null) timeZone = ZoneId.of(timeZoneStr);
|
|
||||||
var timeZone = timeZoneStr==null ? null : TimeZone.getTimeZone(timeZoneStr);
|
|
||||||
calendar = timeZone==null ? Calendar.getInstance() : Calendar.getInstance(timeZone);
|
|
||||||
var spaceWidth = json.dbl("spaceWidth");
|
|
||||||
JSList<JSMap> pics = json.jslist("arrayPics");
|
|
||||||
if(pics!=null && ! pics.isEmpty() && pics.get(0).containsKey("startX")) {
|
|
||||||
var big = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("id"));
|
|
||||||
for(var pic : pics) {
|
|
||||||
var startX = pic.intg("startX");
|
|
||||||
var startY = pic.intg("startY");
|
|
||||||
imgs.put(pic.str("name"), Bitmap.createBitmap(big, startX, startY, pic.intg("endX")-startX, pic.intg("endY")-startY));
|
|
||||||
}
|
|
||||||
} else for(var pic : pics) imgs.put(pic.str("name"), BitmapFactory.decodeFile(Util.programDir+"/"+pic.stnn("id")));
|
|
||||||
int dateStyle = json.intg("dateStyle");
|
|
||||||
isSingleMonth = dateStyle==1||dateStyle==2||dateStyle==4||dateStyle==6||dateStyle==8||dateStyle==10||dateStyle==12;
|
|
||||||
var timeSep = imgs.get("maohao");
|
|
||||||
weekly = json.bool("weekly");
|
|
||||||
var hour12 = json.bool("hour12");
|
|
||||||
var AmPm = hour12 && json.bool("AmPm");
|
|
||||||
timeptn = new SimpleDateFormat(hour12 ? "hhmmssa" : "HHmmss");
|
|
||||||
var hour = json.bool("hour");
|
|
||||||
var min = json.bool("min");
|
|
||||||
var sec = json.bool("sec");
|
|
||||||
multiline = json.bool("multiline");
|
|
||||||
addStretch();
|
|
||||||
if(multiline) {
|
|
||||||
vertical();
|
|
||||||
var hBox = new LinearBox(this).horizontal();
|
|
||||||
hBox.addStretch();
|
|
||||||
addDate(dateStyle, json, hBox);
|
|
||||||
hBox.addStretch();
|
|
||||||
if(weekly) {
|
|
||||||
hBox = new LinearBox(this).horizontal();
|
|
||||||
hBox.addStretch();
|
|
||||||
hBox.addView(weekComp);
|
|
||||||
hBox.addStretch();
|
|
||||||
}
|
|
||||||
hBox = new LinearBox(this).horizontal();
|
|
||||||
hBox.addStretch();
|
|
||||||
if(AmPm) {
|
|
||||||
hBox.addView(ampmComp);
|
|
||||||
hBox.addSpacing((int)spaceWidth);
|
|
||||||
}
|
|
||||||
if(hour) {
|
|
||||||
hBox.addView(hourComps[0]);
|
|
||||||
hBox.addView(hourComps[1]);
|
|
||||||
}
|
|
||||||
if(hour&&min) hBox.addView(newImgView(timeSep));
|
|
||||||
if(min) {
|
|
||||||
hBox.addView(minComps[0]);
|
|
||||||
hBox.addView(minComps[1]);
|
|
||||||
}
|
|
||||||
if(min&&sec) hBox.addView(newImgView(timeSep));
|
|
||||||
if(sec) {
|
|
||||||
hBox.addView(secComps[0]);
|
|
||||||
hBox.addView(secComps[1]);
|
|
||||||
}
|
|
||||||
hBox.addStretch();
|
|
||||||
} else {
|
|
||||||
setOrientation(HORIZONTAL);
|
|
||||||
addDate(dateStyle, json, this);
|
|
||||||
if(getChildCount()>1) addSpacing((int)spaceWidth*2);
|
|
||||||
if(weekly) {
|
|
||||||
addView(weekComp);
|
|
||||||
addSpacing((int)spaceWidth*2);
|
|
||||||
}
|
|
||||||
if(AmPm) {
|
|
||||||
addView(ampmComp);
|
|
||||||
addSpacing((int)spaceWidth);
|
|
||||||
}
|
|
||||||
if(hour) {
|
|
||||||
addView(hourComps[0]);
|
|
||||||
addView(hourComps[1]);
|
|
||||||
}
|
|
||||||
if(hour&&min) addView(newImgView(timeSep));
|
|
||||||
if(min) {
|
|
||||||
addView(minComps[0]);
|
|
||||||
addView(minComps[1]);
|
|
||||||
}
|
|
||||||
if(min&&sec) addView(newImgView(timeSep));
|
|
||||||
if(sec) {
|
|
||||||
addView(secComps[0]);
|
|
||||||
addView(secComps[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addStretch();
|
|
||||||
prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageView newImgView(Bitmap img) {
|
|
||||||
var imgv = new ImageView(getContext());
|
|
||||||
imgv.setImageBitmap(img);
|
|
||||||
return imgv;
|
|
||||||
}
|
|
||||||
void addDate(int dateStyle, JSMap layer, LinearLayout tar) {
|
|
||||||
if(dateStyle==0 || dateStyle==1) {
|
|
||||||
addYear(layer, tar, imgs.get("YEAR"));
|
|
||||||
if(layer.bool("month")) {
|
|
||||||
tar.addView(monthComps[0]);
|
|
||||||
tar.addView(monthComps[1]);
|
|
||||||
tar.addView(newImgView(imgs.get("MONTH")));
|
|
||||||
}
|
|
||||||
if(layer.bool("day")) {
|
|
||||||
tar.addView(dayComps[0]);
|
|
||||||
tar.addView(dayComps[1]);
|
|
||||||
tar.addView(newImgView(imgs.get("DAY")));
|
|
||||||
}
|
|
||||||
} else if(dateStyle==2 || dateStyle==3) {
|
|
||||||
var sep = imgs.get("xiegang");
|
|
||||||
if(layer.bool("month")) {
|
|
||||||
tar.addView(monthComps[0]);
|
|
||||||
tar.addView(monthComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
if(layer.bool("day")) {
|
|
||||||
tar.addView(dayComps[0]);
|
|
||||||
tar.addView(dayComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, null);
|
|
||||||
} else if(dateStyle==4 || dateStyle==5) {
|
|
||||||
var sep = imgs.get("xiegang");
|
|
||||||
if(layer.bool("day")) {
|
|
||||||
tar.addView(dayComps[0]);
|
|
||||||
tar.addView(dayComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
if(layer.bool("month")) {
|
|
||||||
tar.addView(monthComps[0]);
|
|
||||||
tar.addView(monthComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, null);
|
|
||||||
} else if(dateStyle==6 || dateStyle==7) {
|
|
||||||
var sep = imgs.get("xiegang");
|
|
||||||
addYear(layer, tar, sep);
|
|
||||||
if(layer.bool("month")) {
|
|
||||||
tar.addView(monthComps[0]);
|
|
||||||
tar.addView(monthComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
if(layer.bool("day")) {
|
|
||||||
tar.addView(dayComps[0]);
|
|
||||||
tar.addView(dayComps[1]);
|
|
||||||
}
|
|
||||||
} else if(dateStyle==8 || dateStyle==9) {
|
|
||||||
var sep = imgs.get("hengxian");
|
|
||||||
if(layer.bool("month")) {
|
|
||||||
tar.addView(monthComps[0]);
|
|
||||||
tar.addView(monthComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
if(layer.bool("day")) {
|
|
||||||
tar.addView(dayComps[0]);
|
|
||||||
tar.addView(dayComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, null);
|
|
||||||
} else if(dateStyle==10 || dateStyle==11) {
|
|
||||||
var sep = imgs.get("hengxian");
|
|
||||||
if(layer.bool("day")) {
|
|
||||||
tar.addView(dayComps[0]);
|
|
||||||
tar.addView(dayComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
if(layer.bool("month")) {
|
|
||||||
tar.addView(monthComps[0]);
|
|
||||||
tar.addView(monthComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, null);
|
|
||||||
} else if(dateStyle==12 || dateStyle==13) {
|
|
||||||
var sep = imgs.get("hengxian");
|
|
||||||
addYear(layer, tar, sep);
|
|
||||||
if(layer.bool("month")) {
|
|
||||||
tar.addView(monthComps[0]);
|
|
||||||
tar.addView(monthComps[1]);
|
|
||||||
tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
if(layer.bool("day")) {
|
|
||||||
tar.addView(dayComps[0]);
|
|
||||||
tar.addView(dayComps[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void addYear(JSMap layer, LinearLayout tar, Bitmap sep) {
|
|
||||||
if(layer.bool("year")) {
|
|
||||||
if(layer.bool("fullYear")) {
|
|
||||||
tar.addView(yearComps[0]);
|
|
||||||
tar.addView(yearComps[1]);
|
|
||||||
}
|
|
||||||
tar.addView(yearComps[2]);
|
|
||||||
tar.addView(yearComps[3]);
|
|
||||||
if(sep != null) tar.addView(newImgView(sep));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cal() {
|
|
||||||
//var dt = timeZone==null ? LocalDateTime.now() : LocalDateTime.now(timeZone);
|
|
||||||
calendar.setTimeInMillis(lastSec*1000);
|
|
||||||
var hms = timeptn.format(calendar.getTime());
|
|
||||||
ampmComp.setImageBitmap(imgs.get(calendar.get(Calendar.HOUR_OF_DAY) < 12?"AM":"PM"));
|
|
||||||
hourComps[0].setImageBitmap(imgs.get(hms.substring(0,1)));
|
|
||||||
hourComps[1].setImageBitmap(imgs.get(hms.substring(1,2)));
|
|
||||||
minComps[0].setImageBitmap(imgs.get(hms.substring(2,3)));
|
|
||||||
minComps[1].setImageBitmap(imgs.get(hms.substring(3,4)));
|
|
||||||
secComps[0].setImageBitmap(imgs.get(hms.substring(4,5)));
|
|
||||||
secComps[1].setImageBitmap(imgs.get(hms.substring(5,6)));
|
|
||||||
if(yearComps[0].getDrawable()==null || (calendar.get(Calendar.HOUR_OF_DAY)==0 && calendar.get(Calendar.SECOND)==0)) {
|
|
||||||
if(weekly) weekComp.setImageBitmap(imgs.get(weeks[calendar.get(Calendar.DAY_OF_WEEK) - 1]));
|
|
||||||
var ymd = dataFmt.format(calendar.getTime());
|
|
||||||
yearComps[0].setImageBitmap(imgs.get(ymd.substring(0,1)));
|
|
||||||
yearComps[1].setImageBitmap(imgs.get(ymd.substring(1,2)));
|
|
||||||
yearComps[2].setImageBitmap(imgs.get(ymd.substring(2,3)));
|
|
||||||
yearComps[3].setImageBitmap(imgs.get(ymd.substring(3,4)));
|
|
||||||
monthComps[0].setImageBitmap(isSingleMonth && ymd.charAt(4)=='0' ? null : imgs.get(ymd.substring(4,5)));
|
|
||||||
monthComps[1].setImageBitmap(imgs.get(ymd.substring(5,6)));
|
|
||||||
dayComps[0].setImageBitmap(isSingleMonth && ymd.charAt(6)=='0' ? null : imgs.get(ymd.substring(6,7)));
|
|
||||||
dayComps[1].setImageBitmap(imgs.get(ymd.substring(7,8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long lastSec;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) return;
|
|
||||||
var sec = ms / 1000;
|
|
||||||
if(sec != lastSec) {
|
|
||||||
lastSec = sec;
|
|
||||||
cal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.SimpleTimeZone;
|
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.NumFmts;
|
|
||||||
import gnph.util.Txts;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcDigitalClock extends WebView implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
String html, lineHeight, prefix;
|
|
||||||
Calendar calendar;
|
|
||||||
Locale locale;
|
|
||||||
boolean hasYear, hasMonthStr, hasMonth, hasDay, hasWeek, hasAP, hasHour, hasHour12, hasMin, hasSec;
|
|
||||||
|
|
||||||
public SrcDigitalClock(Prog prog, JSMap json) {
|
|
||||||
super(prog.getContext());
|
|
||||||
setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
setVerticalScrollBarEnabled(false);
|
|
||||||
setHorizontalScrollBarEnabled(false);
|
|
||||||
setInitialScale(100);
|
|
||||||
html = json.stnn("html");
|
|
||||||
lineHeight = json.str("lineHeight");
|
|
||||||
var timezone = json.dbl("timezone", 9999);
|
|
||||||
calendar = timezone==9999 ? Calendar.getInstance() : Calendar.getInstance(new SimpleTimeZone((int) (timezone*3600000), ""));
|
|
||||||
prefix = "<body style=\"color:#fff;margin:0;padding:0;";
|
|
||||||
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
|
|
||||||
prefix += "\">";
|
|
||||||
hasYear = html.contains("%y");
|
|
||||||
var hhh = html.replace("%Mw", "");
|
|
||||||
hasMonthStr = html.length()!=hhh.length();
|
|
||||||
hasMonth = hhh.contains("%M");
|
|
||||||
hasDay = html.contains("%d");
|
|
||||||
hasWeek = html.contains("%w");
|
|
||||||
hasAP = html.contains("%am");
|
|
||||||
hasHour = html.contains("%H");
|
|
||||||
hasHour12 = html.contains("%h");
|
|
||||||
hasMin = html.contains("%m");
|
|
||||||
hasSec = html.contains("%s");
|
|
||||||
try {
|
|
||||||
var lan = Txts.split(json.stnn("language"), "-", 1);
|
|
||||||
if(lan.isEmpty()) locale = Locale.getDefault();
|
|
||||||
else if(lan.size()==1) locale = lan.get(0).equals("cn") ? new Locale("zh", "CN") : new Locale(lan.get(0));
|
|
||||||
else locale = new Locale(lan.get(0), lan.get(1));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
Util.makeText(prog.getContext(), Util.toStr(e)).show();
|
|
||||||
}
|
|
||||||
prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cal() {
|
|
||||||
calendar.setTimeInMillis(lastSec*1000);
|
|
||||||
var htm = html;
|
|
||||||
if(hasYear) htm = htm.replace("%y", Long.toString(calendar.get(Calendar.YEAR)));
|
|
||||||
try {
|
|
||||||
if(hasMonthStr) htm = htm.replace("%Mw", calendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, locale));
|
|
||||||
if(hasWeek) htm = htm.replace("%w", calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale));
|
|
||||||
if(hasAP) htm = htm.replace("%am", calendar.getDisplayName(Calendar.AM_PM, Calendar.SHORT, locale));
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
if(hasMonth) htm = htm.replace("%M", NumFmts.zz().format(calendar.get(Calendar.MONTH)+1));
|
|
||||||
if(hasDay) htm = htm.replace("%d", NumFmts.zz().format(calendar.get(Calendar.DAY_OF_MONTH)));
|
|
||||||
if(hasHour) htm = htm.replace("%H", NumFmts.zz().format(calendar.get(Calendar.HOUR_OF_DAY)));
|
|
||||||
if(hasHour12) htm = htm.replace("%h", NumFmts.zz().format(caseThen(calendar.get(Calendar.HOUR), 0, 12)));
|
|
||||||
if(hasMin) htm = htm.replace("%m", NumFmts.zz().format(calendar.get(Calendar.MINUTE)));
|
|
||||||
if(hasSec) htm = htm.replace("%s", NumFmts.zz().format(calendar.get(Calendar.SECOND)));
|
|
||||||
loadDataWithBaseURL(null, prefix+htm+"</body>", "text/html", "UTF-8", null);
|
|
||||||
}
|
|
||||||
int caseThen(int val, int cas, int then) {
|
|
||||||
return val==cas ? then : val;
|
|
||||||
}
|
|
||||||
|
|
||||||
long lastSec;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) return;
|
|
||||||
var sec = ms / 1000;
|
|
||||||
if(sec != lastSec) {
|
|
||||||
lastSec = sec;
|
|
||||||
cal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,217 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.NumFmts;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcEnviron extends View implements Choreographer.FrameCallback, IntentReceiver {
|
|
||||||
static class Item {
|
|
||||||
String key;
|
|
||||||
Bitmap label;
|
|
||||||
ArrayList<Bitmap> nums = new ArrayList<>();
|
|
||||||
Bitmap unit;
|
|
||||||
|
|
||||||
public Item(String key, Bitmap label, Bitmap unit) {
|
|
||||||
this.key = key;
|
|
||||||
this.label = label;
|
|
||||||
this.unit = unit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static String[] directs = {"NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N"};
|
|
||||||
HashMap<String, Bitmap> imgMap = new HashMap<>();
|
|
||||||
Bitmap title;
|
|
||||||
ArrayList<Item> items = new ArrayList<>();
|
|
||||||
MainActivity act;
|
|
||||||
int alignType, spaceWidth, digitHeight;
|
|
||||||
int interval, cur, end, step;
|
|
||||||
boolean isScroll, isFirst = true;
|
|
||||||
|
|
||||||
public SrcEnviron(Prog prog, JSMap json) {
|
|
||||||
super(prog.getContext());
|
|
||||||
act = (MainActivity) prog.getContext();
|
|
||||||
alignType = json.intg("alignType");
|
|
||||||
spaceWidth = json.intg("spaceWidth");
|
|
||||||
isScroll = json.bool("bSingleScroll");
|
|
||||||
try {
|
|
||||||
setBackgroundColor(Color.parseColor(json.stnn("backColor")));
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
var values = json.jsmap("values");
|
|
||||||
if(values!=null) {
|
|
||||||
title = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("title"));
|
|
||||||
var entrys = values.entrySet();
|
|
||||||
for(var entry : entrys) imgMap.put(entry.getKey(), BitmapFactory.decodeFile(Util.programDir+"/"+entry.getValue()));
|
|
||||||
JSList<JSMap> jitems = json.jslist("items");
|
|
||||||
for(var jitem : jitems) {
|
|
||||||
var unit = jitem.str("unit");
|
|
||||||
items.add(new Item(jitem.str("name"), BitmapFactory.decodeFile(Util.programDir + "/" + jitem.stnn("label")), unit == null ? null : BitmapFactory.decodeFile(Util.programDir + "/" + unit)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
JSList<JSMap> pics = json.jslist("arrayPics");
|
|
||||||
if(pics!=null && ! pics.isEmpty() && pics.get(0).containsKey("startX")) {
|
|
||||||
var big = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("id"));
|
|
||||||
for(var pic : pics) {
|
|
||||||
var startX = pic.intg("startX");
|
|
||||||
var startY = pic.intg("startY");
|
|
||||||
imgMap.put(pic.str("name"), Bitmap.createBitmap(big, startX, startY, pic.intg("endX")-startX, pic.intg("endY")-startY));
|
|
||||||
}
|
|
||||||
} else for(var img : pics) imgMap.put(img.str("name"), BitmapFactory.decodeFile(Util.programDir+"/"+img.stnn("id")));
|
|
||||||
imgMap.put("-", imgMap.remove("minus_sign"));
|
|
||||||
title = imgMap.get("labeltitle");
|
|
||||||
if(json.bool("bTemperature")) items.add(new Item("temperature", imgMap.remove("labeltemperature"), imgMap.remove("unit_celsius")));
|
|
||||||
if(json.bool("bHumidity")) items.add(new Item("humidity", imgMap.remove("labelhumidity"), imgMap.remove("unit_humidity")));
|
|
||||||
if(json.bool("bNoise")) items.add(new Item("noise", imgMap.remove("labelnoise"), imgMap.remove("unit_noise")));
|
|
||||||
if(json.bool("bWindSpeed")) items.add(new Item("windSpeed", imgMap.remove("labelwindSpeed"), imgMap.remove("unit_windspeed")));
|
|
||||||
if(json.bool("bWindDirection")) items.add(new Item("windDirection", imgMap.remove("labelwindDirection"), null));
|
|
||||||
if(json.bool("bPM25")) items.add(new Item("pm2.5", imgMap.remove("labelpm25"), imgMap.get("unit_pm10")));
|
|
||||||
if(json.bool("bPM10")) items.add(new Item("pm10", imgMap.remove("labelpm10"), imgMap.get("unit_pm10")));
|
|
||||||
}
|
|
||||||
digitHeight = imgMap.get("0").getHeight();
|
|
||||||
if(spaceWidth==0) spaceWidth = imgMap.get("0").getWidth();
|
|
||||||
var scrollSpeed = json.dbl("scrollSpeed");
|
|
||||||
if(scrollSpeed==0) {
|
|
||||||
var scrollDur = json.dbl("iScrollSpeed");
|
|
||||||
if(scrollDur==0) return;
|
|
||||||
scrollSpeed = 1000 / scrollDur;
|
|
||||||
}
|
|
||||||
interval = step = 1;
|
|
||||||
if(scrollSpeed > 60) step = (int) Math.round(scrollSpeed/60);
|
|
||||||
else if(scrollSpeed < 60) interval = (int) Math.round(60/scrollSpeed);
|
|
||||||
if(isScroll) prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Method method;
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
method = Intent.class.getMethod("getExtra", String.class, Object.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void onReceive(Intent intent) {
|
|
||||||
try {
|
|
||||||
for(var item : items) {
|
|
||||||
item.nums.clear();
|
|
||||||
if(item.unit==null) {
|
|
||||||
var num = intent.getIntExtra(item.key, -1);
|
|
||||||
if(num>=0 && num<=15) item.nums.add(imgMap.get(directs[num]));
|
|
||||||
else {
|
|
||||||
var img = imgMap.get("-");
|
|
||||||
item.nums.add(img);
|
|
||||||
item.nums.add(img);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var num = ((Number) method.invoke(intent, item.key, -999)).floatValue();
|
|
||||||
var str = num==-999 || (num==-1 && ! item.key.endsWith("rature")) ? "--" : NumFmts.zz().format(num);
|
|
||||||
for(int cc=0; cc<str.length(); cc++) item.nums.add(imgMap.get(str.substring(cc, cc+1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
if(isFirst) {
|
|
||||||
isFirst = false;
|
|
||||||
onReceive(act.environIntent);
|
|
||||||
act.environs.add(this);
|
|
||||||
}
|
|
||||||
if(isScroll) {
|
|
||||||
var x = cur;
|
|
||||||
var cycCnt = cur==0 ? 1 : 2;
|
|
||||||
for(int ccc=0; ccc<cycCnt; ccc++) {
|
|
||||||
if(title!=null) {
|
|
||||||
canvas.drawBitmap(title, x, Math.round((getHeight() - title.getHeight()) / 2), null);
|
|
||||||
x += title.getWidth() + spaceWidth<<1;
|
|
||||||
}
|
|
||||||
var y = (int) Math.round((getHeight() - digitHeight) / 2);
|
|
||||||
for(var item : items) {
|
|
||||||
if(item.label !=null) {
|
|
||||||
canvas.drawBitmap(item.label, x, y, null);
|
|
||||||
x += item.label.getWidth();
|
|
||||||
}
|
|
||||||
for(var num : item.nums) if(num!=null) {
|
|
||||||
canvas.drawBitmap(num, x, y, null);
|
|
||||||
x += num.getWidth();
|
|
||||||
}
|
|
||||||
if(item.unit!=null) {
|
|
||||||
canvas.drawBitmap(item.unit, x, y, null);
|
|
||||||
x += item.unit.getWidth();
|
|
||||||
}
|
|
||||||
x += spaceWidth<<1;
|
|
||||||
}
|
|
||||||
if(ccc==0) end = -(x-cur-step);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var itemH = (double) getHeight() / (title!=null ? items.size()+1 : items.size());
|
|
||||||
int i = 0, x = 0;
|
|
||||||
if(title!=null) {
|
|
||||||
if(alignType==1) x = (getWidth() - title.getWidth()) / 2;
|
|
||||||
else if(alignType==2) x = getWidth() - title.getWidth();
|
|
||||||
canvas.drawBitmap(title, x, Math.round(itemH * i++ + (itemH - title.getHeight()) / 2), null);
|
|
||||||
}
|
|
||||||
for(var item : items) {
|
|
||||||
var y = (int) Math.round(itemH * i++ + (itemH - digitHeight) / 2);
|
|
||||||
x = 0;
|
|
||||||
if(alignType!=0) {
|
|
||||||
if(item.label !=null) x += item.label.getWidth();
|
|
||||||
for(var num : item.nums) if(num!=null) x += num.getWidth();
|
|
||||||
if(item.unit!=null) x += item.unit.getWidth();
|
|
||||||
x = getWidth() - x;
|
|
||||||
if(alignType==1) x /= 2;
|
|
||||||
}
|
|
||||||
if(item.label !=null) {
|
|
||||||
canvas.drawBitmap(item.label, x, y, null);
|
|
||||||
x += item.label.getWidth();
|
|
||||||
}
|
|
||||||
for(var num : item.nums) if(num!=null) {
|
|
||||||
canvas.drawBitmap(num, x, y, null);
|
|
||||||
x += num.getWidth();
|
|
||||||
}
|
|
||||||
if(item.unit!=null) canvas.drawBitmap(item.unit, x, y, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVisibilityAggregated(boolean isVisible) {
|
|
||||||
super.onVisibilityAggregated(isVisible);
|
|
||||||
if(! isVisible) {
|
|
||||||
act.environs.remove(this);
|
|
||||||
isFirst = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int freshCnt;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) {
|
|
||||||
freshCnt = cur = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(freshCnt < interval) freshCnt++;
|
|
||||||
else {
|
|
||||||
freshCnt = 1;
|
|
||||||
if(cur <= end) cur -= end;
|
|
||||||
else cur -= step;
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,174 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
|
|
||||||
public class SrcImage extends View implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
static final char effTypes[] = {'l', 't', 'r', 'b'};
|
|
||||||
Bitmap img;
|
|
||||||
Rect RECT = new Rect();
|
|
||||||
RectF rect;
|
|
||||||
Paint paint = new Paint();
|
|
||||||
int entryDur, exitStart;
|
|
||||||
char entryType, exitType;
|
|
||||||
boolean isEntryRand, isExitRand;
|
|
||||||
|
|
||||||
public SrcImage(Context context, JSMap map, int w, int h) {
|
|
||||||
super(context);
|
|
||||||
RECT.right = w;
|
|
||||||
RECT.bottom = h;
|
|
||||||
img = BitmapFactory.decodeFile(Util.programDir+"/"+map.stnn("id"));
|
|
||||||
if(img==null) return;
|
|
||||||
rect = new RectF(0, 0, w, h);
|
|
||||||
// entryDur = map.intg("entryEffectTimeSpan")*60;
|
|
||||||
// if(entryDur > 0) {
|
|
||||||
// var effStr = map.str("entryEffect");
|
|
||||||
// if(effStr == null || effStr.equalsIgnoreCase("None")) entryDur = 0;
|
|
||||||
// else if(effStr.equalsIgnoreCase("moving_left")) entryType = 'l';
|
|
||||||
// else if(effStr.equalsIgnoreCase("moving_top")) entryType = 't';
|
|
||||||
// else if(effStr.equalsIgnoreCase("moving_right")) entryType = 'r';
|
|
||||||
// else if(effStr.equalsIgnoreCase("moving_bottom")) entryType = 'b';
|
|
||||||
// else if(effStr.equalsIgnoreCase("alpha_in")) entryType = 'a';
|
|
||||||
// else if(effStr.equalsIgnoreCase("zoom_in")) entryType = 'z';
|
|
||||||
// else if(effStr.equalsIgnoreCase("Random")) isEntryRand = true;
|
|
||||||
// else entryDur = 0;
|
|
||||||
// }
|
|
||||||
// var exitDur = map.intg("exitEffectTimeSpan")*60;
|
|
||||||
// if(exitDur > 0) {
|
|
||||||
// var effStrExit = map.str("exitEffect");
|
|
||||||
// if(effStrExit == null || effStrExit.equalsIgnoreCase("None")) exitDur = 0;
|
|
||||||
// else if(effStrExit.equalsIgnoreCase("moving_left")) exitType = 'l';
|
|
||||||
// else if(effStrExit.equalsIgnoreCase("moving_top")) exitType = 't';
|
|
||||||
// else if(effStrExit.equalsIgnoreCase("moving_right")) exitType = 'r';
|
|
||||||
// else if(effStrExit.equalsIgnoreCase("moving_bottom")) exitType = 'b';
|
|
||||||
// else if(effStrExit.equalsIgnoreCase("alpha_out")) exitType = 'a';
|
|
||||||
// else if(effStrExit.equalsIgnoreCase("zoom_out")) exitType = 'z';
|
|
||||||
// else if(effStrExit.equalsIgnoreCase("Random")) isExitRand = true;
|
|
||||||
// else exitDur = 0;
|
|
||||||
// }
|
|
||||||
// exitStart = exitDur==0 ? Integer.MAX_VALUE : map.intg("timeSpan")*60 - exitDur;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
drawOther(canvas, this);
|
|
||||||
}
|
|
||||||
public void drawOther(Canvas canvas, View view) {
|
|
||||||
// var fff = ff==0 ? 0 : ff-1;
|
|
||||||
// if(fff < entryDur) {
|
|
||||||
// if(entryType=='l') {
|
|
||||||
// rect.left = RECT.right - fff*RECT.right/(float) entryDur;
|
|
||||||
// rect.right = rect.left + RECT.right;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(entryType=='r') {
|
|
||||||
// rect.left = -RECT.right + fff*RECT.right/(float) entryDur;
|
|
||||||
// rect.right = rect.left + RECT.right;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(entryType=='t') {
|
|
||||||
// rect.top = RECT.bottom - fff*RECT.bottom/(float) entryDur;
|
|
||||||
// rect.bottom = rect.top + RECT.bottom;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(entryType=='b') {
|
|
||||||
// rect.top = -RECT.bottom + fff*RECT.bottom/(float) entryDur;
|
|
||||||
// rect.bottom = rect.top + RECT.bottom;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(entryType=='a') {
|
|
||||||
// paint.setAlpha(fff*255/entryDur);
|
|
||||||
// canvas.drawBitmap(img, null, rect, paint);
|
|
||||||
// } else if(entryType=='z') {
|
|
||||||
// var haw = RECT.right/2f;
|
|
||||||
// var hah = RECT.bottom/2f;
|
|
||||||
// var ww = fff*haw/(float) entryDur;
|
|
||||||
// var hh = fff*hah/(float) entryDur;
|
|
||||||
// rect.left = haw - ww;
|
|
||||||
// rect.right = haw + ww;
|
|
||||||
// rect.top = hah - hh;
|
|
||||||
// rect.bottom = hah + hh;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// }
|
|
||||||
// } else if(fff>=exitStart) {
|
|
||||||
// fff -= exitStart;
|
|
||||||
// if(exitType=='l') {
|
|
||||||
// rect.left = - fff*RECT.right/(float) entryDur;
|
|
||||||
// rect.right = rect.left + RECT.right;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(exitType=='r') {
|
|
||||||
// rect.left = fff*RECT.right/(float) entryDur;
|
|
||||||
// rect.right = rect.left + RECT.right;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(exitType=='t') {
|
|
||||||
// rect.top = - fff*RECT.bottom/(float) entryDur;
|
|
||||||
// rect.bottom = rect.top + RECT.bottom;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(exitType=='b') {
|
|
||||||
// rect.top = fff*RECT.bottom/(float) entryDur;
|
|
||||||
// rect.bottom = rect.top + RECT.bottom;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// } else if(exitType=='a') {
|
|
||||||
// paint.setAlpha(255 - fff*255/entryDur);
|
|
||||||
// canvas.drawBitmap(img, null, rect, paint);
|
|
||||||
// } else if(exitType=='z') {
|
|
||||||
// var haw = RECT.right/2f;
|
|
||||||
// var hah = RECT.bottom/2f;
|
|
||||||
// var ww = haw - fff*haw/(float) entryDur;
|
|
||||||
// var hh = hah - fff*hah/(float) entryDur;
|
|
||||||
// rect.left = haw - ww;
|
|
||||||
// rect.right = haw + ww;
|
|
||||||
// rect.top = hah - hh;
|
|
||||||
// rect.bottom = hah + hh;
|
|
||||||
// canvas.drawBitmap(img, null, rect, null);
|
|
||||||
// }
|
|
||||||
// } else
|
|
||||||
canvas.drawBitmap(img, null, RECT, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
Choreographer choreographer = Choreographer.getInstance();
|
|
||||||
int ff;
|
|
||||||
boolean canAdd = true;
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void onVisibilityAggregated(boolean isVisible) {
|
|
||||||
// super.onVisibilityAggregated(isVisible);
|
|
||||||
// ff = 0;
|
|
||||||
// if(isVisible) {
|
|
||||||
// if(canAdd && (entryDur > 0 || exitStart < Integer.MAX_VALUE)) {
|
|
||||||
// choreographer.postFrameCallback(this);
|
|
||||||
// canAdd = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@Override
|
|
||||||
public void doFrame(long frameTimeNanos) {
|
|
||||||
if(! isShown()) {
|
|
||||||
canAdd = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(ff <= entryDur || ff>=exitStart) {
|
|
||||||
if(ff==0) {
|
|
||||||
if(isEntryRand) entryType = effTypes[Util.rand.nextInt(4)];
|
|
||||||
if(isExitRand) exitType = effTypes[Util.rand.nextInt(4)];
|
|
||||||
}
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
ff++;
|
|
||||||
choreographer.postFrameCallback(this);
|
|
||||||
canAdd = false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcScroll extends View implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
ArrayList<Bitmap> imgs = new ArrayList<>();
|
|
||||||
Rect rect = new Rect();
|
|
||||||
int interval, cur, end, step;
|
|
||||||
WebView webView;
|
|
||||||
char effect;
|
|
||||||
|
|
||||||
public SrcScroll(Prog prog, JSMap json, Bitmap img) {
|
|
||||||
super(prog.getContext());
|
|
||||||
if(img==null) img = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("id"));
|
|
||||||
var imgsWidth = img.getWidth();
|
|
||||||
if(imgsWidth <= 8192) imgs.add(img);
|
|
||||||
else {
|
|
||||||
var rem = img.getWidth();
|
|
||||||
do {
|
|
||||||
imgs.add(Bitmap.createBitmap(img, img.getWidth()-rem, 0, Math.min(8192, rem), img.getHeight()));
|
|
||||||
rem -= 8192;
|
|
||||||
} while (rem>0);
|
|
||||||
}
|
|
||||||
var effStr = json.str("effect");
|
|
||||||
if(effStr==null || effStr.equals("no")) return;
|
|
||||||
var scrollSpeed = json.dbl("scrollSpeed");
|
|
||||||
if(scrollSpeed==0) {
|
|
||||||
var scrollDur = json.dbl("effectSpeed");
|
|
||||||
if(scrollDur==0) return;
|
|
||||||
scrollSpeed = 1000 / scrollDur;
|
|
||||||
}
|
|
||||||
interval = step = 1;
|
|
||||||
if(scrollSpeed > 60) step = (int) Math.round(scrollSpeed/60);
|
|
||||||
else if(scrollSpeed < 60) interval = (int) Math.round(60/scrollSpeed);
|
|
||||||
int idx = effStr.lastIndexOf(' ');
|
|
||||||
if(idx > -1) {
|
|
||||||
effect = effStr.charAt(idx+1);
|
|
||||||
if(effect=='l') end = -(imgsWidth-step);
|
|
||||||
else if(effect=='r') end = imgsWidth-step;
|
|
||||||
else if(effect=='t') end = -(imgs.get(0).getHeight()-step);
|
|
||||||
else if(effect=='b') end = imgs.get(0).getHeight()-step;
|
|
||||||
else effect = 0;
|
|
||||||
}
|
|
||||||
if(effect!=0) prog.calls.add(this);
|
|
||||||
}
|
|
||||||
int aaaaaa;
|
|
||||||
@Override
|
|
||||||
protected void onDraw(@NonNull Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
if(imgs.isEmpty()) return;
|
|
||||||
try {
|
|
||||||
if(webView!=null && aaaaaa++>30) {
|
|
||||||
var canva = new Canvas(imgs.get(0));
|
|
||||||
webView.draw(canva);
|
|
||||||
webView.setVisibility(GONE);
|
|
||||||
webView = null;
|
|
||||||
freshCnt = cur = 0;
|
|
||||||
if(effect=='l') end = -(imgs.get(0).getWidth()-step);
|
|
||||||
else if(effect=='r') end = imgs.get(0).getWidth()-step;
|
|
||||||
}
|
|
||||||
drawOther(canvas);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
setVisibility(GONE);
|
|
||||||
imgs.clear();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void drawOther(Canvas canvas) {
|
|
||||||
if(! canvas.getClipBounds(rect)) {
|
|
||||||
rect.left = rect.top = 0;
|
|
||||||
rect.right = getWidth();
|
|
||||||
rect.bottom = getHeight();
|
|
||||||
}
|
|
||||||
if(effect=='l') {
|
|
||||||
int ii = 0, x = cur;
|
|
||||||
do {
|
|
||||||
if(x > rect.left-imgs.get(ii).getWidth() && x < rect.right) canvas.drawBitmap(imgs.get(ii), x, 0, null);
|
|
||||||
x += imgs.get(ii).getWidth();
|
|
||||||
if(++ii >= imgs.size()) ii = 0;
|
|
||||||
} while(x < rect.right);
|
|
||||||
} else if(effect=='r') {
|
|
||||||
int ii = imgs.size()-1, x = cur + getWidth();
|
|
||||||
boolean con1;
|
|
||||||
do {
|
|
||||||
x -= imgs.get(ii).getWidth();
|
|
||||||
con1 = x > rect.left-imgs.get(ii).getWidth();
|
|
||||||
if(con1 && x < rect.right) canvas.drawBitmap(imgs.get(ii), x, 0, null);
|
|
||||||
if(--ii < 0) ii = imgs.size()-1;
|
|
||||||
} while(con1);
|
|
||||||
} else if(effect=='t') {
|
|
||||||
int ii = 0, y = cur;
|
|
||||||
do {
|
|
||||||
if(y > rect.top-imgs.get(ii).getHeight() && y < rect.bottom) canvas.drawBitmap(imgs.get(ii), 0, y, null);
|
|
||||||
y += imgs.get(ii).getHeight();
|
|
||||||
if(++ii >= imgs.size()) ii = 0;
|
|
||||||
} while(y < rect.bottom);
|
|
||||||
} else if(effect=='b') {
|
|
||||||
int ii = imgs.size()-1, y = cur + getHeight();
|
|
||||||
boolean con1;
|
|
||||||
do {
|
|
||||||
y -= imgs.get(ii).getHeight();
|
|
||||||
con1 = y > rect.top-imgs.get(ii).getHeight();
|
|
||||||
if(con1 && y < rect.bottom) canvas.drawBitmap(imgs.get(ii), 0, y, null);
|
|
||||||
if(--ii < 0) ii = imgs.size()-1;
|
|
||||||
} while(con1);
|
|
||||||
} else canvas.drawBitmap(imgs.get(0), 0, 0, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
int freshCnt;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) {
|
|
||||||
freshCnt = cur = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(freshCnt < interval) freshCnt++;
|
|
||||||
else {
|
|
||||||
freshCnt = 1;
|
|
||||||
if(effect=='t' || effect=='l') {
|
|
||||||
if(cur <= end) cur -= end;
|
|
||||||
else cur -= step;
|
|
||||||
} else if(effect=='b' || effect=='r') {
|
|
||||||
if(cur >= end) cur -= end;
|
|
||||||
else cur += step;
|
|
||||||
}
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,160 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.NumFmts;
|
|
||||||
import gnph.util.Txts;
|
|
||||||
import gnph.util.URLConn;
|
|
||||||
|
|
||||||
public class SrcSensor extends WebView implements IntentReceiver, Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
static String directs[] = {"NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N"};
|
|
||||||
MainActivity act;
|
|
||||||
ArrayList<String> htmls;
|
|
||||||
String prefix, suffix, url, text;
|
|
||||||
int interval, pageDur, cur;
|
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
|
||||||
public SrcSensor(Prog prog, JSMap json, int width, int height) {
|
|
||||||
super(prog.getContext());
|
|
||||||
act = (MainActivity) prog.getContext();
|
|
||||||
setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
setVerticalScrollBarEnabled(false);
|
|
||||||
setHorizontalScrollBarEnabled(false);
|
|
||||||
setInitialScale(100);
|
|
||||||
getSettings().setJavaScriptEnabled(true);
|
|
||||||
|
|
||||||
var html = json.stnn("html").replace("%Co2", "%CO2").replace("<p>", "").trim();
|
|
||||||
htmls = Txts.split(html, "</p>", 1);
|
|
||||||
pageDur = json.intg("speed")*1000;
|
|
||||||
if(pageDur==0) pageDur = json.intg("timeSpan")*1000 / htmls.size();
|
|
||||||
url = json.str("sUrl");
|
|
||||||
interval = json.intg("sInterval") * 1000;
|
|
||||||
if(url!=null && interval>0 && html.contains("%s")) {
|
|
||||||
nextMs = System.currentTimeMillis() + interval;
|
|
||||||
Util.println("url: "+url);
|
|
||||||
try {
|
|
||||||
text = URLConn.send(url);
|
|
||||||
} catch (Exception e) {
|
|
||||||
text = "";
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prefix = "<body style=\"color:#fff;margin:0;padding:0;";
|
|
||||||
var lineHeight = json.str("lineHeight");
|
|
||||||
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
|
|
||||||
prefix += "width:"+width+"; height:"+height+"; position:relative;\"><div id=\"ppp\" style=\"position:absolute;\">";
|
|
||||||
suffix = "</div></body>";
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DecimalFormat fmt0 = NumFmts.newDecFmt("0");
|
|
||||||
public void onReceive(Intent intent) {
|
|
||||||
try {
|
|
||||||
var htm = htmls.get(cur);
|
|
||||||
var temp = intent.getFloatExtra("temperature", -99f);
|
|
||||||
var fa = temp * 1.8f + 32;
|
|
||||||
var noTemp = temp==-99f;
|
|
||||||
var t2 = noTemp ? "--" : NumFmts.fix2().format(temp);
|
|
||||||
var t1 = noTemp ? "--" : NumFmts.fix1().format(temp);
|
|
||||||
var tn = noTemp ? "--" : String.valueOf(temp);
|
|
||||||
var t0 = noTemp ? "--" : fmt0.format(temp);
|
|
||||||
var f2 = noTemp ? "--" : NumFmts.fix2().format(fa);
|
|
||||||
var f1 = noTemp ? "--" : NumFmts.fix1().format(fa);
|
|
||||||
var fn = noTemp ? "--" : String.valueOf(fa);
|
|
||||||
var f0 = noTemp ? "--" : fmt0.format(fa);
|
|
||||||
|
|
||||||
var humi = intent.getFloatExtra("humidity", -1);
|
|
||||||
var h = humi == -1 ? "--" : String.valueOf(humi);
|
|
||||||
var noise = intent.getFloatExtra("noise", -1);
|
|
||||||
var windSpeed = intent.getFloatExtra("windSpeed", -1);
|
|
||||||
int pm2 = intent.getIntExtra("pm2.5", -1);
|
|
||||||
int pm10 = intent.getIntExtra("pm10", -1);
|
|
||||||
int windDir = intent.getIntExtra("windDirection", -1);
|
|
||||||
int SO2 = intent.getIntExtra("SO2", -1);
|
|
||||||
int NO2 = intent.getIntExtra("NO2", -1);
|
|
||||||
int CO2 = intent.getIntExtra("CO2", -1);
|
|
||||||
int CO = intent.getIntExtra("CO", -1);
|
|
||||||
int O3 = intent.getIntExtra("O3", -1);
|
|
||||||
var pressure = intent.getFloatExtra("pressure", -1);
|
|
||||||
var rainfall = intent.getFloatExtra("rainfall", -1);
|
|
||||||
int radiation = intent.getIntExtra("radiation", -1);
|
|
||||||
int beam = intent.getIntExtra("beam", -1);
|
|
||||||
//int brightness = intent.getIntExtra("brightness", -1);
|
|
||||||
var dp = intent.getFloatExtra("dpTemperature", -99f);
|
|
||||||
|
|
||||||
if(text!=null) htm = htm.replace("%s", text);
|
|
||||||
htm = htm.replace("%T2", t2 + '℃').replace("%T1", t1 + '℃').replace("%T", tn + '℃').replace("%c2", t2).replace("%c1", t1).replace("%c", t0)
|
|
||||||
.replace("%t2", f2 + '℉').replace("%t1", f1 + '℉').replace("%t", fn + '℉').replace("%f2", f2).replace("%f1", f1).replace("%f", f0)
|
|
||||||
.replace("%RH", h+'%').replace("%h", h)
|
|
||||||
.replace("%ns", (noise == -1 ? "--" : String.valueOf(noise)) + "dB")
|
|
||||||
.replace("%ws", (windSpeed == -1 ? "--" : String.valueOf(windSpeed)) + "m/s")
|
|
||||||
.replace("%wd", windDir<0||windDir>=directs.length ? "--" : directs[windDir])
|
|
||||||
.replace("%pm2", (pm2 == -1 ? "--" : String.valueOf(pm2)) + "μg/m³")
|
|
||||||
.replace("%pm10", (pm10 == -1 ? "--" : String.valueOf(pm10)) + "μg/m³")
|
|
||||||
|
|
||||||
.replace("%SO2", (SO2 == -1 ? "--" : String.valueOf(SO2)) +"ppb")
|
|
||||||
.replace("%NO2", (NO2 == -1 ? "--" : String.valueOf(NO2)) +"ppb")
|
|
||||||
.replace("%CO2", (CO2 == -1 ? "--" : String.valueOf(CO2)) +"ppm")
|
|
||||||
.replace("%CO", (CO == -1 ? "--" : String.valueOf(CO)) +"ppb")
|
|
||||||
.replace("%O3", (O3 == -1 ? "--" : String.valueOf(O3)) +"ppb")
|
|
||||||
.replace("%dp", (dp == -1 ? "--" : String.valueOf(dp)) +'℃')
|
|
||||||
.replace("%pressure", (pressure == -1 ? "--" : String.valueOf(pressure))+"hPa")
|
|
||||||
.replace("%rainfall", (rainfall == -1 ? "--" : String.valueOf(rainfall))+"mm")
|
|
||||||
.replace("%radiation", (radiation == -1 ? "--" : String.valueOf(radiation))+"W/m²")
|
|
||||||
.replace("%bm", (beam == -1 ? "--" : String.valueOf(beam))+"lux");
|
|
||||||
|
|
||||||
loadDataWithBaseURL(null, prefix+htm+suffix, "text/html", "UTF-8", null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long nextPageMs, nextMs;
|
|
||||||
boolean isFirst = true;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) {
|
|
||||||
if(! isFirst) {
|
|
||||||
act.environs.remove(this);
|
|
||||||
isFirst = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean needRefresh = false;
|
|
||||||
if(isFirst) {
|
|
||||||
isFirst = false;
|
|
||||||
cur = 0;
|
|
||||||
nextPageMs = ms + pageDur;
|
|
||||||
act.environs.add(this);
|
|
||||||
needRefresh = true;
|
|
||||||
} else if(ms>=nextPageMs) {
|
|
||||||
nextPageMs += pageDur;
|
|
||||||
if(cur>=htmls.size()-1) cur = 0;
|
|
||||||
else cur++;
|
|
||||||
needRefresh = true;
|
|
||||||
}
|
|
||||||
if(text!=null && ms>=nextMs) {
|
|
||||||
nextMs = ms + interval;
|
|
||||||
try {
|
|
||||||
text = URLConn.send(url);
|
|
||||||
needRefresh = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(needRefresh) onReceive(act.environIntent);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,158 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.NumFmts;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcTimer extends View implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
HashMap<String, Bitmap> imgMap = new HashMap<>();
|
|
||||||
ArrayList<Bitmap> imgs = new ArrayList<>();
|
|
||||||
Bitmap text, day, hour, min, sec;
|
|
||||||
int spaceWidth, len;
|
|
||||||
Paint paint = new Paint();
|
|
||||||
long targetTime;
|
|
||||||
boolean isDown;
|
|
||||||
boolean isMultiline;
|
|
||||||
boolean hasDay, hasHour, hasMin, hasSec;
|
|
||||||
|
|
||||||
public SrcTimer(Prog prog, JSMap json) {
|
|
||||||
super(prog.getContext());
|
|
||||||
var imgEntrys = json.jsmap("imgs").entrySet();
|
|
||||||
for(var imgEntry : imgEntrys) imgMap.put(imgEntry.getKey(), BitmapFactory.decodeFile(Util.programDir+"/"+imgEntry.getValue()));
|
|
||||||
text = imgMap.get("text");
|
|
||||||
day = imgMap.get("day");
|
|
||||||
hour = imgMap.get("hour");
|
|
||||||
min = imgMap.get("min");
|
|
||||||
sec = imgMap.get("sec");
|
|
||||||
spaceWidth = (int) Math.round(json.dbl("spaceWidth"));
|
|
||||||
isDown = json.bool("isDown");
|
|
||||||
var dateFmt = new SimpleDateFormat("y-M-d H:m:s");
|
|
||||||
try {
|
|
||||||
targetTime = dateFmt.parse(json.stnn("targetTime")).getTime() / 1000;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.makeText(prog.getContext(), Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
hasDay = json.bool("hasDay");
|
|
||||||
hasHour = json.bool("hasHour");
|
|
||||||
hasMin = json.bool("hasMin");
|
|
||||||
hasSec = json.bool("hasSec");
|
|
||||||
isMultiline = json.bool("isMultiline");
|
|
||||||
paint.setTextAlign(Paint.Align.CENTER);
|
|
||||||
try {
|
|
||||||
setBackgroundColor(Color.parseColor(json.stnn("backColor")));
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cal() {
|
|
||||||
var secs = isDown ? targetTime - lastSec : lastSec - targetTime;
|
|
||||||
if(secs < 0) secs = 0;
|
|
||||||
len = 0;
|
|
||||||
imgs.clear();
|
|
||||||
if(text!=null && ! isMultiline) {
|
|
||||||
imgs.add(text);
|
|
||||||
imgs.add(null);
|
|
||||||
len += text.getWidth();
|
|
||||||
len += spaceWidth;
|
|
||||||
}
|
|
||||||
if(hasDay) {
|
|
||||||
var str = Long.toString(secs/86400);
|
|
||||||
for(int cc=0; cc<str.length(); cc++) {
|
|
||||||
var img = imgMap.get(str.substring(cc, cc+1));
|
|
||||||
imgs.add(img);
|
|
||||||
len += img.getWidth();
|
|
||||||
}
|
|
||||||
imgs.add(null);
|
|
||||||
imgs.add(day);
|
|
||||||
imgs.add(null);
|
|
||||||
len += day.getWidth();
|
|
||||||
len += spaceWidth * 2;
|
|
||||||
secs %= 86400;
|
|
||||||
}
|
|
||||||
if(hasHour) {
|
|
||||||
var str = NumFmts.zz().format(secs/3600);
|
|
||||||
for(int cc=0; cc<str.length(); cc++) {
|
|
||||||
var img = imgMap.get(str.substring(cc, cc+1));
|
|
||||||
imgs.add(img);
|
|
||||||
len += img.getWidth();
|
|
||||||
}
|
|
||||||
imgs.add(hour);
|
|
||||||
imgs.add(null);
|
|
||||||
len += hour.getWidth();
|
|
||||||
len += spaceWidth;
|
|
||||||
secs %= 3600;
|
|
||||||
}
|
|
||||||
if(hasMin) {
|
|
||||||
var str = NumFmts.zz().format(secs/60);
|
|
||||||
for(int cc=0; cc<str.length(); cc++) {
|
|
||||||
var img = imgMap.get(str.substring(cc, cc+1));
|
|
||||||
imgs.add(img);
|
|
||||||
len += img.getWidth();
|
|
||||||
}
|
|
||||||
imgs.add(min);
|
|
||||||
imgs.add(null);
|
|
||||||
len += min.getWidth();
|
|
||||||
len += spaceWidth;
|
|
||||||
secs %= 60;
|
|
||||||
}
|
|
||||||
if(hasSec) {
|
|
||||||
var str = NumFmts.zz().format(secs);
|
|
||||||
for(int cc=0; cc<str.length(); cc++) {
|
|
||||||
var img = imgMap.get(str.substring(cc, cc+1));
|
|
||||||
imgs.add(img);
|
|
||||||
len += img.getWidth();
|
|
||||||
}
|
|
||||||
imgs.add(sec);
|
|
||||||
imgs.add(null);
|
|
||||||
len += sec.getWidth();
|
|
||||||
len += spaceWidth;
|
|
||||||
}
|
|
||||||
imgs.remove(imgs.size()-1);
|
|
||||||
len -= spaceWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
int x = (getWidth()-len) / 2, y;
|
|
||||||
if(text!=null && isMultiline) {
|
|
||||||
y = getHeight() / 2;
|
|
||||||
canvas.drawBitmap(text, (getWidth()-text.getWidth()) / 2, y-text.getHeight(), null);
|
|
||||||
} else y = (getHeight() - imgs.get(0).getHeight()) / 2;
|
|
||||||
for(var img : imgs) {
|
|
||||||
if(img==null) x += spaceWidth;
|
|
||||||
else {
|
|
||||||
canvas.drawBitmap(img, x, y, null);
|
|
||||||
x += img.getWidth();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long lastSec;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) return;
|
|
||||||
var sec = ms / 1000;
|
|
||||||
if(sec != lastSec) {
|
|
||||||
lastSec = sec;
|
|
||||||
cal();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,143 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.SurfaceTexture;
|
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.TextureView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.OptIn;
|
|
||||||
import androidx.media3.common.MediaItem;
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
|
||||||
import androidx.media3.exoplayer.SeekParameters;
|
|
||||||
|
|
||||||
import tv.danmaku.ijk.media.player.IMediaPlayer;
|
|
||||||
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcVideo extends TextureView implements TextureView.SurfaceTextureListener {
|
|
||||||
|
|
||||||
String path;
|
|
||||||
float vol;
|
|
||||||
IjkMediaPlayer ijkPlayer;
|
|
||||||
ExoPlayer exoPlayer;
|
|
||||||
long bitRate;
|
|
||||||
boolean isLive;
|
|
||||||
|
|
||||||
public SrcVideo(Context context, String path, float vol, boolean isLive) {
|
|
||||||
super(context);
|
|
||||||
this.path = path;
|
|
||||||
this.vol = vol;
|
|
||||||
this.isLive = isLive;
|
|
||||||
initIjk();
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(markerClass = UnstableApi.class)
|
|
||||||
void initExo() {
|
|
||||||
exoPlayer = new ExoPlayer.Builder(getContext()).build();
|
|
||||||
exoPlayer.setMediaItem(MediaItem.fromUri(path));
|
|
||||||
exoPlayer.setRepeatMode(ExoPlayer.REPEAT_MODE_ONE);
|
|
||||||
exoPlayer.setSeekParameters(SeekParameters.CLOSEST_SYNC);
|
|
||||||
exoPlayer.setVolume(vol);
|
|
||||||
exoPlayer.setVideoTextureView(this);
|
|
||||||
exoPlayer.prepare();
|
|
||||||
}
|
|
||||||
void initIjk() {
|
|
||||||
ijkPlayer = new IjkMediaPlayer();
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-avc", 1);
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 0);
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1);
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48);
|
|
||||||
try {
|
|
||||||
setSurfaceTextureListener(this);
|
|
||||||
ijkPlayer.setDataSource(path);
|
|
||||||
ijkPlayer.setLooping(true);
|
|
||||||
ijkPlayer.setVolume(vol, vol);
|
|
||||||
ijkPlayer.setOnPreparedListener((IMediaPlayer var1)->{
|
|
||||||
ijkPlayer.setOnPreparedListener(null);
|
|
||||||
bitRate = ijkPlayer.getBitRate();
|
|
||||||
if(bitRate > 12000000) {
|
|
||||||
setSurfaceTextureListener(null);
|
|
||||||
release();
|
|
||||||
initExo();
|
|
||||||
}
|
|
||||||
if(isShown()) start();
|
|
||||||
});
|
|
||||||
ijkPlayer.setOnErrorListener((IMediaPlayer var1, int var2, int var3)->{
|
|
||||||
Util.println(" Video Error: "+var1+" "+var2+" "+var3);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
ijkPlayer.prepareAsync();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Util.makeText(getContext(), Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
ijkPlayer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surface, int width, int height) {
|
|
||||||
Util.println(" onSurfaceTextureAvailable "+(ijkPlayer==null?"ijkPlayer==null":""));
|
|
||||||
if(ijkPlayer!=null) ijkPlayer.setSurface(new Surface(surface));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surface, int width, int height) {}
|
|
||||||
@Override
|
|
||||||
public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surface) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {}
|
|
||||||
|
|
||||||
void start() {
|
|
||||||
if(ijkPlayer!=null) {
|
|
||||||
ijkPlayer.seekTo(0);
|
|
||||||
ijkPlayer.start();
|
|
||||||
} else if(exoPlayer!=null) {
|
|
||||||
if(exoPlayer.getPlaybackState()==ExoPlayer.STATE_IDLE) exoPlayer.prepare();
|
|
||||||
exoPlayer.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void pause() {
|
|
||||||
if(ijkPlayer!=null) {
|
|
||||||
ijkPlayer.pause();
|
|
||||||
ijkPlayer.seekTo(0);
|
|
||||||
}
|
|
||||||
if(exoPlayer!=null && exoPlayer.isPlaying()) {
|
|
||||||
exoPlayer.pause();
|
|
||||||
exoPlayer.seekToDefaultPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void release() {
|
|
||||||
if(ijkPlayer!=null) {
|
|
||||||
ijkPlayer.release();
|
|
||||||
ijkPlayer = null;
|
|
||||||
}
|
|
||||||
if(exoPlayer!=null) {
|
|
||||||
exoPlayer.release();
|
|
||||||
exoPlayer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String getState() {
|
|
||||||
if(exoPlayer!=null) {
|
|
||||||
var state = exoPlayer.getPlaybackState();
|
|
||||||
if(state==ExoPlayer.STATE_IDLE) return "STATE_IDLE";
|
|
||||||
if(state==ExoPlayer.STATE_BUFFERING) return "STATE_BUFFERING";
|
|
||||||
if(state==ExoPlayer.STATE_READY) return "STATE_READY";
|
|
||||||
if(state==ExoPlayer.STATE_ENDED) return "STATE_ENDED";
|
|
||||||
}
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVisibilityAggregated(boolean isVisible) {
|
|
||||||
super.onVisibilityAggregated(isVisible);
|
|
||||||
if(isVisible) {
|
|
||||||
start();
|
|
||||||
if(isLive) ijkPlayer.setVolume(vol, vol);
|
|
||||||
} else if(isLive) ijkPlayer.setVolume(0, 0);
|
|
||||||
else pause();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.graphics.SurfaceTexture;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.TextureView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
public class SrcVideo2 extends TextureView implements TextureView.SurfaceTextureListener, Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
float vol;
|
|
||||||
MediaPlayer player;
|
|
||||||
char state;
|
|
||||||
boolean isLive;
|
|
||||||
|
|
||||||
public SrcVideo2(Prog prog, String path, float vol, boolean isLive) {
|
|
||||||
super(prog.getContext());
|
|
||||||
this.vol = vol;
|
|
||||||
this.isLive = isLive;
|
|
||||||
player = new MediaPlayer();
|
|
||||||
setSurfaceTextureListener(this);
|
|
||||||
player.setLooping(true);
|
|
||||||
player.setVolume(vol, vol);
|
|
||||||
player.setOnPreparedListener((MediaPlayer player)->{
|
|
||||||
player.setOnPreparedListener(null);
|
|
||||||
Util.println(" ------Prepared isShown"+isShown()+" "+this);
|
|
||||||
if(isShown()) {
|
|
||||||
player.start();
|
|
||||||
state = 'S';
|
|
||||||
} else state = 'P';
|
|
||||||
prog.calls.add(this);
|
|
||||||
});
|
|
||||||
player.setOnErrorListener((MediaPlayer mp, int what, int extra)->{
|
|
||||||
var err = "Media Error: "+getErrorName(what)+". "+getErrorName(extra);
|
|
||||||
Util.makeText(getContext(), err).show();
|
|
||||||
Util.println(err);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
player.setDataSource(path);
|
|
||||||
player.prepareAsync();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
Util.makeText(getContext(), Util.toStr(e)).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surface, int width, int height) {
|
|
||||||
setSurfaceTextureListener(null);
|
|
||||||
if(player!=null) player.setSurface(new Surface(surface));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surface, int width, int height) {}
|
|
||||||
@Override
|
|
||||||
public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surface) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVisibilityAggregated(boolean isVisible) {
|
|
||||||
super.onVisibilityAggregated(isVisible);
|
|
||||||
if(state==0) return;
|
|
||||||
if(isVisible) {
|
|
||||||
Util.println(" ------start "+this);
|
|
||||||
player.seekTo(0);
|
|
||||||
player.start();
|
|
||||||
if(isLive) player.setVolume(vol, vol);
|
|
||||||
} else if(isLive) player.setVolume(0, 0);
|
|
||||||
else {
|
|
||||||
Util.println(" ------pause "+this);
|
|
||||||
player.pause();
|
|
||||||
player.seekTo(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void release() {
|
|
||||||
if(player!=null) {
|
|
||||||
player.release();
|
|
||||||
player = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
// if(isShown()) return;
|
|
||||||
// if(player!=null) {
|
|
||||||
// player.pause();
|
|
||||||
// player.seekTo(0);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
static String getErrorName(int code) {
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_UNKNOWN) return "UNKNOWN";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_SERVER_DIED) return "SERVER_DIED";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) return "NOT_VALID_FOR_PROGRESSIVE_PLAYBACK";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_IO) return "IO";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_MALFORMED) return "MALFORMED";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_UNSUPPORTED) return "UNSUPPORTED";
|
|
||||||
if(code==MediaPlayer.MEDIA_ERROR_TIMED_OUT) return "TIMED_OUT";
|
|
||||||
if(code==-2147483648) return "SYSTEM";
|
|
||||||
return "Unknown ("+code+")";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,138 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.SurfaceHolder;
|
|
||||||
import android.view.SurfaceView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.OptIn;
|
|
||||||
import androidx.media3.common.MediaItem;
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
|
||||||
import androidx.media3.exoplayer.SeekParameters;
|
|
||||||
|
|
||||||
import tv.danmaku.ijk.media.player.IMediaPlayer;
|
|
||||||
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcVideoSurface extends SurfaceView implements SurfaceHolder.Callback {
|
|
||||||
|
|
||||||
String path;
|
|
||||||
float vol;
|
|
||||||
IjkMediaPlayer ijkPlayer;
|
|
||||||
ExoPlayer exoPlayer;
|
|
||||||
long bitRate;
|
|
||||||
boolean isLive;
|
|
||||||
|
|
||||||
public SrcVideoSurface(Context context, String path, float vol, boolean isLive) {
|
|
||||||
super(context);
|
|
||||||
this.path = path;
|
|
||||||
this.vol = vol;
|
|
||||||
this.isLive = isLive;
|
|
||||||
initIjk();
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(markerClass = UnstableApi.class)
|
|
||||||
void initExo() {
|
|
||||||
exoPlayer = new ExoPlayer.Builder(getContext()).build();
|
|
||||||
exoPlayer.setMediaItem(MediaItem.fromUri(path));
|
|
||||||
exoPlayer.setRepeatMode(ExoPlayer.REPEAT_MODE_ONE);
|
|
||||||
exoPlayer.setSeekParameters(SeekParameters.CLOSEST_SYNC);
|
|
||||||
exoPlayer.setVolume(vol);
|
|
||||||
exoPlayer.setVideoSurfaceView(this);
|
|
||||||
exoPlayer.prepare();
|
|
||||||
}
|
|
||||||
void initIjk() {
|
|
||||||
ijkPlayer = new IjkMediaPlayer();
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-avc", 1);
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 0);
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1);
|
|
||||||
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48);
|
|
||||||
try {
|
|
||||||
getHolder().addCallback(this);
|
|
||||||
ijkPlayer.setDataSource(path);
|
|
||||||
ijkPlayer.setLooping(true);
|
|
||||||
ijkPlayer.setVolume(vol, vol);
|
|
||||||
ijkPlayer.setOnPreparedListener((IMediaPlayer var1)->{
|
|
||||||
ijkPlayer.setOnPreparedListener(null);
|
|
||||||
bitRate = ijkPlayer.getBitRate();
|
|
||||||
if(bitRate > 12000000) {
|
|
||||||
getHolder().removeCallback(this);
|
|
||||||
release();
|
|
||||||
initExo();
|
|
||||||
}
|
|
||||||
if(isShown()) start();
|
|
||||||
});
|
|
||||||
ijkPlayer.setOnErrorListener((IMediaPlayer var1, int var2, int var3)->{
|
|
||||||
Util.println(" Video Error: "+var1+" "+var2+" "+var3);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
ijkPlayer.prepareAsync();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Util.makeText(getContext(), Util.toStr(e)).show();
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
ijkPlayer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
|
||||||
Util.println(" surfaceCreated "+(ijkPlayer==null?"ijkPlayer==null":""));
|
|
||||||
if(ijkPlayer!=null) ijkPlayer.setDisplay(holder);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {}
|
|
||||||
@Override
|
|
||||||
public void surfaceDestroyed(@NonNull SurfaceHolder holder) {}
|
|
||||||
|
|
||||||
void start() {
|
|
||||||
if(ijkPlayer!=null) {
|
|
||||||
ijkPlayer.seekTo(0);
|
|
||||||
ijkPlayer.start();
|
|
||||||
} else if(exoPlayer!=null) {
|
|
||||||
if(exoPlayer.getPlaybackState()==ExoPlayer.STATE_IDLE) exoPlayer.prepare();
|
|
||||||
exoPlayer.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void pause() {
|
|
||||||
if(ijkPlayer!=null) {
|
|
||||||
ijkPlayer.pause();
|
|
||||||
ijkPlayer.seekTo(0);
|
|
||||||
}
|
|
||||||
if(exoPlayer!=null && exoPlayer.isPlaying()) {
|
|
||||||
exoPlayer.pause();
|
|
||||||
exoPlayer.seekToDefaultPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void release() {
|
|
||||||
if(ijkPlayer!=null) {
|
|
||||||
ijkPlayer.release();
|
|
||||||
ijkPlayer = null;
|
|
||||||
}
|
|
||||||
if(exoPlayer!=null) {
|
|
||||||
exoPlayer.release();
|
|
||||||
exoPlayer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String getState() {
|
|
||||||
if(exoPlayer!=null) {
|
|
||||||
var state = exoPlayer.getPlaybackState();
|
|
||||||
if(state==ExoPlayer.STATE_IDLE) return "STATE_IDLE";
|
|
||||||
if(state==ExoPlayer.STATE_BUFFERING) return "STATE_BUFFERING";
|
|
||||||
if(state==ExoPlayer.STATE_READY) return "STATE_READY";
|
|
||||||
if(state==ExoPlayer.STATE_ENDED) return "STATE_ENDED";
|
|
||||||
}
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVisibilityAggregated(boolean isVisible) {
|
|
||||||
super.onVisibilityAggregated(isVisible);
|
|
||||||
if(isVisible) {
|
|
||||||
start();
|
|
||||||
if(isLive) ijkPlayer.setVolume(vol, vol);
|
|
||||||
} else if(isLive) ijkPlayer.setVolume(0, 0);
|
|
||||||
else pause();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.view.Choreographer;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.URLConn;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcVisitor extends WebView implements Choreographer.FrameCallback {
|
|
||||||
|
|
||||||
String html, lineHeight, prefix, url;
|
|
||||||
|
|
||||||
public SrcVisitor(Prog prog, JSMap json) {
|
|
||||||
super(prog.getContext());
|
|
||||||
setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
setVerticalScrollBarEnabled(false);
|
|
||||||
setHorizontalScrollBarEnabled(false);
|
|
||||||
setInitialScale(100);
|
|
||||||
html = json.stnn("html").replace("%{yesterday.", "%{arr.-1.");
|
|
||||||
lineHeight = json.str("lineHeight");
|
|
||||||
url = json.str("url");
|
|
||||||
prefix = "<body style=\"color:#fff;margin:0;padding:0;";
|
|
||||||
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
|
|
||||||
prefix += "\">";
|
|
||||||
if(url!=null) prog.calls.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
try {
|
|
||||||
var htm = html;
|
|
||||||
try {
|
|
||||||
var res = JSMap.fromClose(new URLConn(url).in()).jsmap("data");
|
|
||||||
int lastEnd = 0, appendIdx = 0;
|
|
||||||
var buf = new StringBuilder(htm.length()*3/2);
|
|
||||||
int start;
|
|
||||||
while((start = htm.indexOf("%{", lastEnd)) > -1) {
|
|
||||||
int fds = start+2, fde = start+2;
|
|
||||||
try {
|
|
||||||
for(; fde<=fds+16; fde++) if(htm.charAt(fde)=='}') break;
|
|
||||||
if(fde > fds+16) {
|
|
||||||
lastEnd = fds;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
lastEnd = fde+1;
|
|
||||||
if(fde == fds) continue;
|
|
||||||
var fd = htm.substring(fds, fde);
|
|
||||||
var replace = res.str(fd);
|
|
||||||
if(replace!=null) {
|
|
||||||
buf.append(htm, appendIdx, start).append(replace);
|
|
||||||
appendIdx = lastEnd;
|
|
||||||
}
|
|
||||||
Util.println("Found: " + htm.substring(start, lastEnd)+" fd "+fd);
|
|
||||||
} catch (Exception e) {
|
|
||||||
lastEnd = fds;
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(buf.length()>0) {
|
|
||||||
if(appendIdx < htm.length()) buf.append(htm, appendIdx, htm.length());
|
|
||||||
htm = buf.toString();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
loadDataWithBaseURL(null, prefix+htm+"</body>", "text/html", "UTF-8", null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long nextMs;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFrame(long ms) {
|
|
||||||
if(! isShown()) return;
|
|
||||||
if(ms>=nextMs) {
|
|
||||||
nextMs = ms + 15000;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,244 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import gnph.util.JSList;
|
|
||||||
import gnph.util.JSMap;
|
|
||||||
import gnph.util.Txts;
|
|
||||||
import gnph.util.URLConn;
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
|
||||||
public class SrcWeather extends WebView {
|
|
||||||
|
|
||||||
String html, lineHeight, prefix, city;
|
|
||||||
int code;
|
|
||||||
boolean hasAQI, hasCur, hasDays;
|
|
||||||
|
|
||||||
public SrcWeather(Context context, JSMap json) {
|
|
||||||
super(context);
|
|
||||||
setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
setVerticalScrollBarEnabled(false);
|
|
||||||
setHorizontalScrollBarEnabled(false);
|
|
||||||
setInitialScale(100);
|
|
||||||
html = json.stnn("html").replace("%{yesterday.", "%{arr.-1.");
|
|
||||||
lineHeight = json.str("lineHeight");
|
|
||||||
city = json.str("city");
|
|
||||||
code = json.intg("code");
|
|
||||||
prefix = "<body style=\"color:#fff;margin:0;padding:0;";
|
|
||||||
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
|
|
||||||
prefix += "\">";
|
|
||||||
hasAQI = html.contains("%{aqi}");
|
|
||||||
hasCur = html.contains("%{current}") || html.contains("%{arr.0.");
|
|
||||||
hasDays = html.contains("%{arr.");
|
|
||||||
|
|
||||||
nextMs = System.currentTimeMillis() + 1800000;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
try {
|
|
||||||
var htm = html;
|
|
||||||
if(hasAQI) {
|
|
||||||
try {
|
|
||||||
JSList<JSMap> aqiForecast = JSMap.fromClose(new URLConn("https://www.ledokcloud.com/weather/whapi/json/alicityweather/aqiforecast5days").writeJson("{\"cityId\":"+code+"}").in()).jsmap("data").jslist("aqiForecast");
|
|
||||||
htm = htm.replace("%{aqi}", aqiForecast.get(1).stnn("value"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String type = null;
|
|
||||||
if(hasCur) {
|
|
||||||
try {
|
|
||||||
var condition = JSMap.fromClose(new URLConn("https://www.ledokcloud.com/weather/whapi/json/alicityweather/condition").writeJson("{\"cityId\":"+code+"}").in()).jsmap("data").jsmap("condition");
|
|
||||||
htm = htm.replace("%{current}", condition.stnn("temp"));
|
|
||||||
htm = htm.replace("%{arr.0.type}", type = condition.stnn("condition"));
|
|
||||||
htm = htm.replace("%{arr.0.fx}", condition.stnn("windDir"));
|
|
||||||
htm = htm.replace("%{arr.0.fl}", condition.stnn("windLevel"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(hasDays) {
|
|
||||||
try {
|
|
||||||
JSList<JSMap> days = JSMap.fromClose(new URLConn("https://www.ledokcloud.com/weather/whapi/json/alicityweather/forecast15days").writeJson("{\"cityId\":"+code+"}").in()).jsmap("data").jslist("forecast");
|
|
||||||
int lastEnd = 0, appendIdx = 0;
|
|
||||||
var buf = new StringBuilder(htm.length()*3/2);
|
|
||||||
int start;
|
|
||||||
while((start = htm.indexOf("%{arr.", lastEnd)) > -1) {
|
|
||||||
int idxS = start+6, idxE;
|
|
||||||
try {
|
|
||||||
if(htm.charAt(idxS+1)=='.') idxE = idxS+1;
|
|
||||||
else if(htm.charAt(idxS+2)=='.') idxE = idxS+2;
|
|
||||||
else {
|
|
||||||
lastEnd = idxS;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var dd = Integer.parseInt(htm.substring(idxS, idxE))+1;
|
|
||||||
if(dd>=days.size()) {
|
|
||||||
lastEnd = idxE+1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int fds = idxE+1, fde = idxE+2;
|
|
||||||
for(; fde<=fds+16; fde++) if(htm.charAt(fde)=='}') break;
|
|
||||||
if(fde > fds+16) {
|
|
||||||
lastEnd = fds;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var fd = htm.substring(fds, fde);
|
|
||||||
String replace = null;
|
|
||||||
if(fd.equals("date")) replace = days.get(dd).stnn("predictDate");
|
|
||||||
else if(fd.equals("type")) replace = days.get(dd).stnn("conditionDay");
|
|
||||||
else if(fd.equals("high")) replace = days.get(dd).stnn("tempDay");
|
|
||||||
else if(fd.equals("low")) replace = days.get(dd).stnn("tempNight");
|
|
||||||
else if(fd.equals("fx")) replace = days.get(dd).stnn("windDirDay");
|
|
||||||
else if(fd.equals("fl")) replace = days.get(dd).stnn("windLevelDay");
|
|
||||||
else if(fd.startsWith("img-")) {
|
|
||||||
var parts = Txts.split(fd, "-", 1);
|
|
||||||
String w = "32", h = "32";
|
|
||||||
if(parts.size()>=3) {
|
|
||||||
w = parts.get(1);
|
|
||||||
h = parts.get(2);
|
|
||||||
}
|
|
||||||
replace = "<img src=\"file:///android_asset/imgs/W" + dayImgMap.get(dd==1 ? type : days.get(dd).stnn("conditionDay")) + ".png\" style=\"width:"+w+"px; height:"+h+"px;\">";
|
|
||||||
}
|
|
||||||
lastEnd = fde+1;
|
|
||||||
if(replace!=null) {
|
|
||||||
buf.append(htm, appendIdx, start).append(replace);
|
|
||||||
appendIdx = lastEnd;
|
|
||||||
}
|
|
||||||
Util.println("Found: " + htm.substring(start, lastEnd)+" dd "+dd+" fd "+fd);
|
|
||||||
} catch (Exception e) {
|
|
||||||
lastEnd = idxS;
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(buf.length()>0) {
|
|
||||||
if(appendIdx < htm.length()) buf.append(htm, appendIdx, htm.length());
|
|
||||||
htm = buf.toString();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
loadDataWithBaseURL(null, prefix+htm+"</body>", "text/html", "UTF-8", null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Util.printStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static HashMap<String, String> dayImgMap = new HashMap<>();
|
|
||||||
static HashMap<String, String> nitImgMap = new HashMap<>();
|
|
||||||
|
|
||||||
static{
|
|
||||||
dayImgMap.put("晴", "0");
|
|
||||||
dayImgMap.put("大部晴朗", "0");
|
|
||||||
dayImgMap.put("多云", "1");
|
|
||||||
dayImgMap.put("少云", "1");
|
|
||||||
dayImgMap.put("阴", "2");
|
|
||||||
dayImgMap.put("阵雨", "3");
|
|
||||||
dayImgMap.put("局部阵雨", "3");
|
|
||||||
dayImgMap.put("小阵雨", "3");
|
|
||||||
dayImgMap.put("强阵雨", "3");
|
|
||||||
dayImgMap.put("阵雪", "13");
|
|
||||||
dayImgMap.put("小阵雪", "13");
|
|
||||||
dayImgMap.put("雾", "18");
|
|
||||||
dayImgMap.put("冻雾", "18");
|
|
||||||
dayImgMap.put("沙尘暴", "20");
|
|
||||||
dayImgMap.put("浮尘", "29");
|
|
||||||
dayImgMap.put("尘卷风", "29");
|
|
||||||
dayImgMap.put("扬沙", "29");
|
|
||||||
dayImgMap.put("强沙尘暴", "20");
|
|
||||||
dayImgMap.put("霾", "45");
|
|
||||||
dayImgMap.put("雷阵雨", "4");
|
|
||||||
dayImgMap.put("雷电", "4");
|
|
||||||
dayImgMap.put("雷暴", "4");
|
|
||||||
dayImgMap.put("雷阵雨伴有冰雹", "5");
|
|
||||||
dayImgMap.put("冰雹", "5");
|
|
||||||
dayImgMap.put("冰针", "5");
|
|
||||||
dayImgMap.put("冰粒", "5");
|
|
||||||
dayImgMap.put("雨夹雪", "6");
|
|
||||||
dayImgMap.put("小雨", "7");
|
|
||||||
dayImgMap.put("中雨", "8");
|
|
||||||
dayImgMap.put("大雨", "9");
|
|
||||||
dayImgMap.put("暴雨", "10");
|
|
||||||
dayImgMap.put("大暴雨", "10");
|
|
||||||
dayImgMap.put("特大暴雨", "10");
|
|
||||||
dayImgMap.put("小雪", "14");
|
|
||||||
dayImgMap.put("中雪", "15");
|
|
||||||
dayImgMap.put("大雪", "16");
|
|
||||||
dayImgMap.put("暴雪", "17");
|
|
||||||
dayImgMap.put("冻雨", "19");
|
|
||||||
dayImgMap.put("雪", "15");
|
|
||||||
dayImgMap.put("雨", "8");
|
|
||||||
dayImgMap.put("小到中雨", "7");
|
|
||||||
dayImgMap.put("中到大雨", "9");
|
|
||||||
dayImgMap.put("大到暴雨", "10");
|
|
||||||
dayImgMap.put("小到中雪", "15");
|
|
||||||
dayImgMap.put("无天气类型", "unknown");
|
|
||||||
|
|
||||||
nitImgMap.put("晴", "30");
|
|
||||||
nitImgMap.put("大部晴朗", "30");
|
|
||||||
nitImgMap.put("多云", "31");
|
|
||||||
nitImgMap.put("少云", "31");
|
|
||||||
nitImgMap.put("阴", "2");
|
|
||||||
nitImgMap.put("阵雨", "33");
|
|
||||||
nitImgMap.put("局部阵雨", "33");
|
|
||||||
nitImgMap.put("小阵雨", "33");
|
|
||||||
nitImgMap.put("强阵雨", "33");
|
|
||||||
nitImgMap.put("阵雪", "34");
|
|
||||||
nitImgMap.put("小阵雪", "4");
|
|
||||||
nitImgMap.put("雾", "32");
|
|
||||||
nitImgMap.put("冻雾", "32");
|
|
||||||
nitImgMap.put("沙尘暴", "36");
|
|
||||||
nitImgMap.put("浮尘", "35");
|
|
||||||
nitImgMap.put("尘卷风", "5");
|
|
||||||
nitImgMap.put("扬沙", "35");
|
|
||||||
nitImgMap.put("强沙尘暴", "36");
|
|
||||||
nitImgMap.put("霾", "46");
|
|
||||||
nitImgMap.put("雷阵雨", "4");
|
|
||||||
nitImgMap.put("雷电", "4");
|
|
||||||
nitImgMap.put("雷暴", "4");
|
|
||||||
nitImgMap.put("雷阵雨伴有冰雹", "5");
|
|
||||||
nitImgMap.put("冰雹", "5");
|
|
||||||
nitImgMap.put("冰针", "5");
|
|
||||||
nitImgMap.put("冰粒", "5");
|
|
||||||
nitImgMap.put("雨夹雪", "6");
|
|
||||||
nitImgMap.put("小雨", "7");
|
|
||||||
nitImgMap.put("中雨", "8");
|
|
||||||
nitImgMap.put("大雨", "9");
|
|
||||||
nitImgMap.put("暴雨", "10");
|
|
||||||
nitImgMap.put("大暴雨", "10");
|
|
||||||
nitImgMap.put("特大暴雨", "10");
|
|
||||||
nitImgMap.put("小雪", "14");
|
|
||||||
nitImgMap.put("中雪", "15");
|
|
||||||
nitImgMap.put("大雪", "16");
|
|
||||||
nitImgMap.put("暴雪", "17");
|
|
||||||
nitImgMap.put("冻雨", "19");
|
|
||||||
nitImgMap.put("雪", "15");
|
|
||||||
nitImgMap.put("雨", "8");
|
|
||||||
nitImgMap.put("小到中雨", "7");
|
|
||||||
nitImgMap.put("中到大雨", "9");
|
|
||||||
nitImgMap.put("大到暴雨", "10");
|
|
||||||
nitImgMap.put("小到中雪", "15");
|
|
||||||
nitImgMap.put("无天气类型", "unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
long nextMs;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVisibilityAggregated(boolean isVisible) {
|
|
||||||
super.onVisibilityAggregated(isVisible);
|
|
||||||
if(isVisible) {
|
|
||||||
var ms = System.currentTimeMillis();
|
|
||||||
if(ms>=nextMs) {
|
|
||||||
nextMs = ms + 1800000;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,123 +0,0 @@
|
||||||
package com.xixun.xixunplayer;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.StatFs;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.io.CharArrayWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
|
|
||||||
import gnph.util.IOs;
|
|
||||||
|
|
||||||
public class Util {
|
|
||||||
public static String serverURL;
|
|
||||||
public static int screenWidth, screenHeight;
|
|
||||||
public static boolean isScreenOn;
|
|
||||||
|
|
||||||
public static final Vector<SocketThread> socketThreads = new Vector<>();
|
|
||||||
public static final HashMap<Integer, String[]> stateDescs = new HashMap<>();
|
|
||||||
static {
|
|
||||||
stateDescs.put(1, new String[]{"Initialize", "初始化"});
|
|
||||||
stateDescs.put(2, new String[]{"Schedules is over", "定时节目结束"});
|
|
||||||
stateDescs.put(3, new String[]{"No programs waiting to be played", "无待播放的节目"});
|
|
||||||
stateDescs.put(4, new String[]{"Delete program", "删除节目"});
|
|
||||||
stateDescs.put(5, new String[]{"Program processing", "处理节目中"});
|
|
||||||
stateDescs.put(6, new String[]{"Program Processed", "处理节目完成"});
|
|
||||||
stateDescs.put(7, new String[]{"Program maybe error", "节目可能有误"});
|
|
||||||
stateDescs.put(8, new String[]{"Screen-off", "关屏"});
|
|
||||||
stateDescs.put(9, new String[]{"Program's area hasn't arrived yet", "定点节目不在范围"});
|
|
||||||
}
|
|
||||||
public static final String[] stateDescsUnknow = {"Unknown", "未知"};
|
|
||||||
|
|
||||||
public static StringBuffer buf = new StringBuffer();
|
|
||||||
public static Random rand = new Random();
|
|
||||||
|
|
||||||
public static void println(String msg) {
|
|
||||||
System.out.println(msg);
|
|
||||||
if(buf.length()>1000000) buf.replace(0, 100000, "");
|
|
||||||
buf.append(msg).append("\n");
|
|
||||||
}
|
|
||||||
public static void printStackTrace(Throwable e) {
|
|
||||||
println(toStackTrace(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toStr(Throwable e) {
|
|
||||||
var traces = e.getStackTrace();
|
|
||||||
var msg = e.toString();
|
|
||||||
for(var trace : traces) if(trace.getClassName().startsWith("com.xixun.xixunplayer.")) {
|
|
||||||
msg += "\n at "+trace.getFileName()+'.'+trace.getMethodName()+':'+trace.getLineNumber();
|
|
||||||
}
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
public static String toStackTrace(Throwable e) {
|
|
||||||
var out = new CharArrayWriter();
|
|
||||||
var writer = new PrintWriter(out);
|
|
||||||
e.printStackTrace(writer);
|
|
||||||
writer.flush();
|
|
||||||
return out.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Toast makeText(Context context, CharSequence text) {
|
|
||||||
var toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
|
|
||||||
toast.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0);
|
|
||||||
return toast;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getState(int state) {
|
|
||||||
var descs = stateDescs.get(state);
|
|
||||||
return descs!=null ? descs : stateDescsUnknow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String programDir, backImgFile;
|
|
||||||
public static String getCardId() {
|
|
||||||
try {
|
|
||||||
var bytes = IOs.readBytesClose(new FileInputStream(new File("/data/joey/signed/card.id")));
|
|
||||||
if(bytes.length < 40) return "";
|
|
||||||
byte[] cMyKey = new byte[]{97, 119, 38, 3, 46, 112, 36, 93, 58, 100, 103, 62, 115, 112, 114, 51, 43, 61, 2, 101, 119};
|
|
||||||
for(int i=0; i<20; ++i) bytes[i] = (byte) (bytes[i * 2] - cMyKey[i] - i - (bytes[i * 2 + 1] - 3));
|
|
||||||
var cardId = new String(bytes);
|
|
||||||
if(cardId.length() > 13) cardId = cardId.substring(0, 13);
|
|
||||||
return cardId;
|
|
||||||
} catch (IOException e) {
|
|
||||||
printStackTrace(e);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteFiles(long proSize, Set<String> keeps) {
|
|
||||||
var statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
|
||||||
var remain = statFs.getAvailableBytes() - proSize - 1048576;
|
|
||||||
if(remain >= 0) return;
|
|
||||||
var latch = new CountDownLatch(1);
|
|
||||||
MainActivity.ins.runOnUiThread(() -> {
|
|
||||||
System.out.println("stopProg ...");
|
|
||||||
MainActivity.ins.stopProg();
|
|
||||||
latch.countDown();
|
|
||||||
});
|
|
||||||
var files = new File(Util.programDir).listFiles();
|
|
||||||
if(files == null) return;
|
|
||||||
Arrays.sort(files, (f1, f2) -> (int) (f1.lastModified() - f2.lastModified()));
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch (InterruptedException ignored) {}
|
|
||||||
for(var file : files) {
|
|
||||||
if(keeps!=null && keeps.contains(file.getName())) continue;
|
|
||||||
var len = file.length();
|
|
||||||
if(file.delete()) {
|
|
||||||
remain += len;
|
|
||||||
if(remain>=0) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package gnph.android;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
public class LinearBox extends LinearLayout {
|
|
||||||
|
|
||||||
public LinearBox(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
public LinearBox(ViewGroup box) {
|
|
||||||
super(box.getContext());
|
|
||||||
box.addView(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinearBox horizontal() {
|
|
||||||
setOrientation(HORIZONTAL);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public LinearBox vertical() {
|
|
||||||
setOrientation(VERTICAL);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinearBox addSpacing(int spacing) {
|
|
||||||
if(getOrientation()==HORIZONTAL) addView(new View(getContext()), new LayoutParams(spacing, 0));
|
|
||||||
else addView(new View(getContext()), new LayoutParams(0, spacing));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public LinearBox addStretch() {
|
|
||||||
addView(new View(getContext()), new LayoutParams(0, 0,1));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 1.9 KiB |
|
@ -1,170 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="108dp"
|
|
||||||
android:height="108dp"
|
|
||||||
android:viewportWidth="108"
|
|
||||||
android:viewportHeight="108">
|
|
||||||
<path
|
|
||||||
android:fillColor="#3DDC84"
|
|
||||||
android:pathData="M0,0h108v108h-108z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M9,0L9,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,0L19,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M29,0L29,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M39,0L39,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M49,0L49,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M59,0L59,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M69,0L69,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M79,0L79,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M89,0L89,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M99,0L99,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,9L108,9"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,19L108,19"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,29L108,29"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,39L108,39"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,49L108,49"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,59L108,59"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,69L108,69"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,79L108,79"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,89L108,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,99L108,99"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,29L89,29"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,39L89,39"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,49L89,49"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,59L89,59"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,69L89,69"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,79L89,79"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M29,19L29,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M39,19L39,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M49,19L49,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M59,19L59,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M69,19L69,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M79,19L79,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
</vector>
|
|
|
@ -1,30 +0,0 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:aapt="http://schemas.android.com/aapt"
|
|
||||||
android:width="108dp"
|
|
||||||
android:height="108dp"
|
|
||||||
android:viewportWidth="108"
|
|
||||||
android:viewportHeight="108">
|
|
||||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
|
||||||
<aapt:attr name="android:fillColor">
|
|
||||||
<gradient
|
|
||||||
android:endX="85.84757"
|
|
||||||
android:endY="92.4963"
|
|
||||||
android:startX="42.9492"
|
|
||||||
android:startY="49.59793"
|
|
||||||
android:type="linear">
|
|
||||||
<item
|
|
||||||
android:color="#44000000"
|
|
||||||
android:offset="0.0" />
|
|
||||||
<item
|
|
||||||
android:color="#00000000"
|
|
||||||
android:offset="1.0" />
|
|
||||||
</gradient>
|
|
||||||
</aapt:attr>
|
|
||||||
</path>
|
|
||||||
<path
|
|
||||||
android:fillColor="#FFFFFF"
|
|
||||||
android:fillType="nonZero"
|
|
||||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
|
||||||
android:strokeWidth="1"
|
|
||||||
android:strokeColor="#00000000" />
|
|
||||||
</vector>
|
|
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 982 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 7.6 KiB |
|
@ -1,5 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<color name="black">#FF000000</color>
|
|
||||||
<color name="white">#FFFFFFFF</color>
|
|
||||||
</resources>
|
|
|
@ -1,3 +0,0 @@
|
||||||
<resources>
|
|
||||||
<string name="app_name">XixunPlayer</string>
|
|
||||||
</resources>
|
|
|
@ -1,4 +0,0 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
plugins {
|
|
||||||
id 'com.android.application' version '8.1.1' apply false
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
# Project-wide Gradle settings.
|
|
||||||
# IDE (e.g. Android Studio) users:
|
|
||||||
# Gradle settings configured through the IDE *will override*
|
|
||||||
# any settings specified in this file.
|
|
||||||
# For more details on how to configure your build environment visit
|
|
||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
|
||||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
|
||||||
# org.gradle.parallel=true
|
|
||||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
|
||||||
# Android operating system, and which are packaged with your app's APK
|
|
||||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
|
||||||
android.useAndroidX=true
|
|
||||||
# Enables namespacing of each library's R class so that its R class includes only the
|
|
||||||
# resources declared in the library itself and none from the library's dependencies,
|
|
||||||
# thereby reducing the size of the R class for that library
|
|
||||||
android.nonTransitiveRClass=true
|
|
|
@ -1,6 +0,0 @@
|
||||||
#Wed Oct 11 11:55:49 CST 2023
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
|
@ -1,185 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright 2015 the original author or authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##
|
|
||||||
## Gradle start up script for UN*X
|
|
||||||
##
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
||||||
else
|
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD="java"
|
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
|
||||||
if [ $? -eq 0 ] ; then
|
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
ulimit -n $MAX_FD
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Escape application args
|
|
||||||
save () {
|
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
||||||
echo " "
|
|
||||||
}
|
|
||||||
APP_ARGS=`save "$@"`
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
|
@ -1,89 +0,0 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
||||||
exit /b 1
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|