androidx.appcompat.widget.AppCompatImageButton Java Examples

The following examples show how to use androidx.appcompat.widget.AppCompatImageButton. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseFragment.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
AppCompatImageButton createButton(
        @DrawableRes int imageId, @StringRes int descriptionId,
        final ISCPMessage msg, Object tag,
        int leftMargin, int rightMargin, int verticalMargin)
{
    ContextThemeWrapper wrappedContext = new ContextThemeWrapper(activity, R.style.ImageButtonPrimaryStyle);
    final AppCompatImageButton b = new AppCompatImageButton(wrappedContext, null, 0);

    final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(buttonSize, buttonSize);
    lp.setMargins(leftMargin, verticalMargin, rightMargin, verticalMargin);
    b.setLayoutParams(lp);

    b.setTag(tag);
    prepareButton(b, msg, imageId, descriptionId);
    return b;
}
 
Example #2
Source File: IntroduceActivity.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initWidget() {
    AppCompatImageButton backBtn = findViewById(R.id.activity_introduce_backBtn);
    backBtn.setOnClickListener(v -> finishSelf(true));

    if (introduceModelList.size() <= 1) {
        findViewById(R.id.activity_introduce_buttonBar).setVisibility(View.GONE);
    }

    setBottomButtonStyle(0);

    initPage();

    InkPageIndicator indicator = findViewById(R.id.activity_introduce_indicator);
    if (introduceModelList.size() <= 1) {
        indicator.setAlpha(0f);
    } else {
        indicator.setViewPager(viewPager);
        indicator.setAlpha(1f);
    }
}
 
Example #3
Source File: BasicCastUITest.java    From CastVideos-android with Apache License 2.0 6 votes vote down vote up
/**
 * Verify the Mini Controller is displayed
 * Click the Mini Controller and verify the Expanded Controller is displayed
 */
@Test
public void testMiniController() throws InterruptedException, UiObjectNotFoundException {
    mTestUtils.connectToCastDevice();
    mTestUtils.playCastContent(VIDEO_TITLE);

    // click to close expanded controller
    onView(allOf(
            isAssignableFrom(AppCompatImageButton.class)
            , withParent(isAssignableFrom(Toolbar.class))
    ))
            .check(matches(isDisplayed()))
            .perform(click());

    mTestUtils.verifyMiniController();

    mDevice.pressEnter();
    onView(withId(R.id.cast_mini_controller))
            .perform(click());

    mTestUtils.verifyExpandedController();

    mTestUtils.disconnectFromCastDevice();
}
 
Example #4
Source File: DialogPaletteSettings.java    From microMathematics with GNU General Public License v3.0 6 votes vote down vote up
private void prepareGroup(Context context, LinearLayout itemLayout, String s, List<String> visibleGroups)
{
    final AppCompatCheckBox cb = itemLayout.findViewById(R.id.dialog_palette_settings_checkbox);
    cb.setTag(s);
    cb.setChecked(visibleGroups.contains(s));
    final LinearLayout buttonLayout = itemLayout.findViewById(R.id.dialog_palette_settings_buttons);
    for (int i = 0; i < buttonLayout.getChildCount(); i++)
    {
        if (buttonLayout.getChildAt(i) instanceof AppCompatImageButton)
        {
            final AppCompatImageButton b = (AppCompatImageButton) buttonLayout.getChildAt(i);
            b.setOnLongClickListener(this);
            ViewUtils.setImageButtonColorAttr(context, b, R.attr.colorDialogContent);
        }
    }
}
 
Example #5
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
private void prepareAmplifierButtons()
{
    clearSoundVolumeButtons();
    soundControlLayout.setVisibility(View.VISIBLE);
    listeningModeLayout.setVisibility(View.GONE);

    final AmpOperationCommandMsg.Command[] commands = new AmpOperationCommandMsg.Command[]
    {
        AmpOperationCommandMsg.Command.AMTTG,
        AmpOperationCommandMsg.Command.MVLDOWN,
        AmpOperationCommandMsg.Command.MVLUP
    };
    for (AmpOperationCommandMsg.Command c : commands)
    {
        final AmpOperationCommandMsg msg = new AmpOperationCommandMsg(c.getCode());
        final AppCompatImageButton b = createButton(
                msg.getCommand().getImageId(), msg.getCommand().getDescriptionId(),
                msg, msg.getCommand().getCode());
        soundControlLayout.addView(b);
        amplifierButtons.add(b);
    }
}
 
