<commit_before>package com.martinet.emplitude.Reveil;
/**
 * Created by Arnaud on 04/01/2016.
 */

import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.hardware.camera2.CameraManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.NumberPicker;
import android.widget.Switch;
import android.widget.TextView;

import com.martinet.emplitude.Constants;
import com.martinet.emplitude.R;

import java.text.SimpleDateFormat;
import java.util.Calendar;


public class ReveilActivity extends Fragment implements NumberPicker.OnValueChangeListener {
    //---------------------------------------------------------------
    //------------------Declaration Variables------------------------
    //---------------------------------------------------------------
    public static final String MesPREFERENCES = "mesPreferences";
    public static final String keyDSonner = "keyDSonner";
    public static final String keyDFondu = "keyDFondu";
    public static final String keyDTorche = "keyDTorche";
    public static final String keyNpDureePrepa = "keyNpDureePrepa";
    public static final String keyDActivDesactiv = "keyDActivDesactiv";
    public static final String keyNbRepetition = "keyNbRepetition";
    public static final String keyNbRepetitionRestante = "keyNbRepetitionRestante";
    public static final String keyMinRepetition = "keyMinRepetition";
    public static final String keyMinTempo = "keyMinTempo";
    public static final String keySonChoisis = "keySonChoisis";
    public static int minRepetition = 0;
    public static SharedPreferences sharedpreferences;
    private SharedPreferences.Editor editor;
    public static AlarmManager alarmManager;
    public static Button btnRepeter;
    public static Button btnTempo;
    public static boolean dSonner = false;
    public static boolean dFondu = false;
    public static boolean dTorche = false;
    public static boolean dActivDesaciv = true;
    public static int nbRepetionRestante = 0;
    private static int timeHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    private static int timeMinute = Calendar.getInstance().get(Calendar.MINUTE);
    private static PendingIntent pendingIntent;
    private static Context mContext;
    private FragmentActivity myContext;
    private TextView textView1;
    private TextView tvrTempsPreparation;
    private TextView tvrMinutes;
    private TextView tvrRepeter;
    private TextView tvrSon;
    private TextView tvrTempo;
    private Switch switchVibreur;
    private Switch switchTorche;
    private Switch switchFondu;
    private Switch switchActivDesactiv;
    private NumberPicker npDureePrepa;
    private NumberPicker nprMinTempo;
    private NumberPicker nprFoisRepeter;
    private NumberPicker nprMinRepeter;
    private Button btn1;
    public static  Button btnSon;
    private View view;
    private int tmpa;
    private ProgrammerAlarm proAlarm;
    private ImageButton help;
    private CameraManager cameraManager;





