<commit_before>package com.android.vending.billing.test;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class TestPaymentScreenActivity extends Activity {
	public static final String DEVELOPER_PAYLOAD_INTENT_KEY = "DEVELOPER_PAYLOAD";
	public static final String ITEM_ID_INTENT_KEY = "ITEM_ID";
	public static final String PACKAGE_NAME_INTENT_KEY = "PACKAGE_NAME";
	public static final String REQUEST_ID_INTENT_KEY = "REQUEST_ID";
	
	private ResponseIntentFactory responseIntentFactory = new ResponseIntentFactory();
	
	private Button createTestButton(String text, OnClickListener listener) {
        Button testButton = new Button(this);
        testButton.setText(text);
        testButton.setOnClickListener(listener);
        return testButton;
	}
	
	private void addTestButton(LinearLayout layout, String text, OnClickListener listener) {
		layout.addView(createTestButton(text, listener));
	}
	
	private String getDeveloperPayload() {
		return getIntent().getExtras().getString(DEVELOPER_PAYLOAD_INTENT_KEY);
	}
	private String getItemId() {
		return getIntent().getExtras().getString(ITEM_ID_INTENT_KEY);
	}
	private String getCallerPackageName() {
		return getIntent().getExtras().getString(PACKAGE_NAME_INTENT_KEY);
	}
	private long getRequestId() {
		return getIntent().getExtras().getLong(REQUEST_ID_INTENT_KEY);
	}
	
	private PurchaseStateOrder createOrder() {
		PurchaseStateOrder order = new PurchaseStateOrder();
		order.setDeveloperPayload(getDeveloperPayload());
		order.setPackageName(getCallerPackageName());
		order.setProductId(getItemId());
		return order;
	}
	
	private void notifyAboutOrder(PurchaseStateOrder order) {
		// request has reached the server
		this.sendBroadcast(responseIntentFactory.createResponseCodeIntent(getRequestId(), ResponseCode.RESULT_OK));
		
		// order notification
		String notificationId = OrderNotificationRepository.getInstance().add(order);
		this.sendBroadcast(responseIntentFactory.createAppNotificationIntent(notificationId));	
	}
	
	private AlertDialog createOrderSelectionDialog(android.content.DialogInterface.OnClickListener listener) {
		PurchaseStateOrder[] orders = PurchaseStateOrderRepository.getInstance().getAllOrders();
		
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle("select an order");
		
		String[] orderIds = new String[orders.length];
		for (int i = 0; i < orders.length; i++) {
			orderIds[i] = orders[i].getOrderId() + " - " + orders[i].getProductId();
		}
		builder.setSingleChoiceItems(orderIds, -1, listener);		
		return builder.create();
	}	
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout layout = new LinearLayout(this);
        
        addTestButton(layout, "buy item", new OnClickListener() {
			public void onClick(View v) {
				PurchaseStateOrder order = createOrder();
				order.setPurchaseState(PurchaseStateOrder.STATE_PURCHASED);
				PurchaseStateOrderRepository.getInstance().add(order);
				notifyAboutOrder(order);
			}
		});        
        addTestButton(layout, "cancel the order", new OnClickListener() {
			public void onClick(View v) {
				PurchaseStateOrder order = createOrder();
				order.setPurchaseState(PurchaseStateOrder.STATE_CANCELED);
				PurchaseStateOrderRepository.getInstance().add(order);
				notifyAboutOrder(order);
			}
		});        
        addTestButton(layout, "refund the order", new OnClickListener() {
			public void onClick(View v) {
				AlertDialog dialog = createOrderSelectionDialog(new android.content.DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {						
						PurchaseStateOrder[] orders = PurchaseStateOrderRepository.getInstance().getAllOrders();
						PurchaseStateOrder order = orders[which];
						if (order != null) {
							order.setPurchaseState(PurchaseStateOrder.STATE_REFUNDED);				
							notifyAboutOrder(order);
						}
					}
				});
				dialog.show();
			}
		});        
        addTestButton(layout, "service unavailable", new OnClickListener() {
			public void onClick(View v) {
				v.getContext().sendBroadcast(responseIntentFactory.createResponseCodeIntent(getRequestId(), ResponseCode.RESULT_SERVICE_UNAVAILABLE));
			}
		});        
        addTestButton(layout, "abandon checkout", new OnClickListener() {
			public void onClick(View v) {
				v.getContext().sendBroadcast(responseIntentFactory.createResponseCodeIntent(getRequestId(), ResponseCode.RESULT_USER_CANCELED));
			}
		});        
        
        this.setContentView(layout);
    }
    
    @Override
    protected void onStart() {
    	super.onStart();
    }
    
   
}<commit_msg>build fix<commit_after>package com.android.vending.billing.test;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class TestPaymentScreenActivity extends Activity {
	public static final String DEVELOPER_PAYLOAD_INTENT_KEY = "DEVELOPER_PAYLOAD";
	public static final String ITEM_ID_INTENT_KEY = "ITEM_ID";
	public static final String PACKAGE_NAME_INTENT_KEY = "PACKAGE_NAME";
	public static final String REQUEST_ID_INTENT_KEY = "REQUEST_ID";
	
	private ResponseIntentFactory responseIntentFactory = new ResponseIntentFactory();
	
	private Button createTestButton(String text, OnClickListener listener) {
        Button testButton = new Button(this);
        testButton.setText(text);
        testButton.setOnClickListener(listener);
        return testButton;
	}
	
	private void addTestButton(LinearLayout layout, String text, OnClickListener listener) {
		layout.addView(createTestButton(text, listener));
	}
	
	private String getDeveloperPayload() {
		return getIntent().getExtras().getString(DEVELOPER_PAYLOAD_INTENT_KEY);
	}
	private String getItemId() {
		return getIntent().getExtras().getString(ITEM_ID_INTENT_KEY);
	}
	private String getCallerPackageName() {
		return getIntent().getExtras().getString(PACKAGE_NAME_INTENT_KEY);
	}
	private long getRequestId() {
		return getIntent().getExtras().getLong(REQUEST_ID_INTENT_KEY);
	}
	
	private PurchaseStateOrder createOrder() {
		PurchaseStateOrder order = new PurchaseStateOrder();
		order.setDeveloperPayload(getDeveloperPayload());
		order.setPackageName(getCallerPackageName());
		order.setProductId(getItemId());
		return order;
	}
	
	private void notifyAboutOrder(PurchaseStateOrder order) {
		// request has reached the server
		this.sendBroadcast(responseIntentFactory.createResponseCodeIntent(getRequestId(), ResponseCode.RESULT_OK));
		
		// order notification
		String notificationId = OrderNotificationRepository.getInstance().add(order);
		this.sendBroadcast(responseIntentFactory.createAppNotificationIntent(notificationId));	
	}
	
	private AlertDialog createOrderSelectionDialog(android.content.DialogInterface.OnClickListener listener) {
		PurchaseStateOrder[] orders = PurchaseStateOrderRepository.getInstance().getAllOrders();
		
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle("select an order");
		
		String[] orderIds = new String[orders.length];
		for (int i = 0; i < orders.length; i++) {
			orderIds[i] = orders[i].getOrderId() + " - " + orders[i].getProductId();
		}
		builder.setSingleChoiceItems(orderIds, -1, listener);		
		return builder.create();
	}	
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        LayoutParams layoutParams = new LinearLayout.LayoutParams(
        	LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
        
        addTestButton(layout, "buy item", new OnClickListener() {
			public void onClick(View v) {
				PurchaseStateOrder order = createOrder();
				order.setPurchaseState(PurchaseStateOrder.STATE_PURCHASED);
				PurchaseStateOrderRepository.getInstance().add(order);
				notifyAboutOrder(order);
			}
		});        
        addTestButton(layout, "cancel the order", new OnClickListener() {
			public void onClick(View v) {
				PurchaseStateOrder order = createOrder();
				order.setPurchaseState(PurchaseStateOrder.STATE_CANCELED);
				PurchaseStateOrderRepository.getInstance().add(order);
				notifyAboutOrder(order);
			}
		});        
        addTestButton(layout, "refund the order", new OnClickListener() {
			public void onClick(View v) {
				AlertDialog dialog = createOrderSelectionDialog(new android.content.DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {						
						PurchaseStateOrder[] orders = PurchaseStateOrderRepository.getInstance().getAllOrders();
						PurchaseStateOrder order = orders[which];
						if (order != null) {
							order.setPurchaseState(PurchaseStateOrder.STATE_REFUNDED);				
							notifyAboutOrder(order);
						}
					}
				});
				dialog.show();
			}
		});        
        addTestButton(layout, "service unavailable", new OnClickListener() {
			public void onClick(View v) {
				v.getContext().sendBroadcast(responseIntentFactory.createResponseCodeIntent(getRequestId(), ResponseCode.RESULT_SERVICE_UNAVAILABLE));
			}
		});        
        addTestButton(layout, "abandon checkout", new OnClickListener() {
			public void onClick(View v) {
				v.getContext().sendBroadcast(responseIntentFactory.createResponseCodeIntent(getRequestId(), ResponseCode.RESULT_USER_CANCELED));
			}
		});        
        
        this.setContentView(layout, layoutParams);
    }
    
    @Override
    protected void onStart() {
    	super.onStart();
    }
    
   
}
{'fraction_non_alphanumeric': 0.09953359134663094, 'fraction_numerical': 0.0003969435347821772, 'mean_word_length': 4.574115044247788, 'pattern_counts': {'":': 0, '<': 5, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5936760', 'n_tokens_mistral': 3126, 'n_tokens_neox': 2736, 'n_words': 530}