<commit_before>/*
 * Copyright (C) 2014 <NAME> (<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 org.tlhInganHol.android.klingonassistant;

import android.app.SearchManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TwoLineListItem;
import wei.mark.standout.StandOutWindow;

// TUTORIAL:
import com.espian.showcaseview.ShowcaseView;
import com.espian.showcaseview.targets.ActionItemTarget;
import com.espian.showcaseview.targets.ActionViewTarget;

/**
 * The main activity for the dictionary. Displays search results triggered by the search dialog and
 * handles actions from search suggestions.
 */
public class KlingonAssistant extends BaseActivity {
  private static final String TAG = "KlingonAssistant";

  // Whether to include the tutorial or not. If false, the code should be stripped out of the binary.
  public static final boolean INCLUDE_TUTORIAL = true;

  // Preference key for whether to show help.
  public static final String  KEY_SHOW_HELP                    = "show_help";

  // This holds the {pIqaD} typeface.
  private static Typeface     mKlingonFontTypeface             = null;

  // The two main views in app's main screen.
  private TextView            mTextView;
  private ListView            mListView;

  // Keep the query for passing to the FloatingWindow.
  private String mQuery = "";

  private int mTutorialCounter;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    if (sharedPrefs.getBoolean(Preferences.KEY_KLINGON_UI_CHECKBOX_PREFERENCE, /* default */false)) {
      setDrawerContentView(R.layout.main_tlh);
    } else {
      setDrawerContentView(R.layout.main);
    }

    mTextView = (TextView) findViewById(R.id.text);
    mListView = (ListView) findViewById(R.id.list);

