Loading src/com/android/settings/panel/MediaOutputPanel.java +1 −1 Original line number Diff line number Diff line Loading @@ -166,7 +166,7 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC } @Override public CharSequence getCustomButtonTitle() { public CharSequence getCustomizedButtonTitle() { return mContext.getText(R.string.media_output_panel_stop_casting_button); } Loading src/com/android/settings/panel/PanelContent.java +2 −2 Original line number Diff line number Diff line Loading @@ -86,9 +86,9 @@ public interface PanelContent extends Instrumentable { } /** * @return a string for the title of the custom button. * @return a string for the title of the customized button. */ default CharSequence getCustomButtonTitle() { default CharSequence getCustomizedButtonTitle() { return null; } Loading src/com/android/settings/panel/PanelFragment.java +2 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ public class PanelFragment extends Fragment { mDoneButton.setOnClickListener(getCloseListener()); if (mPanel.isCustomizedButtonUsed()) { final CharSequence customTitle = mPanel.getCustomButtonTitle(); final CharSequence customTitle = mPanel.getCustomizedButtonTitle(); if (TextUtils.isEmpty(customTitle)) { mSeeMoreButton.setVisibility(View.GONE); } else { Loading Loading @@ -422,6 +422,7 @@ public class PanelFragment extends Fragment { ThreadUtils.postOnMainThread(() -> { mSeeMoreButton.setVisibility( mPanel.isCustomizedButtonUsed() ? View.VISIBLE : View.GONE); mSeeMoreButton.setText(mPanel.getCustomizedButtonTitle()); }); } Loading tests/robotests/src/com/android/settings/panel/FakePanelContent.java +20 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public class FakePanelContent implements PanelContent { private CharSequence mSubTitle; private IconCompat mIcon; private int mViewType; private boolean mIsCustomizedButtonUsed = false; private CharSequence mCustomizedButtonTitle; @Override public IconCompat getIcon() { Loading Loading @@ -97,4 +99,22 @@ public class FakePanelContent implements PanelContent { public int getViewType() { return mViewType; } @Override public boolean isCustomizedButtonUsed() { return mIsCustomizedButtonUsed; } public void setIsCustomizedButtonUsed(boolean isUsed) { mIsCustomizedButtonUsed = isUsed; } @Override public CharSequence getCustomizedButtonTitle() { return mCustomizedButtonTitle; } public void setCustomizedButtonTitle(CharSequence title) { mCustomizedButtonTitle = title; } } tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; Loading Loading @@ -250,4 +251,27 @@ public class PanelFragmentTest { verify(mActivity).finish(); } @Test public void onCustomizedButtonStateChanged_isCustomized_showCustomizedTitle() { final ActivityController<FakeSettingsPanelActivity> activityController = Robolectric.buildActivity(FakeSettingsPanelActivity.class); activityController.setup(); final PanelFragment panelFragment = (PanelFragment) Objects.requireNonNull(activityController .get() .getSupportFragmentManager() .findFragmentById(R.id.main_content)); final Button seeMoreButton = panelFragment.mLayoutView.findViewById(R.id.see_more); mFakePanelContent.setIsCustomizedButtonUsed(true); mFakePanelContent.setCustomizedButtonTitle("test_title"); verify(mFakePanelContent).registerCallback(mPanelContentCbs.capture()); final PanelContentCallback panelContentCallbacks = mPanelContentCbs.getValue(); panelContentCallbacks.onCustomizedButtonStateChanged(); assertThat(seeMoreButton.getVisibility()).isEqualTo(View.VISIBLE); assertThat(seeMoreButton.getText()).isEqualTo("test_title"); } } No newline at end of file Loading
src/com/android/settings/panel/MediaOutputPanel.java +1 −1 Original line number Diff line number Diff line Loading @@ -166,7 +166,7 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC } @Override public CharSequence getCustomButtonTitle() { public CharSequence getCustomizedButtonTitle() { return mContext.getText(R.string.media_output_panel_stop_casting_button); } Loading
src/com/android/settings/panel/PanelContent.java +2 −2 Original line number Diff line number Diff line Loading @@ -86,9 +86,9 @@ public interface PanelContent extends Instrumentable { } /** * @return a string for the title of the custom button. * @return a string for the title of the customized button. */ default CharSequence getCustomButtonTitle() { default CharSequence getCustomizedButtonTitle() { return null; } Loading
src/com/android/settings/panel/PanelFragment.java +2 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ public class PanelFragment extends Fragment { mDoneButton.setOnClickListener(getCloseListener()); if (mPanel.isCustomizedButtonUsed()) { final CharSequence customTitle = mPanel.getCustomButtonTitle(); final CharSequence customTitle = mPanel.getCustomizedButtonTitle(); if (TextUtils.isEmpty(customTitle)) { mSeeMoreButton.setVisibility(View.GONE); } else { Loading Loading @@ -422,6 +422,7 @@ public class PanelFragment extends Fragment { ThreadUtils.postOnMainThread(() -> { mSeeMoreButton.setVisibility( mPanel.isCustomizedButtonUsed() ? View.VISIBLE : View.GONE); mSeeMoreButton.setText(mPanel.getCustomizedButtonTitle()); }); } Loading
tests/robotests/src/com/android/settings/panel/FakePanelContent.java +20 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public class FakePanelContent implements PanelContent { private CharSequence mSubTitle; private IconCompat mIcon; private int mViewType; private boolean mIsCustomizedButtonUsed = false; private CharSequence mCustomizedButtonTitle; @Override public IconCompat getIcon() { Loading Loading @@ -97,4 +99,22 @@ public class FakePanelContent implements PanelContent { public int getViewType() { return mViewType; } @Override public boolean isCustomizedButtonUsed() { return mIsCustomizedButtonUsed; } public void setIsCustomizedButtonUsed(boolean isUsed) { mIsCustomizedButtonUsed = isUsed; } @Override public CharSequence getCustomizedButtonTitle() { return mCustomizedButtonTitle; } public void setCustomizedButtonTitle(CharSequence title) { mCustomizedButtonTitle = title; } }
tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; Loading Loading @@ -250,4 +251,27 @@ public class PanelFragmentTest { verify(mActivity).finish(); } @Test public void onCustomizedButtonStateChanged_isCustomized_showCustomizedTitle() { final ActivityController<FakeSettingsPanelActivity> activityController = Robolectric.buildActivity(FakeSettingsPanelActivity.class); activityController.setup(); final PanelFragment panelFragment = (PanelFragment) Objects.requireNonNull(activityController .get() .getSupportFragmentManager() .findFragmentById(R.id.main_content)); final Button seeMoreButton = panelFragment.mLayoutView.findViewById(R.id.see_more); mFakePanelContent.setIsCustomizedButtonUsed(true); mFakePanelContent.setCustomizedButtonTitle("test_title"); verify(mFakePanelContent).registerCallback(mPanelContentCbs.capture()); final PanelContentCallback panelContentCallbacks = mPanelContentCbs.getValue(); panelContentCallbacks.onCustomizedButtonStateChanged(); assertThat(seeMoreButton.getVisibility()).isEqualTo(View.VISIBLE); assertThat(seeMoreButton.getText()).isEqualTo("test_title"); } } No newline at end of file