Merge "Add NFC Panel"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d986c59c97
@@ -2977,6 +2977,10 @@
|
||||
<action android:name="android.settings.panel.action.VOLUME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.settings.panel.action.NFC" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider android:name=".slices.SettingsSliceProvider"
|
||||
|
53
src/com/android/settings/panel/NfcPanel.java
Normal file
53
src/com/android/settings/panel/NfcPanel.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.android.settings.panel;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SubSettings;
|
||||
import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
import com.android.settings.slices.SliceBuilderUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NfcPanel implements PanelContent {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public static NfcPanel create(Context context) {
|
||||
return new NfcPanel(context);
|
||||
}
|
||||
|
||||
private NfcPanel(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return mContext.getText(R.string.nfc_quick_toggle_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Uri> getSlices() {
|
||||
final List<Uri> uris = new ArrayList<>();
|
||||
uris.add(CustomSliceRegistry.NFC_SLICE_URI);
|
||||
return uris;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getSeeMoreIntent() {
|
||||
final String screenTitle =
|
||||
mContext.getText(R.string.connected_device_connections_title).toString();
|
||||
Intent intent = SliceBuilderUtils.buildSearchResultPageIntent(mContext,
|
||||
AdvancedConnectedDeviceDashboardFragment.class.getName(),
|
||||
null /* key */,
|
||||
screenTitle,
|
||||
SettingsEnums.SETTINGS_CONNECTED_DEVICE_CATEGORY);
|
||||
intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
|
||||
return intent;
|
||||
}
|
||||
}
|
@@ -28,6 +28,8 @@ public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
||||
return InternetConnectivityPanel.create(context);
|
||||
case Settings.Panel.ACTION_VOLUME:
|
||||
return VolumePanel.create(context);
|
||||
case Settings.Panel.ACTION_NFC:
|
||||
return NfcPanel.create(context);
|
||||
}
|
||||
|
||||
throw new IllegalStateException("No matching panel for: " + panelType);
|
||||
|
@@ -154,6 +154,15 @@ public class CustomSliceRegistry {
|
||||
.appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT)
|
||||
.appendPath("low_storage")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for NFC Slice
|
||||
*/
|
||||
public static final Uri NFC_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath("toggle_nfc")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for Notification channel Slice.
|
||||
*/
|
||||
|
@@ -0,0 +1,40 @@
|
||||
package com.android.settings.panel;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class NfcPanelTest {
|
||||
|
||||
private NfcPanel mPanel;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mPanel = NfcPanel.create(RuntimeEnvironment.application);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlices_containsNecessarySlices() {
|
||||
final List<Uri> uris = mPanel.getSlices();
|
||||
|
||||
assertThat(uris).containsExactly(
|
||||
CustomSliceRegistry.NFC_SLICE_URI);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSeeMoreIntent_notNull() {
|
||||
assertThat(mPanel.getSeeMoreIntent()).isNotNull();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user