Update opp/pbap look and feel

Update OPP BtEnabling Dialog-add timeout handling, handle Bluetooth ON intent, handle back key

Change-Id: I3d3ade3a9a4de645ddb7195e8b81ca42afb3d31e
diff --git a/android/app/AndroidManifest.xml b/android/app/AndroidManifest.xml
index 5e983da..6538420 100644
--- a/android/app/AndroidManifest.xml
+++ b/android/app/AndroidManifest.xml
@@ -55,17 +55,25 @@
                 <data android:mimeType="vnd.android.cursor.item/vnd.android.btopp" />
             </intent-filter>
         </activity>
-        <activity android:name=".opp.BluetoothOppBtEnableActivity">
+        <activity android:name=".opp.BluetoothOppBtEnableActivity"
+                  android:excludeFromRecents="true"
+                  android:theme="@*android:style/Theme.Dialog.Alert">
         </activity>
-        <activity android:name=".opp.BluetoothOppBtErrorActivity">
+        <activity android:name=".opp.BluetoothOppBtErrorActivity"
+                  android:excludeFromRecents="true"
+                  android:theme="@*android:style/Theme.Dialog.Alert">
         </activity>
-        <activity android:name=".opp.BluetoothOppBtEnablingActivity">
-            android:theme="@android:style/Theme.Dialog"> </activity>
+        <activity android:name=".opp.BluetoothOppBtEnablingActivity"
+                  android:excludeFromRecents="true"
+                  android:theme="@*android:style/Theme.Dialog.Alert">
+        </activity>
         <activity android:name=".opp.BluetoothOppIncomingFileConfirmActivity"
                   android:excludeFromRecents="true"
                   android:theme="@*android:style/Theme.Dialog.Alert">
         </activity>
-        <activity android:name=".opp.BluetoothOppTransferActivity">
+        <activity android:name=".opp.BluetoothOppTransferActivity"
+                  android:excludeFromRecents="true"
+                  android:theme="@*android:style/Theme.Dialog.Alert">
         </activity>
         <activity android:name=".opp.BluetoothOppLiveFolder"
             android:label="@string/btopp_live_folder">
@@ -75,7 +83,7 @@
             </intent-filter>
         </activity>
         <activity android:name=".pbap.BluetoothPbapActivity"
-            android:label=" "
+            android:excludeFromRecents="true"
             android:theme="@*android:style/Theme.Dialog.Alert">
             <intent-filter>
                 <category android:name="android.intent.category.DEFAULT" />
diff --git a/android/app/res/layout/access.xml b/android/app/res/layout/access.xml
index 9fdb958..5905b2c 100644
--- a/android/app/res/layout/access.xml
+++ b/android/app/res/layout/access.xml
@@ -1,26 +1,46 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, 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.
+*/
+-->
+
 <ScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent">
 
     <LinearLayout
-        xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_height="fill_parent"
         android:layout_width="fill_parent"
         android:orientation="vertical">
 
         <TextView
-        android:id="@+id/message"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:gravity="center_horizontal"
-        android:textAppearance="?android:attr/textAppearanceMedium" />
-
-        <CheckBox android:id="@+id/alwaysallowed"
+            android:id="@+id/message"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:gravity="center_horizontal"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
+        <CheckBox android:id="@+id/alwaysallowed"
+            style="?android:attr/textAppearanceMedium"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="2dip"
             android:text="@string/alwaysallowed" />
 
     </LinearLayout>
diff --git a/android/app/res/layout/auth.xml b/android/app/res/layout/auth.xml
index d6a35cd..e5c079a 100644
--- a/android/app/res/layout/auth.xml
+++ b/android/app/res/layout/auth.xml
@@ -1,10 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, 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.
+*/
+-->
+
 <ScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent">
 
     <LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent"
     android:orientation="vertical">
