Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5399c512 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Update customize button title when state changed" into rvc-dev am: b11a46cf

Change-Id: I47a54efbdbcb2b052cd4ba04881630109bd7dd52
parents d96297e8 b11a46cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }

+2 −2
Original line number Diff line number Diff line
@@ -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;
    }

+2 −1
Original line number Diff line number Diff line
@@ -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 {
@@ -422,6 +422,7 @@ public class PanelFragment extends Fragment {
            ThreadUtils.postOnMainThread(() -> {
                mSeeMoreButton.setVisibility(
                        mPanel.isCustomizedButtonUsed() ? View.VISIBLE : View.GONE);
                mSeeMoreButton.setText(mPanel.getCustomizedButtonTitle());
            });
        }

+20 −0
Original line number Diff line number Diff line
@@ -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() {
@@ -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;
    }
}
+24 −0
Original line number Diff line number Diff line
@@ -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;

@@ -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