Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/.github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
distribution: 'zulu' # 指定 Java 发行版

- name: Set up Android SDK
uses: android-actions/setup-android@v2
uses: android-actions/setup-android@v4
with:
api-level: 30
build-tools: 30.0.3
Expand Down
4 changes: 2 additions & 2 deletions pos_android_studio_demo/pos_android_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
applicationId "com.dspread.pos_android_app"
minSdk 24
targetSdk 34
versionCode 148
versionName "8.5.5-2609101405"
versionCode 149
versionName "8.5.5-2609201905"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// Set up supported SO library architecture
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.dspread.pos.dualScreen.manager;

public class Constant {
public static final String VERSION = "1.0.0"; ///< 版本号

// ===== 返回码常量 =====
public class ResultConstant {
public static final int RESULT_SUCCESS = 0;
public static final int RESULT_ERROR_NO_DISPLAY = -1;
public static final int RESULT_ERROR_INVALID_PARAM = -2;
public static final int RESULT_ERROR_FILE_NOT_FOUND = -3;
public static final int RESULT_ERROR_NOT_SUPPORTED = -4;
public static final int RESULT_ERROR_SHOW_FAILED = -5;
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.dspread.pos.dualScreen.manager;

/**
* 操作结果回调接口
*/
public interface IResultCallback {
void onSuccess();

void onFailure(int code, String msg);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.dspread.pos.dualScreen.manager;

import android.view.View;

import java.util.ArrayList;

/**
* 副屏控制接口
*
* <p>定义了副屏图片显示、视频播放、自定义View显示、
* 电源控制、亮度调节、开机Logo、分辨率查询等能力。</p>
*/
public interface IViceScreen {

/** 显示单张图片 */
int showPic(String picPath);

/** 显示图片轮播 */
int showPic(ArrayList<String> picPathList, int intervalSeconds);

/** 播放视频 */
int showVideo(String videoPath);

/** 显示自定义View */
void show(View view, IResultCallback callback);

/** 显示自定义View + 图片轮播 */
void show(View view, ArrayList<PictureData> picDataList, IResultCallback callback);

/** 显示壁纸 */
int showWallpaper();

/** 电源开关 */
int power(boolean on);

/** 获取电源状态 */
int getPowerOnStatus();

/** 设置亮度 */
int setBrightness(int value);

/** 获取亮度 */
int getBrightness();

/** 设置开机Logo */
int setBootLogo(String filePath);

/** 获取副屏分辨率 [width, height] */
int[] getScreenResolution();

/** 获取副屏描述信息*/
String getScreenDescription();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.dspread.pos.dualScreen.manager;

import android.os.Parcel;
import android.os.Parcelable;

/**
* 图片显示数据
*
* <p>描述一张图片在副屏上的显示位置和尺寸。</p>
*/
public class PictureData implements Parcelable {
private String path;
private int startX;
private int startY;
private int width;
private int height;

public PictureData() {
}

public PictureData(String path, int startX, int startY, int width, int height) {
this.path = path;
this.startX = startX;
this.startY = startY;
this.width = width;
this.height = height;
}

protected PictureData(Parcel in) {
path = in.readString();
startX = in.readInt();
startY = in.readInt();
width = in.readInt();
height = in.readInt();
}

public static final Creator<PictureData> CREATOR = new Creator<PictureData>() {
@Override
public PictureData createFromParcel(Parcel in) {
return new PictureData(in);
}

@Override
public PictureData[] newArray(int size) {
return new PictureData[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(path);
dest.writeInt(startX);
dest.writeInt(startY);
dest.writeInt(width);
dest.writeInt(height);
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public int getStartX() {
return startX;
}

public void setStartX(int startX) {
this.startX = startX;
}

public int getStartY() {
return startY;
}

public void setStartY(int startY) {
this.startY = startY;
}

public int getWidth() {
return width;
}

public void setWidth(int width) {
this.width = width;
}

public int getHeight() {
return height;
}

public void setHeight(int height) {
this.height = height;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.dspread.pos.dualScreen.manager;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;


import com.dspread.pos.dualScreen.original.ViceScreenOriginal;
import com.dspread.pos_android_app.R;

import java.util.ArrayList;

public class ViceScreenManager {
private static volatile ViceScreenManager instance;

private Context context;
private int deviceType;
private ViceScreenOriginal original;

private ViceScreenManager(Context context, int deviceType) {
this.context = context.getApplicationContext();
this.deviceType = deviceType;
this.original = new ViceScreenOriginal(context);
}

/**
* 获取全局单例(默认设备类型)
* 可在任意 Activity 或其他页面直接调用
*/
public static ViceScreenManager getInstance(Context context) {
return getInstance(context, 0);
}

/**
* 获取全局单例(指定设备类型)
*/
public static ViceScreenManager getInstance(Context context, int deviceType) {
if (instance == null) {
synchronized (ViceScreenManager.class) {
if (instance == null) {
instance = new ViceScreenManager(context, deviceType);
}
}
}
return instance;
}

public int showPic(String picPath) {
return original.showPic(picPath);
}

public int showPic(ArrayList<String> picPathList, int intervalSeconds) {
return original.showPic(picPathList, intervalSeconds);
}

public int showVideo(String videoPath) {
return original.showVideo(videoPath);
}

public void show(View view) {
show(view, null);
}

public void show(View view, IResultCallback callback) {
original.show(view, callback);
}

/**
* 在副屏上显示默认欢迎页(副屏已开启时)
* 供任意页面复用,内部自动判断副屏电源状态
*/
public void showDefaultView() {
if (getPowerOnStatus() == 1) {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.vice_default, null);
show(view, null);
}
}

public void show(View view, ArrayList<PictureData> picDataList, IResultCallback callback) {
original.show(view, picDataList, callback);
}

public int showWallpaper() {
return original.showWallpaper();
}

public int power(boolean on) {
return original.power(on);
}

public int getPowerOnStatus() {
return original.getPowerOnStatus();
}

public int setBrightness(int value) {
return original.setBrightness(value);
}

public int getBrightness() {
return original.getBrightness();
}

public int setBootLogo(String filePath) {
return original.setBootLogo(filePath);
}

public int[] getScreenResolution() {
return original.getScreenResolution();
}

public String getScreenDescription() {
return original.getScreenDescription();
}
}
Loading
Loading