Example #6
Source File: Palette.java    From microMathematics with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View b)
{
    if (b instanceof AppCompatImageButton)
    {
        if (b.getId() == R.id.palette_settings_button)
        {
            DialogPaletteSettings d = new DialogPaletteSettings(context, this, visibleGroups);
            d.show();
        }
        else if (listChangeIf != null)
        {
            final PaletteButton pb = (PaletteButton) b;
            listChangeIf.onPalettePressed(pb.getCode());
        }
    }
}
 
Example #7
Source File: BaseFragment.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
static void collectButtons(LinearLayout layout, ArrayList<View> out)
{
    for (int k = 0; k < layout.getChildCount(); k++)
    {
        View v = layout.getChildAt(k);
        if (v instanceof AppCompatImageButton || v instanceof AppCompatButton)
        {
            out.add(v);
        }
        else if (v instanceof TextView && v.getTag() != null)
        {
            out.add(v);
        }
        if (v instanceof LinearLayout)
        {
            collectButtons((LinearLayout) v, out);
        }
    }
}
 
Example #8
Source File: MainNavigationDrawer.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
private void updateItem(@NonNull final MenuItem m, final @DrawableRes int iconId, final String title, final ButtonListener editListener)
{
    if (m.getActionView() != null && m.getActionView() instanceof LinearLayout)
    {
        final LinearLayout l = (LinearLayout)m.getActionView();
        ((AppCompatImageView) l.findViewWithTag("ICON")).setImageResource(iconId);
        ((AppCompatTextView)l.findViewWithTag("TEXT")).setText(title);
        final AppCompatImageButton editBtn = l.findViewWithTag("EDIT");
        if (editListener != null)
        {
            editBtn.setVisibility(View.VISIBLE);
            editBtn.setOnClickListener(v -> editListener.onEditItem());
            Utils.setButtonEnabled(activity, editBtn, true);
        }
        else
        {
            editBtn.setVisibility(View.GONE);
        }
    }
    m.setVisible(true);
}
 
Example #9
Source File: ThemedToolbar.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    super.addView(child, index, params);
    if (child instanceof AppCompatImageButton) {
        mThemeComponent.addColorProperty(R.attr.actionBarTextColorPrimary, (c) ->
                ImageViewCompat.setImageTintList((ImageView) child, ColorStateList.valueOf(c)));
    } else if (child instanceof ActionMenuView) {
        mThemeComponent.addColorProperty(R.attr.actionBarTextColorPrimary, (c) -> {
            ActionMenuView ch = (ActionMenuView) child;
            Drawable d = DrawableCompat.wrap(ch.getOverflowIcon()).mutate();
            DrawableCompat.setTint(d, c);
            ch.setOverflowIcon(d);
        });
    }
}
 
Example #10
Source File: BaseFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
void prepareButton(@NonNull AppCompatImageButton b,
                   @DrawableRes final int imageId,
                   @StringRes final int descriptionId)
{
    b.setImageResource(imageId);
    if (descriptionId != -1)
    {
        b.setContentDescription(activity.getResources().getString(descriptionId));
    }
}
 
Example #11
Source File: BaseFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
void prepareButton(@NonNull AppCompatImageButton b,
                   final ISCPMessage msg,
                   @DrawableRes final int imageId,
                   @StringRes final int descriptionId)
{
    prepareButton(b, imageId, descriptionId);
    b.setImageResource(imageId);
    prepareButtonListeners(b, msg);
    setButtonEnabled(b, false);
}
 
Example #12
Source File: AwesomeToolbar.java    From AndroidNavigation with MIT License 5 votes vote down vote up
@Override
public void setNavigationIcon(@Nullable Drawable icon) {
    super.setNavigationIcon(icon);
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) {
        int count = getChildCount();
        for (int i = 0; i < count; i++) {
            View child = getChildAt(i);
            if (child instanceof AppCompatImageButton) {
                AppCompatImageButton button = (AppCompatImageButton) child;
                button.setBackgroundResource(R.drawable.nav_toolbar_button_item_background);
            }
        }
    }
}
 
