diff options
author | hughchen <hughchen@google.com> | 2020-01-17 15:19:04 +0800 |
---|---|---|
committer | hughchen <hughchen@google.com> | 2020-02-19 10:05:44 +0800 |
commit | 201b48b885f611c2e1779418a6a77c6e5ba4b2ad (patch) | |
tree | 24c0edeb4925d50687676b4f36011559728978cc /src/com/android/settings/panel/PanelFragment.java | |
parent | 14b758f1c8d8b238f96d41f913c86c8f904b4605 (diff) | |
download | packages_apps_Settings-201b48b885f611c2e1779418a6a77c6e5ba4b2ad.tar.gz packages_apps_Settings-201b48b885f611c2e1779418a6a77c6e5ba4b2ad.tar.bz2 packages_apps_Settings-201b48b885f611c2e1779418a6a77c6e5ba4b2ad.zip |
Add stop casting button for output switch
This CL add a customize button to stop casting when media
is transferred to info device.
This CL include following change:
- Add new methods to PanelContent.java. Let panels to
customize "see more button".
- MediaOutputPanel will check which device is used to
transfer media currently. The customize button will
shown on when transfer device is info device.
Then user can use this button to stop casting.
- Add test case.
Bug: 147856563
Test: make -j42 RunSettingsRoboTests
Change-Id: I8b201a10339f39f1d938d99b5659a82014e5bb89
Diffstat (limited to 'src/com/android/settings/panel/PanelFragment.java')
-rw-r--r-- | src/com/android/settings/panel/PanelFragment.java | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java index 0f46758244..31e2ac6ee5 100644 --- a/src/com/android/settings/panel/PanelFragment.java +++ b/src/com/android/settings/panel/PanelFragment.java @@ -41,6 +41,7 @@ import androidx.annotation.Nullable; import androidx.core.graphics.drawable.IconCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LiveData; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -53,6 +54,7 @@ import com.android.settings.R; import com.android.settings.overlay.FeatureFactory; import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; +import com.android.settingslib.utils.ThreadUtils; import com.google.android.setupdesign.DividerItemDecoration; @@ -183,6 +185,11 @@ public class PanelFragment extends Fragment { activity.finish(); } + mPanel.registerCallback(new LocalPanelCallback()); + if (mPanel instanceof LifecycleObserver) { + getLifecycle().addObserver((LifecycleObserver) mPanel); + } + mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider(); mPanelSlices.setLayoutManager(new LinearLayoutManager((activity))); @@ -208,8 +215,15 @@ public class PanelFragment extends Fragment { mSeeMoreButton.setOnClickListener(getSeeMoreListener()); mDoneButton.setOnClickListener(getCloseListener()); - // If getSeeMoreIntent() is null, hide the mSeeMoreButton. - if (mPanel.getSeeMoreIntent() == null) { + if (mPanel.isCustomizedButtonUsed()) { + final CharSequence customTitle = mPanel.getCustomButtonTitle(); + if (TextUtils.isEmpty(customTitle)) { + mSeeMoreButton.setVisibility(View.GONE); + } else { + mSeeMoreButton.setText(customTitle); + } + } else if (mPanel.getSeeMoreIntent() == null) { + // If getSeeMoreIntent() is null hide the mSeeMoreButton. mSeeMoreButton.setVisibility(View.GONE); } @@ -371,9 +385,13 @@ public class PanelFragment extends Fragment { View.OnClickListener getSeeMoreListener() { return (v) -> { mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE; - final FragmentActivity activity = getActivity(); - activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0); - activity.finish(); + if (mPanel.isCustomizedButtonUsed()) { + mPanel.onClickCustomizedButton(); + } else { + final FragmentActivity activity = getActivity(); + activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0); + activity.finish(); + } }; } @@ -392,4 +410,15 @@ public class PanelFragment extends Fragment { activity.startActivity(mPanel.getHeaderIconIntent()); }; } + + class LocalPanelCallback implements PanelCustomizedButtonCallback { + + @Override + public void onCustomizedButtonStateChanged() { + ThreadUtils.postOnMainThread(() -> { + mSeeMoreButton.setVisibility( + mPanel.isCustomizedButtonUsed() ? View.VISIBLE : View.GONE); + }); + } + } } |