Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c18a471 authored by Kurt Partridge's avatar Kurt Partridge Committed by Android (Google) Code Review
Browse files

Merge "[Rlog29] User interface for recording"

parents 4e049897 faf35c32
Loading
Loading
Loading
Loading
+96 −92
Original line number Diff line number Diff line
@@ -14,26 +14,33 @@
     limitations under the License.
-->

<!-- Adapted from frameworks/base/core/res/res/layout/alert_dialog_holo.xml.  We
   want a dialog, but it must be its own activity so we can launch the soft
   keyboard on it.  A regular dialog will not work since it would be launched from
   the IME. -->
<ScrollView>
    <LinearLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical"
>

    <!-- Mimic a dialog title.  Necessary since the dialog is actually an activity, so the normal
        dialog title construction code is not available. -->
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_marginStart="8dip"
         android:layout_marginEnd="8dip"
         android:orientation="vertical">
        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
         android:orientation="vertical"
    >
        <com.android.internal.widget.DialogTitle
             android:orientation="vertical">
            <View android:layout_width="match_parent"
                android:layout_height="2dip"
                android:visibility="gone"
                android:background="@android:color/holo_blue_light" />
            <TextView
                style="?android:attr/windowTitleStyle"
                android:singleLine="true"
                android:ellipsize="end"
                android:layout_width="match_parent"
            android:layout_height="64dip"
                android:layout_height="wrap_content"
                android:minHeight="64dip"
                android:layout_marginLeft="16dip"
                android:layout_marginRight="16dip"
                android:gravity="center_vertical|left"
@@ -53,68 +60,65 @@
            android:layout_marginRight="8dip"
            android:layout_marginBottom="8dip"
            android:layout_marginTop="8dip"
        android:lines="2"
            android:minLines="2"
            android:scrollbars="vertical"
            android:hint="@string/research_feedback_hint"
        android:inputType="textMultiLine"
        android:imeOptions="flagNoFullscreen"
    >
            android:inputType="textMultiLine">
            <requestFocus />
        </EditText>

        <CheckBox
        android:id="@+id/research_feedback_include_history"
            android:id="@+id/research_feedback_include_account_name"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_marginLeft="16dip"
            android:layout_marginRight="16dip"
            android:layout_marginBottom="8dip"
        android:checked="true"
        android:text="@string/research_feedback_include_history_label"
    />

            android:checked="false"
            android:text="@string/research_feedback_include_account_name_label" />
        <CheckBox
        android:id="@+id/research_feedback_include_account_name"
            android:id="@+id/research_feedback_include_recording_checkbox"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_marginLeft="16dip"
            android:layout_marginRight="16dip"
            android:layout_marginBottom="8dip"
            android:checked="false"
        android:text="@string/research_feedback_include_account_name_label"
    />
            android:text="@string/research_feedback_include_recording_label" />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:divider="?android:attr/dividerHorizontal"
            android:showDividers="beginning"
        android:dividerPadding="0dip"
    >
            android:dividerPadding="0dip">
            <LinearLayout
                style="?android:attr/buttonBarStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
            android:measureWithLargestChild="true"
        >
                android:layoutDirection="locale"
                android:measureWithLargestChild="true">
                <Button
                    android:id="@+id/research_feedback_cancel_button"
                android:layout_width="0dip"
                    android:layout_width="wrap_content"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:maxLines="2"
                    style="?android:attr/buttonBarButtonStyle"
                    android:textSize="14sp"
                    android:text="@string/research_feedback_cancel"
                android:layout_height="wrap_content"
            />
                    android:layout_height="wrap_content" />
                <Button
                    android:id="@+id/research_feedback_send_button"
                android:layout_width="0dip"
                    android:layout_width="wrap_content"
                    android:layout_gravity="right"
                    android:layout_weight="1"
                    android:maxLines="2"
                    style="?android:attr/buttonBarButtonStyle"
                    android:textSize="14sp"
                    android:text="@string/research_feedback_send"
                android:layout_height="wrap_content"
            />
                    android:layout_height="wrap_content" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>
