<commit_before>package com.biermacht.brews.frontend;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.EditText;

import com.biermacht.brews.R;
import com.biermacht.brews.recipe.Recipe;
import com.biermacht.brews.utils.Utils;
import com.biermacht.brews.recipe.*;

import android.widget.*;

public class EditRecipeActivity extends Activity implements OnClickListener {

	// Data entry view declarations
	//private Spinner beerStyleSpinner;
	//private Spinner beerTypeSpinner;
    private ViewGroup mainView;
	//private Spinner mashProfileSpinner;

    // Important things
    private OnClickListener onClickListener;
    private WindowManager windowManager;

    // Rows to be displayed
	private View recipeNameView;
	private View timeView;
	private View efficiencyView;
	private View batchSizeView;
	private View boilSizeView;
    private View measuredOGView;
    private View measuredFGView;

    // Titles
    private TextView recipeNameViewTitle;
    private TextView timeViewTitle;
    private TextView efficiencyViewTitle;
    private TextView batchSizeViewTitle;
    private TextView boilSizeViewTitle;
    private TextView measuredOGViewTitle;
    private TextView measuredFGViewTitle;

    // Contents
    private TextView recipeNameViewText;
    private TextView timeViewText;
    private TextView efficiencyViewText;
    private TextView batchSizeViewText;
    private TextView boilSizeViewText;
    private TextView measuredOGViewText;
    private TextView measuredFGViewText;

    // LayoutInflater
    LayoutInflater inflater;
	
	// Data storage declarations
	private BeerStyle style;
	private MashProfile profile;
	private String type;
	private double efficiency;
	
	// Recipe we are editing
	private Recipe mRecipe;
	
