Search in sources :

Example 1 with CardMarker

use of com.ichi2.anki.reviewer.CardMarker in project AnkiChinaAndroid by ankichinateam.

the class AbstractFlashcardViewer method initLayout.

// Set the content view to the one provided and initialize accessors.
// Tracked separately as #5023 on github for clipboard
@SuppressWarnings("deprecation")
protected void initLayout() {
    FrameLayout mCardContainer = (FrameLayout) findViewById(R.id.flashcard_frame);
    mTopBarLayout = (RelativeLayout) findViewById(R.id.top_bar);
    ImageView mark = mTopBarLayout.findViewById(R.id.mark_icon);
    ImageView flag = mTopBarLayout.findViewById(R.id.flag_icon);
    mCardMarker = new CardMarker(mark, flag);
    mCardFrame = (FrameLayout) findViewById(R.id.flashcard);
    mCardFrameParent = (ViewGroup) mCardFrame.getParent();
    mTouchLayer = (FrameLayout) findViewById(R.id.touch_layer);
    mTouchLayer.setOnTouchListener(mGestureListener);
    if (!mDisableClipboard) {
        mClipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    }
    mCardFrame.removeAllViews();
    // Initialize swipe
    mGestureDetectorImpl = mLinkOverridesTouchGesture ? new LinkDetectingGestureDetector() : new MyGestureDetector();
    gestureDetector = new GestureDetectorCompat(this, mGestureDetectorImpl);
    mEaseButtonsLayout = findViewById(R.id.ease_buttons);
    mEase1 = findViewById(R.id.ease1);
    mEase1Layout = findViewById(R.id.flashcard_layout_ease1);
    mEase1Layout.setOnClickListener(mSelectEaseHandler);
    mEase2 = findViewById(R.id.ease2);
    mEase2Layout = findViewById(R.id.flashcard_layout_ease2);
    mEase2Layout.setOnClickListener(mSelectEaseHandler);
    mEase3 = findViewById(R.id.ease3);
    mEase3Layout = findViewById(R.id.flashcard_layout_ease3);
    mEase3Layout.setOnClickListener(mSelectEaseHandler);
    mEase4 = findViewById(R.id.ease4);
    mEase4Layout = findViewById(R.id.flashcard_layout_ease4);
    mEase4Layout.setOnClickListener(mSelectEaseHandler);
    mNext1 = findViewById(R.id.nextTime1);
    mNext2 = findViewById(R.id.nextTime2);
    mNext3 = findViewById(R.id.nextTime3);
    mNext4 = findViewById(R.id.nextTime4);
    if (!mShowNextReviewTime) {
        mNext1.setVisibility(View.GONE);
        mNext2.setVisibility(View.GONE);
        mNext3.setVisibility(View.GONE);
        mNext4.setVisibility(View.GONE);
    }
    Button mFlipCard = (Button) findViewById(R.id.flip_card);
    mFlipCardLayout = (LinearLayout) findViewById(R.id.flashcard_layout_flip);
    mFlipCardLayout.setOnClickListener(mFlipCardListener);
    if (!mButtonHeightSet && mRelativeButtonSize != 100) {
        ViewGroup.LayoutParams params = mFlipCardLayout.getLayoutParams();
        params.height = params.height * mRelativeButtonSize / 100;
        params = mEase1Layout.getLayoutParams();
        params.height = params.height * mRelativeButtonSize / 100;
        params = mEase2Layout.getLayoutParams();
        params.height = params.height * mRelativeButtonSize / 100;
        params = mEase3Layout.getLayoutParams();
        params.height = params.height * mRelativeButtonSize / 100;
        params = mEase4Layout.getLayoutParams();
        params.height = params.height * mRelativeButtonSize / 100;
        mButtonHeightSet = true;
    }
    mPreviewButtonsLayout = findViewById(R.id.preview_buttons_layout);
    mPreviewPrevCard = findViewById(R.id.preview_previous_flashcard);
    mPreviewNextCard = findViewById(R.id.preview_next_flashcard);
    mPreviewToggleAnswerText = findViewById(R.id.preview_flip_flashcard);
    mCardTimer = (Chronometer) findViewById(R.id.card_time);
    mChosenAnswer = (TextView) findViewById(R.id.choosen_answer);
    mAnswerField = (EditText) findViewById(R.id.answer_field);
    mLookUpIcon = findViewById(R.id.lookup_button);
    mLookUpIcon.setVisibility(View.GONE);
    mLookUpIcon.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Timber.i("AbstractFlashcardViewer:: Lookup button pressed");
            if (clipboardHasText()) {
                lookUp();
            }
        }
    });
    initControls();
    // Position answer buttons
    String answerButtonsPosition = AnkiDroidApp.getSharedPrefs(this).getString(getString(R.string.answer_buttons_position_preference), "bottom");
    LinearLayout answerArea = (LinearLayout) findViewById(R.id.bottom_area_layout);
    RelativeLayout.LayoutParams answerAreaParams = (RelativeLayout.LayoutParams) answerArea.getLayoutParams();
    RelativeLayout.LayoutParams cardContainerParams = (RelativeLayout.LayoutParams) mCardContainer.getLayoutParams();
    switch(answerButtonsPosition) {
        case "top":
            cardContainerParams.addRule(RelativeLayout.BELOW, R.id.bottom_area_layout);
            answerAreaParams.addRule(RelativeLayout.BELOW, R.id.mic_tool_bar_layer);
            answerArea.removeView(mAnswerField);
            answerArea.addView(mAnswerField, 1);
            break;
        case "bottom":
            cardContainerParams.addRule(RelativeLayout.ABOVE, R.id.bottom_area_layout);
            cardContainerParams.addRule(RelativeLayout.BELOW, R.id.mic_tool_bar_layer);
            answerAreaParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            break;
        default:
            Timber.w("Unknown answerButtonsPosition: %s", answerButtonsPosition);
            break;
    }
    answerArea.setLayoutParams(answerAreaParams);
    mCardContainer.setLayoutParams(cardContainerParams);
}
Also used : ViewGroup(android.view.ViewGroup) CardMarker(com.ichi2.anki.reviewer.CardMarker) GestureDetectorCompat(androidx.core.view.GestureDetectorCompat) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) AudioView(com.ichi2.anki.multimediacard.AudioView) ImageButton(android.widget.ImageButton) Button(android.widget.Button) FrameLayout(android.widget.FrameLayout) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) Context(android.content.Context) LinearLayout(android.widget.LinearLayout)

