android-satellite-menu icon indicating copy to clipboard operation
android-satellite-menu copied to clipboard

Strange behavior on Xperia S

Open adgeg opened this issue 12 years ago • 8 comments

Hello,

I am using your animation for an application, and it works perfectly.

The only bug I have is on Sony Xperia S (with Android 4.0.4), at the end of the animation. Indeed, buttons don't stay in the place where they should stay : they are all located in a same vertical line (http://file.rspreprod.fr/Screenshot_XperiaS.png)

Do you have an idea on how to fix it ?

Thanks by advance,

Gabriel

adgeg avatar Oct 25 '12 17:10 adgeg

Hi,

I also experienced the same issue on sony Xperia S (Android 4.0.4).

The menu buttons open nicely but gets pushed towards left the next moment.

Any help would be appreciated.

Thanks,

Sunny

pariharsunny avatar Dec 12 '12 06:12 pariharsunny

Hi Sunny,

I found a really UGLY way to fix this bug on Xperia. Indeed, I didn't find a generic way to fix this, just a special case for this device... BTW, if you really want a fix, it works.

In SatelliteMenu.java :

Modify addItems :

     public void addItems(List<SatelliteMenuItem> items) {
    // special case for Sony Xperia S (ugly, I'm sorry...)
    if(android.os.Build.MODEL.equals("LT26i")){
        theWorstHandlingOfExceptionOfAllTheTimes(items);
        return;
    }
            ....
      }

And create a new method :

 /* Special handling of a strange bug in displaying of items on Sony Xperia S.
 * Caution child, this is done nearly the worst way it could.
 * Don't try this at home ! 
 */
private void theWorstHandlingOfExceptionOfAllTheTimes(List<SatelliteMenuItem> items) {
    RelativeLayout relativeLayout = new RelativeLayout(getContext());
    // Appreciate the hard coding dimensions
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            satelliteDistance + 100, satelliteDistance + 100);
    layoutParams.gravity = Gravity.BOTTOM;
    relativeLayout.setLayoutParams(layoutParams);

    menuItems.addAll(items);
    this.removeView(imgMain);
    float[] degrees = getDegrees(menuItems.size());
    int index = 0;
    for (SatelliteMenuItem menuItem : menuItems) {
        int finalX = SatelliteAnimationCreator.getTranslateX(degrees[index], satelliteDistance);
        int finalY = SatelliteAnimationCreator.getTranslateY(degrees[index], satelliteDistance);

        CustomView itemView = (CustomView) LayoutInflater.from(getContext()).inflate(
                R.layout.sat_item_cr, this, false);
        CustomView cloneView = (CustomView) LayoutInflater.from(getContext()).inflate(
                R.layout.sat_item_cr, this, false);
        itemView.setTag(menuItem.getId());
        cloneView.setVisibility(View.GONE);
        itemView.setVisibility(View.GONE);

        cloneView.setOnClickListener(internalItemClickListener);
        cloneView.setTag(Integer.valueOf(menuItem.getId()));
        RelativeLayout.LayoutParams layoutParamsClone = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        // And again... 
        int finalYInverse = Math.abs(SatelliteAnimationCreator.getTranslateY(degrees[index],
                satelliteDistance)) - 20;
        int finalXInverse = Math.abs(SatelliteAnimationCreator.getTranslateX(degrees[index],
                satelliteDistance));
        layoutParamsClone.setMargins(finalXInverse, satelliteDistance - finalYInverse, 0, 0);
        cloneView.setLayoutParams(layoutParamsClone);
        if (menuItem.getImgResourceId() > 0) {
            itemView.setImageResource(menuItem.getImgResourceId());
            cloneView.setImageResource(menuItem.getImgResourceId());
        } else if (menuItem.getImgDrawable() != null) {
            itemView.setImageDrawable(menuItem.getImgDrawable());
            cloneView.setImageDrawable(menuItem.getImgDrawable());
        }

        Animation itemOut = SatelliteAnimationCreator.createItemOutAnimation(getContext(),
                index, expandDuration, finalX, finalY);
        Animation itemIn = SatelliteAnimationCreator.createItemInAnimation(getContext(), index,
                expandDuration, finalX, finalY);
        Animation itemClick = SatelliteAnimationCreator.createItemClickAnimation(getContext());

        menuItem.setView(itemView);
        menuItem.setCloneView(cloneView);
        menuItem.setInAnimation(itemIn);
        menuItem.setOutAnimation(itemOut);
        menuItem.setClickAnimation(itemClick);
        menuItem.setFinalX(finalX);
        menuItem.setFinalY(finalY);

        itemIn.setAnimationListener(new SatelliteAnimationListener(itemView, true,
                viewToItemMap));
        itemOut.setAnimationListener(new SatelliteAnimationListener(itemView, false,
                viewToItemMap));
        itemClick.setAnimationListener(new SatelliteItemClickAnimationListener(this, menuItem
                .getId()));

        this.addView(itemView);
        relativeLayout.addView(cloneView);
        viewToItemMap.put(itemView, menuItem);
        viewToItemMap.put(cloneView, menuItem);
        index++;
    }

    this.addView(relativeLayout);
    this.addView(imgMain);
}

Hope it will help you...

Gabriel

adgeg avatar Dec 12 '12 12:12 adgeg

Hi Gabriel,

Could please explain what kind of object is: CustomView in the below line of code:

CustomView itemView = (CustomView) LayoutInflater.from(getContext()).inflate( R.layout.sat_item_cr, this, false);

As, the android is unable to resolve it.

Thanks, Sunny

pariharsunny avatar Dec 13 '12 06:12 pariharsunny

Sorry, I forgot that I use my own view instead of the original ImageView. Just use the same image view than in addItems method :

ImageView itemView = (ImageView) LayoutInflater.from(getContext())
                .inflate(R.layout.sat_item_cr, this, false);
ImageView cloneView = (ImageView) LayoutInflater.from(getContext())
                .inflate(R.layout.sat_item_cr, this, false);

Cheers,

Gabriel

adgeg avatar Dec 13 '12 11:12 adgeg

Hi,

I had a similar bug on an Xperia, running 4.0.4. Changing from a FrameLayout to a RelativeLayout seemed to fix the problem for me

dwally89 avatar May 20 '13 10:05 dwally89

Hi dwally, I tried changing from FrameLayout to a RelativeLayout,but its not working. Can you please share your code.

Thanks.

anilari89 avatar Jun 11 '13 14:06 anilari89

Hi I faced the same problem on Xperia Neo L. This fixed it thank you. Do you know if it's like this only on xperia devices or there are other devices that show similar behavior? EDIT: I was wrong. I tested it on Xperia M and it works fine. It was just my own device so I added MT25i to the black list.

sorooshstrife avatar Oct 22 '14 06:10 sorooshstrife

my device oppo find5t,china phone

dosoos avatar Oct 22 '14 07:10 dosoos