1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.android.inputmethod.research; 18 19 import android.app.Activity; 20 import android.app.Fragment; 21 import android.os.Bundle; 22 import android.text.Editable; 23 import android.view.LayoutInflater; 24 import android.view.View; 25 import android.view.View.OnClickListener; 26 import android.view.ViewGroup; 27 import android.widget.Button; 28 import android.widget.CheckBox; 29 import android.widget.EditText; 30 31 import com.android.inputmethod.latin.R; 32 33 public class FeedbackFragment extends Fragment { 34 private EditText mEditText; 35 private CheckBox mCheckBox; 36 37 @Override onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)38 public View onCreateView(LayoutInflater inflater, ViewGroup container, 39 Bundle savedInstanceState) { 40 final View view = inflater.inflate(R.layout.research_feedback_fragment_layout, container, 41 false); 42 mEditText = (EditText) view.findViewById(R.id.research_feedback_contents); 43 mCheckBox = (CheckBox) view.findViewById(R.id.research_feedback_include_history); 44 45 final Button sendButton = (Button) view.findViewById( 46 R.id.research_feedback_send_button); 47 sendButton.setOnClickListener(new OnClickListener() { 48 @Override 49 public void onClick(View v) { 50 final Editable editable = mEditText.getText(); 51 final String feedbackContents = editable.toString(); 52 final boolean includeHistory = mCheckBox.isChecked(); 53 ResearchLogger.getInstance().sendFeedback(feedbackContents, includeHistory); 54 final Activity activity = FeedbackFragment.this.getActivity(); 55 activity.finish(); 56 ResearchLogger.getInstance().onLeavingSendFeedbackDialog(); 57 } 58 }); 59 60 final Button cancelButton = (Button) view.findViewById( 61 R.id.research_feedback_cancel_button); 62 cancelButton.setOnClickListener(new OnClickListener() { 63 @Override 64 public void onClick(View v) { 65 final Activity activity = FeedbackFragment.this.getActivity(); 66 activity.finish(); 67 ResearchLogger.getInstance().onLeavingSendFeedbackDialog(); 68 } 69 }); 70 71 return view; 72 } 73 } 74