Project

General

Profile

« Previous | Next » 

Revision 39176a1f

Added by Leszek Koltunski over 2 years ago

Make the size of the text in the spinners in the bandaged activity look right on all screen sizes.

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java
54 54
    private static final float RATIO_BUT   = 0.07f;
55 55
    static final float RATIO_SCROLL= 0.30f;
56 56

  
57
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
58
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
57
    public static final float DIALOG_BUTTON_SIZE = 0.06f;
58
    public static final float MENU_BIG_TEXT_SIZE = 0.05f;
59
    public static final float SPINNER_TEXT_SIZE  = 0.03f;
59 60

  
60 61
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
61 62
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
src/main/java/org/distorted/bandaged/BandagedCreatorScreen.java
25 25
import android.app.Activity;
26 26
import android.content.SharedPreferences;
27 27
import android.graphics.Bitmap;
28
import android.util.TypedValue;
28 29
import android.view.View;
29 30
import android.view.ViewGroup;
30 31
import android.widget.AdapterView;
......
32 33
import android.widget.ImageView;
33 34
import android.widget.LinearLayout;
34 35
import android.widget.Spinner;
36
import android.widget.TextView;
35 37

  
36 38
import org.distorted.external.RubikFiles;
37 39
import org.distorted.helpers.TransparentImageButton;
......
51 53
  private final ArrayList<BandagedCreatorObjectView> mViews;
52 54
  private Spinner mSpinnerX, mSpinnerY, mSpinnerZ;
53 55
  private boolean mSpinnersReady;
56
  private float mTextSize;
54 57

  
55 58
///////////////////////////////////////////////////////////////////////////////////////////////////
56 59

  
......
149 152
    {
150 153
    mAct = new WeakReference<>(act);
151 154
    mObjectView = act.findViewById(R.id.bandagedCreatorView);
155
    mTextSize = act.getScreenHeightInPixels()*BandagedCreatorActivity.SPINNER_TEXT_SIZE;
152 156

  
153 157
    int width  = act.getScreenWidthInPixels();
154 158
    int height = act.getScreenHeightInPixels();
......
180 184

  
181 185
    mSpinnerX = act.findViewById(R.id.bandagedCreatorX);
182 186
    mSpinnerX.setOnItemSelectedListener(this);
183
    ArrayAdapter<String> adX = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, createSizes("X") );
187
    ArrayAdapter<String> adX = new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("X") );
184 188
    adX.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
185 189
    mSpinnerX.setAdapter(adX);
186 190

  
187 191
    mSpinnerY = act.findViewById(R.id.bandagedCreatorY);
188 192
    mSpinnerY.setOnItemSelectedListener(this);
189
    ArrayAdapter<String> adY = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, createSizes("Y") );
193
    ArrayAdapter<String> adY = new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("Y") );
190 194
    adY.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
191 195
    mSpinnerY.setAdapter(adY);
192 196

  
193 197
    mSpinnerZ = act.findViewById(R.id.bandagedCreatorZ);
194 198
    mSpinnerZ.setOnItemSelectedListener(this);
195
    ArrayAdapter<String> adZ = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, createSizes("Z") );
199
    ArrayAdapter<String> adZ = new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("Z") );
196 200
    adZ.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
197 201
    mSpinnerZ.setAdapter(adZ);
198 202

  
......
341 345
      {
342 346
      int spinnerID = parent.getId();
343 347

  
348
      ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,mTextSize);
349

  
344 350
      if( spinnerID==R.id.bandagedCreatorX )
345 351
        {
346 352
        mX = pos;
src/main/java/org/distorted/dialogs/RubikDialogBandagedSettings.java
48 48
public class RubikDialogBandagedSettings extends AppCompatDialogFragment implements AdapterView.OnItemSelectedListener
49 49
  {
50 50
  private int mAnimPos, mScraPos;
51
  private float mTextSize;
51 52

  
52 53
///////////////////////////////////////////////////////////////////////////////////////////////////
53 54

  
......
80 81
    scramble.setOnItemSelectedListener(this);
81 82
    String[] scrambleModes = createScrambleModes();
82 83

  
83
    ArrayAdapter<String> scrambleAdapter = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, scrambleModes );
84
    ArrayAdapter<String> scrambleAdapter = new ArrayAdapter<>(act, R.layout.spinner_item, scrambleModes );
84 85
    scrambleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
85 86
    scramble.setAdapter(scrambleAdapter);
86 87
    scramble.setSelection(mScraPos);
......
89 90
    animation.setOnItemSelectedListener(this);
90 91
    String[] animationModes = { "ON" , "OFF" };
91 92

  
92
    ArrayAdapter<String> animationAdapter = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, animationModes );
93
    ArrayAdapter<String> animationAdapter = new ArrayAdapter<>(act, R.layout.spinner_item, animationModes );
93 94
    animationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
94 95
    animation.setAdapter(animationAdapter);
95 96
    animation.setSelection(mAnimPos);
......
102 103
    {
103 104
    int spinnerID = parent.getId();
104 105

  
106
    ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,mTextSize);
107

  
105 108
    if( spinnerID == R.id.bandaged_spinner_scramble )
106 109
      {
107 110
      mScraPos = pos;
......
131 134
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
132 135
    final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
133 136
    final float okSize   = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
134
    final float textSize = displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
137
    mTextSize = displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
135 138

  
136 139
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
137 140
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
......
171 174
      });
172 175

  
173 176
    final View view = inflater.inflate(R.layout.dialog_settings, null);
174
    configureView(act,view,textSize,scraPos,animPos);
177
    configureView(act,view,mTextSize,scraPos,animPos);
175 178
    builder.setView(view);
176 179

  
177 180
    Dialog dialog = builder.create();
src/main/res/layout/spinner_item.xml
1
<?xml version="1.0" encoding="utf-8"?>
2

  
3
<TextView
4
    xmlns:android="http://schemas.android.com/apk/res/android"
5
    android:layout_width="match_parent"
6
    android:layout_height="wrap_content"
7
    android:textSize="30sp"
8
    android:gravity="center"
9
    android:textColor="#FFFFFF"
10
    android:padding="5dip"
11
    />

Also available in: Unified diff