    handleIntent(getIntent());
  }

  private void setupTutorial() {
    if (INCLUDE_TUTORIAL) {
      // ShowcaseView for the initial tutorial.
      ShowcaseView.ConfigOptions mShowcaseViewOptions = new ShowcaseView.ConfigOptions();

      // When tutorial is running, block user actions.
      mShowcaseViewOptions.block = true;
      mShowcaseViewOptions.hideOnClickOutside = false;

      // Use ShowcaseView to run the tutorial.
      final ActionItemTarget searchTarget = new ActionItemTarget(this, R.id.search);
      final ActionItemTarget socialTarget = new ActionItemTarget(this, R.id.social_network);
      final ActionViewTarget homeTarget = new ActionViewTarget(this, ActionViewTarget.Type.HOME);
      final ActionViewTarget overflowTarget = new ActionViewTarget(this, ActionViewTarget.Type.OVERFLOW);

      // TODO: Change the display depending on isHorizontalTablet().
      // Display an introductory message.
      mTutorialCounter = 1;
      // The ShowcaseView library doesn't seem to support setting NONE to be the first target, so work
      // around by temporarily setting a target then setting it to NONE.
      final ShowcaseView mShowcaseView = ShowcaseView.insertShowcaseView(searchTarget, this,
                      R.string.tutorial_1_title, R.string.tutorial_1_msg, mShowcaseViewOptions);
      mShowcaseView.setShowcase(ShowcaseView.NONE);
      mShowcaseView.overrideButtonClick(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
             mTutorialCounter++;
             switch(mTutorialCounter) {
               case 2: // Showcase the "Search" button.
                 mShowcaseView.setShowcase(searchTarget, true);
                 mShowcaseView.setText(R.string.tutorial_2_title, R.string.tutorial_2_msg);
                 break;
               case 3: // Showcase the "home" button.
                 mShowcaseView.setShowcase(homeTarget, true);
                 mShowcaseView.setText(R.string.tutorial_3_title, R.string.tutorial_3_msg);
                 break;
               case 4: // Showcase the G+ button.
                 mShowcaseView.setShowcase(socialTarget, true);
                 mShowcaseView.setText(R.string.tutorial_4_title, R.string.tutorial_4_msg);
                 break;
               case 5: // Showcase the overflow menu.
                 // if (... there is an overflow menu...) {
                   // On some devices, the menu target is not visible.
                   // mShowcaseView.setShowcase(overflowTarget, true);
                 // } else {
                   mShowcaseView.setShowcase(ShowcaseView.NONE);
                 // }
                 mShowcaseView.setText(R.string.tutorial_5_title, R.string.tutorial_5_msg);<commit_msg>setting alpha doesn't work on tutorial<commit_after>/*
 * Copyright (C) 2014 <NAME> (<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 org.tlhInganHol.android.klingonassistant;

import android.app.SearchManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TwoLineListItem;
import wei.mark.standout.StandOutWindow;

// TUTORIAL:
import com.espian.showcaseview.ShowcaseView;
import com.espian.showcaseview.targets.ActionItemTarget;
import com.espian.showcaseview.targets.ActionViewTarget;

/**
 * The main activity for the dictionary. Displays search results triggered by the search dialog and
 * handles actions from search suggestions.
 */
public class KlingonAssistant extends BaseActivity {
  private static final String TAG = "KlingonAssistant";

  // Whether to include the tutorial or not. If false, the code should be stripped out of the binary.
  public static final boolean INCLUDE_TUTORIAL = true;

  // Preference key for whether to show help.
  public static final String  KEY_SHOW_HELP                    = "show_help";

  // This holds the {pIqaD} typeface.
  private static Typeface     mKlingonFontTypeface             = null;

  // The two main views in app's main screen.
  private TextView            mTextView;
  private ListView            mListView;

  // Keep the query for passing to the FloatingWindow.
  private String mQuery = "";

  private int mTutorialCounter;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    if (sharedPrefs.getBoolean(Preferences.KEY_KLINGON_UI_CHECKBOX_PREFERENCE, /* default */false)) {
      setDrawerContentView(R.layout.main_tlh);
    } else {
      setDrawerContentView(R.layout.main);
    }

    mTextView = (TextView) findViewById(R.id.text);
    mListView = (ListView) findViewById(R.id.list);

    handleIntent(getIntent());
  }

  private void setupTutorial() {
    if (INCLUDE_TUTORIAL) {
      // ShowcaseView for the initial tutorial.
      ShowcaseView.ConfigOptions mShowcaseViewOptions = new ShowcaseView.ConfigOptions();

      // When tutorial is running, block user actions.
      mShowcaseViewOptions.block = true;
      mShowcaseViewOptions.hideOnClickOutside = false;

      // Use ShowcaseView to run the tutorial.
      final ActionItemTarget searchTarget = new ActionItemTarget(this, R.id.search);
      final ActionItemTarget socialTarget = new ActionItemTarget(this, R.id.social_network);
      final ActionViewTarget homeTarget = new ActionViewTarget(this, ActionViewTarget.Type.HOME);
      final ActionViewTarget overflowTarget = new ActionViewTarget(this, ActionViewTarget.Type.OVERFLOW);

      // TODO: Change the display depending on isHorizontalTablet().
      // Display an introductory message.
      mTutorialCounter = 1;
      // The ShowcaseView library doesn't seem to support setting NONE to be the first target, so work
      // around by temporarily setting a target then setting it to NONE.
      final ShowcaseView mShowcaseView = ShowcaseView.insertShowcaseView(searchTarget, this,
                      R.string.tutorial_1_title, R.string.tutorial_1_msg, mShowcaseViewOptions);
      // mShowcaseView.setAlpha(1.0f);
      mShowcaseView.setShowcase(ShowcaseView.NONE);
      mShowcaseView.overrideButtonClick(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
             mTutorialCounter++;
             switch(mTutorialCounter) {
               case 2: // Showcase the "Search" button.
                 mShowcaseView.setShowcase(searchTarget, true);
                 mShowcaseView.setText(R.string.tutorial_2_title, R.string.tutorial_2_msg);
                 break;
               case 3: // Showcase the "home" button.
                 mShowcaseView.setShowcase(homeTarget, true);
                 mShowcaseView.setText(R.string.tutorial_3_title, R.string.tutorial_3_msg);
                 break;
               case 4: // Showcase the G+ button.
                 mShowcaseView.setShowcase(socialTarget, true);
                 mShowcaseView.setText(R.string.tutorial_4_title, R.string.tutorial_4_msg);
                 break;
               case 5: // Showcase the overflow menu.
                 // if (... there is an overflow menu...) {
                   // On some devices, the menu target is not visible.
                   // mShowcaseView.setShowcase(overflowTarget, true);
                 // } else {
                   mShowcaseView.setShowcase(ShowcaseView.NONE);
                 // }
                 mShowcaseView.setText(R.string.tutorial_5_title, R.string.tutorial_5_msg);
{'fraction_non_alphanumeric': 0.08201193520886615, 'fraction_numerical': 0.004092071611253197, 'mean_word_length': 3.093161200279135, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5566914', 'n_tokens_mistral': 3250, 'n_tokens_neox': 3108, 'n_words': 895}