Once the user allows PBAP phonebook access, do not ask again.
Bug: 9876209 Change-Id: I8d9dcfa03e8d85577af4c4664fa34b3830e3d8f6
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2009, The Android Open Source Project
|
||||
** Copyright 2011, 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.
|
||||
@@ -35,15 +35,6 @@
|
||||
android:layout_marginEnd="20dip"
|
||||
android:gravity="center_horizontal"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<CheckBox android:id="@+id/bluetooth_remember_choice"
|
||||
style="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dip"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:text="@string/bluetooth_remember_choice" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2011, 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="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dip"
|
||||
android:layout_marginEnd="20dip"
|
||||
android:gravity="center_horizontal"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@@ -55,8 +55,6 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
||||
private String mReturnPackage = null;
|
||||
private String mReturnClass = null;
|
||||
|
||||
private CheckBox mRememberChoice;
|
||||
private boolean mRememberChoiceValue = false;
|
||||
private int mRequestType = 0;
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -156,64 +154,50 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
||||
return mRemoteName;
|
||||
}
|
||||
|
||||
// TODO(edjee): createConnectionDialogView, createPhonebookDialogView and createMapDialogView
|
||||
// are similar. Refactor them into one method.
|
||||
// Also, the string resources bluetooth_remember_choice and bluetooth_pb_remember_choice should
|
||||
// be removed.
|
||||
private View createConnectionDialogView() {
|
||||
String mRemoteName = createRemoteName();
|
||||
mView = getLayoutInflater().inflate(R.layout.bluetooth_connection_access, null);
|
||||
mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
|
||||
messageView = (TextView)mView.findViewById(R.id.message);
|
||||
messageView.setText(getString(R.string.bluetooth_connection_dialog_text,
|
||||
mRemoteName));
|
||||
return mView;
|
||||
}
|
||||
|
||||
private void createCheckbox(int viewId)
|
||||
{
|
||||
mRememberChoice = (CheckBox)mView.findViewById(viewId);
|
||||
mRememberChoice.setChecked(false);
|
||||
mRememberChoice.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
mRememberChoiceValue = true;
|
||||
} else {
|
||||
mRememberChoiceValue = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private View createPhonebookDialogView() {
|
||||
String mRemoteName = createRemoteName();
|
||||
mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
|
||||
messageView = (TextView)mView.findViewById(R.id.message);
|
||||
messageView.setText(getString(R.string.bluetooth_pb_acceptance_dialog_text,
|
||||
mRemoteName, mRemoteName));
|
||||
createCheckbox(R.id.bluetooth_remember_choice);
|
||||
return mView;
|
||||
}
|
||||
|
||||
private View createMapDialogView() {
|
||||
String mRemoteName = createRemoteName();
|
||||
mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
|
||||
messageView = (TextView)mView.findViewById(R.id.message);
|
||||
messageView.setText(getString(R.string.bluetooth_map_acceptance_dialog_text,
|
||||
mRemoteName, mRemoteName));
|
||||
createCheckbox(R.id.bluetooth_remember_choice);
|
||||
return mView;
|
||||
}
|
||||
|
||||
private void onPositive() {
|
||||
if (DEBUG) Log.d(TAG, "onPositive mRememberChoiceValue: " + mRememberChoiceValue);
|
||||
if (mRememberChoiceValue)
|
||||
if (DEBUG) Log.d(TAG, "onPositive");
|
||||
savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_ALLOWED);
|
||||
|
||||
// TODO(edjee): Now that we always save the user's choice,
|
||||
// we can get rid of BluetoothDevice#EXTRA_ALWAYS_ALLOWED.
|
||||
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, true,
|
||||
BluetoothDevice.EXTRA_ALWAYS_ALLOWED, mRememberChoiceValue);
|
||||
BluetoothDevice.EXTRA_ALWAYS_ALLOWED, true);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void onNegative() {
|
||||
if (DEBUG) Log.d(TAG, "onNegative mRememberChoiceValue: " + mRememberChoiceValue);
|
||||
|
||||
if (mRememberChoiceValue)
|
||||
savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_REJECTED);
|
||||
|
||||
if (DEBUG) Log.d(TAG, "onNegative");
|
||||
savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_UNKNOWN);
|
||||
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, false,
|
||||
null, false // dummy value, no effect since last param is null
|
||||
);
|
||||
|
Reference in New Issue
Block a user