<commit_before>/*
 * Copyright 2016 <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.pyamsoft.padlock.app.main;

import android.animation.LayoutTransition;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.TransactionDetails;
import com.pyamsoft.padlock.PadLock;
import com.pyamsoft.padlock.R;
import com.pyamsoft.pydroid.tool.AsyncVectorDrawableTask;
import com.pyamsoft.padlock.app.list.LockListFragment;
import com.pyamsoft.padlock.app.service.PadLockService;
import com.pyamsoft.padlock.app.settings.SettingsFragment;
import com.pyamsoft.padlock.dagger.main.DaggerMainComponent;
import com.pyamsoft.padlock.dagger.main.MainModule;
import com.pyamsoft.pydroid.model.AsyncDrawable;
import com.pyamsoft.pydroid.base.ActivityBase;
import com.pyamsoft.pydroid.onboard.HoleView;
import com.pyamsoft.pydroid.tool.DataHolderFragment;
import com.pyamsoft.pydroid.util.AppUtil;
import com.pyamsoft.pydroid.util.DrawableUtil;
import com.pyamsoft.pydroid.util.IMMLeakUtil;
import java.lang.ref.WeakReference;
import javax.inject.Inject;
import timber.log.Timber;

public class MainActivity extends ActivityBase
    implements BillingProcessor.IBillingHandler, MainView {

  private static final String USAGE_TERMS_TAG = "usage_terms";
  private static final int VECTOR_TASK_SIZE = 2;

  @NonNull private final AsyncVectorDrawableTask[] tasks =
      new AsyncVectorDrawableTask[VECTOR_TASK_SIZE];
  @NonNull private final LockListFragment lockListFragment;
  @NonNull private final SettingsFragment settingsFragment;
  @BindView(R.id.main_view) CoordinatorLayout mainView;
  @BindView(R.id.main_pager) ViewPager viewPager;
  @BindView(R.id.main_enable_service) LinearLayout enableService;
  @BindView(R.id.main_service_button) Button serviceButton;
  @BindView(R.id.main_tabs) TabLayout tabLayout;
  @BindView(R.id.toolbar) Toolbar toolbar;
  @BindView(R.id.appbar) AppBarLayout appBarLayout;
  @BindView(R.id.onboard) HoleView holeView;
  @BindView(R.id.onboard_done_button) Button doneButton;
  @Inject MainPresenter presenter;
  private BillingProcessor billingProcessor;
  private MainPagerAdapter adapter;
  private Unbinder unbinder;

  @SuppressWarnings("WeakerAccess") public MainActivity() {
    lockListFragment = new LockListFragment();
    settingsFragment = new SettingsFragment();
  }

  @Override public void onCreate(final Bundle savedInstanceState) {
    setTheme(R.style.Theme_PadLock_Light);
    IMMLeakUtil.fixFocusedViewLeak(getApplication());

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    unbinder = ButterKnife.bind(this);

    DaggerMainComponent.builder()
        .padLockComponent(PadLock.padLockComponent(this))
        .mainModule(new MainModule())
        .build()
        .inject(this);

    presenter.bind(this);

    billingProcessor = new BillingProcessor(this, getBillingKey(), this);

    setAppBarState();
    setupViewPagerAdapter();
    setupViewPager();
    setupTabLayout();
    setupAccessibilityButton();
    setupOnboarding();
  }

  private void setupOnboarding() {
    doneButton.setOnClickListener(view -> {
      Timber.d("Done clicked!");
      presenter.setOnBoard();
      holeView.hide();
    });
  }

  public HoleView getHoleView() {
    return holeView;
  }

  private void setupAccessibilityButton() {
    serviceButton.setOnClickListener(view -> {<commit_msg>Billing token is the package name<commit_after>/*
 * Copyright 2016 <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.pyamsoft.padlock.app.main;

import android.animation.LayoutTransition;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.TransactionDetails;
import com.pyamsoft.padlock.PadLock;
import com.pyamsoft.padlock.R;
import com.pyamsoft.pydroid.tool.AsyncVectorDrawableTask;
import com.pyamsoft.padlock.app.list.LockListFragment;
import com.pyamsoft.padlock.app.service.PadLockService;
import com.pyamsoft.padlock.app.settings.SettingsFragment;
import com.pyamsoft.padlock.dagger.main.DaggerMainComponent;
import com.pyamsoft.padlock.dagger.main.MainModule;
import com.pyamsoft.pydroid.model.AsyncDrawable;
import com.pyamsoft.pydroid.base.ActivityBase;
import com.pyamsoft.pydroid.onboard.HoleView;
import com.pyamsoft.pydroid.tool.DataHolderFragment;
import com.pyamsoft.pydroid.util.AppUtil;
import com.pyamsoft.pydroid.util.DrawableUtil;
import com.pyamsoft.pydroid.util.IMMLeakUtil;
import java.lang.ref.WeakReference;
import javax.inject.Inject;
import timber.log.Timber;

public class MainActivity extends ActivityBase
    implements BillingProcessor.IBillingHandler, MainView {

  private static final String USAGE_TERMS_TAG = "usage_terms";
  private static final int VECTOR_TASK_SIZE = 2;

  @NonNull private final AsyncVectorDrawableTask[] tasks =
      new AsyncVectorDrawableTask[VECTOR_TASK_SIZE];
  @NonNull private final LockListFragment lockListFragment;
  @NonNull private final SettingsFragment settingsFragment;
  @BindView(R.id.main_view) CoordinatorLayout mainView;
  @BindView(R.id.main_pager) ViewPager viewPager;
  @BindView(R.id.main_enable_service) LinearLayout enableService;
  @BindView(R.id.main_service_button) Button serviceButton;
  @BindView(R.id.main_tabs) TabLayout tabLayout;
  @BindView(R.id.toolbar) Toolbar toolbar;
  @BindView(R.id.appbar) AppBarLayout appBarLayout;
  @BindView(R.id.onboard) HoleView holeView;
  @BindView(R.id.onboard_done_button) Button doneButton;
  @Inject MainPresenter presenter;
  private BillingProcessor billingProcessor;
  private MainPagerAdapter adapter;
  private Unbinder unbinder;

  @SuppressWarnings("WeakerAccess") public MainActivity() {
    lockListFragment = new LockListFragment();
    settingsFragment = new SettingsFragment();
  }

  @Override public void onCreate(final Bundle savedInstanceState) {
    setTheme(R.style.Theme_PadLock_Light);
    IMMLeakUtil.fixFocusedViewLeak(getApplication());

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    unbinder = ButterKnife.bind(this);

    DaggerMainComponent.builder()
        .padLockComponent(PadLock.padLockComponent(this))
        .mainModule(new MainModule())
        .build()
        .inject(this);

    presenter.bind(this);

    // The billing key is just the package name
    billingProcessor = new BillingProcessor(this, getPackageName(), this);

    setAppBarState();
    setupViewPagerAdapter();
    setupViewPager();
    setupTabLayout();
    setupAccessibilityButton();
    setupOnboarding();
  }

  private void setupOnboarding() {
    doneButton.setOnClickListener(view -> {
      Timber.d("Done clicked!");
      presenter.setOnBoard();
      holeView.hide();
    });
  }

  public HoleView getHoleView() {
    return holeView;
  }

  private void setupAccessibilityButton() {
    serviceButton.setOnClickListener(view -> {
{'fraction_non_alphanumeric': 0.0943458613468533, 'fraction_numerical': 0.0028656453212829273, 'mean_word_length': 5.110437710437711, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2402749', 'n_tokens_mistral': 2760, 'n_tokens_neox': 2716, 'n_words': 593}