Future support for Galaxy store versions

This commit is contained in:
Chris 2019-08-09 19:50:58 -04:00
parent cf53b76d29
commit 24c1296b25
4 changed files with 21 additions and 20 deletions

View File

@ -17,7 +17,7 @@ import android.util.Log;
public class ApkExtractor{
private static final String TAG = "ApkExtractor";
private static final String[] PACKAGE_NAMES = {"com.martyrpher.stardewvalley", "com.chucklefish.stardewvalley"};
private static final String[] PACKAGE_NAMES = {"com.martyrpher.stardewvalley", "com.chucklefish.stardewvalley", "com.chucklefish.stardewvalleysamsung"};
private final Context context;
@ -25,6 +25,10 @@ public class ApkExtractor{
private PackageManager mPackageManager;
private PackageInfo mPackageInfo;
public static String sourceApkFilename;
private boolean[] foundApk = {false, false, false};
public ApkExtractor(Context appContext)
{
this.context = appContext;
@ -33,7 +37,7 @@ public class ApkExtractor{
public boolean[] checkForInstallOrUpgrade()
{
mPackageManager = context.getPackageManager();
boolean[] foundApk = {false, false};
for (int i = 0; i < foundApk.length; i++)
{
try
@ -60,6 +64,7 @@ public class ApkExtractor{
try
{
File apkFile = new File(mApplicationInfo.publicSourceDir);
Log.e(TAG, "APK path: " + mApplicationInfo.publicSourceDir);
File dest = new File(Environment.getExternalStorageDirectory() + "/SMAPI Installer/");
if (apkFile.exists()) {
try {
@ -67,6 +72,7 @@ public class ApkExtractor{
{
if(dest.mkdir());//directory is created;
}
sourceApkFilename = apkFile.getName();
copy(apkFile.getAbsoluteFile(), new File(dest, apkFile.getName()));
} catch (IOException e) {
Log.e(TAG, e.getLocalizedMessage());

View File

@ -23,16 +23,6 @@ public class DialogFrag extends DialogFragment {
private static ProgressBar mProgressBar;
private static TextView mTextView;
//Test array to cycle through different messages
private static int[] messages = { R.string.installing_pufferchicks,
R.string.install_milk_cows,
R.string.install_ancient_fruit ,
R.string.install_abigail_rocks,
R.string.install_feeding_juminos,
R.string.install_squid_ocean,
R.string.install_dino_egg,
R.string.install_rock_crab };
public DialogFrag()
{
}

View File

@ -38,7 +38,7 @@ public class MainActivity extends AppCompatActivity {
foundGame = apkExtractor.checkForInstallOrUpgrade();
if((foundGame[0] || foundGame[1]))
if((foundGame[0] || foundGame[1] || foundGame[2]))
{
BackgroundTask backgroundTask = new BackgroundTask(MainActivity.this, apkExtractor, foundGame[0]);
backgroundTask.execute();

View File

@ -1,5 +1,7 @@
package com.MartyrPher.smapiandroidinstaller;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@ -7,14 +9,13 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class WriteApk {
private static final String TAG = "OpenApk";
private static final String TAG = "WriteApk";
//Blank Constructor
public WriteApk()
@ -25,13 +26,15 @@ public class WriteApk {
try
{
byte[] buffer = new byte[4096];
ZipFile zipFile = new ZipFile(source);
ZipInputStream zin = new ZipInputStream(new FileInputStream(source));
ZipOutputStream out = new ZipOutputStream(new FileOutputStream( source + "_patched.apk"));
for(int i = 0; i < files.length; i++){
CRC32 crc = new CRC32();
CRC32 crc = new CRC32();
for(int i = 0; i < files.length; i++)
{
if (!compression[i])
{
int bytesRead;
@ -63,6 +66,7 @@ public class WriteApk {
}
for(ZipEntry ze = zin.getNextEntry(); ze != null; ze = zin.getNextEntry()){
if(!apkEntryMatch(ze.getName(), files, path)){
//ZipEntry loc_ze = new ZipEntry(ze.getName());
out.putNextEntry(ze);
for(int read = zin.read(buffer); read > -1; read = zin.read(buffer)){
out.write(buffer, 0, read);
@ -73,8 +77,9 @@ public class WriteApk {
out.close();
zin.close();
source.delete();
}catch(Exception e){
e.printStackTrace();
}
catch(Exception e){
Log.e(TAG, e.getMessage(), e);
}
}