<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.grarak.kerneladiutor.fragments.kernel;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.AppCompatCheckBox;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.grarak.kerneladiutor.R;
import com.grarak.kerneladiutor.elements.DAdapter;
import com.grarak.kerneladiutor.elements.cards.CardViewItem;
import com.grarak.kerneladiutor.elements.cards.DDividerCard;
import com.grarak.kerneladiutor.elements.cards.PopupCardView;
import com.grarak.kerneladiutor.elements.cards.SeekBarCardView;
import com.grarak.kerneladiutor.elements.cards.SwitchCardView;
import com.grarak.kerneladiutor.elements.cards.UsageCardView;
import com.grarak.kerneladiutor.fragments.PathReaderFragment;
import com.grarak.kerneladiutor.fragments.RecyclerViewFragment;
import com.grarak.kerneladiutor.fragments.ViewPagerFragment;
import com.grarak.kerneladiutor.utils.Constants;
import com.grarak.kerneladiutor.utils.Utils;
import com.grarak.kerneladiutor.utils.kernel.CPU;
import com.grarak.kerneladiutor.utils.root.Control;
import com.grarak.kerneladiutor.utils.root.RootFile;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

/**
 * Created by willi on 07.04.15.
 */
public class CPUFragment extends ViewPagerFragment implements Constants {

    private static CPUFragment cpuFragment;
    private CPUPart cpuPart;
    private GovernorPart governorPart;
    private int core;

    @Override
    public void preInit(Bundle savedInstanceState) {
        super.preInit(savedInstanceState);
        showTabs(false);
    }

    @Override
    public void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        cpuFragment = this;

