Bug fix, donation entrance

This commit is contained in:
ZaneYork 2020-03-11 03:15:13 +08:00
parent b4e8917f8d
commit df58b507cc
19 changed files with 269 additions and 82 deletions

View File

@ -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'

View File

@ -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<ApkFilesManifest> findAllApkFileManifest(Context context) {
ApkFilesManifest apkFilesManifest = com.zane.smapiinstaller.utils.FileUtils.getAssetJson(context, "apk_files_manifest.json", ApkFilesManifest.class);
ArrayList<ApkFilesManifest> apkFilesManifests = Lists.newArrayList(apkFilesManifest);

View File

@ -180,6 +180,15 @@ public class ModAssetsManager {
return false;
}
ImmutableList<ModManifestEntry> 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<ModManifestEntry> 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();

View File

@ -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();
}
}

View File

@ -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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -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">
<TextView
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_qq_1"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/tencentqq"
android:contentDescription="@string/icon_desc" />
<Button
android:id="@+id/button_qq_group_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_message" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/img_qq_1"
app:layout_constraintEnd_toEndOf="parent"
style="@style/Widget.AppCompat.Button.Borderless"
android:gravity="center"
android:textSize="24sp"
android:text="@string/button_qq_group_1_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_qq_2"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/tencentqq"
android:contentDescription="@string/icon_desc" />
<Button
android:id="@+id/button_qq_group_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/img_qq_2"
app:layout_constraintEnd_toEndOf="parent"
style="@style/Widget.AppCompat.Button.Borderless"
android:gravity="center"
android:textSize="24sp"
android:text="@string/button_qq_group_2_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_test"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/ic_menu_share"
android:contentDescription="@string/icon_desc" />
<TextView
android:id="@+id/button_release"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/img_test"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:textSize="24sp"
android:text="@string/button_release" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_heart"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/heart"
android:contentDescription="@string/icon_desc" />
<Button
android:id="@+id/button_donation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/img_heart"
app:layout_constraintEnd_toEndOf="parent"
style="@style/Widget.AppCompat.Button.Borderless"
android:gravity="center"
android:textSize="24sp"
android:text="@string/button_donation_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@ -30,14 +30,6 @@
app:layout_constraintTop_toBottomOf="@id/guideline_h1"
app:layout_constraintStart_toEndOf="@id/button_nexus" />
<Button
android:id="@+id/button_release"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_release"
app:layout_constraintTop_toBottomOf="@id/guideline_h1"
app:layout_constraintStart_toEndOf="@id/button_logs" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_h1"
android:layout_width="wrap_content"

View File

@ -16,7 +16,7 @@
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/nav_header_desc"
android:contentDescription="@string/icon_desc"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher_round" />

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="donation_methods">
<item>支付寶</item>
<item>微信</item>
<item>QQ</item>
<item>紅包碼</item>
</string-array>
</resources>

View File

@ -4,7 +4,6 @@
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">SMAPI安裝器</string>
<string name="nav_header_subtitle">ZaneYork@qq.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">設置</string>
<string name="menu_install">安裝</string>
@ -45,13 +44,16 @@
<string name="error_no_supported_game_version">遊戲版本不支持,請更新版本或者下載兼容包</string>
<string name="menu_download">下載</string>
<string name="error_failed_to_download">無法下載目標資源</string>
<string name="error_depends_on_mod">%s依賴%s前置請先安裝它</string>
<string name="error_depends_on_mod">%1$s依賴%2$s前置請先安裝它</string>
<string name="locale_pack">語言包</string>
<string name="info">提示</string>
<string name="download_unpack_success">已完成下載安裝</string>
<string name="progress">進度</string>
<string name="downloading">正在下載: %d KB / %d KB</string>
<string name="downloading">正在下載: %1$d KB / %2$d KB</string>
<string name="menu_about">關於</string>
<string name="android_version_confirm">你的系統版本過老可能會導致0Harmony無效建議升級到安卓6及以上版本</string>
<string name="error_depends_on_mod_version" >The %s is depends on %s %s version or later, please update it first</string>
<string name="error_depends_on_mod_version" >%1$s依賴%2$s %3$s版本請先更新它</string>
<string name="button_qq_group_1_text">QQ群①: 860453392</string>
<string name="button_donation_text">捐贈</string>
<string name="button_qq_group_2_text">QQ群②: 1078428449</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="donation_methods">
<item>支付寶</item>
<item>微信</item>
<item>QQ</item>
<item>紅包碼</item>
</string-array>
</resources>

View File

