Update customize button title when state changed
- This CL update customize button title when onCustomizedButtonStateChanged() is called. - Add test case Bug: 152002708 Test: make -j42 RunSettingsRoboTests Change-Id: I85c9cf90305757e279c058db2875e303b4add437
This commit is contained in:
@@ -166,7 +166,7 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getCustomButtonTitle() {
|
public CharSequence getCustomizedButtonTitle() {
|
||||||
return mContext.getText(R.string.media_output_panel_stop_casting_button);
|
return mContext.getText(R.string.media_output_panel_stop_casting_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -216,7 +216,7 @@ public class PanelFragment extends Fragment {
|
|||||||
mDoneButton.setOnClickListener(getCloseListener());
|
mDoneButton.setOnClickListener(getCloseListener());
|
||||||
|
|
||||||
if (mPanel.isCustomizedButtonUsed()) {
|
if (mPanel.isCustomizedButtonUsed()) {
|
||||||
final CharSequence customTitle = mPanel.getCustomButtonTitle();
|
final CharSequence customTitle = mPanel.getCustomizedButtonTitle();
|
||||||
if (TextUtils.isEmpty(customTitle)) {
|
if (TextUtils.isEmpty(customTitle)) {
|
||||||
mSeeMoreButton.setVisibility(View.GONE);
|
mSeeMoreButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@@ -422,6 +422,7 @@ public class PanelFragment extends Fragment {
|
|||||||
ThreadUtils.postOnMainThread(() -> {
|
ThreadUtils.postOnMainThread(() -> {
|
||||||
mSeeMoreButton.setVisibility(
|
mSeeMoreButton.setVisibility(
|
||||||
mPanel.isCustomizedButtonUsed() ? View.VISIBLE : View.GONE);
|
mPanel.isCustomizedButtonUsed() ? View.VISIBLE : View.GONE);
|
||||||
|
mSeeMoreButton.setText(mPanel.getCustomizedButtonTitle());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,8 @@ public class FakePanelContent implements PanelContent {
|
|||||||
private CharSequence mSubTitle;
|
private CharSequence mSubTitle;
|
||||||
private IconCompat mIcon;
|
private IconCompat mIcon;
|
||||||
private int mViewType;
|
private int mViewType;
|
||||||
|
private boolean mIsCustomizedButtonUsed = false;
|
||||||
|
private CharSequence mCustomizedButtonTitle;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IconCompat getIcon() {
|
public IconCompat getIcon() {
|
||||||
@@ -97,4 +99,22 @@ public class FakePanelContent implements PanelContent {
|
|||||||
public int getViewType() {
|
public int getViewType() {
|
||||||
return mViewType;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -250,4 +251,27 @@ public class PanelFragmentTest {
|
|||||||
|
|
||||||
verify(mActivity).finish();
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user