Example #13
Source File: FrequencyButtonView.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateView(View view) {
    AppCompatImageButton refresh = view.findViewById(R.id.frequency_refresh);
    AppCompatImageButton reset = view.findViewById(R.id.frequency_reset);
    AppCompatImageButton restore = view.findViewById(R.id.frequency_restore);

    refresh.setOnClickListener(v -> {
        rotate(v, false);
        if (mRefreshListener != null) {
            mRefreshListener.onClick(v);
        }
    });
    reset.setOnClickListener(v -> {
        rotate(v, true);
        if (mResetListener != null) {
            mResetListener.onClick(v);
        }
    });
    restore.setOnClickListener(v -> {
        rotate(v, true);
        if (mRestoreListener != null) {
            mRestoreListener.onClick(v);
        }
    });

    setFullSpan(true);
    super.onCreateView(view);
}
 
Example #14
Source File: FrequencyButtonView.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateView(View view) {
    AppCompatImageButton refresh = view.findViewById(R.id.frequency_refresh);
    AppCompatImageButton reset = view.findViewById(R.id.frequency_reset);
    AppCompatImageButton restore = view.findViewById(R.id.frequency_restore);

    refresh.setOnClickListener(v -> {
        rotate(v, false);
        if (mRefreshListener != null) {
            mRefreshListener.onClick(v);
        }
    });
    reset.setOnClickListener(v -> {
        rotate(v, true);
        if (mResetListener != null) {
            mResetListener.onClick(v);
        }
    });
    restore.setOnClickListener(v -> {
        rotate(v, true);
        if (mRestoreListener != null) {
            mRestoreListener.onClick(v);
        }
    });

    setFullSpan(true);
    super.onCreateView(view);
}
 
Example #15
Source File: ApplicationsDialogPreferenceFragmentX.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    AppCompatImageButton addButton = view.findViewById(R.id.applications_pref_dlg_add);
    TooltipCompat.setTooltipText(addButton, getString(R.string.applications_pref_dlg_add_button_tooltip));

    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
    applicationsListView = view.findViewById(R.id.applications_pref_dlg_listview);
    //applicationsListView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
    applicationsListView.setLayoutManager(layoutManager);
    applicationsListView.setHasFixedSize(true);

    linlaProgress = view.findViewById(R.id.applications_pref_dlg_linla_progress);
    rellaDialog = view.findViewById(R.id.applications_pref_dlg_rella_dialog);

    listAdapter = new ApplicationsDialogPreferenceAdapterX(prefContext, preference, this);

    // added touch helper for drag and drop items
    ItemTouchHelper.Callback callback = new ItemTouchHelperCallback(listAdapter, false, false);
    itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(applicationsListView);

    addButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            preference.startEditor(null);
        }
    });

    refreshListView(false);
}
 
Example #16
Source File: Palette.java    From microMathematics with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onLongClick(View b)
{
    if (b instanceof AppCompatImageButton)
    {
        return ViewUtils.showButtonDescription(context, b);
    }
    return false;
}
 
Example #17
Source File: GlobalGUIRoutines.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
static void setImageButtonEnabled(boolean enabled, AppCompatImageButton item, /*int iconResId,*/ Context context) {
    item.setEnabled(enabled);
    //Drawable originalIcon = ContextCompat.getDrawable(context, iconResId);
    //Drawable icon = enabled ? originalIcon : convertDrawableToGrayScale(originalIcon);
    //item.setImageDrawable(icon);
    if (enabled)
        item.setColorFilter(null);
    else
        item.setColorFilter(context.getColor(R.color.activityDisabledTextColor), PorterDuff.Mode.SRC_IN);
}
 
Example #18
Source File: BaseFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
AppCompatImageButton createButton(
        @DrawableRes int imageId, @StringRes int descriptionId,
        final ISCPMessage msg, Object tag)
{
    return createButton(imageId, descriptionId, msg, tag,
            buttonMarginHorizontal, buttonMarginHorizontal, buttonMarginVertical);
}
 
