diff --git a/app/build.gradle b/app/build.gradle index 5c4a2be..e1521e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.zane.smapiinstaller" minSdkVersion 19 targetSdkVersion 28 - versionCode 6 - versionName "1.1.2" + versionCode 7 + versionName "1.1.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true @@ -68,6 +68,8 @@ dependencies { implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.3' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.10.3' + implementation 'com.github.didikee:AndroidDonate:0.1.0' + testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 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 71f668d..1a16519 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java @@ -1,6 +1,8 @@ package com.zane.smapiinstaller.logic; import android.app.Activity; +import android.content.ClipData; +import android.content.ClipboardManager; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; @@ -111,6 +113,17 @@ public class CommonLogic { context.startActivity(intent); } + public static boolean copyToClipboard(Context context, String copyStr) { + try { + ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); + ClipData mClipData = ClipData.newPlainText("Label", copyStr); + cm.setPrimaryClip(mClipData); + return true; + } catch (Exception e) { + return false; + } + } + public static List findAllApkFileManifest(Context context) { ApkFilesManifest apkFilesManifest = com.zane.smapiinstaller.utils.FileUtils.getAssetJson(context, "apk_files_manifest.json", ApkFilesManifest.class); ArrayList apkFilesManifests = Lists.newArrayList(apkFilesManifest); 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 ab75df3..8a43712 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java @@ -180,6 +180,15 @@ public class ModAssetsManager { return false; } ImmutableList entries = installedModMap.get(dependency.getUniqueID()); + if(entries.size() == 0) { + for (String key : installedModMap.keySet()) { + if(StringUtils.equalsIgnoreCase(key, dependency.getUniqueID())) { + dependency.setUniqueID(key); + entries = installedModMap.get(dependency.getUniqueID()); + break; + } + } + } if (entries.size() != 1) return true; String version = entries.get(0).getVersion(); @@ -223,6 +232,15 @@ public class ModAssetsManager { return null; } ImmutableList entries = installedModMap.get(dependency.getUniqueID()); + if(entries.size() == 0) { + for (String key : installedModMap.keySet()) { + if(StringUtils.equalsIgnoreCase(key, dependency.getUniqueID())) { + dependency.setUniqueID(key); + entries = installedModMap.get(dependency.getUniqueID()); + break; + } + } + } if (entries.size() != 1) return root.getContext().getString(R.string.error_depends_on_mod, mod.getUniqueID(), dependency.getUniqueID()); String version = entries.get(0).getVersion(); diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/about/AboutFragment.java b/app/src/main/java/com/zane/smapiinstaller/ui/about/AboutFragment.java index 062cda8..0cf88dc 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/about/AboutFragment.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/about/AboutFragment.java @@ -1,65 +1,82 @@ package com.zane.smapiinstaller.ui.about; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.didikee.donate.AlipayDonate; import android.os.Bundle; import androidx.fragment.app.Fragment; +import butterknife.ButterKnife; +import butterknife.OnClick; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.Toast; +import com.afollestad.materialdialogs.MaterialDialog; import com.zane.smapiinstaller.R; +import com.zane.smapiinstaller.logic.CommonLogic; + +import java.time.Duration; -/** - * A simple {@link Fragment} subclass. - * Use the {@link AboutFragment#newInstance} factory method to - * create an instance of this fragment. - */ public class AboutFragment extends Fragment { - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - - public AboutFragment() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment AboutFragment. - */ - // TODO: Rename and change types and number of parameters - public static AboutFragment newInstance(String param1, String param2) { - AboutFragment fragment = new AboutFragment(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } - } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_about, container, false); + View root = inflater.inflate(R.layout.fragment_about, container, false); + ButterKnife.bind(this, root); + return root; + } + @OnClick(R.id.button_release) void release() { + CommonLogic.openUrl(this.getContext(), "https://github.com/ZaneYork/SMAPI-Android-Installer/releases"); + } + @OnClick({R.id.button_qq_group_1, R.id.button_qq_group_2}) void joinQQ(Button which) { + String baseUrl = "mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D"; + if(which.getId() == R.id.button_qq_group_1) { + CommonLogic.openUrl(this.getContext(), baseUrl + "AAflCLHiWw1haM1obu_f-CpGsETxXc6b"); + } + else { + CommonLogic.openUrl(this.getContext(), baseUrl + "kshK7BavcS2jXZ6exDvezc18ksLB8YsM"); + } + } + + @OnClick(R.id.button_donation) void donation() { + Context context = this.getContext(); + new MaterialDialog.Builder(context).title(R.string.button_donation_text).items(R.array.donation_methods).itemsCallback((dialog, itemView, position, text) -> { + switch (position){ + case 0: + boolean hasInstalledAlipayClient = AlipayDonate.hasInstalledAlipayClient(context); + if (hasInstalledAlipayClient) { + AlipayDonate.startAlipayClient(this.getActivity(), "fkx13570v1pp2xenyrx4y3f"); + } + else { + CommonLogic.openUrl(context, "http://dl.zaneyork.cn/alipay.png"); + } + break; + case 1: + CommonLogic.openUrl(context, "http://dl.zaneyork.cn/wechat.png"); + break; + case 2: + CommonLogic.openUrl(context, "http://dl.zaneyork.cn/qqpay.png"); + break; + case 3: + hasInstalledAlipayClient = AlipayDonate.hasInstalledAlipayClient(context); + if (hasInstalledAlipayClient) { + if (CommonLogic.copyToClipboard(context, "9188262")) { + PackageManager packageManager = context.getPackageManager(); + Intent intent = packageManager.getLaunchIntentForPackage("com.eg.android.AlipayGphone"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + Toast.makeText(context, R.string.toast_redpacket_message, Toast.LENGTH_LONG).show(); + } + } + break; + } + }).show(); } } 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 8a7e0fe..defef85 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 @@ -33,9 +33,6 @@ public class HelpFragment extends Fragment { @OnClick(R.id.button_nexus) void nexus() { CommonLogic.openUrl(this.getContext(), "https://www.nexusmods.com/stardewvalley/mods/"); } - @OnClick(R.id.button_release) void release() { - CommonLogic.openUrl(this.getContext(), "https://github.com/ZaneYork/SMAPI-Android-Installer/releases"); - } @OnClick({R.id.button_logs}) void showLog() { NavController controller = Navigation.findNavController(this.getView()); File logFile = new File(Environment.getExternalStorageDirectory(), Constants.LOG_PATH); diff --git a/app/src/main/res/drawable/heart.png b/app/src/main/res/drawable/heart.png new file mode 100644 index 0000000..0b5731c Binary files /dev/null and b/app/src/main/res/drawable/heart.png differ diff --git a/app/src/main/res/drawable/tencentqq.png b/app/src/main/res/drawable/tencentqq.png new file mode 100644 index 0000000..c93c078 Binary files /dev/null and b/app/src/main/res/drawable/tencentqq.png differ diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index d6d36c4..449c32d 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -3,13 +3,116 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" android:divider="@drawable/horizontal_divider" + android:padding="10dp" android:showDividers="middle" + android:orientation="vertical" tools:context=".ui.about.AboutFragment"> - + android:layout_height="wrap_content"> + +