Project

General

Profile

« Previous | Next » 

Revision 2e99ba6a

Added by Leszek Koltunski over 2 years ago

Progress with ConfigPane.

View differences:

src/main/java/org/distorted/config/ConfigScreenPane.java
19 19

  
20 20
package org.distorted.config;
21 21

  
22
import android.util.TypedValue;
22 23
import android.widget.LinearLayout;
24
import android.widget.RadioButton;
25
import android.widget.RadioGroup;
23 26
import android.widget.TextView;
24 27

  
25 28
import org.distorted.jsons.ObjectJson;
......
35 38

  
36 39
public class ConfigScreenPane
37 40
{
38
  private static final float TEXT_RATIO = 0.015f;
41
  private static final float PADDING_RATIO = 0.015f;
42
  private static final float TEXT_RATIO    = 0.025f;
43
  private static final float RADIO_RATIO   = 0.900f;
44

  
39 45
  private JsonReader mReader;
40 46

  
41 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
64 70

  
65 71
  ConfigScreenPane(final ConfigActivity act, int objectOrdinal)
66 72
    {
73
    int height = act.getScreenHeightInPixels();
74
    float textSize = height*TEXT_RATIO;
75
    int padding = (int)(height*PADDING_RATIO);
76

  
67 77
    LinearLayout detailsLayout    = (LinearLayout)inflate( act, R.layout.config_details   , null);
68 78
    LinearLayout difficultyLayout = (LinearLayout)inflate( act, R.layout.config_difficulty, null);
69 79
    LinearLayout meshLayout       = (LinearLayout)inflate( act, R.layout.config_mesh      , null);
70 80

  
71
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f);
72
    detailsLayout.setLayoutParams(params);
73
    difficultyLayout.setLayoutParams(params);
74
    meshLayout.setLayoutParams(params);
81
    detailsLayout.setPadding(padding,padding,padding,padding/2);
82
    difficultyLayout.setPadding(padding,padding/2,padding,padding/2);
83
    meshLayout.setPadding(padding,padding/2,padding,padding);
84

  
85
    LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f);
86
    LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f);
87
    LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.3f);
88

  
89
    detailsLayout.setLayoutParams(params1);
90
    difficultyLayout.setLayoutParams(params2);
91
    meshLayout.setLayoutParams(params3);
75 92

  
76
    int height = act.getScreenHeightInPixels();
77
    float textSize = height*TEXT_RATIO;
78 93
    TextView text;
79 94
    text = detailsLayout.findViewById(R.id.configDetailsTitle);
80
    text.setTextSize(textSize);
95
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
81 96
    text = detailsLayout.findViewById(R.id.configDetailsName1);
82
    text.setTextSize(textSize);
97
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
83 98
    text = detailsLayout.findViewById(R.id.configDetailsName2);
84
    text.setTextSize(textSize);
99
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
85 100
    text = detailsLayout.findViewById(R.id.configDetailsAuthor1);
86
    text.setTextSize(textSize);
101
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
87 102
    text = detailsLayout.findViewById(R.id.configDetailsAuthor2);
88
    text.setTextSize(textSize);
103
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
89 104

  
90 105
    text = difficultyLayout.findViewById(R.id.configDifficultyTitle);
91
    text.setTextSize(textSize);
106
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
92 107
    text = meshLayout.findViewById(R.id.configMeshTitle);
93
    text.setTextSize(textSize);
108
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
109

  
110
    RadioButton butt1 = meshLayout.findViewById(R.id.meshNice);
111
    butt1.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
112
    RadioButton butt2 = meshLayout.findViewById(R.id.meshSimple);
113
    butt2.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
114

  
115
    LinearLayout layoutDiff = difficultyLayout.findViewById(R.id.configDifficultyLayout);
116
    layoutDiff.setPadding(padding,padding,padding,padding);
117

  
118
    RadioGroup radioGroup = meshLayout.findViewById(R.id.meshRadioGroup);
119

  
120
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
121
      {
122
      @Override
123
      public void onCheckedChanged(RadioGroup group, int checkedId)
124
        {
125
        if(checkedId == R.id.meshNice)
126
          {
127
          android.util.Log.e("D", "mesh Nice");
128
          }
129
        else
130
          {
131
          android.util.Log.e("D", "mesh Simple");
132
          }
133
        }
134
      });
94 135

  
95 136
    LinearLayout layout = act.findViewById(R.id.configLayout);
96 137
    layout.removeAllViews();

Also available in: Unified diff