Search in sources :

Example 1 with MarkdownPreviewWebView

use of com.gh4a.widget.MarkdownPreviewWebView in project gh4a by slapperwan.

the class IssueEditActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        mEditIssue = savedInstanceState.getParcelable(STATE_KEY_ISSUE);
        mOriginalIssue = savedInstanceState.getParcelable(STATE_KEY_ORIGINAL_ISSUE);
    }
    super.onCreate(savedInstanceState);
    if (!Gh4Application.get().isAuthorized()) {
        Intent intent = new Intent(this, Github4AndroidActivity.class);
        startActivity(intent);
        finish();
        return;
    }
    LayoutInflater headerInflater = LayoutInflater.from(UiUtils.makeHeaderThemedContext(this));
    View header = headerInflater.inflate(R.layout.issue_create_header, null);
    addHeaderView(header, false);
    mTitleWrapper = header.findViewById(R.id.title_wrapper);
    mTitleView = header.findViewById(R.id.et_title);
    mTitleView.setOnFocusChangeListener(this);
    mDescView = findViewById(R.id.editor);
    mSelectedMilestoneView = findViewById(R.id.tv_milestone);
    mSelectedAssigneeContainer = findViewById(R.id.assignee_list);
    mLabelsView = findViewById(R.id.tv_labels);
    mMarkdownButtons = findViewById(R.id.markdown_buttons);
    mMarkdownButtons.setEditText(mDescView);
    View topLeftShadow = findViewById(R.id.markdown_buttons_top_left_shadow);
    if (topLeftShadow != null) {
        topLeftShadow.setVisibility(View.GONE);
    }
    View topShadow = findViewById(R.id.markdown_buttons_top_shadow);
    if (topShadow != null) {
        topShadow.setVisibility(View.GONE);
    }
    MarkdownPreviewWebView preview = findViewById(R.id.preview);
    preview.setEditText(mDescView);
    findViewById(R.id.milestone_container).setOnClickListener(this);
    findViewById(R.id.assignee_container).setOnClickListener(this);
    findViewById(R.id.label_container).setOnClickListener(this);
    CoordinatorLayout rootLayout = getRootLayout();
    mFab = (FloatingActionButton) getLayoutInflater().inflate(R.layout.accept_fab, rootLayout, false);
    mFab.setOnClickListener(this);
    rootLayout.addView(mFab);
    loadCollaboratorStatus(false);
    if (savedInstanceState == null && !isInEditMode()) {
        loadIssueTemplate();
        mDescView.setEnabled(false);
        mDescView.setHint(getString(R.string.issue_loading_template_hint));
    }
    mTitleView.setText(mEditIssue.title());
    mDescView.setText(mEditIssue.body());
    mTitleView.addTextChangedListener(new UiUtils.ButtonEnableTextWatcher(mTitleView, mFab));
    mTitleView.addTextChangedListener(new UiUtils.EmptinessWatchingTextWatcher(mTitleView) {

        @Override
        public void onIsEmpty(boolean isEmpty) {
            if (isEmpty) {
                mTitleWrapper.setError(getString(R.string.issue_error_title));
            } else {
                mTitleWrapper.setErrorEnabled(false);
            }
            mFab.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
        }
    });
    adjustTabsForHeaderAlignedFab(true);
    setToolbarScrollable(false);
    updateOptionViews();
    addAppBarOffsetListener(this);
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) LayoutInflater(android.view.LayoutInflater) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) Intent(android.content.Intent) ImageView(android.widget.ImageView) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) View(android.view.View) TextView(android.widget.TextView) UiUtils(com.gh4a.utils.UiUtils)

Example 2 with MarkdownPreviewWebView

use of com.gh4a.widget.MarkdownPreviewWebView in project gh4a by slapperwan.

the class IssueMilestoneEditActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Gh4Application.get().isAuthorized()) {
        Intent intent = new Intent(this, Github4AndroidActivity.class);
        startActivity(intent);
        finish();
        return;
    }
    LayoutInflater headerInflater = LayoutInflater.from(UiUtils.makeHeaderThemedContext(this));
    View header = headerInflater.inflate(R.layout.issue_create_header, null);
    addHeaderView(header, false);
    mTitleWrapper = header.findViewById(R.id.title_wrapper);
    mTitleView = header.findViewById(R.id.et_title);
    mTitleView.setOnFocusChangeListener(this);
    mDescriptionView = findViewById(R.id.editor);
    mDueView = findViewById(R.id.tv_due);
    mMarkdownButtons = findViewById(R.id.markdown_buttons);
    mMarkdownButtons.setEditText(mDescriptionView);
    MarkdownPreviewWebView preview = findViewById(R.id.preview);
    preview.setEditText(mDescriptionView);
    CoordinatorLayout rootLayout = getRootLayout();
    mSaveFab = (IssueStateTrackingFloatingActionButton) getLayoutInflater().inflate(R.layout.accept_fab, rootLayout, false);
    mSaveFab.setOnClickListener(this);
    rootLayout.addView(mSaveFab);
    findViewById(R.id.due_container).setOnClickListener(this);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    if (mMilestone == null) {
        mMilestone = Milestone.builder().state(IssueState.Open).build();
    }
    mTitleView.addTextChangedListener(new UiUtils.ButtonEnableTextWatcher(mTitleView, mSaveFab));
    mTitleView.addTextChangedListener(new UiUtils.EmptinessWatchingTextWatcher(mTitleView) {

        @Override
        public void onIsEmpty(boolean isEmpty) {
            if (isEmpty) {
                mTitleWrapper.setError(getString(R.string.issue_error_milestone_title));
            } else {
                mTitleWrapper.setErrorEnabled(false);
            }
        }
    });
    mTitleView.setText(mMilestone.title());
    mDescriptionView.setText(mMilestone.description());
    updateHighlightColor();
    updateLabels();
    setToolbarScrollable(false);
    adjustTabsForHeaderAlignedFab(true);
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) LayoutInflater(android.view.LayoutInflater) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) Intent(android.content.Intent) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) UiUtils(com.gh4a.utils.UiUtils)

Aggregations

Intent (android.content.Intent)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 TextView (android.widget.TextView)2 UiUtils (com.gh4a.utils.UiUtils)2 MarkdownPreviewWebView (com.gh4a.widget.MarkdownPreviewWebView)2 ActionBar (android.support.v7.app.ActionBar)1 ImageView (android.widget.ImageView)1