1
1
package net .azib .ipscan .config ;
2
2
3
3
import java .util .Locale ;
4
- import java .util .UUID ;
4
+ import java .util .Random ;
5
5
import java .util .prefs .Preferences ;
6
6
7
7
/**
13
13
public final class Config {
14
14
private Preferences preferences ;
15
15
public String language ;
16
- public String uuid ;
16
+ public String gaClientId ;
17
17
public boolean allowReports ;
18
18
19
19
/** easily accessible scanner configuration */
@@ -32,10 +32,13 @@ public final class Config {
32
32
favoritesConfig = new FavoritesConfig (preferences );
33
33
openersConfig = new OpenersConfig (preferences );
34
34
language = preferences .get ("language" , "system" );
35
- uuid = preferences .get ("uuid" , null );
36
- if (uuid == null ) {
37
- uuid = UUID .randomUUID ().toString ();
38
- preferences .put ("uuid" , uuid );
35
+ gaClientId = preferences .get ("gaClientId" , null );
36
+ if (gaClientId == null ) {
37
+ Random random = new Random ();
38
+ long firstPart = 1000000000L + (long )(random .nextDouble () * 9000000000L );
39
+ long secondPart = 1000000000L + (long )(random .nextDouble () * 9000000000L );
40
+ gaClientId = firstPart + "." + secondPart ;
41
+ preferences .put ("gaClientId" , gaClientId );
39
42
}
40
43
allowReports = preferences .getBoolean ("allowReports" , true );
41
44
}
@@ -50,7 +53,6 @@ public static Config getConfig() {
50
53
51
54
public void store () {
52
55
preferences .put ("language" , language );
53
- preferences .put ("uuid" , uuid );
54
56
preferences .putBoolean ("allowReports" , allowReports );
55
57
scannerConfig .store ();
56
58
guiConfig .store ();
@@ -103,7 +105,7 @@ private Locale createLocale(String locale) {
103
105
return Locale .forLanguageTag (locale .replace ('_' , '-' ));
104
106
}
105
107
106
- public String getUUID () {
107
- return uuid ;
108
+ public String getGaClientId () {
109
+ return gaClientId ;
108
110
}
109
111
}
0 commit comments