@@ -13,13 +31,15 @@
         android:id="@+id/message"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="20dip"
         android:gravity="center_horizontal"
         android:textAppearance="?android:attr/textAppearanceMedium" />
 
     <EditText
         android:id="@+id/text"
-        android:layout_height="wrap_content"
         android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
         android:layout_marginTop="20dip"
         android:layout_marginLeft="20dip"
         android:layout_marginRight="20dip"
diff --git a/android/app/res/layout/bt_enabling_progress.xml b/android/app/res/layout/bt_enabling_progress.xml
index ea5ba45..fa09d4e 100644
--- a/android/app/res/layout/bt_enabling_progress.xml
+++ b/android/app/res/layout/bt_enabling_progress.xml
@@ -1,20 +1,45 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, 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:orientation="horizontal"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content">
+<ScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_height="fill_parent"
+    android:layout_width="fill_parent">
 
-    <ProgressBar android:id="@+android:id/progress"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-    />
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent">
 
-    <TextView
-        android:id="@+id/progress_info"
-        android:layout_height="fill_parent"
-        android:layout_width="wrap_content"
-        android:layout_marginLeft="10dip"
-    />
+        <ProgressBar android:id="@+android:id/progress"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
 
- </LinearLayout>
+        <TextView
+            android:id="@+id/progress_info"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:layout_gravity="center_vertical"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
+     </LinearLayout>
+
+ </ScrollView>
diff --git a/android/app/res/layout/file_transfer.xml b/android/app/res/layout/file_transfer.xml
index e43fe3a..55a75ad 100644
--- a/android/app/res/layout/file_transfer.xml
+++ b/android/app/res/layout/file_transfer.xml
@@ -1,72 +1,103 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, 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="fill_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical">
-
-    <TextView
-        android:id="@+id/line1_view"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_marginLeft="6dip"
-        android:textSize="16sp"
-        android:text="@string/download_line1" />
-
-    <TextView
-        android:id="@+id/line2_view"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_marginLeft="6dip"
-        android:textSize="16sp"
-        android:text="@string/download_line2" />
-
-    <TextView
-        android:id="@+id/line3_view"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_marginLeft="6dip"
-        android:textSize="16sp"
-        android:text="@string/download_line3" />
-
-    <TextView
-        android:id="@+id/line4_view"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_marginLeft="6dip"
-        android:textSize="16sp"
-        android:text="@string/download_line4" />
-
-    <TextView
-        android:id="@+id/line5_view"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:gravity="center"
-        android:textSize="16sp"
-        android:text="@string/download_line5" />
+<ScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_height="fill_parent"
+    android:layout_width="fill_parent">
 
     <LinearLayout
-        android:orientation="horizontal"
-        android:layout_width="fill_parent"
         android:layout_height="fill_parent"
-        >
+        android:layout_width="fill_parent"
+        android:orientation="vertical">
 
         <TextView
-            android:id="@+id/progress_percent"
+            android:id="@+id/line1_view"
+            android:layout_width="fill_parent"
             android:layout_height="wrap_content"
-            android:layout_width="wrap_content"
-            android:layout_marginLeft="10dip"
-            android:gravity="left"/>
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:text="@string/download_line1" />
 
-        <ProgressBar android:id="@+id/progress_transfer"
-            style="?android:attr/progressBarStyleHorizontal"
-            android:layout_marginLeft="10dip"
-            android:layout_marginRight="10dip"
-            android:layout_width="0dip"
-            android:layout_weight="1"
+        <TextView
+            android:id="@+id/line2_view"
+            android:layout_width="fill_parent"
             android:layout_height="wrap_content"
