-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathBRSharedPrefs.java
More file actions
538 lines (448 loc) · 23.6 KB
/
BRSharedPrefs.java
File metadata and controls
538 lines (448 loc) · 23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
package com.ravenwallet.tools.manager;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.ravenwallet.tools.util.BRConstants;
import org.json.JSONArray;
import java.util.ArrayList;
import java.util.Currency;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
/**
* RavenWallet
* <p>
* Created by Mihail Gutan <mihail@breadwallet.com> on 6/13/16.
* Copyright (c) 2016 breadwallet LLC
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
public class BRSharedPrefs {
public static final String TAG = BRSharedPrefs.class.getName();
public static List<OnIsoChangedListener> isoChangedListeners = new ArrayList<>();
public static final String PREFS_NAME = "MyPrefsFile";
private static final String CURRENT_WALLET_CURRENCY_CODE = "currentWalletIso";
private static final String LAST_RESCAN_MODE_USED = "lastRescanModeUsed_RVN";
private static final String LAST_SEND_TRANSACTION_BLOCK_HEIGHT = "lastSendTransactionBlockheight_RVN";
private static final String KNOWN_SEED_TIME = "knownSeedTime_RVN";
private static final String RESCAN_TIME = "rescanTime_RVN";
public interface OnIsoChangedListener {
void onIsoChanged(String iso);
}
public static void addIsoChangedListener(OnIsoChangedListener listener) {
if (isoChangedListeners == null) {
isoChangedListeners = new ArrayList<>();
}
if (!isoChangedListeners.contains(listener))
isoChangedListeners.add(listener);
}
public static void removeListener(OnIsoChangedListener listener) {
if (isoChangedListeners == null) {
isoChangedListeners = new ArrayList<>();
}
isoChangedListeners.remove(listener);
}
public static String getPreferredFiatIso(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
String defIso;
try {
defIso = Currency.getInstance(Locale.getDefault()).getCurrencyCode();
} catch (IllegalArgumentException e) {
e.printStackTrace();
defIso = Currency.getInstance(Locale.US).getCurrencyCode();
}
return settingsToGet.getString("currentCurrency", defIso);
}
public static void putPreferredFiatIso(Context context, String iso) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("currentCurrency", iso.equalsIgnoreCase(Locale.getDefault().getISO3Language()) ? null : iso);
editor.apply();
for (OnIsoChangedListener listener : isoChangedListeners) {
if (listener != null) listener.onIsoChanged(iso);
}
}
public static String getPreferredIPFSGateway(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
return settingsToGet.getString("ipfsGateway", BRConstants.IPFS_DEFAULT_HOST);
}
public static void putPreferredIPFSGateway(Context context, String gateway) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("ipfsGateway", gateway);
editor.apply();
}
public static boolean getExpertMode(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("expertMode", false);
}
public static void putExpertMode(Context context, boolean check) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("expertMode", check);
editor.apply();
}
public static boolean getShowAddressInput(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("isShowAddressInput", true);
}
public static void putShowAddressInput(Context context, boolean check) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("isShowAddressInput", check);
editor.apply();
}
public static boolean getPhraseWroteDown(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("phraseWritten", false);
}
public static void putPhraseWroteDown(Context context, boolean check) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("phraseWritten", check);
editor.apply();
}
public static boolean getGreetingsShown(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("greetingsShown", false);
}
public static void putGreetingsShown(Context context, boolean shown) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("greetingsShown", shown);
editor.apply();
}
public static boolean getFavorStandardFee(Context context, String iso) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("favorStandardFee" + iso.toUpperCase(), true);
}
public static void putFavorStandardFee(Context context, String iso, boolean favorStandardFee) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("favorStandardFee" + iso.toUpperCase(), favorStandardFee);
editor.apply();
}
public static String getReceiveAddress(Context context, String iso) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getString("receive_address" + iso.toUpperCase(), "");
}
public static void putReceiveAddress(Context ctx, String tmpAddr, String iso) {
SharedPreferences.Editor editor = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
editor.putString("receive_address" + iso.toUpperCase(), tmpAddr);
editor.apply();
}
public static String getFirstAddress(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getString("firstAddress", "");
}
public static void putFirstAddress(Context context, String firstAddress) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("firstAddress", firstAddress);
editor.apply();
}
public static long getFeePerKb(Context context, String iso) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong("feeKb" + iso.toUpperCase(), 0);
}
public static void putFeePerKb(Context context, String iso, long fee) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("feeKb" + iso.toUpperCase(), fee);
editor.apply();
}
public static long getEconomyFeePerKb(Context context, String iso) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong("economyFeeKb" + iso.toUpperCase(), 0);
}
public static void putEconomyFeePerKb(Context context, String iso, long fee) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("economyFeeKb" + iso.toUpperCase(), fee);
editor.apply();
}
public static long getCachedBalance(Context context, String iso) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong("balance_" + iso.toUpperCase(), 0);
}
public static void putCachedBalance(Context context, String iso, long balance) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("balance_" + iso.toUpperCase(), balance);
editor.apply();
}
public static long getSecureTime(Context activity) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong("secureTime", System.currentTimeMillis() / 1000);
}
//secure time from the server
public static void putSecureTime(Context activity, long date) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("secureTime", date);
editor.apply();
}
public static long getLastSyncTime(Context activity, String iso) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong("lastSyncTime_" + iso.toUpperCase(), 0);
}
public static void putLastSyncTime(Context activity, String iso, long time) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("lastSyncTime_" + iso.toUpperCase(), time);
editor.apply();
}
public static String getLastRescanModeUsed(Context activity) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getString(LAST_RESCAN_MODE_USED, null);
}
public static void putLastRescanModeUsed(Context activity, String mode) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(LAST_RESCAN_MODE_USED, mode);
editor.apply();
}
public static long getLastSendTransactionBlockheight(Context activity) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong(LAST_SEND_TRANSACTION_BLOCK_HEIGHT, 0);
}
public static void putLastSendTransactionBlockheight(Context activity, long blockHeight) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(LAST_SEND_TRANSACTION_BLOCK_HEIGHT, blockHeight);
editor.apply();
}
public static long getKnownSeedTime(Context activity) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong(KNOWN_SEED_TIME, 0);
}
public static void putKnownSeedTime(Context activity, long seedTime) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(KNOWN_SEED_TIME, seedTime);
editor.apply();
}
public static long getFeeTime(Context activity, String iso) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getLong("feeTime_" + iso.toUpperCase(), 0);
}
public static void putFeeTime(Context activity, String iso, long feeTime) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("feeTime_" + iso.toUpperCase(), feeTime);
editor.apply();
}
public static List<Integer> getBitIdNonces(Context activity, String key) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
String result = prefs.getString(key, null);
List<Integer> list = new ArrayList<>();
try {
JSONArray arr = new JSONArray(result);
for (int i = 0; i < arr.length(); i++) {
int a = arr.getInt(i);
Log.d("found a nonce: ", a + "");
list.add(a);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public static void putBitIdNonces(Context activity, List<Integer> nonces, String key) {
JSONArray arr = new JSONArray();
arr.put(nonces);
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(key, arr.toString());
editor.apply();
}
public static boolean getAllowSpend(Context activity, String iso) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("allowSpend_" + iso.toUpperCase(), true);
}
public static void putAllowSpend(Context activity, String iso, boolean allow) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("allowSpend_" + iso.toUpperCase(), allow);
editor.apply();
}
//if the user prefers all in crypto units, not fiat currencies
public static boolean isCryptoPreferred(Context activity) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("priceInCrypto", true);
}
//if the user prefers all in crypto units, not fiat currencies
public static void setIsCryptoPreferred(Context activity, boolean b) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("priceInCrypto", b);
editor.apply();
}
public static boolean getUseFingerprint(Context activity) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("useFingerprint", false);
}
public static void putUseFingerprint(Context activity, boolean use) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("useFingerprint", use);
editor.apply();
}
public static boolean getFeatureEnabled(Context activity, String feature) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean(feature, false);
}
public static void putFeatureEnabled(Context activity, boolean enabled, String feature) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(feature, enabled);
editor.apply();
}
public static String getCurrentWalletIso(Context activity) {
// Log.d(TAG, "getCurrentWalletIso() Activity -> " + activity.getClass().getSimpleName());
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
// Log.d(TAG, "Getting current wallet ISO -> " + prefs.getString("currentWalletIso", "RVN"));
return prefs.getString(CURRENT_WALLET_CURRENCY_CODE, "RVN");
}
public static void putCurrentWalletIso(Context activity, String iso) {
Log.d(TAG, "putCurrentWalletIso(), ISO -> " + iso);
if (iso == null) throw new NullPointerException("cannot be null");
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(CURRENT_WALLET_CURRENCY_CODE, iso);
editor.apply();
}
public static boolean getGeoPermissionsRequested(Context activity) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("geoPermissionsRequested", false);
}
public static void putGeoPermissionsRequested(Context activity, boolean requested) {
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("geoPermissionsRequested", requested);
editor.apply();
}
public static long getStartHeight(Context context, String iso) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
return settingsToGet.getLong("startHeight_" + iso.toUpperCase(), 0);
}
public static void putStartHeight(Context context, String iso, long startHeight) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putLong("startHeight_" + iso.toUpperCase(), startHeight);
editor.apply();
}
public static long getLastRescanTime(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
return settingsToGet.getLong(RESCAN_TIME, 0);
}
public static void putLastRescanTime(Context context, long time) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putLong(RESCAN_TIME, time);
editor.apply();
}
public static int getLastBlockHeight(Context context, String iso) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
return settingsToGet.getInt("lastBlockHeight" + iso.toUpperCase(), 0);
}
public static void putLastBlockHeight(Context context, String iso, int lastHeight) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("lastBlockHeight" + iso.toUpperCase(), lastHeight);
editor.apply();
}
public static boolean getScanRecommended(Context context, String iso) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
return settingsToGet.getBoolean("scanRecommended_" + iso.toUpperCase(), false);
}
public static void putScanRecommended(Context context, String iso, boolean recommended) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("scanRecommended_" + iso.toUpperCase(), recommended);
editor.apply();
}
public static int getCryptoDenomination(Context context, String iso) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
return settingsToGet.getInt("currencyUnit", BRConstants.CURRENT_UNIT_RAVENS);
}
public static void putCryptoDenomination(Context context, String iso, int unit) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("currencyUnit", unit);
editor.apply();
}
public static String getDeviceId(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, 0);
String deviceId = settingsToGet.getString("userId", "");
if (deviceId.isEmpty()) setDeviceId(context, UUID.randomUUID().toString());
return (settingsToGet.getString("userId", ""));
}
private static void setDeviceId(Context context, String uuid) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("userId", uuid);
editor.apply();
}
public static void clearAllPrefs(Context activity) {
SharedPreferences.Editor editor = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
editor.clear();
editor.apply();
}
public static boolean getShowNotification(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return settingsToGet.getBoolean("showNotification", false);
}
public static void putShowNotification(Context context, boolean show) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("showNotification", show);
editor.apply();
}
public static boolean getShareData(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return settingsToGet.getBoolean("shareData", false);
}
public static void putShareData(Context context, boolean show) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("shareData", show);
editor.apply();
}
public static boolean getShareDataDismissed(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return settingsToGet.getBoolean("shareDataDismissed", false);
}
public static void putShareDataDismissed(Context context, boolean dismissed) {
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("shareDataDismissed", dismissed);
editor.apply();
}
public static String getTrustNode(Context context, String iso) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getString("trustNode_" + iso.toUpperCase(), "");
}
public static void putTrustNode(Context context, String iso, String trustNode) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("trustNode_" + iso.toUpperCase(), trustNode);
editor.apply();
}
}