diff --git a/res/drawable-nodpi/nfc_detection_point.png b/res/drawable-nodpi/nfc_detection_point.png new file mode 100644 index 00000000000..1914264c087 Binary files /dev/null and b/res/drawable-nodpi/nfc_detection_point.png differ diff --git a/res/layout/nfc_detection_point.xml b/res/layout/nfc_detection_point.xml new file mode 100644 index 00000000000..8f938d1926e --- /dev/null +++ b/res/layout/nfc_detection_point.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/res/values/config.xml b/res/values/config.xml index 64d9ab7081f..5bddc5eb291 100755 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -442,4 +442,7 @@ + + + false diff --git a/res/values/dimens.xml b/res/values/dimens.xml index aadd62d5696..c2539fa9fea 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -67,6 +67,8 @@ 6 + 300dp + 64dp 20dp 4dp diff --git a/res/xml/nfc_and_payment_settings.xml b/res/xml/nfc_and_payment_settings.xml index f240388279a..8ff4983579b 100644 --- a/res/xml/nfc_and_payment_settings.xml +++ b/res/xml/nfc_and_payment_settings.xml @@ -19,6 +19,12 @@ xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/nfc_quick_toggle_title"> + + - \ No newline at end of file + diff --git a/src/com/android/settings/nfc/NfcDetectionPointController.java b/src/com/android/settings/nfc/NfcDetectionPointController.java new file mode 100644 index 00000000000..b2e8f6abdea --- /dev/null +++ b/src/com/android/settings/nfc/NfcDetectionPointController.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020 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.content.Context; + +import androidx.annotation.VisibleForTesting; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +/** + * Controller that used to show nfc detection point guidance + */ +public class NfcDetectionPointController extends BasePreferenceController { + private boolean mEnabled; + + public NfcDetectionPointController(Context context, String preferenceKey) { + super(context, preferenceKey); + mEnabled = mContext.getResources().getBoolean(R.bool.config_nfc_detection_point); + } + + @Override + public int getAvailabilityStatus() { + if (!mEnabled) { + return UNSUPPORTED_ON_DEVICE; + } + return AVAILABLE; + } + + @VisibleForTesting + public void setConfig(boolean value) { + mEnabled = value; + } +} diff --git a/tests/robotests/src/com/android/settings/nfc/NfcDetectionPointControllerTest.java b/tests/robotests/src/com/android/settings/nfc/NfcDetectionPointControllerTest.java new file mode 100644 index 00000000000..31ac7d67e02 --- /dev/null +++ b/tests/robotests/src/com/android/settings/nfc/NfcDetectionPointControllerTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2020 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 static com.google.common.truth.Truth.assertThat; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + +@RunWith(RobolectricTestRunner.class) +public class NfcDetectionPointControllerTest { + + private NfcDetectionPointController mController; + + @Before + public void setUp() { + mController = new NfcDetectionPointController(RuntimeEnvironment.application, "fakeKey"); + } + + @Test + public void getAvailabilityStatus_withConfigIsTrue_returnAvailable() { + mController.setConfig(true); + assertThat(mController.getAvailabilityStatus()) + .isEqualTo(NfcDetectionPointController.AVAILABLE); + } + + @Test + public void getAvailabilityStatus_withConfigIsFalse_returnUnavailable() { + mController.setConfig(false); + assertThat(mController.getAvailabilityStatus()) + .isNotEqualTo(NfcDetectionPointController.AVAILABLE); + } +}