-            android:max="100"
-            android:progress="100" />
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:text="@string/download_line2" />
+
+        <TextView
+            android:id="@+id/line3_view"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:text="@string/download_line3" />
+
+        <TextView
+            android:id="@+id/line4_view"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:text="@string/download_line4" />
+
+        <TextView
+            android:id="@+id/line5_view"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:text="@string/download_line5" />
+
+        <LinearLayout
+            android:orientation="horizontal"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            >
+
+            <TextView
+                android:id="@+id/progress_percent"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="20dip"
+                android:textAppearance="?android:attr/textAppearanceSmall"
+                android:gravity="left" />
+
+            <ProgressBar android:id="@+id/progress_transfer"
+                style="?android:attr/progressBarStyleHorizontal"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="10dip"
+                android:layout_marginRight="20dip"
+                android:layout_width="0dip"
+                android:layout_weight="1"
+                android:max="100"
+                android:progress="100" />
+        </LinearLayout>
+
     </LinearLayout>
 
-</LinearLayout>
+ </ScrollView>
\ No newline at end of file
diff --git a/android/app/res/values/strings.xml b/android/app/res/values/strings.xml
index 196f500..25228c4 100644
--- a/android/app/res/values/strings.xml
+++ b/android/app/res/values/strings.xml
@@ -45,52 +45,52 @@
     <!--Title -->
     <string name="incoming_file_confirm_title">File transfer</string>
     <!--content -->
-    <string name="incoming_file_confirm_content">%1$s wants to send you %2$s (%3$s). \n\n Accept this file? </string>
+    <string name="incoming_file_confirm_content">\u0022%1$s\u0022 wants to send you %2$s (%3$s). \n\n Accept the file? </string>
     <!-- Label for a cancel button. -->
     <string name="incoming_file_confirm_cancel">Decline</string>
     <!-- Label for a confirm button.-->
     <string name="incoming_file_confirm_ok">Accept</string>
 
     <!-- Bluetooth File Transfer Acceptance Notification item -->
-    <string name="incoming_file_confirm_Notification_title">Incoming file</string>
+    <string name="incoming_file_confirm_Notification_title">Bluetooth share: Incoming file</string>
     <string name="incoming_file_confirm_Notification_caption">Please confirm you want to receive this file</string>
     <string name="incoming_file_toast_msg">There is an inoming file from another device,
         please confirm that you want to receive this file</string>
 
     <!-- Inbound File Transfer Progress Notification item -->
     <!-- label for the notification item of receiving file -->
-    <string name="notification_receiving">Receiving %1$s </string>
+    <string name="notification_receiving">Bluetooth share: Receiving %1$s</string>
     <!-- label for the notification item of received file -->
-    <string name="notification_received">Received %1$s</string>
+    <string name="notification_received">Bluetooth share: Received %1$s</string>
     <!-- label for the notification item of received file -status -->
     <string name="notification_received_complete">100% complete</string>
     <!-- label for the notification item of failed receiving file -->
-    <string name="notification_received_fail">File not received: %1$s</string>
+    <string name="notification_received_fail">Bluetooth share: File %1$s not received</string>
 
     <!-- Outbound File Transfer Progress Notification item -->
     <!-- label for the notification item of sending file -->
-    <string name="notification_sending">Sending %1$s</string>
+    <string name="notification_sending">Bluetooth share: Sending %1$s</string>
     <!-- label for the notification item of sending files -->
-    <string name="notification_sending_multi">Sending file</string>
+    <string name="notification_sending_multi">Bluetooth share: Sending file</string>
     <!-- label for the notification item of sent file -->
-    <string name="notification_sent">Sent %1$s</string>
+    <string name="notification_sent">Bluetooth share: Sent %1$s</string>
     <!-- label for the notification item of sent file -status -->
     <string name="notification_sent_complete">100% complete</string>
     <!-- label for the notification item of failed sending file -->
-    <string name="notification_sent_fail">File not sent: %1$s</string>
+    <string name="notification_sent_fail">Bluetooth share: File %1$s not sent</string>
 
     <!-- Bluetooth Download Progress Dialog -->
     <!--Title -->
     <string name="download_title">File transfer</string>
     <!--Line 1 -->
