leinardi / leinardi/FloatingActionButtonSpeedDial

Orientation change issue

Open
#139 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug Type: Question
Dominant language
Java
Stars
1.5k
Forks
149
PR merge metrics
No merged PRs in 30d

Description

Orientation issue

Hi

I started using this speed dial and I'm running into an issue with orientation

In protrait mode I load items and set lables. in landscape mode I do noty set the labels

when the activity detects an orientation change I clear the itmes and reload them with labels on or off based on the orientation.
I also set the oriienation of the speed dial itsel and reopen it if it was open before the orientation change

Starting in protrait mode: all is good. FABs are displayed vertivcally with labels.
Change to landscape mode: all is good. FABS displayed horizontally without labels
Back to protrait: Problem: FABS are displayed vertically but the labels are missing.

Is there somethins I'm missing?

Thanks for the help

Here is the orientation change code:

@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); boolean open = mSpeedDialView.isOpen();
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        setFabItems(newConfig.orientation);
        mSpeedDialView.setOrientation(LinearLayout.VERTICAL);
    } else {
        setFabItems(newConfig.orientation);
        mSpeedDialView.setOrientation(LinearLayout.HORIZONTAL);
    }
    
    mSpeedDialView.requestLayout();
    if (open) {
        mSpeedDialView.open();
    }
}
private void setFabItems(int orientation) { SpeedDialActionItem item1 = null; SpeedDialActionItem item2 = null;
    mSpeedDialView.clearActionItems();
    
    if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        item1 = new SpeedDialActionItem.Builder(R.id.fab_item1, R.drawable.ic_fab_item1)
                .setLabel(R.string.fab_item1)
                .setFabBackgroundColor(getResources().getColor(R.color.colorPrimary, null))
                .setLabelBackgroundColor(getResources().getColor(R.color.colorPrimaryDark, null))
                .setLabelColor(getResources().getColor(R.color.grey_18, null))
                .create();

        item2 = new SpeedDialActionItem.Builder(R.id.fab_item2, R.drawable.ic_fab_item2)
                .setLabel(R.string.fab_item2)
                .setFabBackgroundColor(getResources().getColor(R.color.colorPrimary, null))
                .setLabelBackgroundColor(getResources().getColor(R.color.colorPrimaryDark, null))
                .setLabelColor(getResources().getColor(R.color.grey_18, null))
                .create();
    } else {
        item1 = new SpeedDialActionItem.Builder(R.id.fab_item1, R.drawable.ic_fab_item1)
                .setLabel(R.string.fab_item1)
                .setFabBackgroundColor(getResources().getColor(R.color.colorPrimary, null))
                .create();

        item2 = new SpeedDialActionItem.Builder(R.id.fab_item2, R.drawable.ic_fab_item2)
                .setLabel(R.string.fab_item2)
                .setFabBackgroundColor(getResources().getColor(R.color.colorPrimary, null))
                .create();
    }

    mSpeedDialView.addActionItem(item1);
    mSpeedDialView.addActionItem(item2);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the orientation-change flow in onConfigurationChanged and setFabItems, focusing on how mSpeedDialView handles action items and labels after clearActionItems(). Reproduce the portrait-to-landscape-to-portrait sequence and verify that the portrait labels are restored when the speed dial is reopened.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.