Search in sources :

Example 1 with URL_FEEDBACK

use of com.ichi2.libanki.Consts.URL_FEEDBACK in project AnkiChinaAndroid by ankichinateam.

the class SettingFragment method onClick.

@Override
public void onClick(View v) {
    int id = v.getId();
    if (id == R.id.user_protocol) {
        WebViewActivity.openUrlInApp(getAnkiActivity(), URL_USER_PROTOCOL, "");
    } else if (id == R.id.user_private) {
        WebViewActivity.openUrlInApp(getAnkiActivity(), URL_PRIVATE, "");
    } else if (id == R.id.rl_market_like) {
        goAppShop(getAnkiActivity(), BuildConfig.APPLICATION_ID, "");
    } else if (id == R.id.vip_power) {
        Timber.i("click vip button");
        getAnkiActivity().openVipUrl(mVipUrl);
    } else if (id == R.id.rl_anki_course || id == R.id.rl_team || id == R.id.rl_version || id == R.id.rl_feedback) {
        if (id == R.id.rl_anki_course) {
            WebViewActivity.openUrlInApp(getAnkiActivity(), URL_ANKI_COURSE, "");
        } else if (id == R.id.rl_version) {
            WebViewActivity.openUrlInApp(getAnkiActivity(), URL_VERSION, "");
        } else if (id == R.id.rl_team) {
            WebViewActivity.openUrlInApp(getAnkiActivity(), URL_VOLUNTEER, "");
        } else {
            WebViewActivity.openUrlInApp(getAnkiActivity(), URL_FEEDBACK, "");
        }
    } else if (id == R.id.ll_switch_server) {
        final Dialog dialog = new Dialog(getAnkiActivity(), R.style.DialogTheme);
        dialog.setContentView(R.layout.dialog_switch_server);
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setGravity(Gravity.TOP | Gravity.LEFT);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        int notificationBar = Resources.getSystem().getDimensionPixelSize(Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android"));
        int[] location = new int[2];
        // 获取在当前窗体内的绝对坐标
        mLl_switch_server.getLocationInWindow(location);
        // 获取在整个屏幕内的绝对坐标
        mLl_switch_server.getLocationOnScreen(location);
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.x = location[0];
        lp.y = location[1] + mLl_switch_server.getHeight() - notificationBar + 20;
        dialogWindow.setAttributes(lp);
        updateSwitchServerDialog(dialog);
        dialog.findViewById(R.id.rl_over_sea_server).setOnClickListener(view -> {
            String account = AnkiDroidApp.getSharedPrefs(getAnkiActivity()).getString(Consts.KEY_SAVED_ANKI_WEB_ACCOUNT, "");
            if (account.isEmpty()) {
                // 未登陆,跳转到登陆
                Intent myAccount = new Intent(getAnkiActivity(), MyAccount2.class);
                myAccount.putExtra("notLoggedIn", true);
                getAnkiActivity().startActivityWithAnimation(myAccount, ActivityTransitionAnimation.FADE);
            } else if (Consts.LOGIN_SERVER == Consts.LOGIN_SERVER_ANKICHINA) {
                // 已登陆,切换为当前状态
                SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getAnkiActivity());
                SharedPreferences.Editor editor = preferences.edit();
                editor.putString("username", preferences.getString(Consts.KEY_SAVED_ANKI_WEB_ACCOUNT, ""));
                editor.putString("hkey", preferences.getString(Consts.KEY_SAVED_ANKI_WEB_HKEY, ""));
                editor.putString("token", "");
                Consts.LOGIN_SERVER = Consts.LOGIN_SERVER_ANKIWEB;
                editor.putInt(Consts.KEY_ANKI_ACCOUNT_SERVER, Consts.LOGIN_SERVER);
                editor.apply();
                HostNumFactory.getInstance(getAnkiActivity()).reset();
                // force media resync on deauth
                getAnkiActivity().getCol().getMedia().forceResync();
                MobclickAgent.onProfileSignOff();
                updateSwitchServerLayout();
            }
            checkRestServerSpace();
            dialog.dismiss();
        });
        dialog.findViewById(R.id.rl_china_server).setOnClickListener(view -> {
            String account = AnkiDroidApp.getSharedPrefs(getAnkiActivity()).getString(Consts.KEY_SAVED_ANKI_CHINA_PHONE, "");
            if (account.isEmpty()) {
                // 未登陆,跳转到登陆
                Intent myAccount = new Intent(getAnkiActivity(), MyAccount.class);
                myAccount.putExtra("notLoggedIn", true);
                getAnkiActivity().startActivityWithAnimation(myAccount, ActivityTransitionAnimation.FADE);
            } else if (Consts.LOGIN_SERVER == Consts.LOGIN_SERVER_ANKIWEB) {
                // 已登陆,切换为当前状态
                SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getAnkiActivity());
                SharedPreferences.Editor editor = preferences.edit();
                // 切换为ankichina的登陆状态
                editor.putString("username", preferences.getString(Consts.KEY_SAVED_ANKI_CHINA_PHONE, ""));
                editor.putString("hkey", preferences.getString(Consts.KEY_SAVED_ANKI_CHINA_HKEY, ""));
                editor.putString("token", preferences.getString(Consts.KEY_SAVED_ANKI_CHINA_TOKEN, ""));
                Consts.LOGIN_SERVER = Consts.LOGIN_SERVER_ANKICHINA;
                editor.putInt(Consts.KEY_ANKI_ACCOUNT_SERVER, Consts.LOGIN_SERVER);
                editor.apply();
                HostNumFactory.getInstance(getAnkiActivity()).reset();
                getAnkiActivity().getCol().getMedia().forceResync();
                MobclickAgent.onProfileSignOff();
                updateSwitchServerLayout();
            }
            checkRestServerSpace();
            dialog.dismiss();
        });
        dialog.show();
    }
}
Also used : Window(android.view.Window) StringFormat(org.acra.data.StringFormat) Text(org.w3c.dom.Text) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) URL(java.net.URL) NonNull(androidx.annotation.NonNull) WindowManager(android.view.WindowManager) ImageView(android.widget.ImageView) ForeGroundColorSpan(com.ichi2.anki.DeckPicker.ForeGroundColorSpan) Drawable(android.graphics.drawable.Drawable) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) Handler(android.os.Handler) View(android.view.View) ForegroundColorSpan(android.text.style.ForegroundColorSpan) CHANGE_ACCOUNT(com.ichi2.anki.DeckPicker.CHANGE_ACCOUNT) URL_ANKI_COURSE(com.ichi2.libanki.Consts.URL_ANKI_COURSE) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) HostNumFactory(com.ichi2.anki.web.HostNumFactory) Consts(com.ichi2.libanki.Consts) OKHttpUtil(com.ichi2.utils.OKHttpUtil) MobclickAgent(com.umeng.analytics.MobclickAgent) RelativeLayout(android.widget.RelativeLayout) Window(android.view.Window) DeckPicker.goAppShop(com.ichi2.anki.DeckPicker.goAppShop) URL_FEEDBACK(com.ichi2.libanki.Consts.URL_FEEDBACK) Spanned(android.text.Spanned) Dialog(android.app.Dialog) Intent(android.content.Intent) Collection(com.ichi2.libanki.Collection) URL_PRIVATE(com.ichi2.libanki.Consts.URL_PRIVATE) TypedArray(android.content.res.TypedArray) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) SyncErrorDialog(com.ichi2.anki.dialogs.SyncErrorDialog) Toast(android.widget.Toast) Connection(com.ichi2.async.Connection) Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) ActionBar(android.app.ActionBar) URL_VERSION(com.ichi2.libanki.Consts.URL_VERSION) SettingItem(com.ichi2.ui.SettingItem) SwitchCompat(androidx.appcompat.widget.SwitchCompat) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) URL_VOLUNTEER(com.ichi2.libanki.Consts.URL_VOLUNTEER) URL_USER_PROTOCOL(com.ichi2.libanki.Consts.URL_USER_PROTOCOL) TextUtils(android.text.TextUtils) BackgroundColorSpan(android.text.style.BackgroundColorSpan) IOException(java.io.IOException) Themes(com.ichi2.themes.Themes) Color(android.graphics.Color) Gravity(android.view.Gravity) TaskStackBuilder(androidx.core.app.TaskStackBuilder) SharedPreferences(android.content.SharedPreferences) ActivityTransitionAnimation(com.ichi2.anim.ActivityTransitionAnimation) JSONArray(org.json.JSONArray) Resources(android.content.res.Resources) SharedPreferences(android.content.SharedPreferences) Dialog(android.app.Dialog) SyncErrorDialog(com.ichi2.anki.dialogs.SyncErrorDialog) Intent(android.content.Intent) SpannableString(android.text.SpannableString)

Aggregations

ActionBar (android.app.ActionBar)1 Dialog (android.app.Dialog)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Resources (android.content.res.Resources)1 TypedArray (android.content.res.TypedArray)1 Color (android.graphics.Color)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 SpannableString (android.text.SpannableString)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 Spanned (android.text.Spanned)1 TextUtils (android.text.TextUtils)1 BackgroundColorSpan (android.text.style.BackgroundColorSpan)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 Gravity (android.view.Gravity)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1