@ -4,7 +4,6 @@
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">SMAPI安裝器</string>
<string name="nav_header_subtitle">ZaneYork@qq.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">設置</string>
<string name="menu_install">安裝</string>
@ -45,13 +44,16 @@
<string name="error_no_supported_game_version">遊戲版本不支持,請更新版本或者下載兼容包</string>
<string name="menu_download">下載</string>
<string name="error_failed_to_download">無法下載目標資源</string>
<string name="error_depends_on_mod">%s依賴%s前置請先安裝它</string>
<string name="error_depends_on_mod">%1$s依賴%2$s前置請先安裝它</string>
<string name="locale_pack">語言包</string>
<string name="info">提示</string>
<string name="download_unpack_success">已完成下載安裝</string>
<string name="progress">進度</string>
<string name="downloading">正在下載: %d KB / %d KB</string>
<string name="downloading">正在下載: %1$d KB / %2$d KB</string>
<string name="menu_about">關於</string>
<string name="android_version_confirm">你的系統版本過老可能會導致0Harmony無效建議升級到安卓6及以上版本</string>
<string name="error_depends_on_mod_version" >The %s is depends on %s %s version or later, please update it first</string>
<string name="error_depends_on_mod_version" >%1$s依賴%2$s %3$s版本請先更新它</string>
<string name="button_qq_group_1_text">QQ群①: 860453392</string>
<string name="button_donation_text">捐贈</string>
<string name="button_qq_group_2_text">QQ群②: 1078428449</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="donation_methods">
<item>支付宝</item>
<item>微信</item>
<item>QQ</item>
<item>红包码</item>
</string-array>
</resources>

View File

@ -4,7 +4,6 @@
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">SMAPI安装器</string>
<string name="nav_header_subtitle">ZaneYork@qq.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">设置</string>
<string name="menu_install">安装</string>
@ -45,13 +44,16 @@
<string name="error_no_supported_game_version">游戏版本不支持,请更新版本或者下载兼容包</string>
<string name="menu_download">下载</string>
<string name="error_failed_to_download">无法下载目标资源</string>
<string name="error_depends_on_mod">%s依赖%s前置请先安装它</string>
<string name="error_depends_on_mod">%1$s依赖%2$s前置请先安装它</string>
<string name="locale_pack">语言包</string>
<string name="info">提示</string>
<string name="download_unpack_success">已完成下载安装</string>
<string name="progress">进度</string>
<string name="downloading">正在下载: %d KB / %d KB</string>
<string name="downloading">正在下载: %1$d KB / %2$d KB</string>
<string name="menu_about">关于</string>
<string name="android_version_confirm">你的系统版本过老可能会导致0Harmony无效建议升级到安卓6及以上版本</string>
<string name="error_depends_on_mod_version" >%s依赖%s %s版本请先更新它</string>
<string name="button_qq_group_1_text">QQ群①: 860453392</string>
<string name="button_donation_text">捐赠</string>
<string name="button_qq_group_2_text">QQ群②: 1078428449</string>
<string name="error_depends_on_mod_version">%1$s依赖%2$s %3$s版本请先更新它</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="donation_methods">
<item>Alipay</item>
<item>WeChat</item>
<item>QQ</item>
<item>Red Packet Code</item>
</string-array>
</resources>

View File

@ -4,7 +4,6 @@
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">SMAPI Installer</string>
<string name="nav_header_subtitle">ZaneYork@qq.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string>
<string name="menu_install">Install</string>
@ -45,16 +44,20 @@
<string name="error_no_supported_game_version">Game version not supported, upgrade or download compat package first</string>
<string name="menu_download">Download</string>
<string name="error_failed_to_download">Failed to download target resources</string>
<string name="error_depends_on_mod">The %s is depends on %s, please install it first</string>
<string name="error_depends_on_mod">The %1$s is depends on %2$s, please install it first</string>
<string name="locale_pack">Locale Pack</string>
<string name="info">Info</string>
<string name="download_unpack_success">Download and unpack success</string>
<string name="progress">Progress</string>
<string name="downloading">Downloading: %d KB / %d KB</string>
<string name="downloading">Downloading: %1$d KB / %2$d KB</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="menu_about">About</string>
<string name="android_version_confirm">You device system version is too old for MonoMod, this may leads to crash of 0Harmony framework, update to Android M or later if possible</string>
<string name="error_depends_on_mod_version">The %s is depends on %s %s version or later, please update it first</string>
<string name="error_depends_on_mod_version">The %1$s is depends on %2$s %3$s version or later, please update it first</string>
<string name="button_qq_group_1_text">QQ Group 1: 860453392</string>
<string name="button_qq_group_2_text">QQ Group 2: 1078428449</string>
<string name="icon_desc" translatable="false">icon</string>
<string name="button_donation_text">Donation</string>
<string name="toast_redpacket_message" translatable="false">红包码已复制\n支付宝首页搜索“9188262” 立即领红包</string>
</resources>

View File

@ -5,11 +5,10 @@ buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha02"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha03"
// NOTE: Do not place your application dependencies here; they belong
@ -21,6 +20,7 @@ allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}