diff --git a/app/build.gradle b/app/build.gradle index ff054956e..d8a32821d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -117,9 +117,6 @@ dependencies { implementation 'com.github.seven332:yorozuya-thread:0.1.1' implementation 'com.github.seven332:yorozuya-collect:0.1.4' implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0' - implementation 'com.microsoft.appcenter:appcenter-analytics:4.4.3' - implementation 'com.microsoft.appcenter:appcenter-crashes:4.4.3' - implementation 'com.microsoft.appcenter:appcenter-distribute:4.4.3' implementation 'com.squareup.okhttp3:okhttp:4.9.2' implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.2' implementation 'com.takisoft.preferencex:preferencex:1.1.0' diff --git a/app/src/main/java/com/hippo/ehviewer/Analytics.java b/app/src/main/java/com/hippo/ehviewer/Analytics.java deleted file mode 100644 index ed881a47b..000000000 --- a/app/src/main/java/com/hippo/ehviewer/Analytics.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2016 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hippo.ehviewer; - -import android.app.Application; - -import com.hippo.scene.SceneFragment; -import com.microsoft.appcenter.AppCenter; -import com.microsoft.appcenter.crashes.Crashes; -import com.microsoft.appcenter.distribute.Distribute; - -import java.util.HashMap; -import java.util.Map; - -public final class Analytics { - - public static void start(Application application) { - AppCenter.start(application, "1aa06805-037c-4f3c-8aaa-e23d1433986d", com.microsoft.appcenter.analytics.Analytics.class, Crashes.class, Distribute.class); - AppCenter.setUserId(Settings.getUserID()); - com.microsoft.appcenter.analytics.Analytics.setEnabled(Settings.getEnableAnalytics()); - Crashes.setEnabled(!BuildConfig.DEBUG); - Distribute.setEnabledForDebuggableBuild(false); - } - - public static boolean isEnabled() { - return AppCenter.isConfigured() && Settings.getEnableAnalytics(); - } - - public static void setEnabled(boolean enabled) { - com.microsoft.appcenter.analytics.Analytics.setEnabled(enabled); - } - - public static void onSceneView(SceneFragment scene) { - if (isEnabled()) { - Map properties = new HashMap<>(); - properties.put("scene_simple_class", scene.getClass().getSimpleName()); - properties.put("scene_class", scene.getClass().getName()); - com.microsoft.appcenter.analytics.Analytics.trackEvent("scene_view", properties); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java index 858ddff76..f4b5a19d5 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java +++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java @@ -341,8 +341,6 @@ public class EhApplication extends SceneApplication { EhDB.mergeOldDB(this); } - Analytics.start(this); - LocaleDelegate.setDefaultLocale(Settings.getLocale()); DayNightDelegate.setApplicationContext(this); DayNightDelegate.setDefaultNightMode(Settings.getTheme()); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java index b24f08dce..6ba002bfd 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java @@ -59,7 +59,6 @@ import com.hippo.ehviewer.client.EhUtils; import com.hippo.ehviewer.client.data.ListUrlBuilder; import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser; import com.hippo.ehviewer.client.parser.GalleryPageUrlParser; -import com.hippo.ehviewer.ui.scene.AnalyticsScene; import com.hippo.ehviewer.ui.scene.BaseScene; import com.hippo.ehviewer.ui.scene.CookieSignInScene; import com.hippo.ehviewer.ui.scene.DownloadsScene; @@ -107,7 +106,6 @@ public final class MainActivity extends StageActivity static { registerLaunchMode(SecurityScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(WarningScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); - registerLaunchMode(AnalyticsScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(SignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(WebViewSignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(CookieSignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); @@ -159,8 +157,6 @@ public final class MainActivity extends StageActivity return new Announcer(SecurityScene.class); } else if (Settings.getShowWarning()) { return new Announcer(WarningScene.class); - } else if (Settings.getAskAnalytics()) { - return new Announcer(AnalyticsScene.class); } else if (EhUtils.needSignedIn(this)) { return new Announcer(SignInScene.class); } else if (Settings.getSelectSite()) { @@ -185,11 +181,6 @@ public final class MainActivity extends StageActivity newArgs.putString(WarningScene.KEY_TARGET_SCENE, announcer.getClazz().getName()); newArgs.putBundle(WarningScene.KEY_TARGET_ARGS, announcer.getArgs()); return new Announcer(WarningScene.class).setArgs(newArgs); - } else if (Settings.getAskAnalytics()) { - Bundle newArgs = new Bundle(); - newArgs.putString(AnalyticsScene.KEY_TARGET_SCENE, announcer.getClazz().getName()); - newArgs.putBundle(AnalyticsScene.KEY_TARGET_ARGS, announcer.getArgs()); - return new Announcer(AnalyticsScene.class).setArgs(newArgs); } else if (EhUtils.needSignedIn(this)) { Bundle newArgs = new Bundle(); newArgs.putString(SignInScene.KEY_TARGET_SCENE, announcer.getClazz().getName()); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java index c13ab2277..b97068dc8 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java @@ -21,12 +21,10 @@ import android.os.Bundle; import androidx.annotation.Nullable; import androidx.preference.Preference; -import com.hippo.ehviewer.Analytics; import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.R; import com.hippo.text.Html; import com.hippo.util.AppHelper; -import com.microsoft.appcenter.distribute.Distribute; public class AboutFragment extends BasePreferenceFragment { @@ -47,7 +45,6 @@ public class AboutFragment extends BasePreferenceFragment { author.setOnPreferenceClickListener(this); //donate.setOnPreferenceClickListener(this); checkForUpdate.setOnPreferenceClickListener(this); - checkForUpdate.setVisible(Analytics.isEnabled()); } @Override @@ -56,8 +53,6 @@ public class AboutFragment extends BasePreferenceFragment { if (KEY_AUTHOR.equals(key)) { AppHelper.sendEmail(requireActivity(), EhApplication.getDeveloperEmail(), "About EhViewer", null); - } else if (KEY_CHECK_FOR_UPDATES.equals(key)) { - Distribute.checkForUpdate(); } return true; } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.java index e4d2f246e..381b49520 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.java @@ -6,7 +6,6 @@ import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.preference.Preference; -import com.hippo.ehviewer.Analytics; import com.hippo.ehviewer.R; import com.hippo.ehviewer.Settings; @@ -20,9 +19,6 @@ public class PrivacyFragment extends BasePreferenceFragment { @Override public void onCreatePreferencesFix(@Nullable Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.privacy_settings); - Preference enableAnalytics = findPreference(Settings.KEY_ENABLE_ANALYTICS); - - enableAnalytics.setOnPreferenceChangeListener(this); } @Override @@ -34,17 +30,6 @@ public class PrivacyFragment extends BasePreferenceFragment { R.string.settings_privacy_pattern_protection_set); } - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - String key = preference.getKey(); - if (Settings.KEY_ENABLE_ANALYTICS.equals(key)) { - if (newValue instanceof Boolean && (Boolean) newValue) { - Analytics.start(getActivity().getApplication()); - } - } - return true; - } - @Override public int getFragmentTitle() { return R.string.settings_privacy; diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/AnalyticsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/AnalyticsScene.java deleted file mode 100644 index eb427af38..000000000 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/AnalyticsScene.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hippo.ehviewer.ui.scene; - -import android.content.Context; -import android.os.Bundle; -import android.text.method.LinkMovementMethod; -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 com.hippo.ehviewer.Analytics; -import com.hippo.ehviewer.R; -import com.hippo.ehviewer.Settings; -import com.hippo.ehviewer.ui.MainActivity; -import com.hippo.text.Html; -import com.hippo.yorozuya.ViewUtils; - -public class AnalyticsScene extends SolidScene implements View.OnClickListener { - - @Nullable - private View mReject; - @Nullable - private View mAccept; - - @Override - public boolean needShowLeftDrawer() { - return false; - } - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.scene_analytics, container, false); - - mReject = ViewUtils.$$(view, R.id.reject); - mAccept = ViewUtils.$$(view, R.id.accept); - TextView text = (TextView) ViewUtils.$$(view, R.id.text); - - text.setText(Html.fromHtml(getString(R.string.analytics_explain))); - text.setMovementMethod(LinkMovementMethod.getInstance()); - - mReject.setOnClickListener(this); - mAccept.setOnClickListener(this); - - return view; - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - - mReject = null; - mAccept = null; - } - - @Override - public void onClick(View v) { - Context context = getContext(); - MainActivity activity = getMainActivity(); - if (context == null || activity == null) { - return; - } - - if (mReject == v) { - Settings.putEnableAnalytics(false); - } else if (mAccept == v) { - Settings.putEnableAnalytics(true); - } - Analytics.setEnabled(Settings.getEnableAnalytics()); - Settings.putAskAnalytics(false); - - // Start new scene and finish it self - startSceneForCheckStep(CHECK_STEP_ANALYTICS, getArguments()); - finish(); - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.java index 44c92ab8d..8b2677588 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.java @@ -39,7 +39,6 @@ import androidx.core.view.WindowInsetsControllerCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.FragmentActivity; -import com.hippo.ehviewer.Analytics; import com.hippo.ehviewer.ui.MainActivity; import com.hippo.scene.SceneFragment; import com.hippo.util.AppHelper; @@ -274,12 +273,6 @@ public abstract class BaseScene extends SceneFragment { return insetsController; } - @Override - public void onResume() { - super.onResume(); - Analytics.onSceneView(this); - } - @Override public void onDestroy() { super.onDestroy(); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/SolidScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/SolidScene.java index c5ee91185..396e2b187 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/SolidScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/SolidScene.java @@ -30,9 +30,8 @@ public class SolidScene extends BaseScene { public static final int CHECK_STEP_SECURITY = 0; public static final int CHECK_STEP_WARNING = 1; - public static final int CHECK_STEP_ANALYTICS = 2; - public static final int CHECK_STEP_SIGN_IN = 3; - public static final int CHECK_STEP_SELECT_SITE = 4; + public static final int CHECK_STEP_SIGN_IN = 2; + public static final int CHECK_STEP_SELECT_SITE = 3; public static final String KEY_TARGET_SCENE = "target_scene"; public static final String KEY_TARGET_ARGS = "target_args"; private static final String TAG = SolidScene.class.getSimpleName(); @@ -45,11 +44,6 @@ public class SolidScene extends BaseScene { break; } case CHECK_STEP_WARNING: - if (Settings.getAskAnalytics()) { - startScene(new Announcer(AnalyticsScene.class).setArgs(args), true); - break; - } - case CHECK_STEP_ANALYTICS: if (EhUtils.needSignedIn(getContext())) { startScene(new Announcer(SignInScene.class).setArgs(args), true); break; diff --git a/app/src/main/res/layout/dialog_edittext_builder.xml b/app/src/main/res/layout/dialog_edittext_builder.xml index d32d1ac04..3a11be543 100644 --- a/app/src/main/res/layout/dialog_edittext_builder.xml +++ b/app/src/main/res/layout/dialog_edittext_builder.xml @@ -15,7 +15,6 @@ -->