-    <string name="download_line1">From: %1$s</string>
+    <string name="download_line1">From: \u0022%1$s\u0022</string>
     <!--Line 2 -->
     <string name="download_line2">File: %1$s</string>
     <!--Line 3 -->
     <string name="download_line3">File size: %1$s</string>
     <!--Line 4 -->
     <string name="download_line4"></string>
-    <string name="download_line5">Receiving file...</string>
+    <string name="download_line5">Receiving file\u2026</string>
     <!-- Label for a cancel button. -->
     <string name="download_cancel">Stop</string>
     <!-- Label for a hide button.-->
@@ -113,9 +113,9 @@
     <string name="download_succ_ok">Open</string>
 
     <!-- Bluetooth Upload Progress Dialog -->
-    <string name="upload_line1">To: %1$s</string>
+    <string name="upload_line1">To: \u0022%1$s\u0022</string>
     <string name="upload_line3">File Type: %1$s (%2$s)</string>
-    <string name="upload_line5">Sending file...</string>
+    <string name="upload_line5">Sending file\u2026</string>
 
     <!-- Bluetooth Successful Upload Progress Dialog -->
     <!--Line 4 -->
@@ -124,7 +124,7 @@
     <string name="upload_succ_ok">OK</string>
 
     <!-- Bluetooth Failed Upload File Transfer Dialog -->
-    <string name="upload_fail_line1">The file was not sent to %1$s.</string>
+    <string name="upload_fail_line1">The file was not sent to \u0022%1$s\u0022.</string>
     <string name="upload_fail_line1_2">File: %1$s</string>
     <!-- Label for a try again button.-->
     <string name="upload_fail_ok">Try again</string>
@@ -139,35 +139,35 @@
     <string name="not_exist_file_desc">The file does not exist! \n</string>
 
     <!-- Bluetooth  Enabling progress dialog -->
-    <string name="enabling_progress_title">Information</string>
-    <string name="enabling_progress_content">Turning on Bluetooth..</string>
+    <string name="enabling_progress_title">Please wait\u2026</string>
+    <string name="enabling_progress_content">Turning on bluetooth\u2026</string>
 
     <!-- Bluetooth Toast Message -->
     <string name="bt_toast_1">The file will be received. Check progress in the Notifications panel.</string>
     <string name="bt_toast_2">The file will not be received.</string>
-    <string name="bt_toast_3">Stopped receiving file from %1$s</string>
-    <string name="bt_toast_4">Sending file to %1$s</string>
-    <string name="bt_toast_5">Sending %1$s files to %2$s</string>
-    <string name="bt_toast_6">Stopped sending file to %1$s</string>
-    <string name="bt_toast_7">Stopped sending %1$s files to %2$s</string>
+    <string name="bt_toast_3">Stopped receiving file from \u0022%1$s\u0022</string>
+    <string name="bt_toast_4">Sending file to \u0022%1$s\u0022</string>
+    <string name="bt_toast_5">Sending %1$s files to \u0022%2$s\u0022</string>
+    <string name="bt_toast_6">Stopped sending file to \u0022%1$s\u0022</string>
+    <string name="bt_toast_7">Stopped sending %1$s files to \u0022%2$s\u0022</string>
 
     <!-- Bluetooth System Messages -->
-    <string name="bt_sm_2_1">There is not enough space on the SD card to save the file from %1$s</string>
+    <string name="bt_sm_2_1">There is not enough space on the SD card to save the file from \u0022%1$s\u0022</string>
     <string name="bt_sm_2_2">Space needed: %1$s</string>
-    <string name="bt_sm_3_1">%1$s attempted to send you %2$s files. </string>
+    <string name="bt_sm_3_1">\u0022%1$s\u0022 attempted to send you %2$s files. </string>
     <string name="bt_sm_3_2">However, this device can only receive one file at a time. Ask the other party to send the remaining %1$s files individually.</string>
 
     <!-- Bluetooth Transfer Failure Messages -->