Example #19
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void updateFeedButton(final AppCompatImageButton btn, final MenuStatusMsg.Feed feed)
{
    btn.setVisibility(feed.isImageValid() ? View.VISIBLE : View.GONE);
    if (feed.isImageValid())
    {
        btn.setImageResource(feed.getImageId());
        setButtonEnabled(btn, true);
        setButtonSelected(btn, feed == MenuStatusMsg.Feed.LOVE);
    }
}
 
Example #20
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void updateMultiroomGroupBtn(AppCompatImageButton b, @Nullable final State state)
{
    if (state != null && isGroupMenu())
    {
        final boolean isMaster = state.getMultiroomRole() == MultiroomDeviceInformationMsg.RoleType.SRC;
        b.setVisibility(View.VISIBLE);
        setButtonEnabled(b, true);
        setButtonSelected(b, isMaster);
        b.setContentDescription(activity.getString(R.string.cmd_multiroom_group));

        prepareButtonListeners(b, null, () ->
        {
            if (activity.isConnected())
            {
                final AlertDialog alertDialog = MultiroomManager.createDeviceSelectionDialog(
                        activity, b.getContentDescription());
                alertDialog.show();
                Utils.fixIconColor(alertDialog, android.R.attr.textColorSecondary);
            }
        });
    }
    else
    {
        b.setVisibility(View.GONE);
        setButtonEnabled(b, false);
    }
}
 
Example #21
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void updateInputSource(@DrawableRes int imageId, final boolean visible)
{
    AppCompatImageButton btn = rootView.findViewById(R.id.btn_input_selector);
    btn.setImageResource(imageId);
    btn.setVisibility(visible ? View.VISIBLE : View.GONE);
    setButtonEnabled(btn, false);
}
 
Example #22
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void setButtonsVisibility(List<AppCompatImageButton> buttons, int flag)
{
    for (AppCompatImageButton b : buttons)
    {
        b.setVisibility(flag);
    }
}
 
Example #23
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void setButtonsEnabled(List<AppCompatImageButton> buttons, boolean flag)
{
    for (AppCompatImageButton b : buttons)
    {
        setButtonEnabled(b, flag);
    }
}
 
Example #24
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void prepareFmDabButtons()
{
    for (AppCompatImageButton b : fmDabButtons)
    {
        String[] tokens = b.getTag().toString().split(":");
        if (tokens.length != 2)
        {
            continue;
        }
        final String msgName = tokens[0];
        switch (msgName)
        {
        case PresetCommandMsg.CODE:
            final PresetCommandMsg pMsg = new PresetCommandMsg(
                    ReceiverInformationMsg.DEFAULT_ACTIVE_ZONE, tokens[1]);
            if (pMsg.getCommand() != null)
            {
                prepareButton(b, pMsg, pMsg.getCommand().getImageId(), pMsg.getCommand().getDescriptionId());
            }
            break;
        case TuningCommandMsg.CODE:
            final TuningCommandMsg tMsg = new TuningCommandMsg(
                    ReceiverInformationMsg.DEFAULT_ACTIVE_ZONE, tokens[1]);
            if (tMsg.getCommand() != null)
            {
                prepareButton(b, tMsg, tMsg.getCommand().getImageId(), tMsg.getCommand().getDescriptionId());
            }
            break;
        }
    }
}
 
Example #25
Source File: Utils.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
public static void setButtonSelected(Context context, View b, boolean isSelected)
{
    @AttrRes int resId = isSelected ? R.attr.colorAccent : R.attr.colorButtonEnabled;
    b.setSelected(isSelected);
    if (b instanceof AppCompatImageButton)
    {
        Utils.setImageButtonColorAttr(context, (AppCompatImageButton) b, resId);
    }
    if (b instanceof AppCompatButton)
    {
        ((AppCompatButton) b).setTextColor(Utils.getThemeColorAttr(context, resId));
    }
}
 
