• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of 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,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings.homepage.contextualcards;
18 
19 import android.content.DialogInterface;
20 import android.content.Intent;
21 import android.net.Uri;
22 import android.os.Bundle;
23 import android.util.Log;
24 
25 import com.android.internal.app.AlertActivity;
26 import com.android.internal.app.AlertController;
27 import com.android.settings.R;
28 
29 public class ContextualCardFeedbackDialog extends AlertActivity implements
30         DialogInterface.OnClickListener {
31 
32     public static final String EXTRA_CARD_NAME = "card_name";
33     public static final String EXTRA_FEEDBACK_EMAIL = "feedback_email";
34 
35     private static final String TAG = "CardFeedbackDialog";
36     private static final String SUBJECT = "Settings Contextual Card Feedback - ";
37 
38     @Override
onCreate(Bundle savedInstanceState)39     protected void onCreate(Bundle savedInstanceState) {
40         super.onCreate(savedInstanceState);
41 
42         final AlertController.AlertParams alertParams = mAlertParams;
43         alertParams.mMessage = getText(R.string.contextual_card_feedback_confirm_message);
44         alertParams.mPositiveButtonText = getText(R.string.contextual_card_feedback_send);
45         alertParams.mPositiveButtonListener = this;
46         alertParams.mNegativeButtonText = getText(R.string.skip_label);
47 
48         setupAlert();
49     }
50 
51     @Override
onClick(DialogInterface dialog, int which)52     public void onClick(DialogInterface dialog, int which) {
53         final String cardName = getIntent().getStringExtra(EXTRA_CARD_NAME);
54         final String email = getIntent().getStringExtra(EXTRA_FEEDBACK_EMAIL);
55         final Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
56         intent.putExtra(Intent.EXTRA_SUBJECT, SUBJECT + cardName);
57         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
58 
59         try {
60             startActivity(intent);
61         } catch (Exception e) {
62             Log.e(TAG, "Send feedback failed.", e);
63         }
64         finish();
65     }
66 }
67