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

Commit d86bee2a authored by Stephen Bird's avatar Stephen Bird
Browse files

ListPopupWindow: set height of the list

We need to make sure that the list is the proper height
so that it does not draw off the screen.

Ideally, we would stop handling the orientation changes and allow
the app to do the orientation changes as android apps do normally.
This would require some significant changes to how our dialog
system works and could cause other potential issues.

Ticket: QRDL-882
Change-Id: I39176d56d8286ed93b71dbe4c770fe79f39ac753
parent 076be8f1
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.text.InputFilter;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
@@ -571,6 +572,20 @@ public final class DialogHelper {
        popup.setContentWidth(context.getResources().getDimensionPixelSize(R.dimen.popup_width));
        popup.setAnchorView(anchor);
        popup.setModal(true);

        // HACK: set the height to the size of the device screen width or height depending on
        // which is smaller.
        // Because we are handling the orientation change instead of letting
        // android do its thing, this never redraws. If we remove the orientation
        // change, then all the other popup dialogs break when rotating.
        // This isn't perfect, but without some significant changes to this app we cannot
        // properly do this.
        // Get the screen size, determine what number is lower, use that for the height
        DisplayMetrics dM = context.getResources().getDisplayMetrics();
        float width = dM.widthPixels / dM.density;
        float height = dM.heightPixels / dM.density;
        popup.setHeight((int)Math.min(height, width));

        return popup;
    }