Project

General

Profile

« Previous | Next » 

Revision 47ba5ddc

Added by Leszek Koltunski over 4 years ago

RubikCube: further fixes

View differences:

src/main/java/org/distorted/magic/RubikSettings.java
43 43
  {
44 44
  private TextView[] mDurationText;
45 45

  
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

  
48
  public RubikSettings()
49
    {
50
    mDurationText = new TextView[BaseEffect.Type.LENGTH];
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

  
55
  @NonNull
56
  @Override
57
  public Dialog onCreateDialog(Bundle savedInstanceState)
58
    {
59
    FragmentActivity act = getActivity();
60
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
61
    builder.setCancelable(false);
62

  
63
    LayoutInflater inflater = act.getLayoutInflater();
64
    final View view = inflater.inflate(R.layout.settings, null);
65
    builder.setView(view);
66

  
67
    LinearLayout linearLayout = view.findViewById(R.id.main_settings_layout);
68

  
69
    if( linearLayout!=null )
70
      {
71
      for (int i=0; i< BaseEffect.Type.LENGTH; i++)
72
        {
73
        createSettingsSection(act,linearLayout,i);
74
        }
75
      }
76
    else
77
      {
78
      android.util.Log.e("settings", "linearLayout NULL!");
79
      }
80

  
81
    return builder.create();
82
    }
83

  
84 46
///////////////////////////////////////////////////////////////////////////////////////////////////
85 47

  
86 48
  private void createSettingsSection(FragmentActivity act, LinearLayout layout, int index)
......
88 50
    BaseEffect.Type beType = BaseEffect.Type.getType(index);
89 51
    float scale = act.getResources().getDisplayMetrics().density;
90 52

  
91
    ///// TEXT ///////////////////////////////////////////////////////////////////////////
92

  
93
    int layoutHeight = (int)(scale*48 + 0.5f);
94
    int padding      = (int)(scale*10 + 0.5f);
95

  
96
    LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,layoutHeight);
97

  
98
    TextView textView = new TextView(act);
99
    textView.setText(beType.getText());
100
    textView.setLayoutParams(textParams);
101
    textView.setGravity(Gravity.START|Gravity.CENTER);
102
    textView.setPadding(padding,0,padding,0);
103
    textView.setTextAppearance(android.R.style.TextAppearance_Medium);
104
    layout.addView(textView);
105

  
106 53
    ///// OUTER LAYOUT ///////////////////////////////////////////////////////////////////
107 54

  
108 55
    int margin = (int)(scale*10 + 0.5f);
109 56
    int color  = act.getResources().getColor(R.color.grey);
110 57
    LinearLayout outerLayout = new LinearLayout(act);
111 58
    LinearLayout.LayoutParams outerLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 0.5f);
59
    outerLayoutParams.topMargin    = margin;
112 60
    outerLayoutParams.bottomMargin = margin;
113 61
    outerLayoutParams.leftMargin   = margin;
114 62
    outerLayoutParams.rightMargin  = margin;
......
119 67
    outerLayout.setOrientation(LinearLayout.VERTICAL);
120 68
    layout.addView(outerLayout);
121 69

  
70
    ///// TEXT ///////////////////////////////////////////////////////////////////////////
71

  
72
    int layoutHeight = (int)(scale*32 + 0.5f);
73
    int padding      = (int)(scale*10 + 0.5f);
74

  
75
    LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,layoutHeight);
76

  
77
    TextView textView = new TextView(act);
78
    textView.setText(beType.getText());
79
    textView.setLayoutParams(textParams);
80
    textView.setGravity(Gravity.CENTER);
81
    textView.setPadding(padding,0,padding,0);
82
    textView.setTextAppearance(android.R.style.TextAppearance_Small);
83
    outerLayout.addView(textView);
84

  
122 85
    ///// INNER LAYOUT1 //////////////////////////////////////////////////////////////////
123 86

  
124 87
    int innerLayout1Height = (int)(scale*36 + 0.5f);
......
208 171
    spinner.setSelection(beType.getCurrentType());
209 172
    }
210 173

  
174
///////////////////////////////////////////////////////////////////////////////////////////////////
175
// PUBLIC API
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

  
178
  public RubikSettings()
179
    {
180
    mDurationText = new TextView[BaseEffect.Type.LENGTH];
181
    }
182

  
183
///////////////////////////////////////////////////////////////////////////////////////////////////
184

  
185
  @NonNull
186
  @Override
187
  public Dialog onCreateDialog(Bundle savedInstanceState)
188
    {
189
    FragmentActivity act = getActivity();
190
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
191
    builder.setCancelable(false);
192

  
193
    LayoutInflater inflater = act.getLayoutInflater();
194
    final View view = inflater.inflate(R.layout.settings, null);
195
    builder.setView(view);
196

  
197
    LinearLayout linearLayout = view.findViewById(R.id.main_settings_layout);
198

  
199
    if( linearLayout!=null )
200
      {
201
      for (int i=0; i< BaseEffect.Type.LENGTH; i++)
202
        {
203
        createSettingsSection(act,linearLayout,i);
204
        }
205
      }
206
    else
207
      {
208
      android.util.Log.e("settings", "linearLayout NULL!");
209
      }
210

  
211
    return builder.create();
212
    }
213

  
211 214
///////////////////////////////////////////////////////////////////////////////////////////////////
212 215

  
213 216
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)

Also available in: Unified diff