Revision 362807f0
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/dialogs/RubikDialogScoresView.java | ||
---|---|---|
23 | 23 |
import android.content.res.Resources; |
24 | 24 |
import androidx.fragment.app.FragmentActivity; |
25 | 25 |
import android.util.AttributeSet; |
26 |
import android.util.TypedValue; |
|
26 | 27 |
import android.view.View; |
27 | 28 |
import android.widget.FrameLayout; |
28 | 29 |
import android.widget.ImageView; |
... | ... | |
30 | 31 |
import android.widget.TextView; |
31 | 32 |
|
32 | 33 |
import org.distorted.main.R; |
34 |
import org.distorted.main.RubikActivity; |
|
33 | 35 |
import org.distorted.objects.RubikObjectList; |
34 | 36 |
import org.distorted.scores.RubikScores; |
35 | 37 |
|
... | ... | |
39 | 41 |
|
40 | 42 |
public class RubikDialogScoresView extends FrameLayout |
41 | 43 |
{ |
42 |
LinearLayout mLayout; |
|
44 |
private LinearLayout mLayout; |
|
45 |
private int mWidth; |
|
43 | 46 |
|
44 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
45 | 48 |
|
... | ... | |
57 | 60 |
|
58 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
59 | 62 |
|
60 |
public RubikDialogScoresView(Context context, boolean isSubmitting) |
|
63 |
public RubikDialogScoresView(Context context, int width, boolean isSubmitting)
|
|
61 | 64 |
{ |
62 | 65 |
super(context); |
63 | 66 |
|
67 |
mWidth = width; |
|
68 |
|
|
64 | 69 |
View view = inflate(context, R.layout.dialog_scores_downloading, null); |
65 | 70 |
addView(view); |
66 | 71 |
TextView text = findViewById(R.id.message_text); |
... | ... | |
75 | 80 |
TextView text = levelLayout.findViewById(R.id.scoresScrambleTitle); |
76 | 81 |
text.setText(act.getString(R.string.lv_placeholder,level+1)); |
77 | 82 |
|
83 |
int size = (int)(mWidth* RubikActivity.SCORES_LEVEL_TEXT); |
|
84 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
85 |
|
|
78 | 86 |
Resources res = act.getResources(); |
79 | 87 |
String packageName = act.getPackageName(); |
80 | 88 |
|
... | ... | |
93 | 101 |
String theirTime; |
94 | 102 |
int theirCountryID; |
95 | 103 |
|
104 |
int height = (int)(mWidth* RubikActivity.SCORES_ITEM_TEXT); |
|
96 | 105 |
int white = res.getColor(R.color.white); |
97 | 106 |
int red = res.getColor(R.color.red); |
98 | 107 |
boolean equals; |
... | ... | |
104 | 113 |
if( !mySubmitted && myRecordInSeconds<time[j] && !inserted ) |
105 | 114 |
{ |
106 | 115 |
inserted = true; |
107 |
View row = createRow(act, myCountryID, myName, myRecord, red); |
|
116 |
View row = createRow(act, myCountryID, myName, myRecord, height, red);
|
|
108 | 117 |
levelLayout.addView(row); |
109 | 118 |
} |
110 | 119 |
|
... | ... | |
115 | 124 |
if( equals ) inserted=true; |
116 | 125 |
theirCountryID = res.getIdentifier( country[j], "drawable", packageName); |
117 | 126 |
theirTime = Float.toString(time[j]); |
118 |
View row = createRow(act, theirCountryID, name[j], theirTime, equals ? red:white); |
|
127 |
View row = createRow(act, theirCountryID, name[j], theirTime, height, equals ? red:white);
|
|
119 | 128 |
levelLayout.addView(row); |
120 | 129 |
} |
121 | 130 |
} |
... | ... | |
123 | 132 |
|
124 | 133 |
if( !inserted ) |
125 | 134 |
{ |
126 |
View row = createRow(act, myCountryID, myName, myRecord, red); |
|
135 |
View row = createRow(act, myCountryID, myName, myRecord, height, red);
|
|
127 | 136 |
levelLayout.addView(row); |
128 | 137 |
} |
129 | 138 |
|
... | ... | |
132 | 141 |
|
133 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 143 |
|
135 |
private View createRow(FragmentActivity act, int countryID, String name, String time, int color) |
|
144 |
private View createRow(FragmentActivity act, int countryID, String name, String time, int height, int color)
|
|
136 | 145 |
{ |
137 | 146 |
View row = inflate(act, R.layout.dialog_scores_scramble_row, null); |
138 | 147 |
|
... | ... | |
147 | 156 |
textName.setTextColor(color); |
148 | 157 |
textTime.setTextColor(color); |
149 | 158 |
|
159 |
textName.setTextSize(TypedValue.COMPLEX_UNIT_PX, height); |
|
160 |
textTime.setTextSize(TypedValue.COMPLEX_UNIT_PX, height); |
|
161 |
|
|
150 | 162 |
return row; |
151 | 163 |
} |
152 | 164 |
|
Also available in: Unified diff
Make the Scores Dialog screen-size invariant.