diff --git a/app/src/main/java/com/zane/smapiinstaller/MainActivity.java b/app/src/main/java/com/zane/smapiinstaller/MainActivity.java index c787440..7aad8ee 100644 --- a/app/src/main/java/com/zane/smapiinstaller/MainActivity.java +++ b/app/src/main/java/com/zane/smapiinstaller/MainActivity.java @@ -36,7 +36,7 @@ public class MainActivity extends AppCompatActivity { @BindView(R.id.nav_view) NavigationView navigationView; - public void requestPermissions() + private void requestPermissions() { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { diff --git a/app/src/main/java/com/zane/smapiinstaller/constant/Constants.java b/app/src/main/java/com/zane/smapiinstaller/constant/Constants.java index 305e730..2f02bd7 100644 --- a/app/src/main/java/com/zane/smapiinstaller/constant/Constants.java +++ b/app/src/main/java/com/zane/smapiinstaller/constant/Constants.java @@ -1,8 +1,8 @@ package com.zane.smapiinstaller.constant; public class Constants { - public static String MOD_PATH = "StardewValley/Mods"; - public static String LOG_PATH = "StardewValley/ErrorLogs/SMAPI-latest.txt"; + public static final String MOD_PATH = "StardewValley/Mods"; + public static final String LOG_PATH = "StardewValley/ErrorLogs/SMAPI-latest.txt"; - public static String TARGET_PACKAGE_NAME = "com.zane.stardewvalley"; + public static final String TARGET_PACKAGE_NAME = "com.zane.stardewvalley"; } diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java b/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java index 231ff3f..84e36f5 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java @@ -44,9 +44,9 @@ public class ApkPatcher { private static final String PASSWORD = "android"; - private Context context; + private final Context context; - private static String TAG = "PATCHER"; + private static final String TAG = "PATCHER"; public ApkPatcher(Context context) { this.context = context; diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java b/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java index 7df4a5a..fcd6dfc 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java @@ -10,11 +10,9 @@ import android.util.Log; import android.view.View; import com.afollestad.materialdialogs.MaterialDialog; -import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.io.ByteStreams; import com.google.common.io.CharStreams; -import com.google.common.io.Files; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.zane.smapiinstaller.R; @@ -24,7 +22,6 @@ import org.zeroturnaround.zip.ZipUtil; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -109,26 +106,20 @@ public class CommonLogic { public static void showAlertDialog(View view, int title, String message) { Activity activity = getActivityFromView(view); if(activity != null && !activity.isFinishing()) { - activity.runOnUiThread(()->{ - new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show(); - }); + activity.runOnUiThread(()-> new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show()); } } public static void showAlertDialog(View view, int title, int message) { Activity activity = getActivityFromView(view); if(activity != null && !activity.isFinishing()) { - activity.runOnUiThread(()->{ - new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show(); - }); + activity.runOnUiThread(()-> new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show()); } } public static void showConfirmDialog(View view, int title, int message, MaterialDialog.SingleButtonCallback callback) { Activity activity = getActivityFromView(view); if(activity != null && !activity.isFinishing()) { - activity.runOnUiThread(()->{ - new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.confirm).negativeText(R.string.cancel).onAny(callback).show(); - }); + activity.runOnUiThread(()-> new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.confirm).negativeText(R.string.cancel).onAny(callback).show()); } } diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/GameLauncher.java b/app/src/main/java/com/zane/smapiinstaller/logic/GameLauncher.java index 09f90c7..9a391b7 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/GameLauncher.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/GameLauncher.java @@ -11,7 +11,7 @@ import com.zane.smapiinstaller.constant.Constants; public class GameLauncher { - private View root; + private final View root; public GameLauncher(View root) { this.root = root; diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/ManifestTagVisitor.java b/app/src/main/java/com/zane/smapiinstaller/logic/ManifestTagVisitor.java index b294ced..b3782e4 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/ManifestTagVisitor.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/ManifestTagVisitor.java @@ -1,13 +1,12 @@ package com.zane.smapiinstaller.logic; -import com.google.common.base.Function; import com.google.common.base.Predicate; import pxb.android.axml.NodeVisitor; -public class ManifestTagVisitor extends NodeVisitor { +class ManifestTagVisitor extends NodeVisitor { - private Predicate attrProcessLogic; + private final Predicate attrProcessLogic; public ManifestTagVisitor(NodeVisitor nv, Predicate attrProcessLogic) { super(nv); @@ -33,7 +32,7 @@ public class ManifestTagVisitor extends NodeVisitor { int type; Object obj; - public AttrArgs(String ns, String name, int resourceId, int type, Object obj) { + AttrArgs(String ns, String name, int resourceId, int type, Object obj) { this.ns = ns; this.name = name; this.resourceId = resourceId; diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java b/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java index e29a3ed..92711f6 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java @@ -26,9 +26,9 @@ import java.util.concurrent.ConcurrentLinkedQueue; public class ModAssetsManager { - private View root; + private final View root; - private static String TAG = "MANAGER"; + private static final String TAG = "MANAGER"; public ModAssetsManager(View root) { this.root = root; diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigFragment.java b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigFragment.java index 70ebe87..9f3885f 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigFragment.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigFragment.java @@ -4,11 +4,9 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; + import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import androidx.lifecycle.Observer; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -16,10 +14,6 @@ import butterknife.BindView; import butterknife.ButterKnife; import com.zane.smapiinstaller.R; -import com.zane.smapiinstaller.entity.ModManifestEntry; -import com.zane.smapiinstaller.logic.ModAssetsManager; - -import java.util.List; public class ConfigFragment extends Fragment { diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java index b2f993c..e5361fb 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java @@ -1,20 +1,17 @@ package com.zane.smapiinstaller.ui.config; -import android.content.Context; import android.view.View; import com.zane.smapiinstaller.entity.ModManifestEntry; import com.zane.smapiinstaller.logic.ModAssetsManager; import java.util.Collections; -import java.util.Comparator; import java.util.List; -import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; -public class ConfigViewModel extends ViewModel { +class ConfigViewModel extends ViewModel { private MutableLiveData> modList; diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/config/ModManifestAdapter.java b/app/src/main/java/com/zane/smapiinstaller/ui/config/ModManifestAdapter.java index 8f482c8..228b5f1 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/config/ModManifestAdapter.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/config/ModManifestAdapter.java @@ -1,13 +1,12 @@ package com.zane.smapiinstaller.ui.config; -import android.app.Activity; -import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; +import com.afollestad.materialdialogs.DialogAction; import com.zane.smapiinstaller.R; import com.zane.smapiinstaller.entity.ModManifestEntry; import com.zane.smapiinstaller.logic.CommonLogic; @@ -51,7 +50,7 @@ public class ModManifestAdapter extends RecyclerView.Adapter{ - switch (which){ - case POSITIVE: - File file = new File(modPath); - if(file.exists()) { - file.delete(); - } - break; + if (which == DialogAction.POSITIVE) { + File file = new File(modPath); + if (file.exists()) { + file.delete(); + } } }); } diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpFragment.java b/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpFragment.java index 3c261be..940c00a 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpFragment.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpFragment.java @@ -5,20 +5,18 @@ import android.os.Environment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; + import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import androidx.lifecycle.Observer; import androidx.navigation.NavController; import androidx.navigation.Navigation; import butterknife.ButterKnife; import butterknife.OnClick; +import com.afollestad.materialdialogs.DialogAction; import com.zane.smapiinstaller.R; import com.zane.smapiinstaller.constant.Constants; import com.zane.smapiinstaller.logic.CommonLogic; -import com.zane.smapiinstaller.ui.config.ConfigFragmentDirections; import java.io.File; @@ -38,12 +36,10 @@ public class HelpFragment extends Fragment { } @OnClick(R.id.button_release) void release() { CommonLogic.showConfirmDialog(this.getView(), R.string.confirm, R.string.test_message, (dialog, which)-> { - switch (which) { - case POSITIVE: - if(this.getString(R.string.test_message).contains("860453392")) { - CommonLogic.openUrl(this.getContext(), "mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + "AAflCLHiWw1haM1obu_f-CpGsETxXc6b"); - } - break; + if (which == DialogAction.POSITIVE) { + if (this.getString(R.string.test_message).contains("860453392")) { + CommonLogic.openUrl(this.getContext(), "mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + "AAflCLHiWw1haM1obu_f-CpGsETxXc6b"); + } } }); } diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpViewModel.java b/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpViewModel.java index 67aa52f..ce7d25f 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpViewModel.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/help/HelpViewModel.java @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; -public class HelpViewModel extends ViewModel { +class HelpViewModel extends ViewModel { private MutableLiveData mText;