Move Panel to public API
Change the SettingsPanelActivity to reference the public API. Bug: 117804442 Test: robolectric, manual app Change-Id: I4b128ae9d97c1000fdaa0c3fb5b94f8dc096055f
This commit is contained in:
@@ -2977,11 +2977,16 @@
|
|||||||
android:label="@string/settings_panel_title"
|
android:label="@string/settings_panel_title"
|
||||||
android:theme="@style/Theme.BottomDialog"
|
android:theme="@style/Theme.BottomDialog"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.settings.SETTINGSPANEL" />
|
<action android:name="android.settings.panel.action.INTERNET_CONNECTIVITY" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.settings.panel.action.VOLUME" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<provider android:name=".slices.SettingsSliceProvider"
|
<provider android:name=".slices.SettingsSliceProvider"
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/panel_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@@ -17,15 +17,16 @@
|
|||||||
package com.android.settings.panel;
|
package com.android.settings.panel;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PanelContent getPanel(Context context, String panelType) {
|
public PanelContent getPanel(Context context, String panelType) {
|
||||||
switch (panelType) {
|
switch (panelType) {
|
||||||
case SettingsPanelActivity.PANEL_TYPE_WIFI:
|
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
|
||||||
return InternetConnectivityPanel.create(context);
|
return InternetConnectivityPanel.create(context);
|
||||||
case SettingsPanelActivity.PANEL_TYPE_VOLUME:
|
case Settings.Panel.ACTION_VOLUME:
|
||||||
return VolumePanel.create(context);
|
return VolumePanel.create(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ public class PanelFragment extends Fragment {
|
|||||||
mPanelSlices = view.findViewById(R.id.panel_parent_layout);
|
mPanelSlices = view.findViewById(R.id.panel_parent_layout);
|
||||||
mSeeMoreButton = view.findViewById(R.id.see_more);
|
mSeeMoreButton = view.findViewById(R.id.see_more);
|
||||||
mDoneButton = view.findViewById(R.id.done);
|
mDoneButton = view.findViewById(R.id.done);
|
||||||
mTitleView = view.findViewById(R.id.title);
|
mTitleView = view.findViewById(R.id.panel_title);
|
||||||
|
|
||||||
final Bundle arguments = getArguments();
|
final Bundle arguments = getArguments();
|
||||||
final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
|
final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
|
||||||
|
@@ -16,11 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.panel;
|
package com.android.settings.panel;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@@ -35,8 +33,6 @@ import com.android.settings.R;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog Activity to host Settings Slices.
|
* Dialog Activity to host Settings Slices.
|
||||||
*
|
|
||||||
* TODO link to action / framework API
|
|
||||||
*/
|
*/
|
||||||
public class SettingsPanelActivity extends FragmentActivity {
|
public class SettingsPanelActivity extends FragmentActivity {
|
||||||
|
|
||||||
@@ -47,28 +43,10 @@ public class SettingsPanelActivity extends FragmentActivity {
|
|||||||
*/
|
*/
|
||||||
public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
|
public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
|
||||||
|
|
||||||
|
|
||||||
// TODO (b/117804442) move to framework
|
|
||||||
public static final String EXTRA_PANEL_TYPE = "com.android.settings.panel.extra";
|
|
||||||
|
|
||||||
// TODO (b/117804442) move to framework
|
|
||||||
public static final String PANEL_TYPE_WIFI = "wifi_panel";
|
|
||||||
|
|
||||||
// TODO (b/117804442) move to framework
|
|
||||||
public static final String PANEL_TYPE_VOLUME = "volume_panel";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final ComponentName callingActivityName = getCallingActivity();
|
|
||||||
|
|
||||||
if (callingActivityName == null) {
|
|
||||||
Log.e(TAG, "Must start with startActivityForResult. Closing.");
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Intent callingIntent = getIntent();
|
final Intent callingIntent = getIntent();
|
||||||
if (callingIntent == null) {
|
if (callingIntent == null) {
|
||||||
Log.e(TAG, "Null intent, closing Panel Activity");
|
Log.e(TAG, "Null intent, closing Panel Activity");
|
||||||
@@ -76,12 +54,6 @@ public class SettingsPanelActivity extends FragmentActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String typeExtra = callingIntent.getStringExtra(EXTRA_PANEL_TYPE);
|
|
||||||
if (TextUtils.isEmpty(typeExtra)) {
|
|
||||||
Log.e(TAG, "No intent passed, closing Panel Activity");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.settings_panel);
|
setContentView(R.layout.settings_panel);
|
||||||
|
|
||||||
// Move the window to the bottom of screen, and make it take up the entire screen width.
|
// Move the window to the bottom of screen, and make it take up the entire screen width.
|
||||||
@@ -90,9 +62,8 @@ public class SettingsPanelActivity extends FragmentActivity {
|
|||||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT);
|
WindowManager.LayoutParams.WRAP_CONTENT);
|
||||||
|
|
||||||
|
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putString(KEY_PANEL_TYPE_ARGUMENT, typeExtra);
|
bundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
|
||||||
|
|
||||||
final PanelFragment panelFragment = new PanelFragment();
|
final PanelFragment panelFragment = new PanelFragment();
|
||||||
panelFragment.setArguments(bundle);
|
panelFragment.setArguments(bundle);
|
||||||
|
@@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class FakePanelContent implements PanelContent {
|
public class FakePanelContent implements PanelContent {
|
||||||
|
|
||||||
public static final String FAKE_KEY = "fake_key";
|
public static final String FAKE_ACTION = "fake_action";
|
||||||
|
|
||||||
public static final CharSequence TITLE = "title";
|
public static final CharSequence TITLE = "title";
|
||||||
|
|
||||||
|
@@ -27,8 +27,7 @@ public class FakeSettingsPanelActivity extends SettingsPanelActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent getIntent() {
|
public Intent getIntent() {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent(FakePanelContent.FAKE_ACTION);
|
||||||
intent.putExtra(SettingsPanelActivity.EXTRA_PANEL_TYPE, FakePanelContent.FAKE_KEY);
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -20,6 +20,7 @@ package com.android.settings.panel;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -43,8 +44,16 @@ public class PanelFeatureProviderImplTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getPanel_internetConnectivityKey_returnsCorrectPanel() {
|
public void getPanel_internetConnectivityKey_returnsCorrectPanel() {
|
||||||
final PanelContent panel = mProvider.getPanel(mContext,
|
final PanelContent panel = mProvider.getPanel(mContext,
|
||||||
SettingsPanelActivity.PANEL_TYPE_WIFI);
|
Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
|
||||||
|
|
||||||
assertThat(panel).isInstanceOf(InternetConnectivityPanel.class);
|
assertThat(panel).isInstanceOf(InternetConnectivityPanel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getPanel_volume_returnsCorrectPanel() {
|
||||||
|
final PanelContent panel = mProvider.getPanel(mContext,
|
||||||
|
Settings.Panel.ACTION_VOLUME);
|
||||||
|
|
||||||
|
assertThat(panel).isInstanceOf(VolumePanel.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user