Skip to content

Commit

Permalink
小修改
Browse files Browse the repository at this point in the history
  • Loading branch information
StArrayJaN committed Oct 11, 2023
1 parent 071c2fb commit 29cb6dd
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 57 deletions.
20 changes: 0 additions & 20 deletions .androidide/editor/openedFiles.json

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Android CI Debug

on:
pull_request:
push:

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '17'

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew assembleDebug

- name: Upload Debug apk
uses: actions/upload-artifact@v3
with:
name: apk-debug
path: app/build/outputs/apk/debug
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/app/build
/.gradle
/local.properties
/local.properties
/push.sh
Binary file added app/src/main/assets/wmw-extra.zip
Binary file not shown.
24 changes: 1 addition & 23 deletions app/src/main/java/com/disney/WMW/WMWActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,6 @@ protected void onPause() {

protected void onResume() {
super.onResume();
if (new File(getObbPath()).exists())
{
notifyAddObbFilePathToFileManager(getObbPath());
}
this.isRunning = true;
if (this._view != null) {
this.resumeOnFocus = false;
Expand Down Expand Up @@ -424,25 +420,7 @@ protected void onResume() {
shareHandler.sendMessageDelayed(message, 5000L);
}

public String getObbPath() {
PackageManager packageManager = getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {}

String pn = getPackageName();
if (Environment.getExternalStorageState().equals("mounted")) {
File file = Environment.getExternalStorageDirectory();
file = new File(file.toString() + "/Android/obb/" + pn);
if (packageInfo.versionCode > 0) {
String str = file + File.separator + "main." + packageInfo.versionCode + "." + pn + ".obb";
Log.e("WMW", "obbFilePath: " + str);
return str;
}
}
return null;
}


protected void onStart() {
super.onStart();
Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/thercn/wmw/AppUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package thercn.wmw;

import android.app.Activity;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class AppUtils {
public static void ExportAssets(Activity activity, String outPath,
String fileName) {
File outdir = new File(outPath);
if (!outdir.exists()) {
outdir.mkdirs();
}
try {
InputStream inputStream = activity.getAssets().open(fileName);
File outFile = new File(outdir, fileName);
if (outFile.exists()) {
return;
}
FileOutputStream fileOutputStream = new FileOutputStream(outFile);
byte[] buffer = new byte[1024];
int byteRead;
while (-1 != (byteRead = inputStream.read(buffer))) {
fileOutputStream.write(buffer, 0, byteRead);
}
inputStream.close();
fileOutputStream.flush();
fileOutputStream.close();
} catch (IOException e) {
Log.e("WMW", "", e);
}
}


}
70 changes: 57 additions & 13 deletions app/src/main/java/thercn/wmw/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,92 @@
package thercn.wmw;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Switch;
import android.widget.CheckBox;
import com.disney.WMW.WMWActivity;
import java.io.File;
import java.io.IOException;
import android.widget.CheckBox;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class MainActivity extends Activity {


public static String appDataDir = Environment.getExternalStorageDirectory().toString() + "/WMW";
public static boolean isIPadScreen = false;
static
{
System.loadLibrary("wmw");
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Permission.申请(this);
File obbdir = getObbDir();
if (!obbdir.exists()) {

File dataDir = new File(appDataDir);
File extraDataFile = new File(appDataDir + "/wmw-extra.zip");
if (!obbdir.exists() || !dataDir.exists()) {
obbdir.mkdirs();
dataDir.mkdirs();
}
String obbPath = getObbPath();
if (!extraDataFile.exists()) {
AppUtils.ExportAssets(this, appDataDir, "wmw-extra.zip");
}
try {
Runtime.getRuntime().exec("logcat >" + "/sdcard/wmw.log");
} catch (IOException e) {}
Runtime.getRuntime().exec("cp " + extraDataFile.toString() + " " + obbPath);
Runtime.getRuntime().exec("logcat >" + appDataDir + "/wmw.log");
} catch (IOException e) {

} finally {
Path source = Paths.get(extraDataFile.toString());
Path target = Paths.get(obbPath);
try {
Files.copy(source, target);
} catch (IOException e) {}
}
initLayout();

}

public String getObbPath() {
PackageManager packageManager = getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {}

String pn = getPackageName();
if (Environment.getExternalStorageState().equals("mounted")) {
File file = Environment.getExternalStorageDirectory();
file = new File(getObbDir().toString() + "/" + pn);
if (packageInfo.versionCode > 0) {
String str = file + File.separator + "main." + packageInfo.versionCode + "." + pn + ".obb";
Log.e("WMW", "obbFilePath: " + str);
return str;
}
}
return null;
}

private void initLayout() {
final CheckBox ipadScreen = findViewById(R.id.resetSize);
Button startGame = findViewById(R.id.startGame);
ipadScreen.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
if (ipadScreen.isChecked())
{
if (ipadScreen.isChecked()) {
isIPadScreen = true;
}
}
Expand All @@ -51,10 +95,10 @@ public void onClick(View view) {

@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this,WMWActivity.class);
Intent intent = new Intent(MainActivity.this, WMWActivity.class);
startActivity(intent);
}
});
}

}

0 comments on commit 29cb6dd

Please sign in to comment.