Revision fb37b424
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/dialogs/RubikDialogSolved.java | ||
---|---|---|
26 | 26 |
import androidx.fragment.app.FragmentActivity; |
27 | 27 |
import androidx.appcompat.app.AlertDialog; |
28 | 28 |
import androidx.appcompat.app.AppCompatDialogFragment; |
29 |
|
|
30 |
import android.util.DisplayMetrics; |
|
31 |
import android.util.TypedValue; |
|
29 | 32 |
import android.view.LayoutInflater; |
30 | 33 |
import android.view.View; |
31 | 34 |
import android.view.Window; |
32 | 35 |
import android.view.WindowManager; |
36 |
import android.widget.Button; |
|
33 | 37 |
import android.widget.TextView; |
34 | 38 |
|
35 | 39 |
import org.distorted.main.R; |
... | ... | |
48 | 52 |
LayoutInflater inflater = act.getLayoutInflater(); |
49 | 53 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
50 | 54 |
|
55 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
56 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
57 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
58 |
final float okSize = displaymetrics.widthPixels * RubikActivity.MENU_MEDIUM_TEXT_SIZE; |
|
59 |
final float textSize = displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
60 |
|
|
51 | 61 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
62 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
52 | 63 |
tv.setText(R.string.solved); |
53 | 64 |
builder.setCustomTitle(tv); |
54 | 65 |
|
... | ... | |
77 | 88 |
|
78 | 89 |
final View view = inflater.inflate(R.layout.dialog_solved, null); |
79 | 90 |
TextView text = view.findViewById(R.id.solved_time); |
91 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
80 | 92 |
text.setText(getString(R.string.ti_placeholder, (time/100)/10.0f)); |
81 | 93 |
builder.setView(view); |
82 | 94 |
|
... | ... | |
91 | 103 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
92 | 104 |
} |
93 | 105 |
|
106 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
107 |
{ |
|
108 |
@Override |
|
109 |
public void onShow(DialogInterface dialog) |
|
110 |
{ |
|
111 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
112 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
113 |
} |
|
114 |
}); |
|
115 |
|
|
94 | 116 |
return dialog; |
95 | 117 |
} |
96 | 118 |
} |
Also available in: Unified diff
Improvements to the UI - make it proportional regardless of the physical screen size. (Part 6 - next 5 Dialogs)