Example #26
Source File: Utils.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
public static void setButtonEnabled(Context context, View b, boolean isEnabled)
{
    @AttrRes int resId = isEnabled ? R.attr.colorButtonEnabled : R.attr.colorButtonDisabled;
    b.setEnabled(isEnabled);
    if (b instanceof AppCompatImageButton)
    {
        Utils.setImageButtonColorAttr(context, (AppCompatImageButton) b, resId);
    }
    if (b instanceof AppCompatButton)
    {
        ((AppCompatButton) b).setTextColor(Utils.getThemeColorAttr(context, resId));
    }
}
 
Example #27
Source File: Utils.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Procedure sets AppCompatImageButton color given by attribute ID
 */
private static void setImageButtonColorAttr(Context context, AppCompatImageButton b, @AttrRes int resId)
{
    final int c = getThemeColorAttr(context, resId);
    b.clearColorFilter();
    b.setColorFilter(c, PorterDuff.Mode.SRC_ATOP);
}
 
Example #28
Source File: DeviceFragment.java    From onpc with GNU General Public License v3.0 4 votes vote down vote up
private void prepareImageButton(@IdRes int buttonId, final ISCPMessage msg)
{
    final AppCompatImageButton b = rootView.findViewById(buttonId);
    prepareButtonListeners(b, msg, friendlyName::clearFocus);
    setButtonEnabled(b, false);
}
 
Example #29
Source File: DeviceFragment.java    From onpc with GNU General Public License v3.0 4 votes vote down vote up
private void updateDeviceSettings(@NonNull final State state)
{
    // Update settings
    rootView.findViewById(R.id.settings_title).setVisibility(View.GONE);
    rootView.findViewById(R.id.settings_divider).setVisibility(View.GONE);

    // Dimmer level
    prepareSettingPanel(state, state.dimmerLevel != DimmerLevelMsg.Level.NONE,
            R.id.device_dimmer_level_layout, state.dimmerLevel.getDescriptionId(), null);

    // Digital filter
    prepareSettingPanel(state, state.digitalFilter != DigitalFilterMsg.Filter.NONE,
            R.id.device_digital_filter_layout, state.digitalFilter.getDescriptionId(), null);

    // Music Optimizer
    prepareSettingPanel(state, state.musicOptimizer != MusicOptimizerMsg.Status.NONE,
            R.id.music_optimizer_layout, state.musicOptimizer.getDescriptionId(), null);

    // Auto power
    prepareSettingPanel(state, state.autoPower != AutoPowerMsg.Status.NONE,
            R.id.device_auto_power_layout, state.autoPower.getDescriptionId(), null);

    // HDMI CEC
    prepareSettingPanel(state, state.hdmiCec != HdmiCecMsg.Status.NONE,
            R.id.hdmi_cec_layout, state.hdmiCec.getDescriptionId(), null);

    // Phase Matching Bass Command
    prepareSettingPanel(state, state.phaseMatchingBass != PhaseMatchingBassMsg.Status.NONE,
            R.id.phase_matching_bass_layout, state.phaseMatchingBass.getDescriptionId(), null);

    // Sleep time
    {
        final String description = state.sleepTime == SleepSetCommandMsg.SLEEP_OFF ?
                getStringValue(R.string.device_two_way_switch_off) :
                state.sleepTime + " " + getStringValue(R.string.device_sleep_time_minutes);
        prepareSettingPanel(state, state.sleepTime != SleepSetCommandMsg.NOT_APPLICABLE,
                R.id.sleep_time_layout, description,
                new SleepSetCommandMsg(SleepSetCommandMsg.toggle(state.sleepTime)));
    }

    // Speaker A/B (For Main zone and Zone 2 only)
    {
        final int zone = state.getActiveZone();
        final boolean zoneAllowed = (zone < 2);
        final SpeakerABStatus spState = getSpeakerABStatus(state.speakerA, state.speakerB);
        prepareSettingPanel(state, zoneAllowed && spState != SpeakerABStatus.NONE,
                R.id.speaker_ab_layout, spState.getDescriptionId(), null);
        final AppCompatImageButton b = rootView.findViewById(R.id.speaker_ab_command_toggle);
        // OFF -> A_ONLY -> B_ONLY -> ON -> A_ONLY -> B_ONLY -> ON -> A_ONLY -> ...
        switch (spState)
        {
        case NONE:
            // nothing to do
            break;
        case OFF:
        case B_ONLY:
            prepareButtonListeners(b,
                    new SpeakerACommandMsg(zone, SpeakerACommandMsg.Status.ON),
                    () -> sendQueries(zone));
            break;
        case A_ONLY:
            prepareButtonListeners(b,
                    new SpeakerBCommandMsg(zone, SpeakerBCommandMsg.Status.ON),
                    () -> {
                        activity.getStateManager().sendMessage(
                                new SpeakerACommandMsg(zone, SpeakerACommandMsg.Status.OFF));
                        sendQueries(zone);
                    });
            break;
        case ON:
            prepareButtonListeners(b,
                    new SpeakerBCommandMsg(zone, SpeakerBCommandMsg.Status.OFF),
                    () -> sendQueries(zone));
            break;
        }
    }

    // Google Cast analytics
    prepareSettingPanel(state, state.googleCastAnalytics != GoogleCastAnalyticsMsg.Status.NONE,
            R.id.google_cast_analytics_layout, state.googleCastAnalytics.getDescriptionId(),
            new GoogleCastAnalyticsMsg(GoogleCastAnalyticsMsg.toggle(state.googleCastAnalytics)));
}
 
