Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
apk_product
/
ForFun
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
7d192121
...
7d192121f62071a6cae8771479533b19abd7e438
authored
2020-03-30 18:50:01 +0800
by
金学艇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.解决安装包解析错误和卸载apk不能清理残留数据的问题
2.新增网络判断
1 parent
1a642582
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
10 deletions
assets/Scene/sceneMain.fire
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/CommonUtils.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/MelodyApplication.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/OBiPluginLoader.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/TopdrawSDKWrapper.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java
assets/Scene/sceneMain.fire
View file @
7d19212
...
...
@@ -192,7 +192,7 @@
"array": [
0,
0,
271.060
302734375
,
271.060
6994628906
,
0,
0,
0,
...
...
@@ -5376,8 +5376,8 @@
}
],
"_useOriginalSize": false,
"_string": "v1.0.0.202003
17
17",
"_N$string": "v1.0.0.202003
17
17",
"_string": "v1.0.0.202003
30
17",
"_N$string": "v1.0.0.202003
30
17",
"_fontSize": 24,
"_lineHeight": 24,
"_enableWrapText": true,
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/CommonUtils.java
0 → 100644
View file @
7d19212
package
com
.
topdraw
.
melody
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.text.TextUtils
;
import
java.io.File
;
/**
* author : Jinwawa
* date : 2020/3/30 0030.
* desc : 自定义工具类
*/
public
class
CommonUtils
{
public
static
boolean
checkAppInstalled
(
Context
context
,
String
pkgName
)
{
if
(
pkgName
==
null
||
pkgName
.
isEmpty
())
{
return
false
;
}
PackageInfo
packageInfo
;
try
{
packageInfo
=
context
.
getPackageManager
().
getPackageInfo
(
pkgName
,
0
);
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
packageInfo
=
null
;
e
.
printStackTrace
();
}
if
(
packageInfo
==
null
)
{
return
false
;
}
else
{
return
true
;
//true为安装了,false为未安装
}
}
/**
* 删除指定目录下的文件及目录
*/
public
static
void
deleteFolderFile
(
String
filePath
,
boolean
deleteThisPath
)
{
if
(!
TextUtils
.
isEmpty
(
filePath
))
{
File
file
=
new
File
(
filePath
);
if
(
file
.
isDirectory
())
{
File
files
[]
=
file
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
deleteFolderFile
(
files
[
i
].
getAbsolutePath
(),
true
);
}
}
if
(
deleteThisPath
)
{
if
(!
file
.
isDirectory
())
{
file
.
delete
();
}
else
{
if
(
file
.
listFiles
().
length
==
0
)
{
file
.
delete
();
}
}
}
}
}
public
static
boolean
isNetworkAvalible
(
Context
context
)
{
ConnectivityManager
connectivityManager
=
(
ConnectivityManager
)
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
if
(
connectivityManager
==
null
)
{
return
false
;
}
else
{
NetworkInfo
[]
net_info
=
connectivityManager
.
getAllNetworkInfo
();
if
(
net_info
!=
null
)
{
for
(
int
i
=
0
;
i
<
net_info
.
length
;
i
++)
{
if
(
net_info
[
i
].
getState
()
==
NetworkInfo
.
State
.
CONNECTED
)
{
return
true
;
}
}
}
}
return
false
;
}
}
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/MelodyApplication.java
View file @
7d19212
...
...
@@ -24,7 +24,8 @@ public class MelodyApplication extends TopdrawApplication {
public
static
AppActivity
appActivity
;
public
static
boolean
authResult
=
false
;
private
static
MelodyApplication
app
;
public
static
String
TOPDRAW_API_PATH
=
"http://139.196.4.234:38080/hyperion.chimera"
;;;
public
static
String
TOPDRAW_API_PATH
=
"http://139.196.4.234:38080/hyperion.chimera"
;
;;
private
Handler
mHandler
=
new
Handler
();
@Override
...
...
@@ -40,6 +41,8 @@ public class MelodyApplication extends TopdrawApplication {
PluginLoader
.
getInstance
().
init
(
getApplicationContext
(),
mHandler
,
TOPDRAW_API_PATH
,
"/plugin/plugin.json"
);
PluginLoader
.
getInstance
().
start
();
OBiPluginLoader
.
getInstance
().
init
(
getApplicationContext
());
//CrashHandler crashHandler = CrashHandler.getInstance();
//crashHandler.setCustomCrashHanler(getApplicationContext());
//MobclickAgent.UMAnalyticsConfig kk = new MobclickAgent.UMAnalyticsConfig(this,"5a168338a40fa377b500012b","amt");
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/OBiPluginLoader.java
View file @
7d19212
...
...
@@ -30,18 +30,20 @@ public class OBiPluginLoader {
private
static
OBiPluginLoader
instance
;
private
String
server
;
private
String
path
=
"
http://topdraw-game.oss-cn-shanghai.aliyuncs.com/forfun/XhxAndroid_bird_shdx.apk
"
;
private
String
path
=
""
;
public
static
final
int
PROGRESS_1
=
100
;
public
static
final
int
PROGRESS_0_1
=
10
;
public
static
final
int
PROGRESS_0_01
=
1
;
public
static
double
PROGRESS
=
PROGRESS_1
;
private
String
sdPath
=
Environment
.
getExternalStorageDirectory
()
+
"/"
;
// private String sdPath = Environment.getExternalStorageDirectory() + "/";
private
File
sdPath
;
private
HttpURLConnection
conn
;
private
BufferedInputStream
bis
=
null
;
private
FileOutputStream
fos
=
null
;
private
File
fTemp
;
private
File
dirPackage
;
private
Context
context
;
public
static
OBiPluginLoader
getInstance
()
{
if
(
null
==
instance
)
{
...
...
@@ -50,6 +52,11 @@ public class OBiPluginLoader {
return
instance
;
}
public
void
init
(
Context
context
)
{
this
.
context
=
context
;
sdPath
=
context
.
getExternalCacheDir
().
getParentFile
();
//用这个路径完美解决了解析错误和卸载应用不能删除残留数据的问题
}
/**
* 判断是否有APK
*
...
...
@@ -57,7 +64,7 @@ public class OBiPluginLoader {
* @return
*/
public
boolean
isExistApk
(
String
packageName
)
{
final
File
dirPackage
=
new
File
(
sdPath
+
packageName
);
final
File
dirPackage
=
new
File
(
sdPath
,
packageName
);
if
(
dirPackage
.
exists
())
{
String
path
=
null
;
File
[]
files
=
dirPackage
.
listFiles
();
...
...
@@ -88,7 +95,7 @@ public class OBiPluginLoader {
public
void
start
(
String
downloadUrl
,
String
packageName
,
final
OnResultListener
rListener
,
final
OnProgressListener
pListener
)
{
this
.
path
=
downloadUrl
;
dirPackage
=
new
File
(
sdPath
+
packageName
);
dirPackage
=
new
File
(
sdPath
,
packageName
);
final
OnProgressListener
pl
=
new
OnProgressListener
()
{
@Override
public
void
onProgress
(
double
d
)
{
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/TopdrawSDKWrapper.java
View file @
7d19212
...
...
@@ -21,6 +21,7 @@ import com.topdraw.forfun.R;
import
com.topdraw.sdk.*
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.*
;
import
org.cocos2dx.javascript.AppActivity
;
...
...
@@ -322,7 +323,7 @@ public class TopdrawSDKWrapper {
}
public
static
void
closeDownloadObiApk
()
{
Log
.
d
(
TAG
,
"取消下载。。。"
);
Log
.
d
(
TAG
,
"取消下载。。。"
);
OBiPluginLoader
.
getInstance
().
closeDownloadApk
();
}
...
...
@@ -353,6 +354,15 @@ public class TopdrawSDKWrapper {
*/
public
static
void
startInstall
(
Context
context
,
String
path
)
{
Log
.
d
(
TAG
,
"安装的包路径。。。"
+
path
);
//修改安装包权限
// String cmd="chmod 777 "+path;
// try {
// Runtime.getRuntime().exec(cmd);
// } catch (IOException e) {
// e.printStackTrace();
// }
Intent
install
=
new
Intent
(
Intent
.
ACTION_VIEW
);
install
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
install
.
setDataAndType
(
Uri
.
fromFile
(
new
File
(
path
)),
"application/vnd.android.package-archive"
);
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java
View file @
7d19212
...
...
@@ -28,14 +28,18 @@ import org.cocos2dx.lib.Cocos2dxActivity;
import
org.cocos2dx.lib.Cocos2dxGLSurfaceView
;
import
org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge
;
import
android.app.AlertDialog
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.IntentFilter
;
import
android.os.Bundle
;
import
android.content.Intent
;
import
android.content.res.Configuration
;
import
android.os.Environment
;
import
android.os.Handler
;
import
android.provider.Settings
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
...
...
@@ -47,9 +51,11 @@ import android.widget.FrameLayout;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
com.topdraw.component.CocosMediaPlayer
;
import
com.topdraw.forfun.R
;
import
com.topdraw.melody.CommonUtils
;
import
com.topdraw.melody.MelodyApplication
;
import
com.topdraw.melody.TopdrawSDKWrapper
;
...
...
@@ -68,6 +74,10 @@ public class AppActivity extends Cocos2dxActivity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Log
.
d
(
TAG
,
"判断APK是否安装。。。"
+
getExternalCacheDir
().
getPath
());
checkNetwork
();
//检查网络
//----解决游戏页按返回退出时,背景图透明度过高,onPause和onResume中控制显示还是隐藏
singleView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
activity_main_single_color
,
null
);
mRLSingleColor
=
singleView
.
findViewById
(
R
.
id
.
ll_single
);
...
...
@@ -160,7 +170,6 @@ public class AppActivity extends Cocos2dxActivity {
// setTheme(android.R.style.Theme_NoDisplay);
super
.
onPause
();
SDKWrapper
.
getInstance
().
onPause
();
}
@Override
...
...
@@ -248,6 +257,34 @@ public class AppActivity extends Cocos2dxActivity {
});
}
//检查网络
private
void
checkNetwork
()
{
Log
.
d
(
TAG
,
"网络链接:"
+
CommonUtils
.
isNetworkAvalible
(
AppActivity
.
this
));
if
(!
CommonUtils
.
isNetworkAvalible
(
AppActivity
.
this
))
{
TextView
msg
=
new
TextView
(
AppActivity
.
this
);
msg
.
setText
(
" 当前未连接网络,请设置网络后登陆!"
);
new
AlertDialog
.
Builder
(
AppActivity
.
this
)
.
setIcon
(
R
.
mipmap
.
ic_launcher
)
.
setTitle
(
"网络状态提示"
)
.
setView
(
msg
)
.
setPositiveButton
(
"确定"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
startActivity
(
new
Intent
(
Settings
.
ACTION_WIRELESS_SETTINGS
));
try
{
new
Thread
().
sleep
(
2000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
AppActivity
.
this
.
finish
();
System
.
exit
(
0
);
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
}
}).
create
().
show
();
}
}
public
View
getProgressBarView
()
{
return
view
;
}
...
...
Please
register
or
sign in
to post a comment