Home | History | Annotate | Download | only in mms
      1 /*
      2  * Copyright (C) 2008 Esmertec AG.
      3  * Copyright (C) 2008 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.mms;
     19 
     20 import com.android.mms.data.Contact;
     21 import com.android.mms.data.Conversation;
     22 import com.android.mms.layout.LayoutManager;
     23 import com.android.mms.util.DownloadManager;
     24 import com.android.mms.util.DraftCache;
     25 import com.android.mms.drm.DrmUtils;
     26 import com.android.mms.util.SmileyParser;
     27 import com.android.mms.util.RateController;
     28 import com.android.mms.MmsConfig;
     29 import com.android.mms.transaction.MessagingNotification;
     30 
     31 import android.app.Application;
     32 import android.content.Context;
     33 import android.content.res.Configuration;
     34 import android.preference.PreferenceManager;
     35 import android.provider.SearchRecentSuggestions;
     36 import android.telephony.TelephonyManager;
     37 
     38 public class MmsApp extends Application {
     39     public static final String LOG_TAG = "Mms";
     40 
     41     private SearchRecentSuggestions mRecentSuggestions;
     42     private TelephonyManager mTelephonyManager;
     43     private static MmsApp sMmsApp = null;
     44 
     45     @Override
     46     public void onCreate() {
     47         super.onCreate();
     48 
     49         sMmsApp = this;
     50 
     51         // Load the default preference values
     52         PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
     53 
     54         MmsConfig.init(this);
     55         Contact.init(this);
     56         DraftCache.init(this);
     57         Conversation.init(this);
     58         DownloadManager.init(this);
     59         RateController.init(this);
     60         DrmUtils.cleanupStorage(this);
     61         LayoutManager.init(this);
     62         SmileyParser.init(this);
     63         MessagingNotification.init(this);
     64     }
     65 
     66     synchronized public static MmsApp getApplication() {
     67         return sMmsApp;
     68     }
     69 
     70     @Override
     71     public void onTerminate() {
     72         DrmUtils.cleanupStorage(this);
     73     }
     74 
     75     @Override
     76     public void onConfigurationChanged(Configuration newConfig) {
     77         LayoutManager.getInstance().onConfigurationChanged(newConfig);
     78     }
     79 
     80     /**
     81      * @return Returns the TelephonyManager.
     82      */
     83     public TelephonyManager getTelephonyManager() {
     84         if (mTelephonyManager == null) {
     85             mTelephonyManager = (TelephonyManager)getApplicationContext()
     86                     .getSystemService(Context.TELEPHONY_SERVICE);
     87         }
     88         return mTelephonyManager;
     89     }
     90 
     91     /**
     92      * Returns the content provider wrapper that allows access to recent searches.
     93      * @return Returns the content provider wrapper that allows access to recent searches.
     94      */
     95     public SearchRecentSuggestions getRecentSuggestions() {
     96         /*
     97         if (mRecentSuggestions == null) {
     98             mRecentSuggestions = new SearchRecentSuggestions(this,
     99                     SuggestionsProvider.AUTHORITY, SuggestionsProvider.MODE);
    100         }
    101         */
    102         return mRecentSuggestions;
    103     }
    104 
    105 }
    106