Example 2 with CardMarker

use of com.ichi2.anki.reviewer.CardMarker in project Anki-Android by ankidroid.

the class Reviewer method initLayout.

@Override
protected void initLayout() {
    mTextBarNew = findViewById(R.id.new_number);
    mTextBarLearn = findViewById(R.id.learn_number);
    mTextBarReview = findViewById(R.id.review_number);
    super.initLayout();
    if (!mShowRemainingCardCount) {
        mTextBarNew.setVisibility(View.GONE);
        mTextBarLearn.setVisibility(View.GONE);
        mTextBarReview.setVisibility(View.GONE);
    }
    // can't move this into onCreate due to mTopBarLayout
    ImageView mark = mTopBarLayout.findViewById(R.id.mark_icon);
    ImageView flag = mTopBarLayout.findViewById(R.id.flag_icon);
    mCardMarker = new CardMarker(mark, flag);
}
Also used : CardMarker(com.ichi2.anki.reviewer.CardMarker) ImageView(android.widget.ImageView)

Aggregations

ImageView (android.widget.ImageView)2 CardMarker (com.ichi2.anki.reviewer.CardMarker)2 Context (android.content.Context)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ViewGroup (android.view.ViewGroup)1 WebView (android.webkit.WebView)1 Button (android.widget.Button)1 FrameLayout (android.widget.FrameLayout)1 ImageButton (android.widget.ImageButton)1 LinearLayout (android.widget.LinearLayout)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 GestureDetectorCompat (androidx.core.view.GestureDetectorCompat)1 AudioView (com.ichi2.anki.multimediacard.AudioView)1