<commit_before>package info.nightscout.androidaps.interaction.actions;


import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.wearable.view.DotsPageIndicator;
import android.support.wearable.view.GridPagerAdapter;
import android.support.wearable.view.GridViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.DecimalFormat;

import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
import info.nightscout.androidaps.interaction.utils.SafeParse;

import static android.preference.PreferenceManager.getDefaultSharedPreferences;

/**
 * Created by adrian on 09/02/17.
 */


public class TempTargetActivity extends ViewSelectorActivity {

    PlusMinusEditText lowRange;
    PlusMinusEditText highRange;
    PlusMinusEditText time;
    boolean isMGDL;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid_layout);
        final Resources res = getResources();
        final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);

        pager.setAdapter(new MyGridViewPagerAdapter());
        DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
        dotsPageIndicator.setPager(pager);

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        isMGDL = sp.getBoolean("units_mgdl", true);
    }


    @Override
    protected void onPause() {
        super.onPause();
        finish();
    }


    private class MyGridViewPagerAdapter extends GridPagerAdapter {
        @Override
        public int getColumnCount(int arg0) {
            return 4;
        }

        @Override
        public int getRowCount() {
            return 1;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int row, int col) {

             if(col == 0){
                final View view = getInflatedPlusMinusView(container);
                final TextView textView = (TextView) view.findViewById(R.id.label);
                textView.setText("duration");
                if (time == null) {
                    time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false);
                } else {
                    double def = SafeParse.stringToDouble(time.editText.getText().toString());
                    time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false);
                }
                 setLabelToPlusMinusView(view, "duration");
                 container.addView(view);
                return view;

            } else if(col == 1){
                 final View view = getInflatedPlusMinusView(container);
                 if (isMGDL){
                     double def = 100;
                     if (lowRange != null){
                         def = SafeParse.stringToDouble(lowRange.editText.getText().toString());
                     }
                     lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 1d, new DecimalFormat("0"), false);
                 } else {
                     double def = 5.5;
                     if (lowRange != null){
                         def = SafeParse.stringToDouble(lowRange.editText.getText().toString());
                     }
                     lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
                 }
                 setLabelToPlusMinusView(view, "low");
                 container.addView(view);
                 return view;
             } else if(col == 2){<commit_msg>wear 5 minute steps for duration of temp targets<commit_after>package info.nightscout.androidaps.interaction.actions;


import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.wearable.view.DotsPageIndicator;
import android.support.wearable.view.GridPagerAdapter;
import android.support.wearable.view.GridViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.DecimalFormat;

import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
import info.nightscout.androidaps.interaction.utils.SafeParse;

import static android.preference.PreferenceManager.getDefaultSharedPreferences;

/**
 * Created by adrian on 09/02/17.
 */


public class TempTargetActivity extends ViewSelectorActivity {

    PlusMinusEditText lowRange;
    PlusMinusEditText highRange;
    PlusMinusEditText time;
    boolean isMGDL;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid_layout);
        final Resources res = getResources();
        final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);

        pager.setAdapter(new MyGridViewPagerAdapter());
        DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
        dotsPageIndicator.setPager(pager);

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        isMGDL = sp.getBoolean("units_mgdl", true);
    }


    @Override
    protected void onPause() {
        super.onPause();
        finish();
    }


    private class MyGridViewPagerAdapter extends GridPagerAdapter {
        @Override
        public int getColumnCount(int arg0) {
            return 4;
        }

        @Override
        public int getRowCount() {
            return 1;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int row, int col) {

             if(col == 0){
                final View view = getInflatedPlusMinusView(container);
                final TextView textView = (TextView) view.findViewById(R.id.label);
                textView.setText("duration");
                if (time == null) {
                    time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24 * 60d, 5d, new DecimalFormat("0"), false);
                } else {
                    double def = SafeParse.stringToDouble(time.editText.getText().toString());
                    time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 24 * 60d, 5d, new DecimalFormat("0"), false);
                }
                 setLabelToPlusMinusView(view, "duration");
                 container.addView(view);
                return view;

            } else if(col == 1){
                 final View view = getInflatedPlusMinusView(container);
                 if (isMGDL){
                     double def = 100;
                     if (lowRange != null){
                         def = SafeParse.stringToDouble(lowRange.editText.getText().toString());
                     }
                     lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 1d, new DecimalFormat("0"), false);
                 } else {
                     double def = 5.5;
                     if (lowRange != null){
                         def = SafeParse.stringToDouble(lowRange.editText.getText().toString());
                     }
                     lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
                 }
                 setLabelToPlusMinusView(view, "low");
                 container.addView(view);
                 return view;
             } else if(col == 2){
{'fraction_non_alphanumeric': 0.09800406358312418, 'fraction_numerical': 0.01135412931755707, 'mean_word_length': 2.400243803331979, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1923502', 'n_tokens_mistral': 2410, 'n_tokens_neox': 2242, 'n_words': 473}