Project

General

Profile

« Previous | Next » 

Revision 7ebd72f7

Added by Leszek Koltunski over 4 years ago

Improvements to the UI - make it proportional regardless of the physical screen size. (Part 3)

View differences:

src/main/java/org/distorted/dialogs/RubikDialogMain.java
25 25
import androidx.fragment.app.FragmentActivity;
26 26
import androidx.appcompat.app.AlertDialog;
27 27
import androidx.appcompat.app.AppCompatDialogFragment;
28

  
29
import android.util.DisplayMetrics;
30
import android.util.TypedValue;
28 31
import android.view.LayoutInflater;
29 32
import android.view.View;
30 33
import android.view.Window;
31 34
import android.view.WindowManager;
35
import android.widget.Button;
32 36

  
33 37
import org.distorted.main.R;
38
import org.distorted.main.RubikActivity;
34 39

  
35 40
///////////////////////////////////////////////////////////////////////////////////////////////////
36 41

  
......
44 49
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
45 50
    LayoutInflater inflater = act.getLayoutInflater();
46 51
    final View view = inflater.inflate(R.layout.dialog_main, null);
52

  
53
    DisplayMetrics displaymetrics = new DisplayMetrics();
54
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
55
    float textSize = displaymetrics.widthPixels * RubikActivity.MENU_TEXT_SIZE;
56
    int buttonSize = (int)(2.5f*textSize);
57

  
58
    Button play = view.findViewById(R.id.rubikPlay);
59
    play.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
60
    play.setHeight(buttonSize);
61
    Button scor = view.findViewById(R.id.rubikScores);
62
    scor.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
63
    scor.setHeight(buttonSize);
64
    Button patt = view.findViewById(R.id.rubikPatterns);
65
    patt.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
66
    patt.setHeight(buttonSize);
67
    Button solv = view.findViewById(R.id.rubikSolver);
68
    solv.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
69
    solv.setHeight(buttonSize);
70
    Button abou = view.findViewById(R.id.rubikAbout);
71
    abou.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
72
    abou.setHeight(buttonSize);
73

  
47 74
    builder.setView(view);
48 75

  
49 76
    Dialog dialog = builder.create();
src/main/java/org/distorted/main/RubikActivity.java
49 49
    public static final float BUTTON_TEXT_SIZE = 0.05f;
50 50
    public static final float TITLE_TEXT_SIZE  = 0.06f;
51 51
    public static final float BITMAP_TEXT_SIZE = 0.09f;
52
    public static final float MENU_TEXT_SIZE   = 0.04f;
52 53

  
53 54
    private boolean mJustStarted;
54 55
    private FirebaseAnalytics mFirebaseAnalytics;
......
69 70
      DisplayMetrics displaymetrics = new DisplayMetrics();
70 71
      getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
71 72
      mScreenWidth=displaymetrics.widthPixels;
72

  
73
      android.util.Log.e("act", "screenWidth="+mScreenWidth);
74 73
      }
75 74

  
76 75
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/states/RubikStateSolver.java
102 102

  
103 103
    if( mNumFaces>0 )
104 104
      {
105
      setupBitmaps(scale);
105
      setupBitmaps();
106 106
      setupColorButtons(act,scale);
107

  
108 107
      markButton(act);
109 108
      }
110 109

  
......
126 125

  
127 126
///////////////////////////////////////////////////////////////////////////////////////////////////
128 127

  
129
  private void setupBitmaps(float scale)
128
  private void setupBitmaps()
130 129
    {
131 130
    final int SIZE = (int)mBitmapSize;
132 131
    final float R = SIZE*0.15f;

Also available in: Unified diff