+10 −0
Original line number Diff line number Diff line
@@ -278,6 +278,9 @@
    <!-- Text for checkbox option to include user account name in feedback for research purposes [CHAR LIMIT=50] -->
    <!-- TODO: remove translatable=false attribute once text is stable -->
    <string name="research_feedback_include_account_name_label" translatable="false">Include account name</string>
    <!-- Text for checkbox option to include a recording in feedback for research purposes [CHAR LIMIT=50] -->
    <!-- TODO: remove translatable=false attribute once text is stable -->
    <string name="research_feedback_include_recording_label" translatable="false">Include recorded demonstration</string>
    <!-- Hint to user about the text entry field where they should enter research feedback [CHAR LIMIT=40] -->
    <!-- TODO: remove translatable=false attribute once text is stable -->
    <string name="research_feedback_hint" translatable="false">Enter your feedback here.</string>
@@ -287,6 +290,13 @@
    <!-- Dialog button choice to cancel sending research feedback [CHAR LIMIT=35] -->
    <!-- TODO: remove translatable=false attribute once text is stable -->
    <string name="research_feedback_cancel" translatable="false">Cancel</string>
    <!-- Temporary notification to provide user with instructions about stopping a recording
      - operation[CHAR LIMIT=100] -->
    <!-- TODO: remove translatable=false attribute once text is stable -->
    <string name="research_feedback_demonstration_instructions" translatable="false">Please demonstrate the issue you are writing about.\n\nWhen finished, select the \"Bug?\" button again."</string>
    <!-- Temporary notification of recording failure [CHAR LIMIT=100] -->
    <!-- TODO: remove translatable=false attribute once text is stable -->
    <string name="research_feedback_recording_failure" translatable="false">Recording cancelled due to timeout</string>
    <!-- Toast notification to ask user to quit the research feedback dialog to perform this operation [CHAR LIMIT=100] -->
    <!-- TODO: remove translatable=false attribute once text is stable -->
    <string name="research_please_exit_feedback_form" translatable="false">Please exit the feedback dialog to access the research log menu</string>
