Search in sources :

Example 6 with CustomStyleDialog

use of com.ichi2.ui.CustomStyleDialog in project AnkiChinaAndroid by ankichinateam.

the class StudySettingActivity method onClick.

@Override
public void onClick(View v) {
    int id = v.getId();
    CustomStyleDialog customDialog = null;
    switch(id) {
        case R.id.rl_max_learn_card:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("每日新卡上限").setEditorText(tx_max_learn_card.getText().toString(), "学习一段时间后,未来每天新卡+复习卡约180张,大约需30分钟").addSingleTextChangedListener(new CustomStyleDialog.Builder.MyTextWatcher() {

                @Override
                public void beforeTextChanged(Dialog dialog, CharSequence s, int start, int count, int after) {
                }

                @Override
                public void onTextChanged(Dialog dialog, CharSequence s, int start, int before, int count) {
                    if (s.toString().isEmpty()) {
                        ((CustomStyleDialog) dialog).getSingleEditorModeHintView().setText("未来每天学习量=新卡数x6");
                    } else {
                        try {
                            int num = Integer.parseInt(s.toString()) * 6;
                            int time = num * 10 / 60;
                            ((CustomStyleDialog) dialog).getSingleEditorModeHintView().setText(String.format("学习一段时间后,未来每天新卡+复习卡约%s张,大约需%s分钟", num, time));
                        } catch (Exception e) {
                            e.printStackTrace();
                            UIUtils.showThemedToast(StudySettingActivity.this, "请填写0至9999之间的数值", false);
                        }
                    }
                }

                @Override
                public void afterTextChanged(Dialog dialog, Editable s) {
                }
            }).setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 0 && num <= 9999) {
                        mOptions.getJSONObject("new").put("perDay", num);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写0至9999之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写0至9999之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_max_review_card:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("每日复习数上限").setEditorText(tx_max_review_card.getText().toString(), "建议设置为最大9999,有多少复习多少").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 0 && num <= 9999) {
                        mOptions.getJSONObject("rev").put("perDay", num);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写0至9999之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写0至9999之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_deck_conf_max_ivl:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("最大时间间隔").setEditorText(tx_max_review_card.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 0 && num <= 99999) {
                        mOptions.getJSONObject("rev").put("maxIvl", num);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写0至99999之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写0至99999之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_interval_step:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("间隔的步伐(以分钟计)").setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_TEXT).setEditorText(tx_interval_step.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                String num = ((CustomStyleDialog) dialog).getEditorText();
                String validated = getValidatedStepsInput(num);
                if (validated == null) {
                    UIUtils.showThemedToast(this, getResources().getString(R.string.steps_error), false);
                } else if (TextUtils.isEmpty(validated)) {
                    UIUtils.showThemedToast(this, getResources().getString(R.string.steps_min_error), false);
                } else {
                    mOptions.getJSONObject("new").put("delays", convertToJSON(num));
                    saveAndUpdateValues();
                    Timber.i("edit num:%s", num);
                    dialog.dismiss();
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_interval_graduate:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("毕业时间间隔(以天计)").setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_TEXT).setEditorText(tx_interval_graduate.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 1 && num <= 99) {
                        // [graduating, easy]
                        JSONArray newInts = new JSONArray();
                        newInts.put(num);
                        newInts.put(mOptions.getJSONObject("new").getJSONArray("ints").getInt(1));
                        mOptions.getJSONObject("new").put("ints", newInts);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写1至99之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写1至99之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_interval_simple:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("简单按钮对应的时间间隔").setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_TEXT).setEditorText(tx_interval_simple.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 1 && num <= 99) {
                        JSONArray newInts = new JSONArray();
                        // 
                        newInts.put(mOptions.getJSONObject("new").getJSONArray("ints").getInt(0));
                        newInts.put(num);
                        mOptions.getJSONObject("new").put("ints", newInts);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写1至99之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写1至99之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_init_level:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("初始难度").setEditorText(tx_init_level.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 100 && num <= 999) {
                        mOptions.getJSONObject("new").put("initialFactor", num * 10);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写100至999之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写1至99之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_new_card_sequence:
            final int[] selectPosition = { mCurrentNewOrderValue };
            customDialog = new CustomStyleDialog.Builder(this).setTitle("新卡顺序").setSelectListModeCallback(new CustomStyleDialog.Builder.SelectListModeCallback() {

                @Override
                public String[] getItemContent() {
                    return mNewOrderLabels;
                }

                @Override
                public String[] getItemHint() {
                    return new String[0];
                }

                @Override
                public int getDefaultSelectedPosition() {
                    return selectPosition[0];
                }

                @Override
                public void onItemSelect(int position) {
                    selectPosition[0] = position;
                }
            }).setPositiveButton("确认", (dialog, which) -> {
                int oldValue = mOptions.getJSONObject("new").getInt("order");
                if (oldValue != selectPosition[0]) {
                    mOptions.getJSONObject("new").put("order", selectPosition[0]);
                    CollectionTask.launchCollectionTask(REORDER, new ConfChangeHandler(StudySettingActivity.this), new TaskData(new Object[] { mOptions }));
                }
                dialog.dismiss();
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            customDialog.show();
            break;
        case R.id.rl_learn_sequence:
            final int[] selectPosition3 = { mCurrentStudyPreferenceValue };
            customDialog = new CustomStyleDialog.Builder(this).setTitle("学习顺序").setSelectListModeCallback(new CustomStyleDialog.Builder.SelectListModeCallback() {

                @Override
                public String[] getItemContent() {
                    return mStudyPreferenceLabels;
                }

                @Override
                public String[] getItemHint() {
                    return new String[0];
                }

                @Override
                public int getDefaultSelectedPosition() {
                    return selectPosition3[0];
                }

                @Override
                public void onItemSelect(int position) {
                    selectPosition3[0] = position;
                }
            }).setPositiveButton("确认", (dialog, which) -> {
                int oldValue = mCol.getConf().getInt("newSpread");
                if (oldValue != selectPosition3[0]) {
                    mCol.getConf().put("newSpread", selectPosition3[0]);
                    mCol.setMod();
                    CollectionTask.launchCollectionTask(REORDER, new ConfChangeHandler(StudySettingActivity.this), new TaskData(new Object[] { mOptions }));
                }
                dialog.dismiss();
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            customDialog.show();
            break;
        case R.id.rl_medal_simple:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("回答简单的时间间隔增加比例").setEditorText(tx_medal_simple.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 100 && num <= 1000) {
                        mOptions.getJSONObject("rev").put("ease4", (Integer) num / 100.0f);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写100至1000之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写100至1000之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_interval_decoration:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("时间间隔因子").setEditorText(tx_interval_decoration.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num: " + num / 100.0f);
                    if (num >= 0 && num <= 999) {
                        mOptions.getJSONObject("rev").put("ivlFct", num / 100.0f);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写0至999之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写0至999之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_error_interval_step:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("间隔的步伐(以分钟计)").setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_TEXT).setEditorText(tx_error_interval_step.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                String num = ((CustomStyleDialog) dialog).getEditorText();
                String validated = getValidatedStepsInput(num);
                if (validated == null) {
                    UIUtils.showThemedToast(this, getResources().getString(R.string.steps_error), false);
                } else {
                    mOptions.getJSONObject("lapse").put("delays", StepsPreference.convertToJSON(num));
                    saveAndUpdateValues();
                    Timber.i("edit num:%s", num);
                    dialog.dismiss();
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_error_new_interval:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("新的时间间隔").setEditorText(tx_error_new_interval.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 0 && num <= 100) {
                        mOptions.getJSONObject("lapse").put("mult", num / 100.0f);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写0至100之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写0至100之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.rl_error_min_interval:
            customDialog = new CustomStyleDialog.Builder(this).setTitle("最小时间间隔(天)").setEditorText(tx_error_min_interval.getText().toString(), "").setPositiveButton("确认", (dialog, which) -> {
                try {
                    int num = Integer.parseInt(((CustomStyleDialog) dialog).getEditorText());
                    Timber.i("edit num:%s", num);
                    if (num >= 1 && num <= 99) {
                        mOptions.getJSONObject("lapse").put("minInt", num);
                        saveAndUpdateValues();
                        dialog.dismiss();
                    } else {
                        UIUtils.showThemedToast(this, "请填写1至99之间的数值", false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    UIUtils.showThemedToast(this, "请填写1至99之间的数值", false);
                }
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            Timber.i("build a dialog!");
            customDialog.show();
            break;
        case R.id.ll_algorithm:
            final int[] selectPosition4 = { mCurrentMindModeValue };
            customDialog = new CustomStyleDialog.Builder(this).setTitle("选择记忆模式").setSelectListModeCallback(new CustomStyleDialog.Builder.SelectListModeCallback() {

                @Override
                public String[] getItemContent() {
                    return mMindModeLabels;
                }

                @Override
                public String[] getItemHint() {
                    return mMindModeHints;
                }

                @Override
                public int getDefaultSelectedPosition() {
                    return selectPosition4[0];
                }

                @Override
                public void onItemSelect(int position) {
                    selectPosition4[0] = position;
                }
            }).setPositiveButton("确认", (dialog, which) -> {
                SharedPreferences sharedPreferences = getSharedPreferences(STUDY_SETTING, 0);
                String oldValue = sharedPreferences.getString(KEY_MIND_MODE, "");
                // Timber.i("看看保存成什么样子了 %s ", oldValue);
                Map<String, Integer> oldMap = null;
                Gson gson = new Gson();
                try {
                    oldMap = gson.fromJson(oldValue, Map.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (oldMap == null) {
                    oldMap = new HashMap<>();
                }
                for (long did : getDeckIds(mDeckId, getCol())) {
                    // Timber.i("看看都是什么id %s,%s", did, selectPosition4[0]);
                    oldMap.put(String.valueOf(did), selectPosition4[0]);
                }
                String newValue = gson.toJson(oldMap);
                sharedPreferences.edit().putString(KEY_MIND_MODE, newValue).apply();
                mSavedMaxNewCardNum = mOptions.getJSONObject("new").getInt("perDay");
                mSavedMaxRevCardNum = mOptions.getJSONObject("rev").getInt("perDay");
                CollectionTask.launchCollectionTask(CONF_RESET, new ConfChangeHandler(StudySettingActivity.this, selectPosition4[0]), // 先恢复默认,即长记模式
                new TaskData(new Object[] { mOptions }));
                dialog.dismiss();
            }).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
            customDialog.show();
            break;
    }
}
Also used : LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) TypeToken(com.google.gson.reflect.TypeToken) Deck(com.ichi2.libanki.Deck) NonNull(androidx.annotation.NonNull) Dialog(android.app.Dialog) HashMap(java.util.HashMap) StepsPreference.convertToJSON(com.ichi2.preferences.StepsPreference.convertToJSON) Collection(com.ichi2.libanki.Collection) Editable(android.text.Editable) TypedArray(android.content.res.TypedArray) JSONArray(com.ichi2.utils.JSONArray) StepsPreference(com.ichi2.preferences.StepsPreference) Gson(com.google.gson.Gson) DeckConfig(com.ichi2.libanki.DeckConfig) Map(java.util.Map) View(android.view.View) TaskData(com.ichi2.async.TaskData) ContextCompat(androidx.core.content.ContextCompat) REORDER(com.ichi2.async.CollectionTask.TASK_TYPE.REORDER) InputType(android.text.InputType) TextUtils(android.text.TextUtils) CollectionTask(com.ichi2.async.CollectionTask) JSONObject(com.ichi2.utils.JSONObject) Timber(timber.log.Timber) StudyOptionsFragment.getDeckIds(com.ichi2.anki.StudyOptionsFragment.getDeckIds) IdRes(androidx.annotation.IdRes) CONF_RESET(com.ichi2.async.CollectionTask.TASK_TYPE.CONF_RESET) TextView(android.widget.TextView) SharedPreferences(android.content.SharedPreferences) RelativeLayout(android.widget.RelativeLayout) Toolbar(androidx.appcompat.widget.Toolbar) TaskListenerWithContext(com.ichi2.async.TaskListenerWithContext) ActivityTransitionAnimation(com.ichi2.anim.ActivityTransitionAnimation) CustomStyleDialog(com.ichi2.ui.CustomStyleDialog) SharedPreferences(android.content.SharedPreferences) HashMap(java.util.HashMap) JSONArray(com.ichi2.utils.JSONArray) Gson(com.google.gson.Gson) TaskData(com.ichi2.async.TaskData) CustomStyleDialog(com.ichi2.ui.CustomStyleDialog) Dialog(android.app.Dialog) CustomStyleDialog(com.ichi2.ui.CustomStyleDialog) Editable(android.text.Editable) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with CustomStyleDialog

use of com.ichi2.ui.CustomStyleDialog in project AnkiChinaAndroid by ankichinateam.

the class DeckPicker method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.navigation_activity);
    AnkiChinaSyncer.SYNCING = false;
    // Toolbar toolbar = findViewById(R.id.toolbar);
    // if (toolbar != null) {
    // setSupportActionBar(toolbar);
    // }
    viewPager = findViewById(R.id.viewpager);
    viewPager.setUserInputEnabled(false);
    // viewPager.setScrolledListener(new CustomScrollViewPager.ScrolledListener() {
    // @Override
    // public void onScroll() {
    // openCardBrowser();
    // }
    // });
    bottomNavigationView = findViewById(R.id.navigation);
    bottomNavigationView.setItemIconTintList(null);
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomNavigationView.getChildAt(0);
    mBottomAddMenuIcon = menuView.getChildAt(2).findViewById(com.google.android.material.R.id.navigation_bar_item_icon_view);
    // menuView.getItemIconSize()
    // mBottomAddMenuIcon =( (NavigationBarItemView)menuView.getChildAt(2)).setIcon();
    final ViewGroup.LayoutParams layoutParams = mBottomAddMenuIcon.getLayoutParams();
    final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 37, displayMetrics);
    layoutParams.width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 37, displayMetrics);
    mBottomAddMenuIcon.setLayoutParams(layoutParams);
    restoreWelcomeMessage(savedInstanceState);
    registerExternalStorageListener();
    SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this);
    if (!preferences.contains(CONFIRM_PRIVATE_STRATEGY) && !mShowingPrivateStrategyDialog) {
        mShowingPrivateStrategyDialog = true;
        new MaterialDialog.Builder(this).title(R.string.collection_load_welcome_request_permissions_title).titleGravity(GravityEnum.CENTER).content(getClickableSpan(this)).negativeText(R.string.dialog_disagree).positiveText(R.string.dialog_agree).onPositive((innerDialog, innerWhich) -> {
            preferences.edit().putBoolean(CONFIRM_PRIVATE_STRATEGY, true).apply();
            mShowingPrivateStrategyDialog = false;
            continueActivity(preferences);
        }).positiveColor(ContextCompat.getColor(this, R.color.new_primary_color)).onNegative((innerDialog, innerWhich) -> {
            mShowingPrivateStrategyDialog = false;
            finishWithoutAnimation();
        }).negativeColor(ContextCompat.getColor(this, R.color.new_primary_text_secondary_color)).cancelable(false).canceledOnTouchOutside(false).show();
    } else {
        continueActivity(preferences);
    }
    int count = preferences.getInt(START_APP_COUNT, 0);
    count++;
    if (count == 5) {
        CustomStyleDialog customDialog = new CustomStyleDialog.Builder(this).setTitle("给个好评,鼓励一下吧!").setMessage("每一份好评对我们都是极大的鼓励,也是我们持续优化的动力").setPositiveButton("好评鼓励", (dialog, which) -> {
            dialog.dismiss();
            goAppShop(DeckPicker.this, BuildConfig.APPLICATION_ID, "");
        }).setNegativeButton("残忍拒绝", (dialog, which) -> dialog.dismiss()).create();
        customDialog.show();
    }
    preferences.edit().putInt(START_APP_COUNT, count).apply();
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) ImageView(android.widget.ImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) DialogHandler(com.ichi2.anki.dialogs.DialogHandler) NavigationBarItemView(com.google.android.material.navigation.NavigationBarItemView) Manifest(android.Manifest) Decks(com.ichi2.libanki.Decks) Handler(android.os.Handler) JSONException(com.ichi2.utils.JSONException) Fragment(androidx.fragment.app.Fragment) ForegroundColorSpan(android.text.style.ForegroundColorSpan) ContextCompat(androidx.core.content.ContextCompat) DeckPickerBackupNoSpaceLeftDialog(com.ichi2.anki.dialogs.DeckPickerBackupNoSpaceLeftDialog) IntentFilter(android.content.IntentFilter) StringRes(androidx.annotation.StringRes) Nullable(androidx.annotation.Nullable) Message(android.os.Message) HostNumFactory(com.ichi2.anki.web.HostNumFactory) Consts(com.ichi2.libanki.Consts) OKHttpUtil(com.ichi2.utils.OKHttpUtil) MobclickAgent(com.umeng.analytics.MobclickAgent) DeckPickerExportCompleteDialog(com.ichi2.anki.dialogs.DeckPickerExportCompleteDialog) Models(com.ichi2.libanki.Models) SimpleDateFormat(java.text.SimpleDateFormat) Dialog(android.app.Dialog) SdCardReceiver(com.ichi2.anki.receiver.SdCardReceiver) URL_PRIVATE(com.ichi2.libanki.Consts.URL_PRIVATE) ArrayList(java.util.ArrayList) CustomSyncServerUrlException(com.ichi2.libanki.sync.CustomSyncServerUrlException) SpannableStringBuilder(android.text.SpannableStringBuilder) DeckPickerNoSpaceLeftDialog(com.ichi2.anki.dialogs.DeckPickerNoSpaceLeftDialog) Calendar(java.util.Calendar) Toast(android.widget.Toast) Menu(android.view.Menu) Connection(com.ichi2.async.Connection) Response(okhttp3.Response) AnkiPackageImporter(com.ichi2.libanki.importer.AnkiPackageImporter) Call(okhttp3.Call) CHECK_MEDIA(com.ichi2.async.CollectionTask.TASK_TYPE.CHECK_MEDIA) FragmentManager(androidx.fragment.app.FragmentManager) Beta(com.tencent.bugly.beta.Beta) SpannableString(android.text.SpannableString) ALL_DECKS_ID(com.ichi2.anki.SelfStudyActivity.ALL_DECKS_ID) URL_USER_PROTOCOL(com.ichi2.libanki.Consts.URL_USER_PROTOCOL) TextUtils(android.text.TextUtils) IOException(java.io.IOException) File(java.io.File) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ActivityTransitionAnimation(com.ichi2.anim.ActivityTransitionAnimation) EditText(android.widget.EditText) AsyncDialogFragment(com.ichi2.anki.dialogs.AsyncDialogFragment) PackageManager(android.content.pm.PackageManager) Date(java.util.Date) WindowManager(android.view.WindowManager) UnderlineSpan(android.text.style.UnderlineSpan) UsageAnalytics(com.ichi2.anki.analytics.UsageAnalytics) ClickableSpan(android.text.style.ClickableSpan) ExportDialog(com.ichi2.anki.dialogs.ExportDialog) DeviceID(com.ichi2.libanki.DeviceID) ConfirmationDialog(com.ichi2.anki.dialogs.ConfirmationDialog) Permissions(com.ichi2.utils.Permissions) AnkiChinaSyncer(com.ichi2.libanki.sync.AnkiChinaSyncer) JSONObject(org.json.JSONObject) NOT_LOGIN_ANKI_CHINA(com.ichi2.anki.MyAccount.NOT_LOGIN_ANKI_CHINA) View(android.view.View) TaskData(com.ichi2.async.TaskData) SyncStatus(com.ichi2.utils.SyncStatus) FIND_EMPTY_CARDS(com.ichi2.async.CollectionTask.TASK_TYPE.FIND_EMPTY_CARDS) ParseException(java.text.ParseException) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) BroadcastReceiver(android.content.BroadcastReceiver) DatabaseErrorDialog(com.ichi2.anki.dialogs.DatabaseErrorDialog) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) List(java.util.List) TextView(android.widget.TextView) RelativeLayout(android.widget.RelativeLayout) TaskListenerWithContext(com.ichi2.async.TaskListenerWithContext) ViewPropertyAnimator(android.view.ViewPropertyAnimator) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Window(android.view.Window) VersionUtils(com.ichi2.utils.VersionUtils) Context(android.content.Context) TaskListener(com.ichi2.async.TaskListener) Spanned(android.text.Spanned) KeyEvent(android.view.KeyEvent) GravityEnum(com.afollestad.materialdialogs.GravityEnum) DeckPickerAnalyticsOptInDialog(com.ichi2.anki.dialogs.DeckPickerAnalyticsOptInDialog) Intent(android.content.Intent) ViewPager2(androidx.viewpager2.widget.ViewPager2) Collection(com.ichi2.libanki.Collection) StyledProgressDialog(com.ichi2.themes.StyledProgressDialog) MenuItem(android.view.MenuItem) FragmentStateAdapter(androidx.viewpager2.adapter.FragmentStateAdapter) CHECK_DATABASE(com.ichi2.async.CollectionTask.TASK_TYPE.CHECK_DATABASE) Lifecycle(androidx.lifecycle.Lifecycle) REPAIR_COLLECTION(com.ichi2.async.CollectionTask.TASK_TYPE.REPAIR_COLLECTION) WidgetStatus(com.ichi2.widget.WidgetStatus) MotionEvent(android.view.MotionEvent) SyncErrorDialog(com.ichi2.anki.dialogs.SyncErrorDialog) Model(com.ichi2.libanki.Model) ConfirmModSchemaException(com.ichi2.anki.exception.ConfirmModSchemaException) Bugly(com.tencent.bugly.Bugly) LOAD_COLLECTION_COMPLETE(com.ichi2.async.CollectionTask.TASK_TYPE.LOAD_COLLECTION_COMPLETE) UMConfigure(com.umeng.commonsdk.UMConfigure) PlatformConfig(com.umeng.socialize.PlatformConfig) ActivityCompat(androidx.core.app.ActivityCompat) CollectionTask(com.ichi2.async.CollectionTask) BottomNavigationMenuView(com.google.android.material.bottomnavigation.BottomNavigationMenuView) Color(android.graphics.Color) MediaCheckDialog(com.ichi2.anki.dialogs.MediaCheckDialog) LOAD_DECK_COUNTS(com.ichi2.async.CollectionTask.TASK_TYPE.LOAD_DECK_COUNTS) VisibleForTesting(androidx.annotation.VisibleForTesting) CustomStyleDialog(com.ichi2.ui.CustomStyleDialog) Resources(android.content.res.Resources) CustomStyleDialog(com.ichi2.ui.CustomStyleDialog) SharedPreferences(android.content.SharedPreferences) ViewGroup(android.view.ViewGroup) SpannableStringBuilder(android.text.SpannableStringBuilder) BottomNavigationMenuView(com.google.android.material.bottomnavigation.BottomNavigationMenuView) DisplayMetrics(android.util.DisplayMetrics)

Example 8 with CustomStyleDialog

use of com.ichi2.ui.CustomStyleDialog in project AnkiChinaAndroid by ankichinateam.

the class AnkiChinaSyncer method showSyncChinaDialog.

private void showSyncChinaDialog(Activity context) {
    mSyncChinaDialog = new CustomStyleDialog(context, R.style.CommonDialogTheme);
    mSyncChinaDialog.setContentView(R.layout.dialog_sync_china);
    mDialogTitle = mSyncChinaDialog.findViewById(R.id.title);
    mDialogProgress = mSyncChinaDialog.findViewById(R.id.progress);
    mDialogConfirm = mSyncChinaDialog.findViewById(R.id.confirm);
    mSyncChinaDialog.setCancelable(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        if (!context.isFinishing() && !context.isDestroyed()) {
            mSyncChinaDialog.show();
        }
    } else {
        if (!context.isFinishing()) {
            mSyncChinaDialog.show();
        }
    }
}
Also used : CustomStyleDialog(com.ichi2.ui.CustomStyleDialog)

Aggregations

View (android.view.View)7 CustomStyleDialog (com.ichi2.ui.CustomStyleDialog)7 Context (android.content.Context)6 SharedPreferences (android.content.SharedPreferences)6 Bundle (android.os.Bundle)6 Handler (android.os.Handler)6 WindowManager (android.view.WindowManager)6 NonNull (androidx.annotation.NonNull)6 Timber (timber.log.Timber)6 Dialog (android.app.Dialog)5 Intent (android.content.Intent)5 Resources (android.content.res.Resources)5 TypedArray (android.content.res.TypedArray)5 Uri (android.net.Uri)5 TypedValue (android.util.TypedValue)5 Gravity (android.view.Gravity)5 Menu (android.view.Menu)5 MenuItem (android.view.MenuItem)5 ViewGroup (android.view.ViewGroup)5 RelativeLayout (android.widget.RelativeLayout)5