Revision 2eb74743
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/dialogs/RubikDialogAbout.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import android.text.method.LinkMovementMethod; |
33 | 33 |
import android.text.method.MovementMethod; |
34 |
import android.util.DisplayMetrics; |
|
35 |
import android.util.TypedValue; |
|
34 | 36 |
import android.view.LayoutInflater; |
35 | 37 |
import android.view.View; |
36 | 38 |
import android.view.Window; |
37 | 39 |
import android.view.WindowManager; |
40 |
import android.widget.Button; |
|
38 | 41 |
import android.widget.TextView; |
39 | 42 |
|
40 | 43 |
import org.distorted.main.R; |
44 |
import org.distorted.main.RubikActivity; |
|
41 | 45 |
|
42 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 47 |
|
... | ... | |
51 | 55 |
LayoutInflater inflater = act.getLayoutInflater(); |
52 | 56 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
53 | 57 |
|
58 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
59 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
60 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
61 |
final float okSize = displaymetrics.widthPixels * RubikActivity.MENU_MEDIUM_TEXT_SIZE; |
|
62 |
final float textSize = displaymetrics.widthPixels * RubikActivity.MENU_SMALL_TEXT_SIZE; |
|
63 |
|
|
54 | 64 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
65 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
55 | 66 |
tv.setText(R.string.about); |
56 | 67 |
builder.setCustomTitle(tv); |
57 | 68 |
|
... | ... | |
77 | 88 |
} |
78 | 89 |
catch (PackageManager.NameNotFoundException e) |
79 | 90 |
{ |
80 |
appVers = "1.1.1";
|
|
91 |
appVers = "1.2.2";
|
|
81 | 92 |
} |
82 | 93 |
|
94 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
83 | 95 |
text.setText(getString(R.string.ap_placeholder,appName, appVers)); |
84 | 96 |
|
85 | 97 |
MovementMethod mm = LinkMovementMethod.getInstance(); |
86 | 98 |
TextView text1 = view.findViewById(R.id.about_section1); |
99 |
text1.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
87 | 100 |
text1.setMovementMethod(mm); |
88 | 101 |
TextView text2 = view.findViewById(R.id.about_section2); |
102 |
text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
89 | 103 |
text2.setMovementMethod(mm); |
90 | 104 |
TextView text3 = view.findViewById(R.id.about_section3); |
105 |
text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
91 | 106 |
text3.setMovementMethod(mm); |
92 | 107 |
|
93 | 108 |
builder.setView(view); |
... | ... | |
101 | 116 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
102 | 117 |
} |
103 | 118 |
|
119 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
120 |
{ |
|
121 |
@Override |
|
122 |
public void onShow(DialogInterface dialog) |
|
123 |
{ |
|
124 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
125 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
126 |
} |
|
127 |
}); |
|
128 |
|
|
104 | 129 |
return dialog; |
105 | 130 |
} |
106 | 131 |
} |
Also available in: Unified diff
Improvements to the UI - make it proportional regardless of the physical screen size. (Part 5 - first 3 Dialogs)