Project

General

Profile

« Previous | Next » 

Revision 9b6f8f18

Added by Leszek Koltunski 8 months ago

progress with colors in styles

View differences:

src/main/java/org/distorted/helpers/BaseActivity.java
32 32
    protected static final int THEME_WHITE = 1;
33 33
    protected static final int THEME_GREEN = 2;
34 34

  
35
    public static final float RATIO_HID = 0.050f;
36 35
    public static final float RATIO_BAR = 0.080f;
37 36
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
38 37
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
......
45 44
    protected int mScreenWidth, mScreenHeight;
46 45
    protected int mHeightLowerBar, mHeightUpperBar;
47 46
    protected float mDensity;
47
    protected int mDarkC, mNormalC, mMediumC, mLightC;
48 48
    protected SharedPreferences mPreferences;
49 49

  
50 50
///////////////////////////////////////////////////////////////////////////////////////////////////
......
59 59

  
60 60
      switch(mCurrentTheme)
61 61
        {
62
        case THEME_WHITE : setTheme(R.style.WhiteTheme); break;
63
        case THEME_GREEN : setTheme(R.style.GreenTheme); break;
64
        default          : setTheme(R.style.GreyTheme);  break;
62
        case THEME_WHITE : setTheme(R.style.WhiteTheme);
63
                           mDarkC   = R.color.darkWhite;
64
                           mNormalC = R.color.normalWhite;
65
                           mMediumC = R.color.mediumWhite;
66
                           mLightC  = R.color.lightWhite;
67
                           break;
68
        case THEME_GREEN : setTheme(R.style.GreenTheme);
69
                           mDarkC   = R.color.darkGreen;
70
                           mNormalC = R.color.normalGreen;
71
                           mMediumC = R.color.mediumGreen;
72
                           mLightC  = R.color.lightGreen;
73
                           break;
74
        default          : setTheme(R.style.GreyTheme);
75
                           mDarkC   = R.color.darkGrey;
76
                           mNormalC = R.color.normalGrey;
77
                           mMediumC = R.color.mediumGrey;
78
                           mLightC  = R.color.lightGrey;
79
                           break;
65 80
        }
66 81

  
67 82
      super.onCreate(savedState);
src/main/java/org/distorted/helpers/ObjectGridCreator.java
108 108

  
109 109
///////////////////////////////////////////////////////////////////////////////////////////////////
110 110

  
111
  public void createObjectGrid(Activity act, ScrollView scrollView, int sortMode)
111
  public void createObjectGrid(Activity act, ScrollView scrollView, int sortMode, int color)
112 112
    {
113 113
    mSortMode = sortMode;
114 114

  
......
137 137
      int height = (int)(TITLE_SIZE*mCubeSize);
138 138

  
139 139
      mROC = RubikObjectCategories.create(sortMode);
140
      if( mROC.hasIcons() ) constructIconBasedGrid(act,layout,mROC,height);
141
      else                  constructIconlessGrid(act,layout,mROC,height);
140
      if( mROC.hasIcons() ) constructIconBasedGrid(act,layout,mROC,height,color);
141
      else                  constructIconlessGrid(act,layout,mROC,height,color);
142 142
      }
143 143
    }
144 144

  
145 145
///////////////////////////////////////////////////////////////////////////////////////////////////
146 146

  
147
  private void constructIconBasedGrid(Activity act, LinearLayout layout, RubikObjectCategories roc, int height)
147
  private void constructIconBasedGrid(Activity act, LinearLayout layout, RubikObjectCategories roc, int height, int color)
