Home | History | Annotate | Download | only in compose
      1 /*
      2  * Copyright (C) 2012 Google Inc.
      3  * Licensed to The Android Open Source Project.
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 package com.android.mail.compose;
     19 
     20 import android.os.Bundle;
     21 
     22 /**
     23  * An activity that will automatically queue a message, from the contents in
     24  * an ACTION_SEND intent
     25  *
     26  * AutoSendActivity extends ComposeActivity, since the logic that handles the SEND intent
     27  * is in ComposeActivity.
     28  */
     29 public class AutoSendActivity extends ComposeActivity {
     30     // For testing, this extra will cause the message not be be saved or sent
     31     public static final String EXTRA_DONT_SEND_OR_SAVE = "dontSendOrSave";
     32     private boolean mDontSaveOrSend = false;
     33 
     34 
     35     // =============================================================================================
     36     // ComposeActivity methods
     37     // =============================================================================================
     38     /**
     39      * Returns a boolean indicating whether warnings should be shown for empty subject
     40      * and body fields
     41      *
     42      * @return True if a warning should be shown for empty text fields
     43      */
     44     @Override
     45     protected boolean showEmptyTextWarnings() {
     46         return false;
     47     }
     48 
     49     /**
     50      * Returns a boolean indicating whether the user should confirm each send
     51      * Since this is an auto send, the user doesn't confirm the send
     52      *
     53      * @return True if a warning should be on each send
     54      */
     55     @Override
     56     protected boolean showSendConfirmation() {
     57         return false;
     58     }
     59 
     60     @Override
     61     protected void onCreate(Bundle savedInstanceState) {
     62         super.onCreate(savedInstanceState);
     63         mDontSaveOrSend = getIntent().getBooleanExtra(EXTRA_DONT_SEND_OR_SAVE, false);
     64         sendOrSaveWithSanityChecks(false /* send */, true /* show  toast */);
     65     }
     66 
     67     protected boolean sendOrSaveWithSanityChecks(final boolean save,
     68             final boolean showToast) {
     69         if (mDontSaveOrSend) {
     70             return false;
     71         }
     72         return super.sendOrSaveWithSanityChecks(save, showToast, false, true);
     73     }
     74 }
     75