    //---------------------------------------------------------------------
    //------------------Methode principale OnCreate------------------------
    //---------------------------------------------------------------------
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.view = inflater.inflate(R.layout.reveil_activity, container, false);
        this.getActivity().setTitle("Réveil");
        mContext = container.getContext();
        // pour affecter this a la variable utilisé par la suite.
        initialiser();
        appelListeners();
        appelSwitch();
        initNPTempsPrepa();
        proAlarm.setAlarmAuto();
        if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {//Choix en fonction de la version d'android
            switchFondu.setEnabled(false);
            switchFondu.setFocusable(false);
            switchTorche.setEnabled(false);
            switchTorche.setFocusable(false);
            switchActivDesactiv.setChecked(false);
            switchActivDesactiv.setEnabled(false);
            switchActivDesactiv.setFocusable(false);

        }
        btnSon.setTextColor(getResources().getColor(R.color.grisDesactiv));
        tvrSon.setTextColor(getResources().getColor(R.color.grisDesactiv));
        btnSon.setEnabled(false);
        btnSon.setFocusable(false);
        btn1.setVisibility(View.GONE);
        textView1.setVisibility(View.GONE);
        return this.view;




    }




    //------------------Methode pour appeler les listeners------------------------
    private void appelListeners() {
        //Listener pour le bouton Repeter
        OnClickListener listenerRepeter = new OnClickListener() {

            @Override
            public void onClick(View v) {
                afficherDialogRepeter();
                Log.i("btnRepeter", "Appui bouton repeter");

            }
        };
        //Listener pour le bouton Temporisation
        OnClickListener listenerTemporisation = new OnClickListener() {

            @Override
            public void onClick(View v) {
                afficherDialogTempo();
                Log.i("btnTempo", "Appui bouton tempo");
            }
        };
        //Listener pour le bouton Son
        OnClickListener listenerSon = new OnClickListener() {

            @Override
            public void onClick(View v) {
                Log.i("btnSOn", "Appui bouton son");
                Intent myIntent = new Intent(getActivity(), AudioPlayerDemoActivity.class);
                startActivity(myIntent);



            }
        };
        //Listener1 -> bonton lancer l'alarme
        OnClickListener listener1 = new OnClickListener() {
            public void onClick(View view) {
                // textView2.setText("");
                Bundle bundle = new Bundle();
                bundle.putInt(MyConstants.HOUR, timeHour);
                bundle.putInt(MyConstants.MINUTE, timeMinute);
                MyDialogFragment fragment = new MyDialogFragment();
                fragment.setHandler(new MyHandler());
                fragment.setArguments(bundle);
                FragmentManager manager = myContext.getSupportFragmentManager();
                FragmentTransaction transaction = manager.beginTransaction();
                transaction.add(fragment, MyConstants.TIME_PICKER);
                transaction.commit();

            }
        };

        OnClickListener listenerhelp = new OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
                dialog.setTitle("Aide");
                TextView editText = new TextView(mContext);
                editText.setText("Selectionner la durée dont vous avez besoin entre votre réveil et votre arrivé en emploi_cour.\n Le temps de préparation sélectionner determinera l'heure de  sonnerie reveil");
                LinearLayout linearLayout= new LinearLayout(mContext);
                linearLayout.setPadding(20, 10, 20, 10);
                linearLayout.setOrientation(LinearLayout.VERTICAL);
                linearLayout.addView(editText);
                dialog.setView(linearLayout);
                dialog.show();<commit_msg>Update ReveilActivity.java<commit_after>package com.martinet.emplitude.Reveil;
/**
 * Created by Arnaud on 04/01/2016.
 */

import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.hardware.camera2.CameraManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.NumberPicker;
import android.widget.Switch;
import android.widget.TextView;

import com.martinet.emplitude.Constants;
import com.martinet.emplitude.R;

import java.text.SimpleDateFormat;
import java.util.Calendar;


public class ReveilActivity extends Fragment implements NumberPicker.OnValueChangeListener {
    //---------------------------------------------------------------
    //------------------Declaration Variables------------------------
    //---------------------------------------------------------------
    public static final String MesPREFERENCES = "mesPreferences";
    public static final String keyDSonner = "keyDSonner";
    public static final String keyDFondu = "keyDFondu";
    public static final String keyDTorche = "keyDTorche";
    public static final String keyNpDureePrepa = "keyNpDureePrepa";
    public static final String keyDActivDesactiv = "keyDActivDesactiv";
    public static final String keyNbRepetition = "keyNbRepetition";
    public static final String keyNbRepetitionRestante = "keyNbRepetitionRestante";
    public static final String keyMinRepetition = "keyMinRepetition";
    public static final String keyMinTempo = "keyMinTempo";
    public static final String keySonChoisis = "keySonChoisis";
    public static int minRepetition = 0;
    public static SharedPreferences sharedpreferences;
    private SharedPreferences.Editor editor;
    public static AlarmManager alarmManager;
    public static Button btnRepeter;
    public static Button btnTempo;
    public static boolean dSonner = false;
    public static boolean dFondu = false;
    public static boolean dTorche = false;
    public static boolean dActivDesaciv = true;
    public static int nbRepetionRestante = 0;
    private static int timeHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    private static int timeMinute = Calendar.getInstance().get(Calendar.MINUTE);
    private static PendingIntent pendingIntent;
    private static Context mContext;
    private FragmentActivity myContext;
    private TextView textView1;
    private TextView tvrTempsPreparation;
    private TextView tvrMinutes;
    private TextView tvrRepeter;
    private TextView tvrSon;
    private TextView tvrTempo;
    private Switch switchVibreur;
    private Switch switchTorche;
    private Switch switchFondu;
    private Switch switchActivDesactiv;
    private NumberPicker npDureePrepa;
    private NumberPicker nprMinTempo;
    private NumberPicker nprFoisRepeter;
    private NumberPicker nprMinRepeter;
    private Button btn1;
    public static  Button btnSon;
    private View view;
    private int tmpa;
    private ProgrammerAlarm proAlarm;
    private ImageButton help;
    private CameraManager cameraManager;





    //---------------------------------------------------------------------
    //------------------Methode principale OnCreate------------------------
    //---------------------------------------------------------------------
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.view = inflater.inflate(R.layout.reveil_activity, container, false);
        this.getActivity().setTitle("Réveil");
        mContext = container.getContext();
        // pour affecter this a la variable utilisé par la suite.
        initialiser();
        appelListeners();
        appelSwitch();
        initNPTempsPrepa();
        proAlarm.setAlarmAuto();
        if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {//Choix en fonction de la version d'android
            switchFondu.setEnabled(false);
            switchFondu.setFocusable(false);
            switchTorche.setEnabled(false);
            switchTorche.setFocusable(false);
            switchActivDesactiv.setChecked(false);
            switchActivDesactiv.setEnabled(false);
            switchActivDesactiv.setFocusable(false);

        }
        btnSon.setTextColor(getResources().getColor(R.color.grisDesactiv));
        tvrSon.setTextColor(getResources().getColor(R.color.grisDesactiv));
        btnSon.setEnabled(false);
        btnSon.setFocusable(false);
        btn1.setVisibility(View.GONE);
        textView1.setVisibility(View.GONE);
        return this.view;




    }




    //------------------Methode pour appeler les listeners------------------------
    private void appelListeners() {
        //Listener pour le bouton Repeter
        OnClickListener listenerRepeter = new OnClickListener() {

            @Override
            public void onClick(View v) {
                afficherDialogRepeter();
                Log.i("btnRepeter", "Appui bouton repeter");

            }
        };
        //Listener pour le bouton Temporisation
        OnClickListener listenerTemporisation = new OnClickListener() {

            @Override
            public void onClick(View v) {
                afficherDialogTempo();
                Log.i("btnTempo", "Appui bouton tempo");
            }
        };
        //Listener pour le bouton Son
        OnClickListener listenerSon = new OnClickListener() {

            @Override
            public void onClick(View v) {
                Log.i("btnSOn", "Appui bouton son");
                Intent myIntent = new Intent(getActivity(), AudioPlayerDemoActivity.class);
                startActivity(myIntent);



            }
        };
        //Listener1 -> bonton lancer l'alarme
        OnClickListener listener1 = new OnClickListener() {
            public void onClick(View view) {
                // textView2.setText("");
                Bundle bundle = new Bundle();
                bundle.putInt(MyConstants.HOUR, timeHour);
                bundle.putInt(MyConstants.MINUTE, timeMinute);
                MyDialogFragment fragment = new MyDialogFragment();
                fragment.setHandler(new MyHandler());
                fragment.setArguments(bundle);
                FragmentManager manager = myContext.getSupportFragmentManager();
                FragmentTransaction transaction = manager.beginTransaction();
                transaction.add(fragment, MyConstants.TIME_PICKER);
                transaction.commit();

            }
        };

        OnClickListener listenerhelp = new OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
                dialog.setTitle("Aide");
                TextView editText = new TextView(mContext);
                editText.setText("Sélectionner la durée dont vous avez besoin entre votre réveil et votre arrivé en cour.\n Le temps de préparation sélectionné déterminera l'heure de sonnerie du réveil\n");
                LinearLayout linearLayout= new LinearLayout(mContext);
                linearLayout.setPadding(20, 10, 20, 10);
                linearLayout.setOrientation(LinearLayout.VERTICAL);
                linearLayout.addView(editText);
                dialog.setView(linearLayout);
                dialog.show();
{'fraction_non_alphanumeric': 0.12318975697681646, 'fraction_numerical': 0.003729256013425322, 'mean_word_length': 2.4219481071884306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6100813', 'n_tokens_mistral': 4204, 'n_tokens_neox': 3961, 'n_words': 1001}