open source

This commit is contained in:
lvfulong
2020-11-11 16:17:13 +08:00
parent 4d989f3ecb
commit bc4ca748de
2441 changed files with 623057 additions and 2 deletions
@@ -0,0 +1 @@
/build
@@ -0,0 +1,43 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.layabox.conch6"
minSdkVersion 14
targetSdkVersion 28
versionCode 17
versionName "release-2.9.0"
}
sourceSets.main{
jniLibs.srcDir 'libs'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
}
}
/* externalNativeBuild {
ndkBuild {
path '../../proj.android/jni/Android.mk'
}
}*/
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation project(':conch5')
implementation group: 'com.google.zxing', name: 'core', version: '3.3.1'
implementation 'com.journeyapps:zxing-android-embedded:3.3.0'
implementation 'com.android.support:appcompat-v7:25.3.1'
}
@@ -0,0 +1,58 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# 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 *;
#}
-dontusemixedcaseclassnames
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep class layaair.game.PlatformInterface.** {*;}
-keep class layaair.game.wrapper.** {*;}
-keep class layaair.game.device.DevID {*;}
-keep class layaair.game.browser.ConchJNI{*;}
-keep class layaair.game.browser.ExportJavaFunction {*;}
-keep class layaair.game.utility.ProcessInfo {*;}
-keep class layaair.game.utility.LayaAudioMusic {*;}
-keep class layaair.game.Notifycation.LayaNotifyManager {*;}
-keep class layaair.game.conch.ILayaEventListener {*;}
-keep class layaair.game.conch.ILayaGameEgine {*;}
-keep class layaair.game.conch.LayaConch5 {*;}
-keepclasseswithmembernames class *{
native <methods>;
}
-keepclasseswithmembers class *{
public <init>(android.content.Context,android.util.AttributeSet);
}
-keepclasseswithmembers class *{
public <init>(android.content.Context,android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity{
public void *(android.view.View);
}
@@ -0,0 +1,13 @@
package com.layabox.conch6;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.layabox.conch6">
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
<!-- 竖portrait 横landscape sensorLandscape sensorPortrait -->
<activity
android:name="layaair.game.browser.MainActivity"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="layabox" />
</intent-filter>
</activity>
<activity
android:name="layaair.game.browser.ScanActivity"
android:clearTaskOnLaunch="true"
android:screenOrientation="portrait"
android:stateNotNeeded="true"
android:theme="@style/AppCompatCaptureTheme"
android:windowSoftInputMode="stateAlwaysHidden"></activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.layabox.conch6.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
</manifest>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,8 @@
IsHandleUpdateAPK=1
ApkUpdateUrl=https://www.layabox.com/layanative2.0/apk/update/conch-layaair/version.xml
UpdateDownloadPath=mnt/sdcard
UpdateAPKFileName=autoupdate.apk
CheckNetwork=1
ThreadMode=1
JSDebugPort=5959
JSDebugMode=1
@@ -0,0 +1,115 @@
class loadingView
{
constructor()
{
this.sOS = conchConfig.getOS();
if (this.sOS == "Conch-ios")
{
this.bridge = PlatformClass.createClass("JSBridge");
}
else if (this.sOS == "Conch-android")
{
this.bridge = PlatformClass.createClass("layaair.game.browser.JSBridge");
}
}
set loadingAutoClose(value)
{
this._loadingAutoClose = value;
}
get loadingAutoClose()
{
return this._loadingAutoClose;
}
set showTextInfo(value)
{
this._showTextInfo = value;
if(this.bridge)
{
if (this.sOS == "Conch-ios")
{
this.bridge.call("showTextInfo:",value);
}
else if(this.sOS == "Conch-android")
{
this.bridge.call("showTextInfo",value);
}
}
}
get showTextInfo()
{
return this._showTextInfo;
}
bgColor(value)
{
if(this.bridge)
{
if (this.sOS == "Conch-ios")
{
this.bridge.call("bgColor:",value);
}
else if(this.sOS == "Conch-android")
{
this.bridge.call("bgColor",value);
}
}
}
setFontColor(value)
{
if(this.bridge)
{
if (this.sOS == "Conch-ios")
{
this.bridge.call("setFontColor:",value);
}
else if(this.sOS == "Conch-android")
{
this.bridge.call("setFontColor",value);
}
}
}
setTips(value)
{
if(this.bridge)
{
if (this.sOS == "Conch-ios")
{
this.bridge.call("setTips:",value);
}
else if(this.sOS == "Conch-android")
{
this.bridge.call("setTips",value);
}
}
}
loading(value)
{
if(this.bridge)
{
if (this.sOS == "Conch-ios")
{
this.bridge.call("loading:",value);
}
else if(this.sOS == "Conch-android")
{
this.bridge.call("loading",value);
}
}
}
hideLoadingView()
{
this.bridge.call("hideSplash");
}
}
window.loadingView = new loadingView();
if(window.loadingView)
{
window.loadingView.loadingAutoClose=true;//true代表当动画播放完毕,自动进入游戏。false为开发者手动控制
window.loadingView.bgColor("#000000");//设置背景颜色
window.loadingView.setFontColor("#ffffff");//设置字体颜色
window.loadingView.setTips(["新世界的大门即将打开","敌军还有30秒抵达战场","妈妈说,心急吃不了热豆腐"]);//设置tips数组,会随机出现
}
window.onLayaInitError=function(e)
{
console.log("onLayaInitError error=" + e);
alert("加载游戏失败,可能由于您的网络不稳定,请退出重进");
}
@@ -0,0 +1,308 @@
package layaair.autoupdateversion;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
import java.util.Random;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.webkit.ValueCallback;
import layaair.autoupdateversion.data.VersionData;
import layaair.game.config.config;
public class AutoUpdateAPK {
//static public final String CHECK_VERSION_URL = "http://localhost:80/setuptest_update.xml";
//static public final String APK_DOWNLOAD_PATH = "mnt/sdcard/";
//static public final String DOWNLOAD_APK_NAME = "autoupdate.apk";
static private final int UPDATE_CHECKCOMPLETED = 1;
static private final int UPDATE_DOWNLOADING = 2;
static private final int UPDATE_DOWNLOAD_ERROR = 3;
static private final int UPDATE_DOWNLOAD_COMPLETED = 4;
static private final int UPDATE_DOWNLOAD_CANCELED = 5;
static private AutoUpdateAPK s_instance;
private layaair.autoupdateversion.IUpdateCallback m_callback;
private String m_szDownloadAPKName;// = DOWNLOAD_APK_NAME;
private String m_szDownloadPath;
private int m_iVersionCode = 0;
private int m_iProgressValue = 0;
private Context m_context = null;
private VersionData m_versionData = new VersionData();
private boolean m_hasNewVersion = false;
private boolean m_hasCanceled = false;
private ValueCallback<Integer> m_pCallback;
public AutoUpdateAPK(Context p_context,ValueCallback<Integer> callback)
{
m_pCallback=callback;
s_instance = this;
m_callback = new UpdateCallback();
m_context = p_context;
this.m_szDownloadAPKName = config.GetInstance().getProperty("UpdateAPKFileName");
this.m_szDownloadPath = config.GetInstance().getProperty("UpdateDownloadPath");
setVersionCode(p_context);
downloadVersionXML(config.GetInstance().getProperty("ApkUpdateUrl"));
}
public static void DelInstance()
{
s_instance=null;
}
static public AutoUpdateAPK getInstance() {
return s_instance;
}
public void cancelDownload() {
m_hasCanceled = true;
}
private static class UpdateHandle extends Handler
{
@Override
public void handleMessage(Message msg) {
AutoUpdateAPK that=AutoUpdateAPK.getInstance();
switch (msg.what) {
case UPDATE_CHECKCOMPLETED:
that.m_callback.checkUpdateCompleted(that.getHasNewVersion(),
that.m_versionData.getName() +that.m_versionData.getVersion());
break;
case UPDATE_DOWNLOADING:
that.m_callback.downloadProgressChanged(that.m_iProgressValue);
break;
case UPDATE_DOWNLOAD_ERROR:
onUpdateEnd(1);
that.m_callback.downloadCompleted(false, msg.obj.toString());
break;
case UPDATE_DOWNLOAD_COMPLETED:
onUpdateEnd(0);
that.m_callback.downloadCompleted(true, "");
break;
case UPDATE_DOWNLOAD_CANCELED:
that.m_callback.downloadCanceled();
default:
break;
}
}
}
public static void onUpdateEnd(int ecode)
{
if (ecode == 2 || ecode == 3) {
s_instance.m_pCallback.onReceiveValue(1);
} else {
s_instance.m_pCallback.onReceiveValue(0);
}
}
Handler updateHandler = new UpdateHandle();
public void updateAPK() {
Intent intent = new Intent(Intent.ACTION_VIEW);
File file = new File(m_szDownloadPath, m_szDownloadAPKName);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri contentUri = android.support.v4.content.FileProvider.getUriForFile(m_context, "com.layabox.conch6.fileprovider", file);
intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
} else {
intent.setDataAndType(
Uri.fromFile(file),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
m_context.startActivity(intent);
}
public void downloadAPK() {
new Thread() {
public void run() {
try {
URL url = new URL(m_versionData.getDownloasURL());
Log.i("","update apk url:"+url.toString());
HttpURLConnection conn = (HttpURLConnection) url
.openConnection();
conn .setRequestProperty("Accept-Encoding", "identity");
conn.setConnectTimeout(6 * 1000);
conn.connect();
// if (conn.getResponseCode() != 200)
// throw new RuntimeException("请求url失败");
int length = conn.getContentLength();
InputStream is = conn.getInputStream();
File fileAPK = new File(m_szDownloadPath,
m_szDownloadAPKName);
if (fileAPK.exists()) {
if(fileAPK.delete())
{
Log.i("","删除apk成功");
}
else
{
Log.e("","删除apk失败");
}
}
FileOutputStream fos = new FileOutputStream(fileAPK);
int count = 0;
byte buf[] = new byte[512];
int nLastProg=0;
do {
int numread = is.read(buf);
count += numread;
m_iProgressValue = (int) (((float) count / length) * 100);
if(m_iProgressValue!=nLastProg)
{
updateHandler.sendMessage(updateHandler.obtainMessage(UPDATE_DOWNLOADING));
nLastProg = m_iProgressValue;
}
if (numread <= 0) {
updateHandler.sendEmptyMessage(UPDATE_DOWNLOAD_COMPLETED);
break;
}
fos.write(buf, 0, numread);
} while (!m_hasCanceled);
if (m_hasCanceled) {
updateHandler.sendEmptyMessage(UPDATE_DOWNLOAD_CANCELED);
}
fos.close();
is.close();
} catch (MalformedURLException e) {
e.printStackTrace();
updateHandler.sendMessage(updateHandler.obtainMessage(UPDATE_DOWNLOAD_ERROR, e.getMessage()));
} catch (IOException e) {
e.printStackTrace();
updateHandler.sendMessage(updateHandler.obtainMessage(UPDATE_DOWNLOAD_ERROR, e.getMessage()));
}
}
}.start();
}
public void setVersionCode(Context p_context) {
try {
m_iVersionCode = p_context.getPackageManager().getPackageInfo(
p_context.getPackageName(), 0).versionCode;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
public void downloadVersionXML(final String p_szURL) {
this.setHasNewVersion(false);
new Thread() {
// ***************************************************************
@Override
public void run() {
try {
Random rnd;
rnd = new Random();
String url=p_szURL+"?r="+rnd.nextInt();
Log.i("","update url="+url);
String verjson = NetHelper
.httpStringGet(url);
parseVersionXMLFromString(verjson);
if (m_versionData.getVersionCode() > m_iVersionCode) {
setHasNewVersion(true);
}
} catch (Exception e) {
Log.e("","自动更新失败,应该是无法连接到"+p_szURL);
}
updateHandler.sendEmptyMessage(UPDATE_CHECKCOMPLETED);
}
}.start();
}
public boolean parseVersionXMLFromString(String p_szContent) {
DocumentBuilder db = null;
Document document = null;
try {
db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
try {
InputStream in = new ByteArrayInputStream(p_szContent.getBytes());
assert db != null;
document = db.parse(in);
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Element root = null;
if (document != null) {
root = document.getDocumentElement();
}
// System.out.println("根节点名称:"+root.getTagName()); //根节点名称
return doParseVersionXML(root);
}
@SuppressLint({ "NewApi", "NewApi", "NewApi", "NewApi", "NewApi" })
private boolean doParseVersionXML(Element p_root) {
if(p_root==null)return false;
NodeList __ls = p_root.getChildNodes();
Node node;
for (int i = 0; i < __ls.getLength(); i++) {
node = __ls.item(i);
if (node.getNodeName().toLowerCase(Locale.ENGLISH).equals("versioncode")) {
m_versionData.setVersionCode(Integer.parseInt(node
.getTextContent()));
continue;
}
if (node.getNodeName().toLowerCase(Locale.ENGLISH).equals("version")) {
m_versionData.setVersion(node.getTextContent());
continue;
}
if (node.getNodeName().toLowerCase(Locale.ENGLISH).equals("name")) {
m_versionData.setName(node.getTextContent());
continue;
}
if (node.getNodeName().toLowerCase(Locale.ENGLISH).equals("url")) {
m_versionData.setDownloasURL(node.getTextContent());
}
}
//给apk地址加个参数,防止服务器的缓存
m_versionData.setDownloasURL(m_versionData.getDownloasURL()+"?vc="+m_versionData.getVersionCode());
return false;
}
public boolean getHasNewVersion() {
return m_hasNewVersion;
}
public void setHasNewVersion(boolean m_hasNewVersion) {
this.m_hasNewVersion = m_hasNewVersion;
}
public Context getContext() {
return this.m_context;
}
}
@@ -0,0 +1,39 @@
package layaair.autoupdateversion;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;
public class DialogHelper {
public static void Confirm(Context ctx, CharSequence title, CharSequence message,
CharSequence okText, OnClickListener oklistener, CharSequence cancelText,
OnClickListener cancellistener) {
AlertDialog.Builder builder = createDialog(ctx, title, message);
builder.setPositiveButton(okText, oklistener);
builder.setNegativeButton(cancelText, cancellistener);
AlertDialog dlg = builder.create();
dlg.setCanceledOnTouchOutside(false); //防止点到外面自动关掉对话框。
dlg.show();
}
private static AlertDialog.Builder createDialog(Context ctx, CharSequence title,
CharSequence message) {
AlertDialog.Builder builder = new Builder(ctx);
builder.setMessage(message);
if(title!=null)
{
builder.setTitle(title);
}
return builder;
}
@SuppressWarnings("unused")
private static AlertDialog.Builder createDialog(Context ctx,int titleId, int messageId) {
AlertDialog.Builder builder = new Builder(ctx);
builder.setMessage(messageId);
builder.setTitle(titleId);
return builder;
}
}
@@ -0,0 +1,10 @@
package layaair.autoupdateversion;
public interface IUpdateCallback {
void checkUpdateCompleted(Boolean hasUpdate,
CharSequence updateInfo);
void downloadProgressChanged(int progress);
void downloadCanceled();
void downloadCompleted(Boolean sucess, CharSequence errorMsg);
}
@@ -0,0 +1,55 @@
package layaair.autoupdateversion;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
public class NetHelper {
public static String httpStringGet(String url) throws Exception {
return httpStringGet(url, "utf-8");
}
public static String httpStringGet(String url, String enc) throws Exception {
HttpURLConnection connection = null;
BufferedReader reader = null;
try {
URL u = new URL( url );
connection = (HttpURLConnection) u.openConnection();
connection.setRequestMethod( "GET" );
connection.setConnectTimeout( 5000 );
connection.setReadTimeout( 5000 );
InputStream in = connection.getInputStream();
reader = new BufferedReader( new InputStreamReader( in ) );
StringBuilder result = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
result.append( line );
}
return String.valueOf( result );
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (connection != null) {
connection.disconnect();
}
}
return "";
}
}
@@ -0,0 +1,95 @@
package layaair.autoupdateversion;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.util.Log;
public class UpdateCallback implements IUpdateCallback {
static private final String DIALOG_DOWNLOAD_ERROR_TITLE = "下载失败";
static private final String DIALOG_DOWNLOAD_ERROR_MSG = "下载更新文件失败";
static private final String DIALOG_DOWNLOAD_BUTTON_TRY = "重试";
static private final String DIALOG_DOWNLOAD_BUTTON_CANCEL= "取消";
static private final String DIALOG_UPDATE_TITLE = "更新";
static private final String DIALOG_UPDATE_MSG = "立刻更新[";
static private final String DIALOG_UPDATE_MSGEND = "]吗?";
static private final String DIALOG_UPDATE_PROGRESS= "更新进度";
static private final String DIALOG_UPDATE_BUTTON_TRY = "开始更新";
static private final String DIALOG_UPDATE_BUTTON_CANCEL= "取消更新";
ProgressDialog updateProgressDialog = null;
public void downloadProgressChanged(int progress) {
if (updateProgressDialog != null
&& updateProgressDialog.isShowing()) {
updateProgressDialog.setProgress(progress);
}
}
public void downloadCompleted(Boolean sucess, CharSequence errorMsg) {
if (updateProgressDialog != null
&& updateProgressDialog.isShowing()) {
updateProgressDialog.dismiss();
}
if (sucess) {
if (AutoUpdateAPK.getInstance() != null)
AutoUpdateAPK.getInstance().updateAPK();
} else {
if (AutoUpdateAPK.getInstance() == null)
return ;
DialogHelper.Confirm(AutoUpdateAPK.getInstance().getContext(),
DIALOG_DOWNLOAD_ERROR_TITLE,
DIALOG_DOWNLOAD_ERROR_MSG,
DIALOG_DOWNLOAD_BUTTON_TRY,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
AutoUpdateAPK.getInstance().downloadAPK();
}
}, DIALOG_DOWNLOAD_BUTTON_CANCEL, null);
}
}
public void downloadCanceled() {
Log.i("", "download canceled");
}
public void checkUpdateCompleted(Boolean hasUpdate, CharSequence updateInfo) {
if (AutoUpdateAPK.getInstance() == null)
return ;
if (hasUpdate)
{
DialogHelper.Confirm(
AutoUpdateAPK.getInstance().getContext(),
DIALOG_UPDATE_TITLE,
DIALOG_UPDATE_MSG + updateInfo+ DIALOG_UPDATE_MSGEND,DIALOG_UPDATE_BUTTON_TRY,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
updateProgressDialog = new ProgressDialog(AutoUpdateAPK.getInstance().getContext());
updateProgressDialog.setMessage(DIALOG_UPDATE_PROGRESS);
updateProgressDialog.setIndeterminate(false);
updateProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
updateProgressDialog.setMax(100);
updateProgressDialog.setProgress(0);
updateProgressDialog.setCancelable(false);
updateProgressDialog.setCanceledOnTouchOutside(false);
updateProgressDialog.show();
AutoUpdateAPK.getInstance().downloadAPK();
}
}, DIALOG_UPDATE_BUTTON_CANCEL,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
AutoUpdateAPK.onUpdateEnd(3);
}
}
);
}else{
AutoUpdateAPK.onUpdateEnd(2);
}
}
}
@@ -0,0 +1,41 @@
package layaair.autoupdateversion.data;
public class VersionData {
private int m_iVersionCode;
private String m_szName;
private String m_szVersion;
private String m_szDownloasURL;
public int getVersionCode() {
return m_iVersionCode;
}
public void setVersionCode(int p_iVersionCode) {
this.m_iVersionCode = p_iVersionCode;
}
public String getName() {
return m_szName;
}
public void setName(String p_szName) {
this.m_szName = p_szName;
}
public String getDownloasURL() {
return m_szDownloasURL;
}
public void setDownloasURL(String p_szDownloasURL) {
this.m_szDownloasURL = p_szDownloasURL;
}
public String getVersion() {
return m_szVersion;
}
public void setVersion(String m_szVersion) {
this.m_szVersion = m_szVersion;
}
}
@@ -0,0 +1,179 @@
package layaair.game.browser;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import com.google.zxing.integration.android.IntentIntegrator;
import org.json.JSONArray;
import org.json.JSONException;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import layaair.game.config.config;
import static android.content.Context.CONNECTIVITY_SERVICE;
public class JSBridge {
public static Handler m_Handler = new Handler(Looper.getMainLooper());
public static Activity mMainActivity = null;
public static void hideSplash() {
m_Handler.post(
new Runnable() {
public void run() {
MainActivity.mSplashDialog.dismissSplash();
}
});
}
public static void setFontColor(final String color) {
m_Handler.post(
new Runnable() {
public void run() {
MainActivity.mSplashDialog.setFontColor(Color.parseColor(color));
}
});
}
public static void setTips(final JSONArray tips) {
m_Handler.post(
new Runnable() {
public void run() {
try {
String[] tipsArray = new String[tips.length()];
for (int i = 0; i < tips.length(); i++) {
tipsArray[i] = tips.getString(i);
}
MainActivity.mSplashDialog.setTips(tipsArray);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
public static void bgColor(final String color) {
m_Handler.post(
new Runnable() {
public void run() {
MainActivity.mSplashDialog.setBackgroundColor(Color.parseColor(color));
}
});
}
public static void loading(final double percent) {
m_Handler.post(
new Runnable() {
public void run() {
MainActivity.mSplashDialog.setPercent((int)percent);
}
});
}
public static void showTextInfo(final boolean show) {
m_Handler.post(
new Runnable() {
public void run() {
MainActivity.mSplashDialog.showTextInfo(show);
}
});
}
public static void showFloatPanel(final boolean show) {
m_Handler.post(
new Runnable() {
public void run() {
if (MainActivity.m_FloatPanel != null) {
if (show) {
MainActivity.m_FloatPanel.show();
} else {
MainActivity.m_FloatPanel.hide();
}
}
}
});
}
public static void showScanner(final boolean show) {
m_Handler.post(
new Runnable() {
public void run() {
if (MainActivity.m_FloatPanel != null) {
if (show) {
new IntentIntegrator(mMainActivity).setCaptureActivity(ScanActivity.class).initiateScan();
} else {
if (ScanActivity.m_instance != null) {
ScanActivity.m_instance.finish();
}
}
}
}
});
}
public static void getIP() {
m_Handler.post(
new Runnable() {
public void run() {
ExportJavaFunction.CallBackToJS(JSBridge.class,"getIP", getIP(mMainActivity));
}
});
}
public static void onOrientationChange() {
MainActivity.m_FloatPanel.updatePosition();
}
public static void onScanResult(String result) {
Log.d("JSBridge", "url " + result);
if (ScanActivity.m_instance != null) {
ScanActivity.m_instance.finish();
}
String js = "script.UIController.instance.onScanResult('";
js += result;
js += "');";
ConchJNI.RunJS(js);
}
public static String getIP(Context context){
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress() && (inetAddress instanceof Inet4Address)) {
NetworkInfo activeNetInfo = ((ConnectivityManager)context.getSystemService(CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
String str = "";
if(activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
str += "WifiNetworkIP: ";
}
else if(activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
str += "MobileNetworkIP: ";
}
else {
str += "UnknowNetworkIP: ";
}
str += inetAddress.getHostAddress().toString();
return str;
}
}
}
}
catch (SocketException ex) {
ex.printStackTrace();
}
return "";
}
}
@@ -0,0 +1,644 @@
package layaair.game.browser;
import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.webkit.ValueCallback;
import android.widget.AbsoluteLayout;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map.Entry;
import layaair.autoupdateversion.AutoUpdateAPK;
import layaair.game.conch.ILayaEventListener;
import layaair.game.conch.LayaConch5;
import layaair.game.config.config;
import layaair.game.wrapper.ILayaLibWrapper;
@SuppressLint("Wakelock")
public class LayaWrapper implements ILayaLibWrapper{
public static final int AR_CHECK_UPDATE = 1;
public static final int AR_INIT_PLATFORM = 2;
private static int m_nStartActivityType = 0; //设置网络之后,再次调用到哪个函数的标记
public static final int BACK_TO_MAIN = 0;
public static final int REFRESH = 1;
public static final int CLOSE_BIG = 2;
//------------------------------------------------------------------------------
static LayaWrapper ms_layaEngine = null;
public boolean m_bPopAD = true;
static public AbsoluteLayout m_pAbsEditLayout = null;
private long m_nBackPressTime=0;
//kuo change code here
public View m_pExternalLoadingView = null;
static private Toast mToast;
//------------------------------------------------------------------------------
public SensorManager m_pSensorManager = null;
public Sensor m_pSensor = null;
public SensorEventListener m_pSensorListener = null;
public int SENSOR_OFFSET = 6;
public double m_fSensorX = 0;
public double m_fSensorY = 0;
public double m_fSensorZ = 0;
public int m_nScreenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
private String tempSoPath = "";
private String tempSoFile = "";
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
public static Activity m_LayaEngineContext = null;
public static LayaConch5 m_pEngine = null;
//------------------------------------------------------------------------------
public static LayaWrapper GetInstance()
{
if (ms_layaEngine == null) {
ms_layaEngine = new LayaWrapper();
}
return ms_layaEngine;
}
//------------------------------------------------------------------------------
public LayaWrapper()
{
}
public void setLayaEventListener(ILayaEventListener _lis){
if(m_pEngine!=null)
m_pEngine.setLayaEventListener(_lis);
}
//------------------------------------------------------------------------------
public void initEngine(Activity pContext)
{
ms_layaMainActivity = pContext;
ms_layaEngine = this;
m_LayaEngineContext = pContext;
ms_mCtx = m_LayaEngineContext;//.getApplicationContext();
/*try{
InputStream is = m_LayaEngineContext.getResources().getAssets().open("config.ini");
config.GetInstance().init( is );
}catch(Exception e){
Log.e("","打开配置文件错误。");
}*/
m_pEngine = new LayaConch5(ms_mCtx);
m_pEngine.game_conch3_SetIsPlug(false);
if (tempSoPath.length()>0) {
m_pEngine.setSoPath(tempSoPath);
}
if (tempSoFile.length()>0) {
m_pEngine.setSoPath(tempSoFile);
}
}
//------------------------------------------------------------------------------
public void setSoPath(String pSoPath)
{
tempSoPath = pSoPath;
if (m_pEngine!=null) {
m_pEngine.setSoPath(pSoPath);
}
}
public void setAlertTitle(String title) {
if (m_pEngine!=null) {
m_pEngine.setAlertTitle(title);
}
}
public void setStringOnBackPressed(String str) {
if (m_pEngine!=null) {
m_pEngine.setStringOnBackPressed(str);
}
}
//------------------------------------------------------------------------------
public void setSoFile(String pSoFile)
{
tempSoFile = pSoFile;
if (m_pEngine!=null) {
m_pEngine.setSoFile(pSoFile);
}
}
//------------------------------------------------------------------------------
public void setGameUrl(String pUrl)
{
m_pEngine.setGameUrl(pUrl);
}
public void setLocalizable(boolean b)
{
m_pEngine.setLocalizable(b);
}
//------------------------------------------------------------------------------
public void startGame()
{
EngineStart();
}
public String getCacheDir() {
//return m_LayaEngineContext.getCacheDir().toString();
String sCache = m_LayaEngineContext.getCacheDir().toString();
String []vString = sCache.split("/");
String sNewCache="";
for( int i = 0; i < vString.length-1; i++ )
{
sNewCache += vString[i];
sNewCache += "/";
}
return sNewCache;
}
// ------------------------------------------------------------------------------
public void EngineStart()
{
String cachePath = getCacheDir();
String strLayaCache = cachePath + "/LayaCache";
File cacheFolder=new File(strLayaCache);
if(!cacheFolder.exists()) {
cacheFolder.mkdir();
}
AssetManager am = LayaWrapper.getLayaApplicationAsset();
/*if (m_pExternalLoadingView!=null) {
m_pEngine.setLoadingView(m_pExternalLoadingView);
}else {
m_pEngine.setLoadingView(m_pLoadingView);
}*/
m_pEngine.game_conch3_setAppWorkPath(cachePath);
m_pEngine.game_conch3_setAssetInfo(am);
m_pEngine.game_conch3_init();
//准备localStorage目录
File localStoragePath = new File(strLayaCache + "/localstorage");
if (!localStoragePath.exists()) {
if (!localStoragePath.mkdirs()) {
Log.e("", "创建localstorage目录失败!");
}
}
ConchJNI.SetLocalStoragePath(strLayaCache + "/localstorage");
//环境都准备好了,开始流程了。
if (PermisionUtils.checkExternalStoragePermission(ms_layaMainActivity)) {
checkApkUpdate();
}
}
public boolean isOpenNetwork(Context context)
{
if (!config.GetInstance().m_bCheckNetwork)
return true;
ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
return connManager.getActiveNetworkInfo() != null && (connManager.getActiveNetworkInfo().isAvailable() && connManager.getActiveNetworkInfo().isConnected());
}
public void settingNetwork(final Context context, final int p_nType)
{
AlertDialog.Builder pBuilder = new AlertDialog.Builder(context);
pBuilder.setTitle("连接失败,请检查网络或与开发商联系").setMessage("是否对网络进行设置?");
// 退出按钮
pBuilder.setPositiveButton("", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface p_pDialog, int arg1) {
Intent intent;
try {
String sdkVersion = android.os.Build.VERSION.SDK;
if (Integer.valueOf(sdkVersion) > 10) {
intent = new Intent(
android.provider.Settings.ACTION_WIRELESS_SETTINGS);
} else {
intent = new Intent();
ComponentName comp = new ComponentName(
"com.android.settings",
"com.android.settings.WirelessSettings");
intent.setComponent(comp);
intent.setAction("android.intent.action.VIEW");
}
((Activity)context).startActivityForResult(intent, p_nType);
} catch (Exception e) {
e.printStackTrace();
}
}
});
pBuilder.setNegativeButton("", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
((Activity)context).finish();
}
});
AlertDialog alertdlg = pBuilder.create();
alertdlg.setCanceledOnTouchOutside(false);
alertdlg.show();
}
public void checkApkUpdate( Context context,final ValueCallback<Integer> callback)
{
if (isOpenNetwork(context)) {
// 自动版本更新
if ( "0".equals(config.GetInstance().getProperty("IsHandleUpdateAPK","0")) == false && ContextCompat.checkSelfPermission(ms_layaMainActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
Log.e("0", "==============Java流程 checkApkUpdate");
new AutoUpdateAPK(context, new ValueCallback<Integer>() {
@Override
public void onReceiveValue(Integer integer) {
Log.e("",">>>>>>>>>>>>>>>>>>");
callback.onReceiveValue(integer);
}
});
} else {
Log.e("0", "==============Java流程 checkApkUpdate 不需要自己管理update");
callback.onReceiveValue(1);
}
} else {
settingNetwork(context,1);
}
}
public void checkApkUpdate() {
checkApkUpdate(m_LayaEngineContext,new ValueCallback<Integer>() {
@Override
public void onReceiveValue(Integer integer) {
if (integer.intValue() == 1) {
InitView();
} else {
((Activity)m_LayaEngineContext).finish();
}
}
});
}
//------------------------------------------------------------------------------
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void InitView() {
View view = m_pEngine.game_conch3_get_view();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
}
m_LayaEngineContext.setContentView(view);
}
//------------------------------------------------------------------------------
//获取当前应用的版本名称
static public String getAppVersionName()
{
String versionName = "";
int versioncode = 0;
try {
// ---get the package info---
PackageManager pm = LayaWrapper.ms_mCtx.getPackageManager();
PackageInfo pi = pm.getPackageInfo(LayaWrapper.ms_mCtx.getPackageName(), 0);
versionName = pi.versionName;
versioncode = pi.versionCode;
if (versionName == null || versionName.length() <= 0) {
return "";
}
} catch (Exception e) {
Log.e("VersionInfo", "Exception", e);
}
return versionName;
}
/*
* 从assets目录下拷贝文件 srcFile 只能是资源根目录下的文件
*/
public void CopyFileFromAssets(String srcFile, String destPath) {
File curWorkingPath = new File(destPath);
if (!curWorkingPath.exists()) {
Log.i("", "mkdir:" + destPath);
if (!curWorkingPath.mkdirs()) {
// TODO 要验证,看文件夹和文件的处理方式
Log.e("", "copyasserts error 创建文件夹出错,dir=" + destPath);
}
}
try {
File outFile = new File(curWorkingPath, srcFile);
InputStream in = null;
try {
in = m_LayaEngineContext.getAssets().open(srcFile);
Log.i("", "copy file: " + srcFile);
} catch (IOException e) {
Log.e("", "open file err:" + srcFile);
return;
}
OutputStream out = new FileOutputStream(outFile);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
Log.e("", "拷贝文件" + srcFile + "成功");
} catch (Exception e) {
e.printStackTrace();
}
}
// ------------------------------------------------------------------------------
public void InitSensor() {
m_pSensorManager = (SensorManager) m_LayaEngineContext.getSystemService(Context.SENSOR_SERVICE);
m_pSensor = m_pSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
m_pSensorListener = new SensorEventListener() {
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
public void onSensorChanged(SensorEvent event) {
double fX = event.values[SensorManager.DATA_X];
double fY = event.values[SensorManager.DATA_Y];
double fZ = event.values[SensorManager.DATA_Z];
if (Math.abs(m_fSensorX - fX) > 0.1
|| Math.abs(m_fSensorY - fY) > 0.1
|| Math.abs(m_fSensorZ - fZ) > 0.1) {
m_fSensorX = fX;
m_fSensorY = fY;
m_fSensorZ = fZ;
if (fX >= (SENSOR_OFFSET - 1) && fX <= (SENSOR_OFFSET + 1)
&& Math.abs(fY) < 2) {
ConchJNI.onSensorChanged(-1);
// Log.e("0", ">>>>>>>arc=-1" + ",x=" + fX + ",y=" + fY
// + ",z=" + fZ );
} else {
double fArc = Math.atan2(fY, fX
- SENSOR_OFFSET)
- Math.PI / 2.0f;
fArc = (fArc < 0) ? (fArc + Math.PI * 2) : fArc;
ConchJNI.onSensorChanged((float) (fArc));
// Log.e("0", ">>>>>>>arc=" + fArc + ",x=" + fX + ",y="
// + fY + ",z=" + fZ );
}
}
}
};
m_pSensorManager.registerListener(m_pSensorListener, m_pSensor,
SensorManager.SENSOR_DELAY_GAME);
}
public void handleUncaughtException (Thread thread, Throwable e){
e.printStackTrace(); // not all Android versions will print the stack trace automatically
Intent intent = new Intent ();
intent.setAction ("com.dawawa.SEND_LOG");
intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); // required when starting from Application
m_LayaEngineContext.startActivity (intent);
System.exit(1); // kill off the crashed app
}
// ------------------------------------------------------------------------------
public static void onPopMenu(int id)
{
switch (id) {
case BACK_TO_MAIN:
//Toast.makeText(GetInstance(), "BACK_TO_MAIN", Toast.LENGTH_SHORT).show();
ConchJNI.onRunCmd(0x400 + 3333 + 104, -1, 0);
break;
case CLOSE_BIG:
//Toast.makeText(GetInstance(), "CLOSE_BIG", Toast.LENGTH_SHORT).show();
break;
case REFRESH:
//Toast.makeText(GetInstance(), "REFRESH", Toast.LENGTH_SHORT).show();
ConchJNI.onRunCmd(0x400 + 3333 + 102, 0, 0);
break;
}
}
// ------------------------------------------------------------------------------
// public void initPlatform() {
// // 初始化平台c
// m_pEngine.setMarketName( config.GetInstance().m_sMarketPlatformClassname!=null?config.GetInstance().m_sMarketPlatformClassname:"");
// if ((config.GetInstance().m_sMarketPlatformClassname != null)
// && (config.GetInstance().m_sMarketPlatformClassname.length() > 1)) {
// if (isOpenNetwork()) {
// Log.e("0", "==============Java流程 第三方平台初始化");
// m_pPlatform.LP_Init(m_LayaEngineContext);
// } else {
// settingNetwork(AR_INIT_PLATFORM);
// }
// } else {
// Log.e("0", "==============Java流程 没有第三方平台直接调用 PlatformInitOK");
// PlatformInitOK(0);
// }
// }
// ------------------------------------------------------------------------------
public void PlatformInitOK(int p_nFlag) {
Log.e("0", "==============Java流程 InitMainCanvas()");
InitView();
}
// ---------------------------------------------------------------------------
public void onActivityResult(int requestCode, int resultCode,Intent intent) {
if (requestCode == AR_INIT_PLATFORM) {
InitView();
} else if (requestCode == AR_CHECK_UPDATE) {
checkApkUpdate();
}
m_pEngine.onActivityResult(requestCode,resultCode,intent);
/*
* if( m_pPlatform != null ) { m_pPlatform.LP_handleActivityResult(
* requestCode, resultCode, intent); }
*/
}
public void setResolution(int w, int h){
m_pEngine.setResolution(w,h);
}
public void _enableOnLayout(boolean b){
m_pEngine._enableOnLayout(b);
}
// ------------------------------------------------------------------------------
public void onPause() {
if (m_pSensorManager != null) {
m_pSensorManager.unregisterListener(m_pSensorListener);
}
m_pEngine.game_conch3_onPause();
}
//------------------------------------------------------------------------------
public void onResume() {
if( m_pSensorManager != null ) {
m_pSensorManager.registerListener( m_pSensorListener, m_pSensor, SensorManager.SENSOR_DELAY_GAME );
}
m_pEngine.game_conch3_onResume();
}
public void onDestroy(){
m_pEngine.onDestroy();
DelInstance();
}
private static void DelInstance()
{
AutoUpdateAPK.DelInstance();
m_pEngine=null;
m_LayaEngineContext=null;
ms_layaEngine=null;
ms_layaMainActivity=null;
ms_mCtx=null;
}
@Override
public void onStop() {
m_pEngine.onStop();
}
@Override
public void onNewIntent(Intent intent) {
m_pEngine.onNewIntent(intent);
}
@Override
public void onRestart() {
m_pEngine.onRestart();
}
public void setInterceptKey(boolean _intercept)
{
m_pEngine.setInterceptKey(_intercept);
}
public void setOptions(HashMap<String, Object> _option)
{
for (Object o : _option.entrySet()) {
Entry entry = (Entry) o;
String key = (String) entry.getKey();
Log.i("setOption", "setOptions() key=" + key + " value=" + entry.getValue());
if (key.compareToIgnoreCase("url") == 0) {
m_pEngine.setGameUrl((String) entry.getValue());
} else if (key.compareToIgnoreCase("sopath") == 0) {
setSoPath((String) entry.getValue());
} else if (key.compareToIgnoreCase("sofile") == 0) {
setSoFile((String) entry.getValue());
}
}
}
public static boolean IsFinishing(Activity context)
{
if(context==null||context.isFinishing())
return true;
return false;
}
// ------------------------------------------------------------------------------
public static void ShowMessage(String pMessage, LayaConch5 _pEngine){
_pEngine.showMessage(pMessage);
}
// ------------------------------------------------------------------------------
static public int GetScreenWidth() {
DisplayMetrics pDm = new DisplayMetrics();
LayaWrapper.getLayaApplicationActivity().getWindowManager().getDefaultDisplay().getMetrics( pDm );
return pDm.widthPixels;
}
// ------------------------------------------------------------------------------
static public int GetScreenHeight() {
DisplayMetrics pDm = new DisplayMetrics();
LayaWrapper.getLayaApplicationActivity().getWindowManager().getDefaultDisplay().getMetrics( pDm );
return pDm.heightPixels;
}
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
static public float GetScreenInch() {
DisplayMetrics pDm = new DisplayMetrics();
LayaWrapper.getLayaApplicationActivity().getWindowManager().getDefaultDisplay().getMetrics( pDm );
int nWidth = pDm.widthPixels;
int nHeight = pDm.heightPixels;
float nDpi = pDm.densityDpi;
return (float) (Math.sqrt(nWidth * nWidth + nHeight * nHeight) / nDpi);
}
// ------------------------------------------------------------------------------
public Bitmap getResImage(String name) {
ApplicationInfo pAppInfo = m_LayaEngineContext.getApplicationInfo();
int nResID = m_LayaEngineContext.getResources().getIdentifier(name, "drawable",pAppInfo.packageName);
return BitmapFactory.decodeResource(m_LayaEngineContext.getResources(), nResID);
}
// ------------------------------------------------------------------------------
static public void reloadApp(){
ConchJNI.reloadJS();
}
// ------------------------------------------------------------------------------
// 通过 AlarmManager 来重新启动应用
public void restartApp() {
Intent intent = new Intent(m_LayaEngineContext.getApplicationContext(), LayaWrapper.class);
PendingIntent restartIntent = PendingIntent.getActivity(
m_LayaEngineContext.getApplicationContext(), 0, intent,Intent.FLAG_ACTIVITY_NEW_TASK);
// 退出程序
AlarmManager mgr = (AlarmManager) m_LayaEngineContext.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000,
restartIntent); // 1秒钟后重启应用
m_LayaEngineContext.finishActivity(0);
}
// ------------------------------------------------------------------------------
static public void MyJSAlert(String title, String msg, int p_nCallbackType, final LayaConch5 _gameEngine) {
if(_gameEngine!=null)
_gameEngine.alertJS(title,msg,p_nCallbackType);
}
//------------------------------------------------------------------------------
static public void setScreenWakeLock( boolean p_bWakeLock ) {
Activity activity = LayaWrapper.getLayaApplicationActivity();
if(activity==null)
{
return;
}
if( p_bWakeLock )
{
LayaWrapper.getLayaApplicationActivity().getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON );
}
else
{
LayaWrapper.getLayaApplicationActivity().getWindow().clearFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON );
}
}
// ------------------------------------------------------------------------------
/*
* The follow code for plugin implementation
* author:kuo
*{{ begin
*/
static private Activity ms_layaMainActivity=null;
static public Context ms_mCtx=null;
static public Context getLayaApplicationContext()
{
return ms_mCtx;
}
static public Activity getLayaApplicationActivity()
{
return ms_layaMainActivity;
}
static public AssetManager getLayaApplicationAsset()
{
return ms_layaMainActivity.getAssets();
}
@Override
public void setLoadingView(View view) {
m_pExternalLoadingView = view;
}
}
@@ -0,0 +1,269 @@
package layaair.game.browser;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import layaair.game.conch.ILayaEventListener;
import layaair.game.conch.LayaConch5;
import layaair.game.floatmenu.FloatPanel;
import layaair.game.wrapper.ILayaLibWrapper;
import layaair.game.wrapper.LayaWrapperFactroy;
import com.layabox.conch6.R;
@SuppressLint("Wakelock")
public class MainActivity extends AppCompatActivity {
//------------------------------------------------------------------------------
private long m_nBackPressTime=0;
public ILayaLibWrapper mLayaEngine = null;
public static SplashDialog mSplashDialog;
public static FloatPanel m_FloatPanel = null;;
// ------------------------------------------------------------------------------
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
JSBridge.mMainActivity = this;
mSplashDialog = new SplashDialog(this);
mSplashDialog.showSplash();
m_FloatPanel = new FloatPanel(this);
setFullScreen(true);
Bundle bundle = new Bundle();
bundle.putString(LayaConch5.MARKET_MARKETNAME, "LayaMarket");
LayaConch5.setMarketBundle(bundle);
mLayaEngine = LayaWrapperFactroy.createLayaWrapper();
mLayaEngine.initEngine(this);
mLayaEngine.setAlertTitle(this.getString( R.string.alert_dialog_title ));
mLayaEngine.setStringOnBackPressed(this.getString( R.string.on_back_pressed ));
layaGameListener listener=new layaGameListener();
listener.activity=this;
mLayaEngine.setLayaEventListener(listener);
mLayaEngine.setInterceptKey(true);
Intent intent = getIntent();
String scheme = intent.getScheme();
Uri uri = intent.getData();
Log.e("2jni", "scheme:" + scheme);
mLayaEngine.setLocalizable(false);
if (uri != null) {
String host = uri.getHost();
String dataString = intent.getDataString();
String id = uri.getQueryParameter("d");
String path = uri.getPath();
String path1 = uri.getEncodedPath();
String queryString = uri.getQuery();
Log.e("2jni", "host:" + host);
Log.e("2jni", "dataString:" + dataString);
Log.e("2jni", "id:" + id);
Log.e("2jni", "path:" + path);
Log.e("2jni", "path1:" + path1);
Log.e("2jni", "queryString:" + queryString);
if (dataString.length() > 0) {
String gameUrl = "http" + dataString.substring(7);
Log.e("2jni", "setUrl from intent:" + gameUrl);
mLayaEngine.setGameUrl(gameUrl);
}
}
/*else
{
mLayaEngine.setGameUrl("http://10.10.30.29:8899/conch-main.html");
}*/
// HashMap<String, Object> _option = new HashMap<String, Object>();
// _option.put("sopath", "/data/data/com.layabox.conch3/pluginslib/");
// mLayaEngine.setOptions(_option);
// mLayaEngine.setGameUrl("http://10.10.30.29:8888/starthtml/index4.html");
// mLayaEngine.setGameUrl("http://192.168.0.106:8888/starthtml/default1.html");
mLayaEngine.startGame();
//删除全部推送消息
//LayaNotifyManager.removeAllNotify();
}
@Override
protected void onStop() {
super.onStop();
mLayaEngine.onStop();
}
// ---------------------------------------------------------------------------
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if(result != null) {
if(result.getContents() == null) {
Log.d("MainActivity", "Cancelled scan");
} else {
Log.d("MainActivity", "Scanned");
JSBridge.onScanResult(result.getContents());
}
}
super.onActivityResult(requestCode, resultCode, intent);
((LayaWrapper)mLayaEngine).onActivityResult(requestCode, resultCode, intent);
}
@Override
protected void onRestart() {
super.onRestart();
mLayaEngine.onRestart();
}
// ------------------------------------------------------------------------------
public void setFullScreen(boolean p_bFull) {
if (p_bFull) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
requestWindowFeature(Window.FEATURE_CONTEXT_MENU);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
// ------------------------------------------------------------------------------
@Override
protected void onPause() {
super.onPause();
mLayaEngine.onPause();
}
//------------------------------------------------------------------------------
@Override
protected void onResume() {
super.onResume();
mLayaEngine.onResume();
}
@Override
protected void onDestroy(){
super.onDestroy();
mLayaEngine.onDestroy();
mLayaEngine=null;
m_FloatPanel.destory();
m_FloatPanel = null;
mSplashDialog.dismiss();
mSplashDialog = null;
System.exit(0);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
mLayaEngine.onNewIntent(intent);
}
// ------------------------------------------------------------------------------
public boolean onCreateOptionsMenu(Menu menu) {
// menu.add(0, 0, 0, "refresh");
menu.add(0, 1, 1, "version");
menu.add(Menu.NONE, 2, 2, "url");
menu.add(Menu.NONE, 3, 3, "deviceInfo");
return super.onCreateOptionsMenu(menu);
}
// ------------------------------------------------------------------------------
public void MyAlert(String title, String msg) {
Builder pBuilder = new Builder(this);
pBuilder.setTitle(title);
pBuilder.setMessage(msg);
// 退出按钮
pBuilder.setPositiveButton("OK", new OnClickListener() {
public void onClick(DialogInterface p_pDialog, int arg1) {
p_pDialog.cancel();
}
});
AlertDialog alertdlg = pBuilder.create();
alertdlg.setCanceledOnTouchOutside(false);
alertdlg.show();
}
// ------------------------------------------------------------------------------
public boolean onOptionsItemSelected(MenuItem menuItem) {
super.onOptionsItemSelected(menuItem);
switch (menuItem.getItemId()) {
case 0:
break;
case 1:
MyAlert("", LayaWrapper.getAppVersionName());
break;
case 2:
MyAlert("", ExportJavaFunction.m_sHref);
break;
case 3: {
// 测试用的
int nW = LayaWrapper.GetScreenWidth();
int nH = LayaWrapper.GetScreenHeight();
int nDpi =1;
float nInch = LayaWrapper.GetScreenInch();
int nMoveRange = LayaWrapper.m_pEngine.game_plugin_getTouchMovRange();
MyAlert("", "w=" + nW + ",h=" + nH + ",dpi=" + nDpi + ",inch="
+ nInch + ",MovRange=" + nMoveRange);
}
break;
}
return true;
}
// ------------------------------------------------------------------------------
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.i("0", "=========onConfigurationChanged ORIENTATION_LANDSCAPE");
JSBridge.onOrientationChange();
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
Log.i("0", "=========onConfigurationChanged ORIENTATION_PORTRAIT");
JSBridge.onOrientationChange();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == PermisionUtils.REQUEST_EXTERNAL_STORAGEP_ERMISSION_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
mLayaEngine.checkApkUpdate();
}
else {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(R.string.waring);
dialog.setMessage(R.string.permission_waring);
dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mLayaEngine.checkApkUpdate();
}
});
dialog.show();
}
}
}
static class layaGameListener implements ILayaEventListener{
public Activity activity;
@Override
public void ExitGame() {
Log.i("=======", "======exit");
activity.finish();
activity=null;
//mLayaEngine.onDestroy();
System.exit(0);
}
@Override
public void destory() {
}
}
}
@@ -0,0 +1,23 @@
package layaair.game.browser;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
public class PermisionUtils {
public static final int REQUEST_EXTERNAL_STORAGEP_ERMISSION_CODE = 1;
public static boolean checkExternalStoragePermission(Context context) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_STORAGEP_ERMISSION_CODE);
}
else if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_STORAGEP_ERMISSION_CODE);
}
else {
return true;
}
return false;
}
}
@@ -0,0 +1,74 @@
package layaair.game.browser;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
import com.layabox.conch6.R;
/**
* Created by lvfulong on 2018/1/15.
*/
public class ScanActivity extends AppCompatActivity {
private CaptureManager capture;
private DecoratedBarcodeView barcodeScannerView;
public static Activity m_instance = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
m_instance = this;
setContentView(R.layout.activity_scan);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
toolbar.setTitle("");
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
barcodeScannerView = (DecoratedBarcodeView)findViewById(R.id.zxing_barcode_scanner);
capture = new CaptureManager(this, barcodeScannerView);
capture.initializeFromIntent(getIntent(), savedInstanceState);
capture.decode();
}
@Override
protected void onResume() {
super.onResume();
capture.onResume();
}
@Override
protected void onPause() {
super.onPause();
capture.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
capture.onDestroy();
m_instance = null;
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
capture.onSaveInstanceState(outState);
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return barcodeScannerView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
}
}
@@ -0,0 +1,121 @@
package layaair.game.browser;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import com.layabox.conch6.R;
public class SplashDialog extends Dialog {
private Context mContext;
private long mStartTime;
private long mleastShowTime = 2;
private TextView mTipsView;
private String[] mTips = {};
private int mFontColor;
private int mIndex = 0;
private int mPercent = 0;
private View mLayout;
Handler mSplashHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message message) {
super.handleMessage(message);
switch(message.what) {
case 0:
int length = mTips.length;
mSplashHandler.removeMessages(0);
if (length > 0) {
if (mIndex >= length) {
mIndex = 0;
}
mTipsView.setText(mTips[mIndex] + "(" + mPercent + "%)");
mIndex++;
}
mSplashHandler.sendEmptyMessageDelayed(0, 1000);
break;
case 1:
mSplashHandler.removeMessages(0);
mSplashHandler.removeMessages(1);
SplashDialog.this.dismiss();
break;
default:
break;
}
}
};
public SplashDialog(Context context) {
super(context, R.style.Splash);
mContext = context;
}
public void setTips(String[] tips) {
mTips = tips;
}
public void setPercent(int percent) {
mPercent = percent;
if (mPercent > 100) {
mPercent = 100;
}
if (mPercent < 0) {
mPercent = 0;
}
int length = mTips.length;
if (length > 0) {
if (mIndex >= mTips.length) {
mIndex = 0;
}
mTipsView.setText(mTips[mIndex] + "(" + mPercent + "%)");
}
if (mPercent == 100) {
dismissSplash();
}
}
public void setFontColor(int color) {
mTipsView.setTextColor(color);
}
public void setBackgroundColor(int color) {
mLayout.setBackgroundColor(color);
}
public void showTextInfo(boolean show) {
if (show) {
mTipsView.setVisibility(View.VISIBLE);
}
else {
mTipsView.setVisibility(View.INVISIBLE);
}
}
public void showSplash() {
this.show();
mStartTime = System.currentTimeMillis();
mSplashHandler.sendEmptyMessage(0);
}
public void dismissSplash() {
long showTime = System.currentTimeMillis() - mStartTime;
if (showTime >= mleastShowTime * 1000) {
mSplashHandler.sendEmptyMessage(1);
}
else {
mSplashHandler.sendEmptyMessageDelayed(1, (long) (this.mleastShowTime * 1000 - showTime));
}
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.splash_dialog);
mTipsView = (TextView)findViewById(R.id.tipsView);
mLayout = findViewById(R.id.layout);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_BACK){
return true;
}else {
return super.dispatchKeyEvent(event);
}
}
}
@@ -0,0 +1,122 @@
package layaair.game.floatmenu;
import com.layabox.conch6.R;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import layaair.game.browser.ConchJNI;
import layaair.game.browser.LayaWrapper;
public class FloatPanel extends FrameLayout {
private WindowManager mWindowManager;
private WindowManager.LayoutParams mParams;
private View mView;
private Context mContext;
private boolean mShow = false;
public FloatPanel(Context context) {
super(context);
mContext = context;
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater layout = (LayoutInflater)context.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = layout.inflate(R.layout.float_panel , null);
View panel = mView.findViewById(R.id.float_panel);
View refresh = panel.findViewById(R.id.refresh_btn);
View back = panel.findViewById(R.id.back_btn);
refresh.setOnClickListener(onClick);
back.setOnClickListener(onClick);
}
public void show() {
mParams = new WindowManager.LayoutParams();
mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mParams.gravity = Gravity.LEFT | Gravity.TOP;
mParams.format = PixelFormat.RGBA_8888;
mParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
mParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec((1<<30)-1, MeasureSpec.AT_MOST);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec((1<<30)-1, MeasureSpec.AT_MOST);
mView.measure(widthMeasureSpec, heightMeasureSpec);
int screenWidth = mWindowManager.getDefaultDisplay().getWidth();
int screenHeight = mWindowManager.getDefaultDisplay().getHeight();
if (mContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
mParams.x = screenWidth - mView.getMeasuredWidth() - 30;
mParams.y = 30;
}
if (mContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
mParams.x = screenWidth - mView.getMeasuredWidth() - 30;
mParams.y = 30;
}
try {
mWindowManager.addView(mView, mParams);
mShow = true;
} catch (Exception e) {
Log.d("", ">>>>>>>>>>>>>" + e.toString());
}
updatePosition();
}
public void hide() {
if (mShow) {
try {
mWindowManager.removeView( mView );
mShow = false;
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void destory() {
if (mShow) {
mWindowManager.removeViewImmediate( mView );
}
}
private static OnClickListener onClick = new OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.back_btn:
String js = "window.conchConfig.JSDebugMode = 1;";
ConchJNI.RunJS(js);
LayaWrapper.onPopMenu(LayaWrapper.BACK_TO_MAIN);
break;
case R.id.refresh_btn:
LayaWrapper.onPopMenu( LayaWrapper.REFRESH);
break;
default:
break;
}
}
};
public void updatePosition() {
if (mShow) {
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec( (1 << 30) - 1, MeasureSpec.AT_MOST );
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec( (1 << 30) - 1, MeasureSpec.AT_MOST );
mView.measure( widthMeasureSpec, heightMeasureSpec );
int screenWidth = mWindowManager.getDefaultDisplay().getWidth();
int screenHeight = mWindowManager.getDefaultDisplay().getHeight();
if (mContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
mParams.x = screenWidth - mView.getMeasuredWidth() - 30;
mParams.y = 30;
}
if (mContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
mParams.x = screenWidth - mView.getMeasuredWidth() - 30;
mParams.y = 30;
}
mWindowManager.updateViewLayout( mView, mParams );
}
}
}
@@ -0,0 +1,9 @@
package layaair.game.wrapper;
import layaair.game.browser.LayaWrapper;
public class LayaWrapperFactroy {
public static ILayaLibWrapper createLayaWrapper(){
return new LayaWrapper();
}
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/btn_back_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/btn_back_focused" /> <!-- focused -->
<item android:drawable="@drawable/btn_back_normal" /> <!-- default -->
</selector>
Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/btn_refresh_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/btn_refresh_focused" /> <!-- focused -->
<item android:drawable="@drawable/btn_refresh_normal" /> <!-- default -->
</selector>
Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

@@ -0,0 +1,25 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/my_awesome_toolbar"
android:layout_alignParentBottom="true"
android:id="@+id/zxing_barcode_scanner"
app:zxing_use_texture_view="true"/>
</RelativeLayout>
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/float_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/panel"
android:clickable="false"
android:gravity="center"
android:orientation="horizontal">
<ImageButton
android:id="@+id/refresh_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="TODO"
android:background="#00000000"
android:src="@drawable/btn_refresh" />
<ImageButton
android:id="@+id/back_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="false"
android:background="#00000000"
android:contentDescription="TODO"
android:src="@drawable/btn_back" />
</LinearLayout>
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<ImageView
android:id="@+id/logoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:maxHeight="200dp"
android:maxWidth="200dp"
android:src="@drawable/layabox"
tools:scaleType="fitCenter" />
<TextView
android:id="@+id/tipsView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="68dp"
android:text="" />
</RelativeLayout>
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="editText">#AAAAAA</color>
<color name="blue">#008dff</color>
<color name="gray">#bbbbbb</color>
<color name="back_tv_color">#FF000000</color>
<color name="plush_tv_color">#FF000000</color>
<color name="cancel_tv_color">#FF000000</color>
</resources>
@@ -0,0 +1,12 @@
<resources>
<string name="app_name">LayaBox2.0</string>
<string name="action_settings">Settings</string>
<string name="on_back_pressed">再次点击后退键退出游戏!</string>
<string name="exit">退出</string>
<string name="refresh">刷新</string>
<string name="deskTop">桌面</string>
<string name="alert_dialog_title">提示</string>
<string name="waring">警告</string>
<string name="permission_waring">未被授予读写外存权限,自动更新apk和Google Play APK扩展文件功能会被忽略</string>
<string name="ok">确定</string>
</resources>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
</style>
<style name="AppCompatCaptureTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="colorPrimary">#669999</item>
<item name="colorPrimaryDark">#ffb341</item>
<item name="colorAccent">#ffb341</item>
</style>
<style name="Splash" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
</resources>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path path="Android/data/com.layabox.conch6/" name="files_root" />
<external-path path="." name="external_storage_root" />
</paths>