+0 −15
Original line number Diff line number Diff line
@@ -28,24 +28,9 @@ public class FeedbackActivity extends Activity {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.research_feedback_activity);
        final FeedbackLayout layout = (FeedbackLayout) findViewById(R.id.research_feedback_layout);
        final CheckBox checkbox = (CheckBox) findViewById(R.id.research_feedback_include_history);
        final CharSequence cs = checkbox.getText();
        final String actualString = String.format(cs.toString(),
                ResearchLogger.FEEDBACK_WORD_BUFFER_SIZE);
        checkbox.setText(actualString);
        layout.setActivity(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

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

    @Override
    public void onBackPressed() {
        ResearchLogger.getInstance().onLeavingSendFeedbackDialog();
+96 −30
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -30,10 +31,18 @@ import android.widget.EditText;

import com.android.inputmethod.latin.R;

public class FeedbackFragment extends Fragment {
public class FeedbackFragment extends Fragment implements OnClickListener {
    private static final String TAG = FeedbackFragment.class.getSimpleName();

    private static final String KEY_FEEDBACK_STRING = "FeedbackString";
    private static final String KEY_INCLUDE_ACCOUNT_NAME = "IncludeAccountName";
    public static final String KEY_HAS_USER_RECORDING = "HasRecording";

    private EditText mEditText;
    private CheckBox mIncludingHistoryCheckBox;
    private CheckBox mIncludingAccountNameCheckBox;
    private CheckBox mIncludingUserRecordingCheckBox;
    private Button mSendButton;
    private Button mCancelButton;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -41,39 +50,96 @@ public class FeedbackFragment extends Fragment {
        final View view = inflater.inflate(R.layout.research_feedback_fragment_layout, container,
                false);
        mEditText = (EditText) view.findViewById(R.id.research_feedback_contents);
        mIncludingHistoryCheckBox = (CheckBox) view.findViewById(
                R.id.research_feedback_include_history);
        mEditText.requestFocus();
        mIncludingAccountNameCheckBox = (CheckBox) view.findViewById(
                R.id.research_feedback_include_account_name);
        mIncludingUserRecordingCheckBox = (CheckBox) view.findViewById(
                R.id.research_feedback_include_recording_checkbox);
        mIncludingUserRecordingCheckBox.setOnClickListener(this);

        mSendButton = (Button) view.findViewById(R.id.research_feedback_send_button);
        mSendButton.setOnClickListener(this);
        mCancelButton = (Button) view.findViewById(R.id.research_feedback_cancel_button);
        mCancelButton.setOnClickListener(this);

        if (savedInstanceState != null) {
            Log.d(TAG, "restoring from savedInstanceState");
            restoreState(savedInstanceState);
        } else {
            final Bundle bundle = getActivity().getIntent().getExtras();
            if (bundle != null) {
                Log.d(TAG, "restoring from getArguments()");
                restoreState(bundle);
            }
        }
        return view;
    }

        final Button sendButton = (Button) view.findViewById(
                R.id.research_feedback_send_button);
        sendButton.setOnClickListener(new OnClickListener() {
    @Override
            public void onClick(View v) {
    public void onClick(final View view) {
        final ResearchLogger researchLogger = ResearchLogger.getInstance();
        if (view == mIncludingUserRecordingCheckBox) {
            if (hasUserRecording()) {
                // Remove the recording
                setHasUserRecording(false);
            } else {
                final Bundle bundle = new Bundle();
                onSaveInstanceState(bundle);

                // Let the user make a recording
                getActivity().finish();

                researchLogger.setFeedbackDialogBundle(bundle);
                researchLogger.onLeavingSendFeedbackDialog();
                researchLogger.startRecording();
            }
        } else if (view == mSendButton) {
            final Editable editable = mEditText.getText();
            final String feedbackContents = editable.toString();
                final boolean isIncludingHistory = mIncludingHistoryCheckBox.isChecked();
                final boolean isIncludingAccountName = mIncludingAccountNameCheckBox.isChecked();
                ResearchLogger.getInstance().sendFeedback(feedbackContents, isIncludingHistory,
                        isIncludingAccountName);
                final Activity activity = FeedbackFragment.this.getActivity();
                activity.finish();
                ResearchLogger.getInstance().onLeavingSendFeedbackDialog();
            final boolean isIncludingAccountName = isIncludingAccountName();
            researchLogger.sendFeedback(feedbackContents,
                    false /* isIncludingHistory */, isIncludingAccountName, hasUserRecording());
            getActivity().finish();
            researchLogger.setFeedbackDialogBundle(null);
            researchLogger.onLeavingSendFeedbackDialog();
        } else if (view == mCancelButton) {
            Log.d(TAG, "Finishing");
            getActivity().finish();
            researchLogger.setFeedbackDialogBundle(null);
            researchLogger.onLeavingSendFeedbackDialog();
        } else {
            Log.e(TAG, "Unknown view passed to FeedbackFragment.onClick()");
        }
    }
        });

        final Button cancelButton = (Button) view.findViewById(
                R.id.research_feedback_cancel_button);
        cancelButton.setOnClickListener(new OnClickListener() {
    @Override
            public void onClick(View v) {
                final Activity activity = FeedbackFragment.this.getActivity();
                activity.finish();
                ResearchLogger.getInstance().onLeavingSendFeedbackDialog();
    public void onSaveInstanceState(final Bundle bundle) {
        final String savedFeedbackString = mEditText.getText().toString();

        bundle.putString(KEY_FEEDBACK_STRING, savedFeedbackString);
        bundle.putBoolean(KEY_INCLUDE_ACCOUNT_NAME, isIncludingAccountName());
        bundle.putBoolean(KEY_HAS_USER_RECORDING, hasUserRecording());
    }
        });

        return view;
    public void restoreState(final Bundle bundle) {
        mEditText.setText(bundle.getString(KEY_FEEDBACK_STRING));
        setIsIncludingAccountName(bundle.getBoolean(KEY_INCLUDE_ACCOUNT_NAME));
        setHasUserRecording(bundle.getBoolean(KEY_HAS_USER_RECORDING));
    }

    private boolean hasUserRecording() {
        return mIncludingUserRecordingCheckBox.isChecked();
    }

    private void setHasUserRecording(final boolean hasRecording) {
        mIncludingUserRecordingCheckBox.setChecked(hasRecording);
    }

    private boolean isIncludingAccountName() {
        return mIncludingAccountNameCheckBox.isChecked();
    }

    private void setIsIncludingAccountName(final boolean isIncludingAccountName) {
        mIncludingAccountNameCheckBox.setChecked(isIncludingAccountName);
    }
}
+161 −41

File changed.

Preview size limit exceeded, changes collapsed.

Loading