-    <string name="bt_tf_1">%1$s is unavailable.</string>
-    <string name="bt_tf_2">Cannot pair with %1$s.</string>
+    <string name="bt_tf_1">\u0022%1$s\u0022 is unavailable.</string>
+    <string name="bt_tf_2">Cannot pair with \u0022%1$s\u0022.</string>
     <string name="bt_tf_3">The connection was interrupted.</string>
-    <string name="bt_tf_4">%1$s does not support file transfers.</string>
-    <string name="bt_tf_5">%1$s cannot accept %2$s</string>
-    <string name="bt_tf_6">%1$s declined to accept the file.</string>
+    <string name="bt_tf_4">\u0022%1$s\u0022 does not support file transfers.</string>
+    <string name="bt_tf_5">\u0022%1$s\u0022 cannot accept %2$s</string>
+    <string name="bt_tf_6">\u0022%1$s\u0022 declined to accept the file.</string>
     <string name="bt_tf_7">The file could not be sent.</string>
     <string name="bt_tf_8">The file could not be received.</string>
     <string name="bt_tf_10">Locked memory card. You must unlock the memory card to save files.</string>
-    <string name="bt_tf_12">There is a file being transferred to a different device. Please wait...</string>
+    <string name="bt_tf_12">There is a file being transferred to a different device. Please wait\u2026</string>
     <string name="bt_tf_13">Bluetooth is currently busy. Consider turning off another Bluetooth feature and trying again.</string>
 
     <!-- Bluetooth Transfer Failure Reason -->
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnableActivity.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnableActivity.java
index 8cb76bb..029c4f8 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnableActivity.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnableActivity.java
@@ -70,7 +70,7 @@
         View view = getLayoutInflater().inflate(R.layout.confirm_dialog, null);
         TextView contentView = (TextView)view.findViewById(R.id.content);
         contentView.setText(getString(R.string.bt_enable_line1) + "\n\n"
-                + getString(R.string.bt_enable_line2) + "\n\n");
+                + getString(R.string.bt_enable_line2) + "\n");
 
         return view;
     }
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnablingActivity.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnablingActivity.java
index 819404a..d1b0d52 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnablingActivity.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppBtEnablingActivity.java
@@ -33,34 +33,53 @@
 package com.android.bluetooth.opp;
 
 import com.android.bluetooth.R;
-
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.TextView;
 import com.android.internal.app.AlertActivity;
 import com.android.internal.app.AlertController;
 
+import android.bluetooth.BluetoothAdapter;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.TextView;
+
 /**
- * This class is designed to show BT enabling progress; It will be killed when
- * received BT_ENABLED intent.
+ * This class is designed to show BT enabling progress.
  */
 public class BluetoothOppBtEnablingActivity extends AlertActivity {
     private static final String TAG = "BluetoothOppEnablingActivity";
+
     private static final boolean D = Constants.DEBUG;
+
     private static final boolean V = Constants.VERBOSE;
 
+    private static final int BT_ENABLING_TIMEOUT = 0;
+
+    private static final int BT_ENABLING_TIMEOUT_VALUE = 20000;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
+        registerReceiver(mBluetoothReceiver, filter);
+
         // Set up the "dialog"
         final AlertController.AlertParams p = mAlertParams;
         p.mIconId = android.R.drawable.ic_dialog_info;
         p.mTitle = getString(R.string.enabling_progress_title);
         p.mView = createView();
         setupAlert();
+
+        // Add timeout for enabling progress
+        mTimeoutHandler.sendMessageDelayed(mTimeoutHandler.obtainMessage(BT_ENABLING_TIMEOUT),
+                BT_ENABLING_TIMEOUT_VALUE);
     }
 
     private View createView() {
@@ -71,26 +90,59 @@
         return view;
     }
 
