diff --git a/.gitignore b/.gitignore index 2356e1e..167c63f 100644 --- a/.gitignore +++ b/.gitignore @@ -87,4 +87,5 @@ lint/reports/ /debug /release -keystore.properties \ No newline at end of file +keystore.properties +bugly.properties \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6fd9e2b..6f32454 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 4e46b94..990b09a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "tech.yojigen.pivisionm" minSdkVersion 19 targetSdkVersion 29 - versionCode 443000 - versionName '4.4.3' + versionCode 443002 + versionName '4.4.3(443002)' vectorDrawables.useSupportLibrary = true multiDexEnabled = true } @@ -85,4 +85,15 @@ dependencies { implementation 'com.tencent.bugly:crashreport_upgrade:1.4.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' +} + +apply plugin: 'bugly' + +bugly { + def buglyProperties = new Properties() + def buglyPropertiesFile = project.rootProject.file("bugly.properties") + buglyProperties.load(new FileInputStream(buglyPropertiesFile)) + + appId = buglyProperties['APP_ID'] + appKey = buglyProperties['APP_KEY'] } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f65ce8c..9fdd7d4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ android:label="@string/app_name" android:largeHeap="true" android:networkSecurityConfig="@xml/network_security_config" + android:requestLegacyExternalStorage="true" android:resizeableActivity="true" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" diff --git a/app/src/main/java/com/reiya/pixiv/base/BaseApplication.java b/app/src/main/java/com/reiya/pixiv/base/BaseApplication.java index de7100e..956d057 100644 --- a/app/src/main/java/com/reiya/pixiv/base/BaseApplication.java +++ b/app/src/main/java/com/reiya/pixiv/base/BaseApplication.java @@ -4,6 +4,7 @@ import android.app.Application; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.AsyncTask; @@ -125,7 +126,7 @@ private static String getDeviceInfo() { } public static String getUA() { - return "PixivAndroidApp/5.0.156 " + getDeviceInfo(); + return "PixivAndroidApp/5.0.164 " + getDeviceInfo(); } public static String getAppVersionName(Context context) { @@ -153,7 +154,13 @@ public void onCreate() { super.onCreate(); sInstance = this; - Bugly.init(getApplicationContext(), "0fc124925c", true); + //判断是否为Debug版本 + ApplicationInfo applicationInfo = getApplicationInfo(); + if ((applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { + Bugly.init(getApplicationContext(), "0fc124925c", true); + } else { + Bugly.init(getApplicationContext(), "0fc124925c", false); + } HttpClient.init(this); diff --git a/app/src/main/java/com/reiya/pixiv/network/fuckgfw/PixivDNS.java b/app/src/main/java/com/reiya/pixiv/network/fuckgfw/PixivDNS.java index 8165e74..914a028 100644 --- a/app/src/main/java/com/reiya/pixiv/network/fuckgfw/PixivDNS.java +++ b/app/src/main/java/com/reiya/pixiv/network/fuckgfw/PixivDNS.java @@ -14,43 +14,37 @@ public class PixivDNS implements Dns { private static PixivDNS mPixivDNS = null; private static List newDns = new ArrayList<>(); private static final String[] addresses = { - /*主站IP*/ - "210.140.131.203", - "210.140.131.204", - "210.140.131.205", - "210.140.131.206", - "210.140.131.207", - "210.140.131.208", - "210.140.131.209", - "210.140.131.210", - "210.140.131.211", - "210.140.131.212", - "18.211.61.121", - "210.140.131.213", - "210.140.131.214", - "210.140.131.215", - "210.140.131.216", - "210.140.131.217", - "66.6.32.22", - "210.140.131.218", + "210.140.131.224", "210.140.131.219", - "122.208.114.218", - "13.35.19.186", - "210.140.131.220", - "13.35.19.88", - "210.140.131.222", "210.140.131.223", - "210.140.131.224", - "210.140.131.225", - "210.140.131.226", - "13.35.19.46", - "210.140.131.180", - "52.219.68.134", - "210.140.131.181", + "54.192.151.59", + "54.192.151.106", + "54.192.151.22", + "54.192.151.42", "122.208.114.218", - "210.140.131.182", - "210.140.131.183", - "210.140.131.184"}; + "52.219.0.208", + "52.84.225.11", + "52.84.225.87", + "52.84.225.95", + "52.84.225.186", + "66.6.32.22", + "66.6.33.22", + "52.84.225.193", + "52.84.225.8", + "52.84.225.131", + "52.84.225.132", + "52.84.225.230", + "52.84.225.206", + "52.84.225.214", + "52.84.225.221", + "210.140.170.179", + "210.140.174.37", + "210.140.175.130", + "210.140.131.153", + "210.140.131.144", + "210.140.131.145", + "210.140.131.147" + }; private PixivDNS() { for (String address : addresses) { diff --git a/app/src/main/java/com/reiya/pixiv/other/SettingsActivity.java b/app/src/main/java/com/reiya/pixiv/other/SettingsActivity.java index 2da4e05..9784f19 100644 --- a/app/src/main/java/com/reiya/pixiv/other/SettingsActivity.java +++ b/app/src/main/java/com/reiya/pixiv/other/SettingsActivity.java @@ -1,7 +1,9 @@ package com.reiya.pixiv.other; import android.Manifest; +import android.annotation.SuppressLint; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; @@ -12,7 +14,9 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.view.Gravity; +import android.view.LayoutInflater; import android.view.MenuItem; +import android.view.View; import android.widget.TextView; import android.widget.Toast; @@ -53,6 +57,7 @@ public boolean onOptionsItemSelected(MenuItem item) { public static class MyPreferenceFragment extends PreferenceFragment { Preference preferenceCache; + @SuppressLint("SetTextI18n") @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -70,13 +75,22 @@ public void onCreate(final Bundle savedInstanceState) { }); findPreference(getString(R.string.key_connect_mode)).setOnPreferenceChangeListener((preference, newValue) -> { int connectMode = Integer.parseInt(String.valueOf(newValue)); - Toast toast = Toast.makeText(getActivity(), "当前已设置为 " + getActivity().getResources().getStringArray(R.array.pref_connect_mode_strings)[connectMode] + " 模式\n重启后生效", Toast.LENGTH_LONG); - int tvToastId = Resources.getSystem().getIdentifier("message", "id", "android"); - TextView tvToast = toast.getView().findViewById(tvToastId); - if (tvToast != null) { - tvToast.setGravity(Gravity.CENTER); + //解决 Toast Exception : java.lang.IllegalStateException: View has already been added to the window manager. + //原因 布局复用 + Toast toast = new Toast(getActivity()); + LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + int layoutId = Resources.getSystem().getIdentifier("transient_notification", "layout", "android"); + View view = inflater.inflate(layoutId, null); + int textViewId = Resources.getSystem().getIdentifier("message", "id", "android"); + TextView textView = view.findViewById(textViewId); + if (textView != null) { + textView.setText("当前已设置为 " + getActivity().getResources().getStringArray(R.array.pref_connect_mode_strings)[connectMode] + " 模式\n重启后生效"); + textView.setGravity(Gravity.CENTER); } + toast.setDuration(Toast.LENGTH_LONG); + toast.setView(view); toast.show(); + //结束 return true; }); } diff --git a/app/src/main/java/com/reiya/pixiv/util/ItemOperation.java b/app/src/main/java/com/reiya/pixiv/util/ItemOperation.java index 961be51..5e36c38 100644 --- a/app/src/main/java/com/reiya/pixiv/util/ItemOperation.java +++ b/app/src/main/java/com/reiya/pixiv/util/ItemOperation.java @@ -62,12 +62,7 @@ public static void addBookmark(final FragmentActivity activity, final Work work) String defaultType = PreferenceManager.getDefaultSharedPreferences(activity).getString(activity.getString(R.string.key_favorite_work_option), "query"); if (defaultType.equals("query")) { FavoriteWorkDialog favoriteWorkDialog = new FavoriteWorkDialog(); - favoriteWorkDialog.setToAdd(new FavoriteWorkDialog.ToAdd() { - @Override - public void add(String type) { - addBookmark(activity, work.getId(), type); - } - }); + favoriteWorkDialog.setToAdd(type -> addBookmark(activity, work.getId(), type)); favoriteWorkDialog.show(activity.getSupportFragmentManager(), "FavoriteWork"); } else { addBookmark(activity, work.getId(), defaultType); @@ -369,7 +364,6 @@ public void onError(Throwable e) { @Override public void onNext(ResponseBody responseBody) { HttpClient.writeFileFromRequestBody(responseBody, file); - timer.cancel(); Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(file); diff --git a/app/src/main/res/ic_launcher-web.png b/app/src/main/res/ic_launcher-web.png deleted file mode 100644 index d38c45d..0000000 Binary files a/app/src/main/res/ic_launcher-web.png and /dev/null differ diff --git a/app/src/main/res/xml-v25/shortcuts.xml b/app/src/main/res/xml-v25/shortcuts.xml new file mode 100644 index 0000000..eaf9700 --- /dev/null +++ b/app/src/main/res/xml-v25/shortcuts.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/shortcuts.xml b/app/src/main/res/xml/shortcuts.xml index 804215c..e815e6a 100644 --- a/app/src/main/res/xml/shortcuts.xml +++ b/app/src/main/res/xml/shortcuts.xml @@ -2,25 +2,10 @@ + android:icon="@drawable/ic_search_white_24px"> + android:targetPackage=".Search" /> - - - - - - - - - - - - \ No newline at end of file diff --git a/bugly.properties b/bugly.properties new file mode 100644 index 0000000..5bff2cf --- /dev/null +++ b/bugly.properties @@ -0,0 +1,2 @@ +APP_ID=0fc124925c +APP_KEY=95c2e997-cf8d-488a-841e-ce412816eff4 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0159b98..2cfd9b0 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,8 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.5.1' + classpath 'com.tencent.bugly:symtabfileuploader:latest.release' + // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }