Merge "UI refresh for STK app."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1beb3ae..20b35fb 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -49,7 +49,7 @@
</activity>
<activity android:name="StkLauncherActivity"
- android:theme="@android:style/Theme.NoTitleBar"
+ android:theme="@android:style/Theme.Light.NoTitleBar"
android:label="@string/app_name"
android:exported="false"
android:taskAffinity="android.task.stk.StkLauncherActivity">
@@ -61,7 +61,7 @@
</activity>
<activity android:name="StkMenuActivity"
- android:theme="@android:style/Theme.NoTitleBar"
+ android:theme="@android:style/Theme.Light.NoTitleBar"
android:icon="@drawable/ic_launcher_sim_toolkit"
android:label="@string/app_name"
android:configChanges="orientation|locale|screenSize|keyboardHidden|mnc|mcc"
@@ -77,7 +77,7 @@
<activity android:name="StkInputActivity"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher_sim_toolkit"
- android:theme="@android:style/Theme.Holo"
+ android:theme="@android:style/Theme.Material.Light"
android:configChanges="orientation|locale|screenSize|keyboardHidden"
android:exported="false"
android:taskAffinity="android.task.stk.StkLauncherActivity">
@@ -89,14 +89,14 @@
</activity>
<activity android:name="StkDialogActivity"
android:configChanges="orientation|locale|screenSize|keyboardHidden"
- android:theme="@android:style/Theme.DeviceDefault.Dialog"
+ android:theme="@android:style/Theme.Material.Light"
android:exported="false"
android:taskAffinity="android.task.stk.StkLauncherActivity">
</activity>
<activity android:name="ToneDialog"
android:exported="false"
- android:theme="@android:style/Theme.DeviceDefault.Dialog"
+ android:theme="@android:style/Theme.Material.Light"
android:taskAffinity="android.task.stk.StkLauncherActivity">
</activity>
diff --git a/res/layout/stk_msg_dialog.xml b/res/layout/stk_msg_dialog.xml
deleted file mode 100755
index 731d74c..0000000
--- a/res/layout/stk_msg_dialog.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <LinearLayout android:id="@+id/messagePanel"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="vertical">
- <ScrollView android:id="@+id/scrollView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:fillViewport="true"
- android:paddingTop="2dip"
- android:paddingBottom="12dip"
- android:paddingLeft="14dip"
- android:paddingRight="10dip">
- <TextView android:id="@+id/dialog_message"
- style="?android:attr/textAppearanceMedium"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="5dip" />
- </ScrollView>
- </LinearLayout>
-
- <LinearLayout android:id="@+id/buttonPanel"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="54dip"
- android:orientation="vertical" >
- <LinearLayout style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingTop="4dip"
- android:paddingLeft="2dip"
- android:paddingRight="2dip" >
- <Button style="?android:attr/buttonBarButtonStyle"
- android:id="@+id/button_cancel"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left"
- android:layout_weight="1"
- android:maxLines="2"
- android:text="@string/button_cancel" />
- <Button style="?android:attr/buttonBarButtonStyle"
- android:id="@+id/button_ok"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:layout_weight="1"
- android:maxLines="2"
- android:text="@string/button_ok" />
- </LinearLayout>
- </LinearLayout>
-</LinearLayout>
diff --git a/src/com/android/stk/StkDialogActivity.java b/src/com/android/stk/StkDialogActivity.java
index 78e1a2e..09a8b8f 100755
--- a/src/com/android/stk/StkDialogActivity.java
+++ b/src/com/android/stk/StkDialogActivity.java
@@ -18,29 +18,26 @@
import com.android.internal.telephony.cat.CatLog;
import com.android.internal.telephony.cat.TextMessage;
-import com.android.internal.telephony.cat.CatLog;
import android.app.Activity;
import android.app.AlarmManager;
+import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;
import android.content.Context;
-import android.graphics.drawable.BitmapDrawable;
+import android.content.DialogInterface;
+import android.view.KeyEvent;
+
import android.os.Bundle;
import android.os.SystemClock;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.TextView;
/**
* AlertDialog used for DISPLAY TEXT commands.
*
*/
-public class StkDialogActivity extends Activity implements View.OnClickListener {
+public class StkDialogActivity extends Activity {
// members
private static final String className = new Object(){}.getClass().getEnclosingClass().getName();
private static final String LOG_TAG = className.substring(className.lastIndexOf('.') + 1);
@@ -58,12 +55,7 @@
//keys) for saving the state of the dialog in the icicle
private static final String TEXT = "text";
- // message id for time out
- private static final int MSG_ID_TIMEOUT = 1;
-
- // buttons id
- public static final int OK_BUTTON = R.id.button_ok;
- public static final int CANCEL_BUTTON = R.id.button_cancel;
+ private AlertDialog.Builder alertDialogBuilder;
@Override
protected void onCreate(Bundle icicle) {
@@ -82,15 +74,30 @@
// New Dialog is created - set to no response sent
mIsResponseSent = false;
- requestWindowFeature(Window.FEATURE_LEFT_ICON);
+ alertDialogBuilder = new AlertDialog.Builder(this);
- setContentView(R.layout.stk_msg_dialog);
+ alertDialogBuilder.setPositiveButton(R.string.button_ok, new
+ DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ CatLog.d(LOG_TAG, "OK Clicked!, mSlotId: " + mSlotId);
+ cancelTimeOut();
+ sendResponse(StkAppService.RES_ID_CONFIRM, true);
+ finish();
+ }
+ });
- Button okButton = (Button) findViewById(R.id.button_ok);
- Button cancelButton = (Button) findViewById(R.id.button_cancel);
-
- okButton.setOnClickListener(this);
- cancelButton.setOnClickListener(this);
+ alertDialogBuilder.setNegativeButton(R.string.button_cancel, new
+ DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,int id) {
+ CatLog.d(LOG_TAG, "Cancel Clicked!, mSlotId: " + mSlotId);
+ cancelTimeOut();
+ sendResponse(StkAppService.RES_ID_CONFIRM, false);
+ finish();
+ }
+ });
+ alertDialogBuilder.create();
mContext = getBaseContext();
IntentFilter intentFilter = new IntentFilter();
@@ -101,32 +108,15 @@
setFinishOnTouchOutside(false);
}
- public void onClick(View v) {
- String input = null;
- switch (v.getId()) {
- case OK_BUTTON:
- CatLog.d(LOG_TAG, "OK Clicked!, mSlotId: " + mSlotId);
- cancelTimeOut();
- sendResponse(StkAppService.RES_ID_CONFIRM, true);
- break;
- case CANCEL_BUTTON:
- CatLog.d(LOG_TAG, "Cancel Clicked!, mSlotId: " + mSlotId);
- cancelTimeOut();
- sendResponse(StkAppService.RES_ID_CONFIRM, false);
- break;
- }
- finish();
- }
-
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
- case KeyEvent.KEYCODE_BACK:
- CatLog.d(LOG_TAG, "onKeyDown - KEYCODE_BACK");
- cancelTimeOut();
- sendResponse(StkAppService.RES_ID_BACKWARD);
- finish();
- break;
+ case KeyEvent.KEYCODE_BACK:
+ CatLog.d(LOG_TAG, "onKeyDown - KEYCODE_BACK");
+ cancelTimeOut();
+ sendResponse(StkAppService.RES_ID_BACKWARD);
+ finish();
+ break;
}
return false;
}
@@ -143,24 +133,12 @@
return;
}
- Window window = getWindow();
-
- TextView mMessageView = (TextView) window
- .findViewById(R.id.dialog_message);
-
- setTitle(mTextMsg.title);
+ alertDialogBuilder.setTitle(mTextMsg.title);
if (!(mTextMsg.iconSelfExplanatory && mTextMsg.icon != null)) {
- mMessageView.setText(mTextMsg.text);
+ alertDialogBuilder.setMessage(mTextMsg.text);
}
-
- if (mTextMsg.icon == null) {
- window.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
- com.android.internal.R.drawable.stat_notify_sim_toolkit);
- } else {
- window.setFeatureDrawable(Window.FEATURE_LEFT_ICON,
- new BitmapDrawable(mTextMsg.icon));
- }
+ alertDialogBuilder.show();
/*
* If the userClear flag is set and dialogduration is set to 0, the display Text
@@ -169,7 +147,7 @@
* ETSI 102.223, 6.4.1)
*/
if (StkApp.calculateDurationInMilis(mTextMsg.duration) == 0 &&
- !mTextMsg.responseNeeded && mTextMsg.userClear) {
+ !mTextMsg.responseNeeded && mTextMsg.userClear) {
CatLog.d(LOG_TAG, "User should clear text..showing message forever");
return;
}
@@ -180,7 +158,7 @@
* When another activity takes the foreground, we do not want the Terminal
* Response timer to be restarted when our activity resumes. Hence we will
* check if there is an existing timer, and resume it. In this way we will
- * inform the SIM in correct time when there is no response from the User
+ * inform the SIM in correct time when there is no response from the User
* to a dialog.
*/
if (mTimeoutIntent != null) {
@@ -351,11 +329,11 @@
// Try to use a more stringent timer not affected by system sleep.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP,
- SystemClock.elapsedRealtime() + dialogDuration, mTimeoutIntent);
+ SystemClock.elapsedRealtime() + dialogDuration, mTimeoutIntent);
}
else {
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
- SystemClock.elapsedRealtime() + dialogDuration, mTimeoutIntent);
+ SystemClock.elapsedRealtime() + dialogDuration, mTimeoutIntent);
}
}
}