diff options
author | Matt Fritze <mfritze@google.com> | 2018-10-16 12:41:42 -0700 |
---|---|---|
committer | Matthew Fritze <mfritze@google.com> | 2018-11-26 15:26:02 -0800 |
commit | 90899e08f0a1935796f355caa8ca21c17df74939 (patch) | |
tree | 39b1bd60980c1f009905f0821957a11a93bc3d3b /src/com/android/settings/panel/PanelFragment.java | |
parent | 5948259702eecd6c900824d36133541512ea792d (diff) | |
download | packages_apps_Settings-90899e08f0a1935796f355caa8ca21c17df74939.tar.gz packages_apps_Settings-90899e08f0a1935796f355caa8ca21c17df74939.tar.bz2 packages_apps_Settings-90899e08f0a1935796f355caa8ca21c17df74939.zip |
First commit for settings panels
Establish the Activity which hosts Settings panels through the
PanelFragment. The Activity's purpose is to validate the intent
data coming in, including:
- Called with startActivityForResult (so we can log who is calling)
- Intent has the proper intent extra to link to a Panel
The fragment takes the Panelable data and builds a Settings Panel.
Each panel will have:
- Title
- List of Slices
- Link to underlying content
The Panelable interface is created to provide all of those datums, and
the new FetureProvider provides the Panelables by linking them with
keys. The keys will eventually become public APIs with CTS tests.For
now, we store them locally.
I included an exmaple panel, the InternetConnectivityPanel which
currently shows Wifi and Airplane mode.
Screenshot: https://screenshot.googleplex.com/c6sv7ZzQ5OJ
Bug: 117804089
Test: make -j40 RunSettingsRobotest
Test: Manual app
Change-Id: I1932f7179cc32088acd6413a736901ddf9651892
Diffstat (limited to 'src/com/android/settings/panel/PanelFragment.java')
-rw-r--r-- | src/com/android/settings/panel/PanelFragment.java | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java new file mode 100644 index 0000000000..bbdaec351f --- /dev/null +++ b/src/com/android/settings/panel/PanelFragment.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2018 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.panel; + +import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import android.widget.LinearLayout; + +import androidx.lifecycle.LiveData; +import androidx.slice.Slice; +import androidx.slice.widget.SliceLiveData; +import androidx.slice.widget.SliceView; + +import com.android.settings.R; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; + +import com.android.settings.overlay.FeatureFactory; + +import java.util.ArrayList; +import java.util.List; + +public class PanelFragment extends Fragment { + + private static final String TAG = "PanelFragment"; + + private List<SliceView> mSliceViewList; + private List<LiveData<Slice>> mSliceDataList; + private LinearLayout mPanelLayout; + + public PanelFragment() { + mSliceViewList = new ArrayList<>(); + mSliceDataList = new ArrayList<>(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + final FragmentActivity activity = getActivity(); + final View view = inflater.inflate(R.layout.panel_layout, container, false); + + mPanelLayout = view.findViewById(R.id.panel_parent_layout); + final Bundle arguments = getArguments(); + + final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT); + + final PanelContent panel = FeatureFactory.getFactory(activity) + .getPanelFeatureProvider() + .getPanel(activity, panelType); + + activity.setTitle(panel.getTitle()); + + + for (Uri uri : panel.getSlices()) { + final SliceView sliceView = new SliceView(activity); + mPanelLayout.addView(sliceView); + final LiveData<Slice> liveData = SliceLiveData.fromUri(activity, uri); + liveData.observe(this /* lifecycleOwner */, sliceView); + + mSliceDataList.add(liveData); + mSliceViewList.add(sliceView); + } + + return view; + } +} |