-    // TODO(Moto): add timer mech to handle the case
-    // "can not enable BT and can not recv the bt enabled intent".
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        if (keyCode == KeyEvent.KEYCODE_BACK) {
+            if (D) Log.d(TAG, "onKeyDown() called; Key: back key");
+            mTimeoutHandler.removeMessages(BT_ENABLING_TIMEOUT);
+            cancelSendingProgress();
+        }
+        return true;
+    }
 
     @Override
-    protected void onPause() {
-        super.onPause();
+    protected void onDestroy() {
+        super.onDestroy();
+        unregisterReceiver(mBluetoothReceiver);
+    }
 
+    private final Handler mTimeoutHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case BT_ENABLING_TIMEOUT:
+                    if (V) Log.v(TAG, "Received BT_ENABLING_TIMEOUT msg.");
+                    cancelSendingProgress();
+                    break;
+                default:
+                    break;
+            }
+        }
+    };
+
+    private final BroadcastReceiver mBluetoothReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (V) Log.v(TAG, "Received intent: " + action) ;
+            if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
+                switch (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) {
+                    case BluetoothAdapter.STATE_ON:
+                        mTimeoutHandler.removeMessages(BT_ENABLING_TIMEOUT);
+                        finish();
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+    };
+
+    private void cancelSendingProgress() {
         BluetoothOppManager mOppManager = BluetoothOppManager.getInstance(this);
-
-        // if user press "back" key during BT enabling, cancel the sending
-        // operation
         if (mOppManager.mSendingFlag) {
             mOppManager.mSendingFlag = false;
-            mOppManager.disableBluetooth(); // can work? May not!
-            if (V) Log.v(TAG, "Disabling Bluetooth:! ");
         }
-
-        // In this dialog, when press "back" key, will call
-        // AlertActivity.cancel() function - finish()
         finish();
-        if (V) Log.v(TAG, "onPause(): finish() called");
     }
 }
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppIncomingFileConfirmActivity.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppIncomingFileConfirmActivity.java
index 0fd0004..1314b59 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppIncomingFileConfirmActivity.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppIncomingFileConfirmActivity.java
@@ -124,8 +124,6 @@
                 mUpdateValues.put(BluetoothShare.USER_CONFIRMATION,
                         BluetoothShare.USER_CONFIRMATION_DENIED);
                 this.getContentResolver().update(mUri, mUpdateValues, null, null);
-
-                Toast.makeText(this, getString(R.string.bt_toast_2), Toast.LENGTH_SHORT).show();
                 break;
         }
         mOkOrCancelClicked = true;
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
index 0120791..c4a4591 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
@@ -264,7 +264,7 @@
 
         for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
             // Add the notifications
-            int timeStamp = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP));
+            long timeStamp = cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP));
             int dir = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.DIRECTION));
             int id = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare._ID));
             int status = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.STATUS));
@@ -331,7 +331,7 @@
             String caption = mContext
                     .getString(R.string.incoming_file_confirm_Notification_caption);
             int id = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare._ID));
-            int timeStamp = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP));
+            long timeStamp = cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP));
             Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + id);
 
             Notification n = new Notification();
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
index 0d600bd..0bd1193 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
@@ -319,7 +319,7 @@
                 mLine3View.setText(tmp);
             }
             mLine5View = (TextView)mView.findViewById(R.id.line5_view);
-            mLine5View.setVisibility(View.INVISIBLE);
+            mLine5View.setVisibility(View.GONE);
         } else if (mWhichDialog == DIALOG_SEND_COMPLETE_FAIL) {
             mLine1View = (TextView)mView.findViewById(R.id.line1_view);
             tmp = getString(R.string.upload_fail_line1, mTransInfo.mDeviceName);
@@ -332,7 +332,7 @@
                     this, mTransInfo.mStatus));
             mLine3View.setText(tmp);
             mLine5View = (TextView)mView.findViewById(R.id.line5_view);
-            mLine5View.setVisibility(View.INVISIBLE);
+            mLine5View.setVisibility(View.GONE);
         }
 
         if (BluetoothShare.isStatusError(mTransInfo.mStatus)) {