Revision 9881dc03
Added by Leszek Koltunski about 1 month ago
src/main/java/org/distorted/main/MainActivity.java | ||
---|---|---|
25 | 25 |
import android.widget.TextView; |
26 | 26 |
|
27 | 27 |
import androidx.annotation.NonNull; |
28 |
import androidx.preference.PreferenceManager; |
|
29 | 28 |
|
30 | 29 |
import com.google.firebase.analytics.FirebaseAnalytics; |
31 | 30 |
import com.google.firebase.inappmessaging.FirebaseInAppMessaging; |
... | ... | |
79 | 78 |
cutoutHack(); |
80 | 79 |
computeHeights(); |
81 | 80 |
|
81 |
getWindowWidth(getResources().getConfiguration()); |
|
82 |
android.util.Log.e("D", "onCreate: "+mScreenWidth+" "+mScreenHeight); |
|
83 |
|
|
82 | 84 |
mCurrVersion = getAppVers(); |
83 | 85 |
|
84 | 86 |
mBubbleUpdates = findViewById(R.id.bubbleUpdates); |
85 | 87 |
mBubbleUpdates.setVisibility(View.INVISIBLE); |
86 | 88 |
mNumUpdates = 0; |
87 | 89 |
|
90 |
mGrid = new MainScrollGrid(); |
|
91 |
mGrid.createGrid(this,mScreenWidth,mSortMode); |
|
92 |
|
|
88 | 93 |
Thread thread = new Thread() |
89 | 94 |
{ |
90 | 95 |
public void run() |
... | ... | |
116 | 121 |
} |
117 | 122 |
|
118 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
119 |
|
|
124 |
/* |
|
120 | 125 |
@Override |
121 | 126 |
public void onAttachedToWindow() |
122 | 127 |
{ |
123 | 128 |
super.onAttachedToWindow(); |
124 | 129 |
|
125 | 130 |
getWindowWidth(getResources().getConfiguration()); |
131 |
|
|
132 |
|
|
133 |
android.util.Log.e("D", "onAttachedToWindow: "+mScreenWidth+" "+mScreenHeight); |
|
134 |
|
|
135 |
|
|
126 | 136 |
mGrid = new MainScrollGrid(); |
127 | 137 |
mGrid.createGrid(this,mScreenWidth,mSortMode); |
128 | 138 |
|
... | ... | |
133 | 143 |
|
134 | 144 |
if( insetHeight>0 ) |
135 | 145 |
{ |
136 |
LinearLayout.LayoutParams pH = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, RATIO_BAR);
|
|
146 |
LinearLayout.LayoutParams pH = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, RATIO_HID);
|
|
137 | 147 |
LinearLayout layoutHid = findViewById(R.id.hiddenBar); |
138 | 148 |
layoutHid.setLayoutParams(pH); |
139 | 149 |
|
140 |
LinearLayout.LayoutParams pS = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1-3*RATIO_BAR);
|
|
150 |
LinearLayout.LayoutParams pS = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1-2*RATIO_BAR-RATIO_HID);
|
|
141 | 151 |
ScrollView scroll = findViewById(R.id.objectScroll); |
142 | 152 |
scroll.setLayoutParams(pS); |
143 | 153 |
} |
144 | 154 |
} |
145 | 155 |
} |
146 |
|
|
156 |
*/ |
|
147 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
148 | 158 |
|
149 | 159 |
@Override |
... | ... | |
151 | 161 |
{ |
152 | 162 |
super.onConfigurationChanged(conf); |
153 | 163 |
|
164 |
android.util.Log.e("D", "onConfigurationChanged"); |
|
165 |
|
|
154 | 166 |
getWindowWidth(conf); |
155 | 167 |
if( mGrid!=null ) mGrid.updateGrid(this,mScreenWidth); |
156 | 168 |
} |
... | ... | |
163 | 175 |
super.onPause(); |
164 | 176 |
RubikNetwork.onPause(); |
165 | 177 |
savePreferences(); |
178 |
|
|
179 |
|
|
180 |
android.util.Log.e("D", "onPause"); |
|
181 |
|
|
166 | 182 |
} |
167 | 183 |
|
168 | 184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
172 | 188 |
{ |
173 | 189 |
super.onResume(); |
174 | 190 |
|
175 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
|
176 |
restorePreferences(preferences,mJustStarted); |
|
191 |
android.util.Log.e("D", "onResume"); |
|
192 |
|
|
193 |
restorePreferences(mJustStarted); |
|
177 | 194 |
|
178 | 195 |
RubikNetwork network = RubikNetwork.getInstance(); |
179 | 196 |
network.signUpForUpdates(this); |
... | ... | |
208 | 225 |
protected void onDestroy() |
209 | 226 |
{ |
210 | 227 |
super.onDestroy(); |
228 |
|
|
229 |
android.util.Log.e("D", "onDestroy"); |
|
211 | 230 |
} |
212 | 231 |
|
213 | 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
229 | 248 |
|
230 | 249 |
private void savePreferences() |
231 | 250 |
{ |
232 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
|
233 |
SharedPreferences.Editor editor = preferences.edit(); |
|
251 |
SharedPreferences.Editor editor = mPreferences.edit(); |
|
234 | 252 |
|
235 | 253 |
editor.putString("appVersion", mCurrVersion ); |
236 | 254 |
editor.putInt("sortMode", mSortMode); |
... | ... | |
243 | 261 |
|
244 | 262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
245 | 263 |
|
246 |
private void restorePreferences(SharedPreferences preferences, boolean justStarted)
|
|
264 |
private void restorePreferences(boolean justStarted) |
|
247 | 265 |
{ |
248 |
mOldVersion = preferences.getString("appVersion","");
|
|
249 |
mSortMode = preferences.getInt("sortMode", MainSettingsPopup.SORT_DEFAULT);
|
|
266 |
mOldVersion = mPreferences.getString("appVersion","");
|
|
267 |
mSortMode = mPreferences.getInt("sortMode", MainSettingsPopup.SORT_DEFAULT);
|
|
250 | 268 |
|
251 |
RubikObjectList.restorePreferences(this,preferences,justStarted);
|
|
269 |
RubikObjectList.restorePreferences(this,mPreferences,justStarted);
|
|
252 | 270 |
RubikScores scores = RubikScores.getInstance(); |
253 |
scores.restorePreferences(preferences);
|
|
271 |
scores.restorePreferences(mPreferences);
|
|
254 | 272 |
|
255 | 273 |
if( scores.isVerified() ) |
256 | 274 |
{ |
... | ... | |
399 | 417 |
|
400 | 418 |
int vw = v.getWidth(); |
401 | 419 |
|
402 |
MainSettingsPopup popup = new MainSettingsPopup(this,mSortMode,mScreenWidth,mScreenHeight); |
|
420 |
MainSettingsPopup popup = new MainSettingsPopup(this,mSortMode,mCurrentTheme,mScreenWidth,mScreenHeight);
|
|
403 | 421 |
popup.displayPopup(this,v,sw,sh,((vw-sw)/2),0); |
404 | 422 |
} |
405 | 423 |
|
Also available in: Unified diff
common code from all activities to one BaseActivity