	// Spinner array declarations
	private ArrayList<BeerStyle> beerStyleArray;
	private ArrayList<String> beerTypeArray;
	private ArrayList<MashProfile> mashProfileArray;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_recipe);

        // On click listener
        onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /************************************************************
                 * Options for clicking on each of the editable views
                 ************************************************************/

                AlertDialog alert;
                if (v.equals(recipeNameView))
                    alert = editTextStringAlert(recipeNameViewText, recipeNameViewTitle).create();
                else if (v.equals(timeView))
                    alert = editTextIntegerAlert(timeViewText, timeViewTitle).create();
                else if (v.equals(efficiencyView))
                    alert = editTextFloatAlert(efficiencyViewText, efficiencyViewTitle).create();
                else if (v.equals(batchSizeView))
                    alert = editTextFloatAlert(batchSizeViewText, batchSizeViewTitle).create();
                else if (v.equals(boilSizeView))
                    alert = editTextFloatAlert(boilSizeViewText, boilSizeViewTitle).create();
                else if (v.equals(measuredFGView))
                    alert = editTextFloatAlert(measuredFGViewText, measuredFGViewTitle).create();
                else if (v.equals(measuredOGView))
                    alert = editTextFloatAlert(measuredOGViewText, measuredOGViewTitle).create();
                else
                    return; // In case its none of those views...

                alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                alert.show();
            }
        };

        // Window manager
        windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

        // Get the inflater
        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        
        // Get recipe from calling activity
        long id = getIntent().getLongExtra(Utils.INTENT_RECIPE_ID, 0);
        mRecipe = Utils.getRecipeWithId(id);
        style = mRecipe.getStyle();
        profile = mRecipe.getMashProfile();
        type = mRecipe.getType();
        efficiency = mRecipe.getEfficiency();
        
        // Initialize views and stuff
        mainView = (ViewGroup) findViewById(R.id.main_layout);
        recipeNameView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        timeView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        efficiencyView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        batchSizeView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);;
        boilSizeView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        measuredFGView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        measuredOGView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);

        // Set onClickListeners
        recipeNameView.setOnClickListener(onClickListener);
        timeView.setOnClickListener(onClickListener);
        efficiencyView.setOnClickListener(onClickListener);
        batchSizeView.setOnClickListener(onClickListener);
        boilSizeView.setOnClickListener(onClickListener);
        measuredFGView.setOnClickListener(onClickListener);
        measuredOGView.setOnClickListener(onClickListener);

        // Add views to main view
        mainView.addView(recipeNameView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(timeView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(efficiencyView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(batchSizeView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(boilSizeView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(measuredOGView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(measuredFGView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));


        /************************************************************************
        ************* Get titles, set values   **********************************
        *************************************************************************/
        recipeNameViewTitle = (TextView) recipeNameView.findViewById(R.id.title);
        recipeNameViewTitle.setText("Recipe Name");

        timeViewTitle = (TextView) timeView.findViewById(R.id.title);
        timeViewTitle.setText("Time (mins)");

        efficiencyViewTitle = (TextView) efficiencyView.findViewById(R.id.title);
        efficiencyViewTitle.setText("Predicted Efficiency");

        batchSizeViewTitle = (TextView) batchSizeView.findViewById(R.id.title);
        batchSizeViewTitle.setText("Batch Size (gal)");<commit_msg>Changed to Boil Time<commit_after>package com.biermacht.brews.frontend;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.EditText;

import com.biermacht.brews.R;
import com.biermacht.brews.recipe.Recipe;
import com.biermacht.brews.utils.Utils;
import com.biermacht.brews.recipe.*;

import android.widget.*;

public class EditRecipeActivity extends Activity implements OnClickListener {

	// Data entry view declarations
	//private Spinner beerStyleSpinner;
	//private Spinner beerTypeSpinner;
    private ViewGroup mainView;
	//private Spinner mashProfileSpinner;

    // Important things
    private OnClickListener onClickListener;
    private WindowManager windowManager;

    // Rows to be displayed
	private View recipeNameView;
	private View timeView;
	private View efficiencyView;
	private View batchSizeView;
	private View boilSizeView;
    private View measuredOGView;
    private View measuredFGView;

    // Titles
    private TextView recipeNameViewTitle;
    private TextView timeViewTitle;
    private TextView efficiencyViewTitle;
    private TextView batchSizeViewTitle;
    private TextView boilSizeViewTitle;
    private TextView measuredOGViewTitle;
    private TextView measuredFGViewTitle;

    // Contents
    private TextView recipeNameViewText;
    private TextView timeViewText;
    private TextView efficiencyViewText;
    private TextView batchSizeViewText;
    private TextView boilSizeViewText;
    private TextView measuredOGViewText;
    private TextView measuredFGViewText;

    // LayoutInflater
    LayoutInflater inflater;
	
	// Data storage declarations
	private BeerStyle style;
	private MashProfile profile;
	private String type;
	private double efficiency;
	
	// Recipe we are editing
	private Recipe mRecipe;
	
	// Spinner array declarations
	private ArrayList<BeerStyle> beerStyleArray;
	private ArrayList<String> beerTypeArray;
	private ArrayList<MashProfile> mashProfileArray;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_recipe);

        // On click listener
        onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /************************************************************
                 * Options for clicking on each of the editable views
                 ************************************************************/

                AlertDialog alert;
                if (v.equals(recipeNameView))
                    alert = editTextStringAlert(recipeNameViewText, recipeNameViewTitle).create();
                else if (v.equals(timeView))
                    alert = editTextIntegerAlert(timeViewText, timeViewTitle).create();
                else if (v.equals(efficiencyView))
                    alert = editTextFloatAlert(efficiencyViewText, efficiencyViewTitle).create();
                else if (v.equals(batchSizeView))
                    alert = editTextFloatAlert(batchSizeViewText, batchSizeViewTitle).create();
                else if (v.equals(boilSizeView))
                    alert = editTextFloatAlert(boilSizeViewText, boilSizeViewTitle).create();
                else if (v.equals(measuredFGView))
                    alert = editTextFloatAlert(measuredFGViewText, measuredFGViewTitle).create();
                else if (v.equals(measuredOGView))
                    alert = editTextFloatAlert(measuredOGViewText, measuredOGViewTitle).create();
                else
                    return; // In case its none of those views...

                alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                alert.show();
            }
        };

        // Window manager
        windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

        // Get the inflater
        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        
        // Get recipe from calling activity
        long id = getIntent().getLongExtra(Utils.INTENT_RECIPE_ID, 0);
        mRecipe = Utils.getRecipeWithId(id);
        style = mRecipe.getStyle();
        profile = mRecipe.getMashProfile();
        type = mRecipe.getType();
        efficiency = mRecipe.getEfficiency();
        
        // Initialize views and stuff
        mainView = (ViewGroup) findViewById(R.id.main_layout);
        recipeNameView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        timeView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        efficiencyView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        batchSizeView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);;
        boilSizeView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        measuredFGView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);
        measuredOGView = (View) inflater.inflate(R.layout.row_layout_edit_text, mainView, false);

        // Set onClickListeners
        recipeNameView.setOnClickListener(onClickListener);
        timeView.setOnClickListener(onClickListener);
        efficiencyView.setOnClickListener(onClickListener);
        batchSizeView.setOnClickListener(onClickListener);
        boilSizeView.setOnClickListener(onClickListener);
        measuredFGView.setOnClickListener(onClickListener);
        measuredOGView.setOnClickListener(onClickListener);

        // Add views to main view
        mainView.addView(recipeNameView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(timeView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(efficiencyView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(batchSizeView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(boilSizeView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(measuredOGView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));
        mainView.addView(measuredFGView);
        mainView.addView(inflater.inflate(R.layout.divider, mainView, false));


        /************************************************************************
        ************* Get titles, set values   **********************************
        *************************************************************************/
        recipeNameViewTitle = (TextView) recipeNameView.findViewById(R.id.title);
        recipeNameViewTitle.setText("Recipe Name");

        timeViewTitle = (TextView) timeView.findViewById(R.id.title);
        timeViewTitle.setText("Boil Time (mins)");

        efficiencyViewTitle = (TextView) efficiencyView.findViewById(R.id.title);
        efficiencyViewTitle.setText("Predicted Efficiency");

        batchSizeViewTitle = (TextView) batchSizeView.findViewById(R.id.title);
        batchSizeViewTitle.setText("Batch Size (gal)");
{'fraction_non_alphanumeric': 0.12384351044144859, 'fraction_numerical': 0.00013217023526301876, 'mean_word_length': 3.362352262899971, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6644016', 'n_tokens_mistral': 4111, 'n_tokens_neox': 3868, 'n_words': 793}