use of com.ichi2.libanki.Consts.URL_PRIVATE 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();
}
}
Aggregations