148 148
    {
149 149
    int numCategories = roc.getNumCategories();
150 150

  
......
153 153
    for(int c=0; c<numCategories; c++)
154 154
      {
155 155
      int iconID = roc.getIconId(c);
156
      View title = constructTitle(act,iconID,height);
156
      View title = constructTitle(act,iconID,height,color);
157 157
      layout.addView(title);
158 158
      mCategoryGrids[c] = constructGrid(act,c);
159 159
      layout.addView(mCategoryGrids[c]);
......
162 162

  
163 163
///////////////////////////////////////////////////////////////////////////////////////////////////
164 164

  
165
  private void constructIconlessGrid(Activity act, LinearLayout layout, RubikObjectCategories roc, int height)
165
  private void constructIconlessGrid(Activity act, LinearLayout layout, RubikObjectCategories roc, int height, int color)
166 166
    {
167 167
    int numCategories = roc.getNumCategories();
168 168

  
......
171 171
    for(int c=0; c<numCategories; c++)
172 172
      {
173 173
      String titleStr = roc.getTitle(c);
174
      View title = constructTitle(act,titleStr,height);
174
      View title = constructTitle(act,titleStr,height,color);
175 175
      layout.addView(title);
176 176
      mCategoryGrids[c] = constructGrid(act,c);
177 177
      layout.addView(mCategoryGrids[c]);
......
180 180

  
181 181
///////////////////////////////////////////////////////////////////////////////////////////////////
182 182

  
183
  private View constructTitle(Activity act, int iconID, int height)
183
  private View constructTitle(Activity act, int iconID, int height, int color)
184 184
    {
185 185
    ImageView view = new ImageView(act);
186 186
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,height);
......
188 188
    params.leftMargin = m;
189 189
    params.rightMargin = m;
190 190
    view.setLayoutParams(params);
191

  
192
    view.setBackgroundResource(R.color.darkGrey);
193

  
191
    view.setBackgroundResource(color);
194 192
    int p = (int)(TITLE_PADDING*height);
195 193
    view.setPadding( p,p,p,p );
196 194
    view.setImageResource(iconID);
......
200 198

  
201 199
///////////////////////////////////////////////////////////////////////////////////////////////////
202 200

  
203
  private View constructTitle(Activity act, String title, int height)
201
  private View constructTitle(Activity act, String title, int height, int color)
204 202
    {
205 203
    TextView view = new TextView(act);
206 204
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,height);
......
208 206
    params.leftMargin = m;
209 207
    params.rightMargin = m;
210 208
    view.setLayoutParams(params);
211
    view.setBackgroundResource(R.color.darkGrey);
209
    view.setBackgroundResource(color);
212 210
    view.setGravity(Gravity.CENTER);
213 211

  
214 212
    int size = (int)(TEXT_SIZE*height);
src/main/java/org/distorted/main/MainActivity.java
84 84
      mBubbleUpdates.setVisibility(View.INVISIBLE);
85 85
      mNumUpdates = 0;
86 86

  
87
      mGrid = new MainScrollGrid();
88
      mGrid.createGrid(this,mScreenWidth,mSortMode);
89

  
90 87
      Thread thread = new Thread()
91 88
        {
92 89
        public void run()
......
124 121
      {
125 122
      super.onConfigurationChanged(conf);
126 123
      getWindowWidth(conf);
127
      if( mGrid!=null ) mGrid.updateGrid(this,mScreenWidth);
124
      if( mGrid!=null ) mGrid.updateGrid(this,mScreenWidth,mDarkC);
128 125
      }
129 126

  
130 127
///////////////////////////////////////////////////////////////////////////////////////////////////
......
146 143

  
147 144
      restorePreferences(mJustStarted);
148 145

  
146
      mGrid = new MainScrollGrid();
147
      mGrid.createGrid(this,mScreenWidth,mSortMode,mDarkC);
148

  
149 149
      RubikNetwork network = RubikNetwork.getInstance();
150 150
      network.signUpForUpdates(this);
151 151

  
......
369 369

  
370 370
      int vw = v.getWidth();
371 371

  
372
      MainSettingsPopup popup = new MainSettingsPopup(this,mSortMode,mCurrentTheme,mScreenWidth,sw,sh);
372
      MainSettingsPopup popup = new MainSettingsPopup(this,mSortMode,mCurrentTheme,sw,sh);
373 373
      popup.displayPopup(this,v,((vw-sw)/2),0);
374 374
      }
375 375

  
......
419 419
      {
420 420
      mNumUpdates--;
421 421
      updateBubble(mNumUpdates);
422
      mGrid.updateGrid(this,mScreenWidth);
422
      mGrid.updateGrid(this,mScreenWidth,mDarkC);
423 423
      }
424 424

  
425 425
///////////////////////////////////////////////////////////////////////////////////////////////////
......
434 434
    public void sortObjectsBy(int sortMode)
435 435
      {
436 436
      mSortMode = sortMode;
437
      mGrid.createGrid(this,mScreenWidth,mSortMode);
437
      mGrid.createGrid(this,mScreenWidth,mSortMode,mDarkC);
438 438
      }
439 439

  
440 440
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/main/MainScrollGrid.java
31 31

  
32 32
///////////////////////////////////////////////////////////////////////////////////////////////////
33 33

  
34
  void createGrid(final MainActivity act, int windowWidth, int sortMode)
34
  void createGrid(final MainActivity act, int windowWidth, int sortMode, int color)
35 35
    {
36 36
    if( mCreator==null ) mCreator = new ObjectGridCreator(windowWidth);
37 37

  
......
41 41
    ScrollView scrollView = act.findViewById(R.id.objectScroll);
42 42
    scrollView.removeAllViews();
43 43

  
44
    mCreator.createObjectGrid(act,scrollView,sortMode);
44
    mCreator.createObjectGrid(act,scrollView,sortMode,color);
45 45

  
46 46
    DisplayMetrics displaymetrics = new DisplayMetrics();
47 47
    act.getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics);
......
70 70

  
71 71
///////////////////////////////////////////////////////////////////////////////////////////////////
72 72

  
73
  void updateGrid(final MainActivity act, int scrW)
73
  void updateGrid(final MainActivity act, int scrW, int color)
74 74
    {
75 75
    act.runOnUiThread(new Runnable()
76 76
      {
......
78 78
      public void run()
79 79
        {
80 80
        if( mSortMode<0 ) mSortMode = MainSettingsPopup.SORT_DEFAULT;
81
        createGrid(act,scrW,mSortMode);
81
        createGrid(act,scrW,mSortMode,color);
82 82
        }
83 83
      });
84 84
    }
src/main/java/org/distorted/main/MainSettingsPopup.java
12 12
import android.content.Context;
13 13
import android.content.res.Resources;
14 14
import android.os.Build;
15
import android.util.TypedValue;
16 15
import android.view.Gravity;
17 16
import android.view.LayoutInflater;
18 17
import android.view.View;
......
21 20
import android.widget.ListPopupWindow;
22 21
import android.widget.PopupWindow;
23 22
import android.widget.Spinner;
24
import android.widget.TextView;
25 23

  
26 24
import java.lang.ref.WeakReference;
27 25
import java.lang.reflect.Field;
......
38 36

  
39 37
  public static final int SORT_DEFAULT    = SORT_SHAPE;
40 38

  
41
  private static final float MENU_TITLE_SIZE= 0.070f;
42
  private static final float MENU_TEXT_SIZE = 0.060f;
43 39
  private static final int[] mLocation = new int[2];
44 40

  
45 41
  private final int mWidth, mHeight;
......
86 82

  
87 83
///////////////////////////////////////////////////////////////////////////////////////////////////
88 84

  
89
  MainSettingsPopup(MainActivity act, int sortMethod, int themeValue,
90
                    int scrWidth, int popupWidth, int popupHeight)
85
  MainSettingsPopup(MainActivity act, int sortMethod, int themeValue, int popupWidth, int popupHeight)
91 86
    {
92 87
    mAct = new WeakReference<>(act);
93 88

  
......
105 100
    mPopup.setContentView(layout);
106 101
    mPopup.setFocusable(true);
107 102

  
108
    int titleSize = (int)(0.26f*popupHeight);
109
    int textSize  = (int)(0.19f*popupHeight);
110

  
111
    TextView title = layout.findViewById(R.id.settingsTitle);
112
    //title.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
113
    TextView sortText = layout.findViewById(R.id.sortText);
114
    //sortText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
115
    TextView themeTitle = layout.findViewById(R.id.themeText);
116
   // themeTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
117

  
118 103
    Spinner sortSpinner  = layout.findViewById(R.id.sortMethod);
119 104
    sortSpinner.setOnItemSelectedListener(this);
120 105

  
src/main/res/drawable/ui_spinner.xml
5 5
            <item>
6 6
                <shape android:shape="rectangle">
7 7
                    <solid android:color="?lightC" />
8
                    <corners android:radius="6dip" />
8
                    <corners android:radius="6dp" />
9 9
                    <stroke
10 10
                        android:color="?normalC"
11 11
                        android:width="2dp"/>
src/main/res/layout/dialog_scrollable_panes.xml
3 3
    android:id="@+id/updates_scroll"
4 4
    android:layout_width="match_parent"
5 5
    android:layout_height="match_parent"
6
    android:background="?darkC"
6 7
    android:paddingLeft="10dp"
7 8
    android:paddingRight="10dp">
8 9

  
src/main/res/layout/dialog_title.xml
3 3
  android:layout_width="match_parent"
4 4
  android:layout_height="match_parent"
5 5
  android:textSize="20sp"
6
  android:background="?mediumC"
6 7
  android:gravity="center"
7 8
  android:padding="10dp"/>
src/main/res/values/colors.xml
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2
<resources>
3
    <color name="colorPrimary">#008577</color>
4
    <color name="colorPrimaryDark">#00574B</color>
5
    <color name="colorAccent">#D81B60</color>
3

  
6 4
    <color name="red">#ffff0000</color>
7 5
    <color name="black">#ff010101</color>
8 6
    <color name="white">#ffffffff</color>
9 7

  
10
    <color name="darkGreen">#ff009900</color>
11
    <color name="normalGreen">#ff00aa00</color>
12
    <color name="mediumGreen">#ff00bb00</color>
8
    <color name="darkGreen">#ff008800</color>
9
    <color name="normalGreen">#ff00a000</color>
10
    <color name="mediumGreen">#ff00b800</color>
13 11
    <color name="lightGreen">#ff00cc00</color>
14 12

  
15 13
    <color name="darkGrey">#ff222222</color>
......
17 15
    <color name="mediumGrey">#ff444444</color>
18 16
    <color name="lightGrey">#ff555555</color>
19 17

  
20
    <color name="darkWhite">#ffd0d0d0</color>
21
    <color name="normalWhite">#ffe0e0e0</color>
22
    <color name="mediumWhite">#fff0f0f0</color>
18
    <color name="darkWhite">#ffa0a0a0</color>
19
    <color name="normalWhite">#ffc0c0c0</color>
20
    <color name="mediumWhite">#ffe0e0e0</color>
23 21
    <color name="lightWhite">#ffffffff</color>
24 22
</resources>
src/main/res/values/styles.xml
34 34
   </style>
35 35

  
36 36
   <style name="NegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
37
      <item name="android:textColor">#ffffff</item>
37
      <item name="android:textColor">@color/white</item>
38 38
   </style>
39 39

  
40 40
   <style name="PositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
41
      <item name="android:textColor">#ffffff</item>
41
      <item name="android:textColor">@color/white</item>
42 42
   </style>
43 43

  
44 44
   <style name="ButtonStyleTextColor">

Also available in: Unified diff