33import android .os .Bundle ;
44import android .util .Log ;
55
6- import com .facebook .crypto .CryptoConfig ;
76import com .google .gson .reflect .TypeToken ;
87import com .zeroone .conceal .ConcealCrypto ;
98import com .zeroone .conceal .ConcealPrefRepository ;
9+ import com .zeroone .conceal .model .CryptoType ;
1010
1111import java .util .ArrayList ;
12+ import java .util .List ;
1213import java .util .Map ;
1314
1415public class MainActivity extends BaseActivity {
@@ -20,6 +21,8 @@ public class MainActivity extends BaseActivity {
2021 String TASK_DETAIL = "task_detail" ;
2122 String IMAGE_KEY = "user_image" ;
2223 String FILE_KEY = "user_file" ;
24+ String PREFIX = "testing" ;
25+
2326
2427 @ Override
2528 protected void onCreate (Bundle savedInstanceState ) {
@@ -29,7 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
2932 ConcealPrefRepository .applicationInit (getApplication ());
3033
3134 concealPrefRepository .clearPrefs ();
32-
35+
3336
3437 //FIRST TEST
3538 concealPrefRepository .putString (NAME_KEY , "HAFIQ IQMAL" );
@@ -56,25 +59,28 @@ protected void onCreate(Bundle savedInstanceState) {
5659 Log .d ("SECOND TEST" ,concealPrefRepository .getString (AGE_KEY ));
5760 Log .d ("SECOND TEST SIZE" , "" +concealPrefRepository .getPrefsSize ());
5861
62+ getList ();
5963
6064
6165 concealPrefRepository .clearPrefs ();
6266
6367 //add user details preferences
64- new ConcealPrefRepository .
UserPref (
"PREFIX" ).
setFirstName (
"Firstname" ).
setLastName (
"Lasname" ).
setEmail (
"[email protected] " ).
apply ();
68+ new ConcealPrefRepository .
UserPref (
PREFIX ).
setFirstName (
"Firstname" ).
setLastName (
"Lasname" ).
setEmail (
"[email protected] " ).
apply ();
69+
70+ getList ();
6571
6672 //get user details
67- Log .d ("THIRD_TEST" ,new ConcealPrefRepository .UserPref (" PREFIX" ).getFirstName ());
68- Log .d ("THIRD_TEST" ,new ConcealPrefRepository .UserPref ().setDefault ("No Data" ).getLastName ());
69- Log .d ("THIRD_TEST" ,new ConcealPrefRepository .UserPref (" PREFIX" ).setDefault ("No Data" ).getEmail ());
73+ Log .d ("THIRD_TEST" , new ConcealPrefRepository .UserPref (PREFIX ).getFirstName ());
74+ Log .d ("THIRD_TEST" , new ConcealPrefRepository .UserPref ().setDefault ("No Data" ).getLastName ());
75+ Log .d ("THIRD_TEST" , new ConcealPrefRepository .UserPref (PREFIX ).setDefault ("No Data" ).getEmail ());
7076 Log .d ("THIRD_TEST TEST SIZE" , "" +concealPrefRepository .getPrefsSize ());
7177
7278
7379
7480 concealPrefRepository .clearPrefs ();
7581
7682
77- ConcealPrefRepository .UserPref userPref = new ConcealPrefRepository .UserPref (" PREFIX" , "No Data" );
83+ ConcealPrefRepository .UserPref userPref = new ConcealPrefRepository .UserPref (PREFIX , "No Data" );
7884 userPref .setUserName ("afiqiqmal" );
7985 userPref .
setEmail (
"[email protected] " );
8086 userPref .apply ();
@@ -86,7 +92,7 @@ protected void onCreate(Bundle savedInstanceState) {
8692
8793
8894
89- ConcealPrefRepository .DevicePref devicePref = new ConcealPrefRepository .DevicePref (" PREFIX" , "No Data" );
95+ ConcealPrefRepository .DevicePref devicePref = new ConcealPrefRepository .DevicePref (PREFIX , "No Data" );
9096 devicePref .setDeviceId ("ABC123123123" );
9197 devicePref .setDeviceOS ("android" );
9298 devicePref .apply ();
@@ -107,12 +113,14 @@ protected void onCreate(Bundle savedInstanceState) {
107113 e .printStackTrace ();
108114 }
109115 }
110- Log .d ("VIEW ALL SIZE" , "" +concealPrefRepository .getPrefsSize ());
116+
117+
118+ getList ();
111119
112120
113121 ConcealCrypto concealCrypto = new ConcealCrypto .CryptoBuilder (this )
114122 .setEnableCrypto (true ) //default true
115- .setKeyChain (CryptoConfig .KEY_256 ) // CryptoConfig .KEY_256 or CryptoConfig .KEY_128
123+ .setKeyChain (CryptoType .KEY_256 ) // CryptoType .KEY_256 or CryptoType .KEY_128
116124 .createPassword ("Mac OSX" )
117125 .create ();
118126
@@ -137,4 +145,19 @@ protected void onCreate(Bundle savedInstanceState) {
137145
138146
139147 }
148+
149+
150+ private void getList () {
151+ List <String > mapList = concealPrefRepository .getAllSharedPrefDataToString ();
152+ for (String s : mapList ){
153+ try {
154+ Log .d ("VIEW_LIST" , s );
155+ }
156+ catch (Exception e ){
157+ e .printStackTrace ();
158+ }
159+ }
160+
161+ Log .d ("VIEW ALL SIZE" , "" +concealPrefRepository .getPrefsSize ());
162+ }
140163}
0 commit comments