summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2011-07-21 09:33:40 +0200
committerMartijn Coenen <maco@google.com>2011-07-21 11:39:41 +0200
commitba534408011905e657a143eeae9a4c0fa412e0ec (patch)
treeb1c509e0f6362fd7fbceeabac637d6bfe89389e4 /src/com/android
parentc29c6d3f8cec4e326cb1ca7417f383253eb717c9 (diff)
downloadpackages_apps_settings-ba534408011905e657a143eeae9a4c0fa412e0ec.zip
packages_apps_settings-ba534408011905e657a143eeae9a4c0fa412e0ec.tar.gz
packages_apps_settings-ba534408011905e657a143eeae9a4c0fa412e0ec.tar.bz2
Added setting for zero-click sharing over NFC.
Change-Id: I3848c4815d65d3a8b9b5e579c6a353dde6901ee4
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/settings/WirelessSettings.java6
-rw-r--r--src/com/android/settings/nfc/NfcEnabler.java7
-rw-r--r--src/com/android/settings/nfc/ZeroClick.java83
3 files changed, 94 insertions, 2 deletions
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 5560a03..c07388e 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -37,6 +37,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
private static final String KEY_TOGGLE_NFC = "toggle_nfc";
+ private static final String KEY_ZEROCLICK_SETTINGS = "zeroclick_settings";
private static final String KEY_VPN_SETTINGS = "vpn_settings";
private static final String KEY_TETHER_SETTINGS = "tether_settings";
private static final String KEY_PROXY_SETTINGS = "proxy_settings";
@@ -87,9 +88,11 @@ public class WirelessSettings extends SettingsPreferenceFragment {
final Activity activity = getActivity();
mAirplaneModePreference = (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE);
CheckBoxPreference nfc = (CheckBoxPreference) findPreference(KEY_TOGGLE_NFC);
+ PreferenceScreen zeroclick = (PreferenceScreen)
+ findPreference(KEY_ZEROCLICK_SETTINGS);
mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
- mNfcEnabler = new NfcEnabler(activity, nfc);
+ mNfcEnabler = new NfcEnabler(activity, nfc, zeroclick);
String toggleable = Settings.System.getString(activity.getContentResolver(),
Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
@@ -107,6 +110,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
// Remove NFC if its not available
if (NfcAdapter.getDefaultAdapter(activity) == null) {
getPreferenceScreen().removePreference(nfc);
+ getPreferenceScreen().removePreference(zeroclick);
}
// Remove Mobile Network Settings if it's a wifi-only device.
diff --git a/src/com/android/settings/nfc/NfcEnabler.java b/src/com/android/settings/nfc/NfcEnabler.java
index dba1329..99cf8f0 100644
--- a/src/com/android/settings/nfc/NfcEnabler.java
+++ b/src/com/android/settings/nfc/NfcEnabler.java
@@ -24,6 +24,7 @@ import android.nfc.NfcAdapter;
import android.os.Handler;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
+import android.preference.PreferenceScreen;
import android.util.Log;
/**
@@ -36,6 +37,7 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
private final Context mContext;
private final CheckBoxPreference mCheckbox;
+ private final PreferenceScreen mZeroClick;
private final NfcAdapter mNfcAdapter;
private final IntentFilter mIntentFilter;
private final Handler mHandler = new Handler();
@@ -54,9 +56,11 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
private boolean mNfcState;
- public NfcEnabler(Context context, CheckBoxPreference checkBoxPreference) {
+ public NfcEnabler(Context context, CheckBoxPreference checkBoxPreference,
+ PreferenceScreen zeroclick) {
mContext = context;
mCheckbox = checkBoxPreference;
+ mZeroClick = zeroclick;
mNfcAdapter = NfcAdapter.getDefaultAdapter(context);
if (mNfcAdapter == null) {
@@ -127,5 +131,6 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
private void handleNfcStateChanged(boolean newState) {
mCheckbox.setChecked(newState);
mCheckbox.setEnabled(true);
+ mZeroClick.setEnabled(newState);
}
}
diff --git a/src/com/android/settings/nfc/ZeroClick.java b/src/com/android/settings/nfc/ZeroClick.java
new file mode 100644
index 0000000..11c35db
--- /dev/null
+++ b/src/com/android/settings/nfc/ZeroClick.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 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.
+ */
+
+package com.android.settings.nfc;
+
+import android.app.Fragment;
+import android.content.ContentResolver;
+import android.nfc.NfcAdapter;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.provider.Settings;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.util.Log;
+import com.android.settings.R;
+
+public class ZeroClick extends Fragment
+ implements CompoundButton.OnCheckedChangeListener {
+ private View mView;
+ private CheckBox mCheckbox;
+ private NfcAdapter mNfcAdapter;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ mView = inflater.inflate(R.layout.zeroclick, container, false);
+ initView(mView);
+ return mView;
+ }
+
+ private void initView(View view) {
+ mCheckbox = (CheckBox) mView.findViewById(R.id.zeroclick_checkbox);
+ mCheckbox.setOnCheckedChangeListener(this);
+ mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
+ mCheckbox.setChecked(mNfcAdapter.zeroClickEnabled());
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ }
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean value) {
+ Log.e("AAP", "onCheckedChanged!");
+ final boolean desiredState = (Boolean) value;
+ boolean success = false;
+ mCheckbox.setEnabled(false);
+ if (desiredState) {
+ success = mNfcAdapter.enableZeroClick();
+ } else {
+ success = mNfcAdapter.disableZeroClick();
+ }
+ if (success) {
+ mCheckbox.setChecked(desiredState);
+ }
+ mCheckbox.setEnabled(true);
+ }
+}