«
Previous
|
Next
»
Revision 0651572f
Added by Leszek Koltunski about 6 hours ago
- ID 0651572f8bcc096e076ae6c396956bb998fec092
- Parent 4660cd9d
| src/main/java/org/distorted/dialogs/DialogUpdates.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import android.app.Dialog; |
| 15 | 15 |
import android.graphics.Bitmap; |
| 16 |
import android.util.DisplayMetrics; |
|
| 16 | 17 |
import android.util.TypedValue; |
| 17 | 18 |
import android.view.View; |
| 18 | 19 |
import android.view.Window; |
| ... | ... | |
| 42 | 43 |
{
|
| 43 | 44 |
super.onResume(); |
| 44 | 45 |
|
| 45 |
Window window = getDialog().getWindow();
|
|
| 46 |
Dialog dialog = getDialog();
|
|
| 46 | 47 |
|
| 47 |
if( window!=null )
|
|
| 48 |
if( dialog!=null )
|
|
| 48 | 49 |
{
|
| 49 |
WindowManager.LayoutParams params = window.getAttributes(); |
|
| 50 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f ); |
|
| 51 |
window.setAttributes(params); |
|
| 50 |
Window window = dialog.getWindow(); |
|
| 51 |
|
|
| 52 |
if( window!=null ) |
|
| 53 |
{
|
|
| 54 |
WindowManager.LayoutParams params = window.getAttributes(); |
|
| 55 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f ); |
|
| 56 |
|
|
| 57 |
DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); |
|
| 58 |
int maxHeight = (int) (displayMetrics.heightPixels * 0.80); |
|
| 59 |
|
|
| 60 |
View contentView = dialog.findViewById(android.R.id.content); |
|
| 61 |
|
|
| 62 |
if (contentView != null) |
|
| 63 |
{
|
|
| 64 |
int widthSpec = View.MeasureSpec.makeMeasureSpec(displayMetrics.widthPixels, View.MeasureSpec.AT_MOST); |
|
| 65 |
int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); |
|
| 66 |
contentView.measure(widthSpec, heightSpec); |
|
| 67 |
int desiredHeight = contentView.getMeasuredHeight(); |
|
| 68 |
params.height = Math.min(desiredHeight, maxHeight); |
|
| 69 |
} |
|
| 70 |
else params.height = maxHeight; |
|
| 71 |
|
|
| 72 |
window.setAttributes(params); |
|
| 73 |
} |
|
| 52 | 74 |
} |
| 53 | 75 |
} |
| 54 | 76 |
|
| ... | ... | |
| 79 | 101 |
mText = view.findViewById(R.id.dialog_scrollable_message); |
| 80 | 102 |
mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
| 81 | 103 |
mText.setText( act.getString(R.string.downloading) ); |
| 82 |
|
|
| 83 |
mLayout.setMinimumHeight(minH); |
|
| 84 | 104 |
mText.setMinimumHeight(minH); |
| 85 |
view.setMinimumHeight(minH); |
|
| 86 | 105 |
|
| 87 | 106 |
RubikNetwork network = RubikNetwork.getInstance(); |
| 88 | 107 |
network.signUpForUpdates(this); |
Also available in: Unified diff
Improve DialogUpdates