WarnOfStorageLimitsActivity.java revision 6be18bedb5b87dbbcdb54f37d5a0945bd0f71377
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
18package com.android.mms.ui;
19
20import com.android.mms.R;
21
22import android.app.Activity;
23import android.app.AlertDialog;
24import android.content.DialogInterface;
25import android.content.Intent;
26import android.os.Bundle;
27import android.util.Log;
28import android.view.KeyEvent;
29import android.view.View;
30
31/**
32 * This is the UI for telling the user about the storage limit setting.
33 */
34public class WarnOfStorageLimitsActivity extends Activity implements DialogInterface,
35                    DialogInterface.OnClickListener {
36    /**
37     * The model for the alert.
38     *
39     * @see #mAlertParams
40     */
41//    protected AlertController mAlert;
42
43    /**
44     * The parameters for the alert.
45     */
46//    protected AlertController.AlertParams mAlertParams;
47
48    private static final String LOG_TAG = "WarnOfStorageLimitsActivity";
49
50    private static final int POSITIVE_BUTTON = AlertDialog.BUTTON1;
51
52    @Override
53    protected void onCreate(Bundle savedInstanceState) {
54        // Can't set this theme in the manifest. The resource compiler complains the
55        // resource is internal and not visible. Without setting this theme, the window
56        // gets a double window outline.
57        this.setTheme(com.android.internal.R.style.Theme_Dialog_Alert);
58
59        super.onCreate(savedInstanceState);
60
61        // TODO: rewrite using SDK-available classes
62//        mAlert = new AlertController(this, this, getWindow());
63//        mAlertParams = new AlertController.AlertParams(this);
64//
65//        // Set up the "dialog"
66//        final AlertController.AlertParams p = mAlertParams;
67//        p.mTitle = getString(R.string.storage_limits_title);
68//        p.mMessage = getString(R.string.storage_limits_message);
69//        p.mPositiveButtonText = getString(R.string.storage_limits_setting);
70//        p.mNegativeButtonText = getString(R.string.storage_limits_setting_dismiss);
71//        p.mPositiveButtonListener = this;
72        setupAlert();
73    }
74
75    /**
76     * {@inheritDoc}
77     */
78    public void onClick(DialogInterface dialog, int which) {
79
80        if (which == POSITIVE_BUTTON) {
81            Intent intent = new Intent(this,
82                    MessagingPreferenceActivity.class);
83            startActivity(intent);
84        }
85
86        // No matter what, finish the activity
87        finish();
88    }
89
90    public void cancel() {
91        finish();
92    }
93
94    public void dismiss() {
95        // This is called after the click, since we finish when handling the
96        // click, don't do that again here.
97        if (!isFinishing()) {
98            finish();
99        }
100    }
101
102    /**
103     * Sets up the alert, including applying the parameters to the alert model,
104     * and installing the alert's content.
105     *
106     * @see #mAlert
107     * @see #mAlertParams
108     */
109    protected void setupAlert() {
110//        mAlertParams.apply(mAlert);
111//        mAlert.installContent();
112    }
113
114    @Override
115    public boolean onKeyDown(int keyCode, KeyEvent event) {
116//        if (mAlert.onKeyDown(keyCode, event)) return true;
117        return super.onKeyDown(keyCode, event);
118    }
119
120    @Override
121    public boolean onKeyUp(int keyCode, KeyEvent event) {
122//        if (mAlert.onKeyUp(keyCode, event)) return true;
123        return super.onKeyUp(keyCode, event);
124    }
125
126}
127