        allowSwipe(false);
        addFragment(new ViewPagerItem(cpuPart == null ? cpuPart = new CPUPart() : cpuPart, null));
        addFragment(new ViewPagerItem(governorPart == null ? governorPart = new GovernorPart() : governorPart, null));
    }

    @Override
    public void onSwipe(int page) {
        super.onSwipe(page);
        allowSwipe(page == 1);
    }

    @Override
    public boolean onBackPressed() {
        if (getCurrentPage() == 1) {
            setCurrentItem(0);
            return true;
        }
        return false;
    }

    public static class CPUPart extends RecyclerViewFragment implements View.OnClickListener,
            PopupCardView.DPopupCard.OnDPopupCardListener, CardViewItem.DCardView.OnDCardListener,
            SeekBarCardView.DSeekBarCard.OnDSeekBarCardListener,
            SwitchCardView.DSwitchCard.OnDSwitchCardListener {

        private UsageCardView.DUsageCard mUsageCard;

        private CardViewItem.DCardView mTempCard;

        private AppCompatCheckBox[] mCoreCheckBox;
        private ProgressBar[] mCoreProgressBar;
        private AppCompatTextView[] mCoreFreqText;

        private PopupCardView.DPopupCard mMaxFreqCard, mMinFreqCard, mMaxScreenOffFreqCard;

        private PopupCardView.DPopupCard mGovernorCard;
        private CardViewItem.DCardView mGovernorTunableCard;

        private AppCompatCheckBox[] mCoreCheckBoxLITTLE;
        private ProgressBar[] mCoreProgressBarLITTLE;
        private AppCompatTextView[] mCoreFreqTextLITTLE;

        private PopupCardView.DPopupCard mMaxFreqLITTLECard, mMinFreqLITTLECard, mMaxScreenOffFreqLITTLECard;

        private PopupCardView.DPopupCard mGovernorLITTLECard;
        private CardViewItem.DCardView mGovernorTunableLITTLECard;

        private PopupCardView.DPopupCard mMcPowerSavingCard;

        private SwitchCardView.DSwitchCard mPowerSavingWqCard;

        private PopupCardView.DPopupCard mCFSSchedulerCard;

        private SwitchCardView.DSwitchCard mCpuQuietEnableCard;
        private PopupCardView.DPopupCard mCpuQuietGovernorCard;

        private SwitchCardView.DSwitchCard mCpuBoostEnableCard;
        private SwitchCardView.DSwitchCard mCpuBoostDebugMaskCard;
        private SeekBarCardView.DSeekBarCard mCpuBoostMsCard;
        private PopupCardView.DPopupCard mCpuBoostSyncThresholdCard;
        private SeekBarCardView.DSeekBarCard mCpuBoostInputMsCard;
        private PopupCardView.DPopupCard[] mCpuBoostInputFreqCard;

        @Override
        public String getClassName() {
            return CPUFragment.class.getSimpleName();
        }

        @Override
        public void init(Bundle savedInstanceState) {
            super.init(savedInstanceState);

            usageInit();
            if (CPU.hasTemp()) tempInit();
            if (CPU.getFreqs() != null) {
                if (CPU.isBigLITTLE()) {
                    DDividerCard bigDivider = new DDividerCard();
                    bigDivider.setText(getString(R.string.big).toLowerCase(Locale.getDefault()));
                    addView(bigDivider);
                }
                coreInit();
                freqInit();
            }
            if (CPU.getAvailableGovernors() != null) governorInit();
            DDividerCard othersDivider = null;
            if (CPU.isBigLITTLE()) {
                DDividerCard LITTLEDivider = new DDividerCard();
                LITTLEDivider.setText(getString(R.string.little));
                addView(LITTLEDivider);

                if (CPU.getFreqs(CPU.getLITTLEcore()) != null) {
                    coreLITTLEInit();
                    freqLITTLEInit();
                }
                if (CPU.getAvailableGovernors(CPU.getLITTLEcore()) != null) governorLITTLEInit();

                othersDivider = new DDividerCard();
                othersDivider.setText(getString(R.string.other));
                addView(othersDivider);
            }<commit_msg>LITTLE should be uppercase<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.grarak.kerneladiutor.fragments.kernel;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.AppCompatCheckBox;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.grarak.kerneladiutor.R;
import com.grarak.kerneladiutor.elements.DAdapter;
import com.grarak.kerneladiutor.elements.cards.CardViewItem;
import com.grarak.kerneladiutor.elements.cards.DDividerCard;
import com.grarak.kerneladiutor.elements.cards.PopupCardView;
import com.grarak.kerneladiutor.elements.cards.SeekBarCardView;
import com.grarak.kerneladiutor.elements.cards.SwitchCardView;
import com.grarak.kerneladiutor.elements.cards.UsageCardView;
import com.grarak.kerneladiutor.fragments.PathReaderFragment;
import com.grarak.kerneladiutor.fragments.RecyclerViewFragment;
import com.grarak.kerneladiutor.fragments.ViewPagerFragment;
import com.grarak.kerneladiutor.utils.Constants;
import com.grarak.kerneladiutor.utils.Utils;
import com.grarak.kerneladiutor.utils.kernel.CPU;
import com.grarak.kerneladiutor.utils.root.Control;
import com.grarak.kerneladiutor.utils.root.RootFile;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

/**
 * Created by willi on 07.04.15.
 */
public class CPUFragment extends ViewPagerFragment implements Constants {

    private static CPUFragment cpuFragment;
    private CPUPart cpuPart;
    private GovernorPart governorPart;
    private int core;

    @Override
    public void preInit(Bundle savedInstanceState) {
        super.preInit(savedInstanceState);
        showTabs(false);
    }

    @Override
    public void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        cpuFragment = this;

        allowSwipe(false);
        addFragment(new ViewPagerItem(cpuPart == null ? cpuPart = new CPUPart() : cpuPart, null));
        addFragment(new ViewPagerItem(governorPart == null ? governorPart = new GovernorPart() : governorPart, null));
    }

    @Override
    public void onSwipe(int page) {
        super.onSwipe(page);
        allowSwipe(page == 1);
    }

    @Override
    public boolean onBackPressed() {
        if (getCurrentPage() == 1) {
            setCurrentItem(0);
            return true;
        }
        return false;
    }

    public static class CPUPart extends RecyclerViewFragment implements View.OnClickListener,
            PopupCardView.DPopupCard.OnDPopupCardListener, CardViewItem.DCardView.OnDCardListener,
            SeekBarCardView.DSeekBarCard.OnDSeekBarCardListener,
            SwitchCardView.DSwitchCard.OnDSwitchCardListener {

        private UsageCardView.DUsageCard mUsageCard;

        private CardViewItem.DCardView mTempCard;

        private AppCompatCheckBox[] mCoreCheckBox;
        private ProgressBar[] mCoreProgressBar;
        private AppCompatTextView[] mCoreFreqText;

        private PopupCardView.DPopupCard mMaxFreqCard, mMinFreqCard, mMaxScreenOffFreqCard;

        private PopupCardView.DPopupCard mGovernorCard;
        private CardViewItem.DCardView mGovernorTunableCard;

        private AppCompatCheckBox[] mCoreCheckBoxLITTLE;
        private ProgressBar[] mCoreProgressBarLITTLE;
        private AppCompatTextView[] mCoreFreqTextLITTLE;

        private PopupCardView.DPopupCard mMaxFreqLITTLECard, mMinFreqLITTLECard, mMaxScreenOffFreqLITTLECard;

        private PopupCardView.DPopupCard mGovernorLITTLECard;
        private CardViewItem.DCardView mGovernorTunableLITTLECard;

        private PopupCardView.DPopupCard mMcPowerSavingCard;

        private SwitchCardView.DSwitchCard mPowerSavingWqCard;

        private PopupCardView.DPopupCard mCFSSchedulerCard;

        private SwitchCardView.DSwitchCard mCpuQuietEnableCard;
        private PopupCardView.DPopupCard mCpuQuietGovernorCard;

        private SwitchCardView.DSwitchCard mCpuBoostEnableCard;
        private SwitchCardView.DSwitchCard mCpuBoostDebugMaskCard;
        private SeekBarCardView.DSeekBarCard mCpuBoostMsCard;
        private PopupCardView.DPopupCard mCpuBoostSyncThresholdCard;
        private SeekBarCardView.DSeekBarCard mCpuBoostInputMsCard;
        private PopupCardView.DPopupCard[] mCpuBoostInputFreqCard;

        @Override
        public String getClassName() {
            return CPUFragment.class.getSimpleName();
        }

        @Override
        public void init(Bundle savedInstanceState) {
            super.init(savedInstanceState);

            usageInit();
            if (CPU.hasTemp()) tempInit();
            if (CPU.getFreqs() != null) {
                if (CPU.isBigLITTLE()) {
                    DDividerCard bigDivider = new DDividerCard();
                    bigDivider.setText(getString(R.string.big).toLowerCase(Locale.getDefault()));
                    addView(bigDivider);
                }
                coreInit();
                freqInit();
            }
            if (CPU.getAvailableGovernors() != null) governorInit();
            DDividerCard othersDivider = null;
            if (CPU.isBigLITTLE()) {
                DDividerCard LITTLEDivider = new DDividerCard();
                LITTLEDivider.setText(getString(R.string.little).toUpperCase(Locale.getDefault()));
                addView(LITTLEDivider);

                if (CPU.getFreqs(CPU.getLITTLEcore()) != null) {
                    coreLITTLEInit();
                    freqLITTLEInit();
                }
                if (CPU.getAvailableGovernors(CPU.getLITTLEcore()) != null) governorLITTLEInit();

                othersDivider = new DDividerCard();
                othersDivider.setText(getString(R.string.other));
                addView(othersDivider);
            }
{'fraction_non_alphanumeric': 0.07962129442806146, 'fraction_numerical': 0.002948936830668943, 'mean_word_length': 3.1517396907216493, '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': '3525564', 'n_tokens_mistral': 3844, 'n_tokens_neox': 3628, 'n_words': 741}