Drop ms center analyze

* We must be libre with no suspense
This commit is contained in:
tarsin committed 2022-05-17 13:12:35 +08:00
1 parent 6ca3c3261e
commit 4d4358f806
12 files changed
+4 -217

No files matched your search

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