Search in sources :

Example 1 with ScrollTextView

use of com.ichi2.anki.Reviewer.ScrollTextView in project Anki-Android by Ramblurr.

the class PreviewClass method setInterface.

private void setInterface() {
    if (mCurrentCard == null) {
        return;
    }
    if (mSimpleInterface) {
        Note note = mCurrentCard.note();
        mCurrentSimpleInterface = true;
        for (String s : mSimpleInterfaceExcludeTags) {
            if (note.hasTag(s)) {
                mCurrentSimpleInterface = false;
                break;
            }
        }
    }
    if (mCurrentSimpleInterface) {
        if (mSimpleCard == null) {
            mSimpleCard = new ScrollTextView(this);
            Themes.setRegularFont(mSimpleCard);
            mSimpleCard.setTextSize(mSimpleCard.getTextSize() * mDisplayFontSize / 100);
            mSimpleCard.setGravity(Gravity.CENTER);
            try {
                mSetTextIsSelectable = TextView.class.getMethod("setTextIsSelectable", boolean.class);
            } catch (Throwable e) {
                // Log.i(AnkiDroidApp.TAG, "mSetTextIsSelectable could not be found due to a too low Android version (< 3.0)");
                mSetTextIsSelectable = null;
            }
            if (mSetTextIsSelectable != null) {
                try {
                    mSetTextIsSelectable.invoke(mSimpleCard, true);
                } catch (Exception e) {
                    Log.e(AnkiDroidApp.TAG, e.toString());
                }
            }
            mSimpleCard.setClickable(true);
            mCardFrame.addView(mSimpleCard);
            mSimpleCard.setBackgroundColor(mCurrentBackgroundColor);
            mSimpleCard.setTextColor(mForegroundColor);
        }
        if (mSimpleCard.getVisibility() != View.VISIBLE || (mCard != null && mCard.getVisibility() == View.VISIBLE)) {
            mSimpleCard.setVisibility(View.VISIBLE);
            mCard.setVisibility(View.GONE);
        }
    } else {
        if (mCard == null) {
            mCard = createWebView();
            mCardFrame.addView(mCard);
            if (mRefreshWebview) {
                mNextCard = createWebView();
                mNextCard.setVisibility(View.GONE);
                mCardFrame.addView(mNextCard, 0);
                mCard.setBackgroundColor(mCurrentBackgroundColor);
                mCustomFontStyle = getCustomFontsStyle() + getDefaultFontStyle();
            }
        }
        if (mCard.getVisibility() != View.VISIBLE || (mSimpleCard != null && mSimpleCard.getVisibility() == View.VISIBLE)) {
            mSimpleCard.setVisibility(View.GONE);
            mCard.setVisibility(View.VISIBLE);
        }
    }
}
Also used : ScrollTextView(com.ichi2.anki.Reviewer.ScrollTextView) Note(com.ichi2.libanki.Note) TextView(android.widget.TextView) ScrollTextView(com.ichi2.anki.Reviewer.ScrollTextView) SpannedString(android.text.SpannedString) SpannableString(android.text.SpannableString) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 2 with ScrollTextView

use of com.ichi2.anki.Reviewer.ScrollTextView in project Anki-Android by Ramblurr.

the class Reviewer method setInterface.

private void setInterface() {
    if (mCurrentCard == null) {
        return;
    }
    if (mSimpleInterface) {
        Note note = mCurrentCard.note();
        mCurrentSimpleInterface = true;
        for (String s : mSimpleInterfaceExcludeTags) {
            if (note.hasTag(s)) {
                mCurrentSimpleInterface = false;
                break;
            }
        }
    }
    if (mCurrentSimpleInterface) {
        if (mSimpleCard == null) {
            mSimpleCard = new ScrollTextView(this);
            Themes.setRegularFont(mSimpleCard);
            mSimpleCard.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()) * mDisplayFontSize / 100);
            mSimpleCard.setGravity(Gravity.CENTER);
            try {
                mSetTextIsSelectable = TextView.class.getMethod("setTextIsSelectable", boolean.class);
            } catch (Throwable e) {
                Log.i(AnkiDroidApp.TAG, "mSetTextIsSelectable could not be found due to a too low Android version (< 3.0)");
                mSetTextIsSelectable = null;
            }
            if (mSetTextIsSelectable != null) {
                try {
                    mSetTextIsSelectable.invoke(mSimpleCard, true);
                } catch (Exception e) {
                    Log.e(AnkiDroidApp.TAG, e.toString());
                }
            }
            mSimpleCard.setClickable(true);
            mCardFrame.addView(mSimpleCard);
            mSimpleCard.setBackgroundColor(mCurrentBackgroundColor);
            mSimpleCard.setTextColor(mForegroundColor);
        }
        if (mSimpleCard.getVisibility() != View.VISIBLE || (mCard != null && mCard.getVisibility() == View.VISIBLE)) {
            mSimpleCard.setVisibility(View.VISIBLE);
            mCard.setVisibility(View.GONE);
        }
    } else {
        if (mCard == null) {
            mCard = createWebView();
            mCardFrame.addView(mCard);
            if (!mUseQuickUpdate) {
                mNextCard = createWebView();
                mNextCard.setVisibility(View.GONE);
                mCardFrame.addView(mNextCard, 0);
                mCard.setBackgroundColor(mCurrentBackgroundColor);
            }
        }
        if (mCard.getVisibility() != View.VISIBLE || (mSimpleCard != null && mSimpleCard.getVisibility() == View.VISIBLE)) {
            mSimpleCard.setVisibility(View.GONE);
            mCard.setVisibility(View.VISIBLE);
        }
    }
}
Also used : Note(com.ichi2.libanki.Note) TextView(android.widget.TextView) SpannedString(android.text.SpannedString) SpannableString(android.text.SpannableString) JSONException(org.json.JSONException) IOException(java.io.IOException)

Aggregations

SpannableString (android.text.SpannableString)2 SpannedString (android.text.SpannedString)2 TextView (android.widget.TextView)2 Note (com.ichi2.libanki.Note)2 IOException (java.io.IOException)2 ScrollTextView (com.ichi2.anki.Reviewer.ScrollTextView)1 FileNotFoundException (java.io.FileNotFoundException)1 JSONException (org.json.JSONException)1