<commit_before>/*
 * Copyright (C) 2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.onegravity.rteditor.demo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;

import com.onegravity.rteditor.RTEditText;
import com.onegravity.rteditor.RTManager;
import com.onegravity.rteditor.api.RTApi;
import com.onegravity.rteditor.api.RTMediaFactoryImpl;
import com.onegravity.rteditor.api.RTProxyImpl;
import com.onegravity.rteditor.api.format.RTFormat;
import com.onegravity.rteditor.media.MediaUtils;
import com.onegravity.rteditor.toolbar.HorizontalRTToolbar;

import java.io.File;

public class RichTextEditor extends AppCompatActivity {

    private static final int REQUEST_LOAD_FILE = 1;
    private static final int REQUEST_SAVE_FILE = 2;

    private RTManager mRTManager;
    private EditText mSubjectField;
    private RTEditText mRTMessageField;
    private RTEditText mRTSignatureField;

    private boolean mUseDarkTheme;
    private boolean mSplitToolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // read extras
        String subject = "";
        String message = null;
        String signature = null;
        if (savedInstanceState == null) {
            Intent intent = getIntent();
            subject = getStringExtra(intent, "subject");
            message = getStringExtra(intent, "message");
            signature = getStringExtra(intent, "signature");
            mUseDarkTheme = intent.getBooleanExtra("mUseDarkTheme", false);
            mSplitToolbar = intent.getBooleanExtra("mSplitToolbar", false);
        } else {
            subject = savedInstanceState.getString("subject", "");
            mUseDarkTheme = savedInstanceState.getBoolean("mUseDarkTheme", false);
            mSplitToolbar = savedInstanceState.getBoolean("mSplitToolbar", false);
        }

        // set theme
        setTheme(mUseDarkTheme ? R.style.ThemeDark : R.style.ThemeLight);

        super.onCreate(savedInstanceState);

        // set layout
        setContentView(mSplitToolbar ? R.layout.rte_demo_2 : R.layout.rte_demo_1);

        // initialize rich text manager
        RTApi rtApi = new RTApi(this, new RTProxyImpl(this), new RTMediaFactoryImpl(this, true));
        mRTManager = new RTManager(rtApi, savedInstanceState);

        ViewGroup toolbarContainer = (ViewGroup) findViewById(R.id.rte_toolbar_container);

        // register toolbar 0 (if it exists)
        HorizontalRTToolbar rtToolbar0 = (HorizontalRTToolbar) findViewById(R.id.rte_toolbar);
        if (rtToolbar0 != null) {
            mRTManager.registerToolbar(toolbarContainer, rtToolbar0);
        }

        // register toolbar 1 (if it exists)
        HorizontalRTToolbar rtToolbar1 = (HorizontalRTToolbar) findViewById(R.id.rte_toolbar_character);
        if (rtToolbar1 != null) {
            mRTManager.registerToolbar(toolbarContainer, rtToolbar1);
        }

        // register toolbar 2 (if it exists)
        HorizontalRTToolbar rtToolbar2 = (HorizontalRTToolbar) findViewById(R.id.rte_toolbar_paragraph);
        if (rtToolbar2 != null) {
            mRTManager.registerToolbar(toolbarContainer, rtToolbar2);
        }

        // set subject
        mSubjectField = (EditText) findViewById(R.id.subject);
        mSubjectField.setText(subject);

        // register message editor
        mRTMessageField = (RTEditText) findViewById(R.id.rtEditText_1);
        mRTManager.registerEditor(mRTMessageField, true);
        if (message != null) {
            mRTMessageField.setRichTextEditing(true, message);
        }

        // register signature editor
        mRTSignatureField = (RTEditText) findViewById(R.id.rtEditText_2);
        mRTManager.registerEditor(mRTSignatureField, true);
        if (signature != null) {
            mRTSignatureField.setRichTextEditing(true, signature);
        }
<commit_msg>Use RTToolbar instead of the HorozontalRTToolbar to make this more generic.<commit_after>/*
 * Copyright (C) 2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.onegravity.rteditor.demo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;

import com.onegravity.rteditor.RTEditText;
import com.onegravity.rteditor.RTManager;
import com.onegravity.rteditor.RTToolbar;
import com.onegravity.rteditor.api.RTApi;
import com.onegravity.rteditor.api.RTMediaFactoryImpl;
import com.onegravity.rteditor.api.RTProxyImpl;
import com.onegravity.rteditor.api.format.RTFormat;
import com.onegravity.rteditor.media.MediaUtils;

import java.io.File;

public class RichTextEditor extends AppCompatActivity {

    private static final int REQUEST_LOAD_FILE = 1;
    private static final int REQUEST_SAVE_FILE = 2;

    private RTManager mRTManager;
    private EditText mSubjectField;
    private RTEditText mRTMessageField;
    private RTEditText mRTSignatureField;

    private boolean mUseDarkTheme;
    private boolean mSplitToolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // read extras
        String subject = "";
        String message = null;
        String signature = null;
        if (savedInstanceState == null) {
            Intent intent = getIntent();
            subject = getStringExtra(intent, "subject");
            message = getStringExtra(intent, "message");
            signature = getStringExtra(intent, "signature");
            mUseDarkTheme = intent.getBooleanExtra("mUseDarkTheme", false);
            mSplitToolbar = intent.getBooleanExtra("mSplitToolbar", false);
        } else {
            subject = savedInstanceState.getString("subject", "");
            mUseDarkTheme = savedInstanceState.getBoolean("mUseDarkTheme", false);
            mSplitToolbar = savedInstanceState.getBoolean("mSplitToolbar", false);
        }

        // set theme
        setTheme(mUseDarkTheme ? R.style.ThemeDark : R.style.ThemeLight);

        super.onCreate(savedInstanceState);

        // set layout
        setContentView(mSplitToolbar ? R.layout.rte_demo_2 : R.layout.rte_demo_1);

        // initialize rich text manager
        RTApi rtApi = new RTApi(this, new RTProxyImpl(this), new RTMediaFactoryImpl(this, true));
        mRTManager = new RTManager(rtApi, savedInstanceState);

        ViewGroup toolbarContainer = (ViewGroup) findViewById(R.id.rte_toolbar_container);

        // register toolbar 0 (if it exists)
        RTToolbar rtToolbar0 = (RTToolbar) findViewById(R.id.rte_toolbar);
        if (rtToolbar0 != null) {
            mRTManager.registerToolbar(toolbarContainer, rtToolbar0);
        }

        // register toolbar 1 (if it exists)
        RTToolbar rtToolbar1 = (RTToolbar) findViewById(R.id.rte_toolbar_character);
        if (rtToolbar1 != null) {
            mRTManager.registerToolbar(toolbarContainer, rtToolbar1);
        }

        // register toolbar 2 (if it exists)
        RTToolbar rtToolbar2 = (RTToolbar) findViewById(R.id.rte_toolbar_paragraph);
        if (rtToolbar2 != null) {
            mRTManager.registerToolbar(toolbarContainer, rtToolbar2);
        }

        // set subject
        mSubjectField = (EditText) findViewById(R.id.subject);
        mSubjectField.setText(subject);

        // register message editor
        mRTMessageField = (RTEditText) findViewById(R.id.rtEditText_1);
        mRTManager.registerEditor(mRTMessageField, true);
        if (message != null) {
            mRTMessageField.setRichTextEditing(true, message);
        }

        // register signature editor
        mRTSignatureField = (RTEditText) findViewById(R.id.rtEditText_2);
        mRTManager.registerEditor(mRTSignatureField, true);
        if (signature != null) {
            mRTSignatureField.setRichTextEditing(true, signature);
        }

{'fraction_non_alphanumeric': 0.08914310382041873, 'fraction_numerical': 0.005827757392618174, 'mean_word_length': 3.2334399269072636, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2017954', 'n_tokens_mistral': 2585, 'n_tokens_neox': 2522, 'n_words': 634}