Project

General

Profile

« Previous | Next » 

Revision ef1f3e34

Added by Leszek Koltunski over 3 years ago

Make the Tutorial Dialog look better

View differences:

src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java
21 21

  
22 22
import android.content.Context;
23 23
import android.content.res.Resources;
24
import android.graphics.drawable.Drawable;
25 24
import android.os.Bundle;
26 25
import android.util.AttributeSet;
27 26
import android.util.TypedValue;
28 27
import android.view.View;
29 28
import android.widget.Button;
30 29
import android.widget.FrameLayout;
30
import android.widget.ImageView;
31 31
import android.widget.LinearLayout;
32
import android.widget.TextView;
32 33

  
33
import androidx.core.content.ContextCompat;
34 34
import androidx.fragment.app.FragmentActivity;
35 35

  
36 36
import com.google.firebase.analytics.FirebaseAnalytics;
......
59 59

  
60 60
///////////////////////////////////////////////////////////////////////////////////////////////////
61 61

  
62
  public RubikDialogTutorialView(FragmentActivity act, int height, int position)
62
  public RubikDialogTutorialView(FragmentActivity act, int width, int position)
63 63
    {
64 64
    super(act);
65 65

  
66
    int heightT = (int)(height* RubikActivity.TUTORIAL_ITEM_TEXT);
66
    int widthT = (int)(width* RubikActivity.TUTORIAL_ITEM_TEXT);
67 67

  
68 68
    RubikActivity ract = (RubikActivity)getContext();
69 69
    Resources res = act.getResources();
......
87 87

  
88 88
      int countryID = res.getIdentifier( coun, "drawable", packageName);
89 89

  
90
      View row = createRow(ract,countryID,desc,url,auth,heightT,objList,size);
90
      View row = createRow(ract,countryID,desc,url,auth,widthT,objList,size);
91 91
      layout.addView(row);
92 92
      }
93 93

  
......
97 97
///////////////////////////////////////////////////////////////////////////////////////////////////
98 98

  
99 99
  private View createRow(final RubikActivity act, int countryID, final String desc, final String url,
100
                         final String auth, int height, final ObjectList obj, final int size)
100
                         final String auth, int width, final ObjectList obj, final int size)
101 101
    {
102 102
    View row = inflate( act, R.layout.dialog_tutorial_row, null);
103
    Button butt = row.findViewById(R.id.tutorialRowButton);
103
    Button butt = row.findViewById(R.id.tutorialButton);
104 104

  
105
    int id = countryID!=0 ? countryID : R.drawable.un;
106
    final String buttText = desc+" ("+auth+")";
107

  
108
    butt.setText(buttText);
109
    butt.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*height);
110
    butt.setHeight(height);
111

  
112
    Drawable img = ContextCompat.getDrawable(act,id);
113
    img.setBounds(0, 0, (int)(1.0f*height), (int)(0.66f*height) );
114
    butt.setCompoundDrawables(img,null,null,null);
105
    butt.setText(R.string.view);
106
    butt.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*width);
107
    butt.setHeight(width);
115 108

  
116 109
    butt.setOnClickListener( new View.OnClickListener()
117 110
      {
......
123 116
        }
124 117
      });
125 118

  
119
    ImageView image = row.findViewById(R.id.tutorialCountry);
120
    int id = countryID!=0 ? countryID : R.drawable.un;
121
    image.setImageResource(id);
122

  
123
    TextView author = row.findViewById(R.id.tutorialAuthor);
124
    author.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*width);
125
    author.setText(auth);
126

  
127
    TextView title  = row.findViewById(R.id.tutorialTitle);
128
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*width);
129
    title.setText(desc);
130

  
126 131
    return row;
127 132
    }
128 133

  

Also available in: Unified diff