Example #30
Source File: DeviceFragment.java    From onpc with GNU General Public License v3.0 4 votes vote down vote up
private void updateDeviceInformation(@Nullable final State state)
{
    // Host
    ((TextView) rootView.findViewById(R.id.device_info_address)).setText(
            (state != null) ? state.getHostAndPort() : "");

    // Friendly name
    final boolean isFnValid = state != null
            && state.isFriendlyName();
    final LinearLayout fnLayout = rootView.findViewById(R.id.device_friendly_name);
    fnLayout.setVisibility(isFnValid ? View.VISIBLE : View.GONE);
    if (isFnValid)
    {
        // Friendly name
        friendlyName.setText(state.getDeviceName(true));
    }

    // Receiver information
    final boolean isRiValid = state != null
            && state.isReceiverInformation()
            && !state.deviceProperties.isEmpty();
    final LinearLayout riLayout = rootView.findViewById(R.id.device_receiver_information);
    riLayout.setVisibility(isRiValid ? View.VISIBLE : View.GONE);
    if (isRiValid)
    {
        // Common properties
        ((TextView) rootView.findViewById(R.id.device_brand)).setText(state.deviceProperties.get("brand"));
        ((TextView) rootView.findViewById(R.id.device_model)).setText(state.getModel());
        ((TextView) rootView.findViewById(R.id.device_year)).setText(state.deviceProperties.get("year"));
        // Firmware version
        {
            StringBuilder version = new StringBuilder();
            version.append(state.deviceProperties.get("firmwareversion"));
            if (state.firmwareStatus != FirmwareUpdateMsg.Status.NONE)
            {
                version.append(", ").append(getStringValue(state.firmwareStatus.getDescriptionId()));
            }
            ((TextView) rootView.findViewById(R.id.device_firmware)).setText(version.toString());
        }
        // Update button
        {
            final AppCompatImageButton b = rootView.findViewById(R.id.btn_firmware_update);
            b.setVisibility((state.firmwareStatus == FirmwareUpdateMsg.Status.NEW_VERSION ||
                    state.firmwareStatus == FirmwareUpdateMsg.Status.NEW_VERSION_FORCE) ?
                    View.VISIBLE : View.GONE);
            if (b.getVisibility() == View.VISIBLE)
            {
                setButtonEnabled(b, true);
            }
        }
        // Google cast version
        ((TextView) rootView.findViewById(R.id.google_cast_version)).setText(state.googleCastVersion);
    }

    final int[] deviceInfoLayout = new int[]{
            R.id.device_info_layout,
            R.id.device_info_divider
    };
    for (int layoutId : deviceInfoLayout)
    {
        rootView.findViewById(layoutId).setVisibility(isFnValid || isRiValid ? View.VISIBLE : View.GONE);
    }
}