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

Commit cc0069e4 authored by timhypeng's avatar timhypeng
Browse files

Add listener for panel header icon

Bug: 146813761
Test: make -j42 RunSettingsRoboTests
Change-Id: I473b535593d4ecb445027d6c7dafbb235a70ffcf
parent 9ccbadeb
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ public interface PanelContent extends Instrumentable {
     */
    List<Uri> getSlices();


    /**
     * @return an {@link Intent} to the full content in Settings that is summarized by the Panel.
     *
@@ -64,4 +63,15 @@ public interface PanelContent extends Instrumentable {
     * </p>
     */
    Intent getSeeMoreIntent();

    /**
     * @return an {@link Intent} to the go to the target activity.
     *
     * <p>
     *     A common usage is to go back to previous panel.
     * </p>
     */
    default Intent getHeaderIconIntent() {
        return null;
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -201,6 +201,9 @@ public class PanelFragment extends Fragment {
            mTitleIcon.setImageIcon(icon.toIcon(getContext()));
            mHeaderTitle.setText(mPanel.getTitle());
            mHeaderSubtitle.setText(mPanel.getSubTitle());
            if (mPanel.getHeaderIconIntent() != null) {
                mTitleIcon.setOnClickListener(getHeaderIconListener());
            }
        }
        mSeeMoreButton.setOnClickListener(getSeeMoreListener());
        mDoneButton.setOnClickListener(getCloseListener());
@@ -381,4 +384,12 @@ public class PanelFragment extends Fragment {
            getActivity().finish();
        };
    }

    @VisibleForTesting
    View.OnClickListener getHeaderIconListener() {
        return (v) -> {
            final FragmentActivity activity = getActivity();
            activity.startActivity(mPanel.getHeaderIconIntent());
        };
    }
}