diff --git a/IcarusAndroid/.idea/caches/build_file_checksums.ser b/IcarusAndroid/.idea/caches/build_file_checksums.ser index ba777d47a33b1c13fa587329c5deccb710ae2ad1..88145cc900a6004c46abc7506b510ba51ec50728 100644 Binary files a/IcarusAndroid/.idea/caches/build_file_checksums.ser and b/IcarusAndroid/.idea/caches/build_file_checksums.ser differ diff --git a/IcarusAndroid/app/src/main/java/framework/everywaretechnologies/it/icarusandroid/MainActivity.java b/IcarusAndroid/app/src/main/java/framework/everywaretechnologies/it/icarusandroid/MainActivity.java index 57e2062040c5dacfe77ce035048e095f6bbc9637..8be1b322a03f9ed9fbbf89aa15381bb249615d66 100644 --- a/IcarusAndroid/app/src/main/java/framework/everywaretechnologies/it/icarusandroid/MainActivity.java +++ b/IcarusAndroid/app/src/main/java/framework/everywaretechnologies/it/icarusandroid/MainActivity.java @@ -1,5 +1,6 @@ package framework.everywaretechnologies.it.icarusandroid; +import android.content.SharedPreferences; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; @@ -8,6 +9,7 @@ import android.widget.EditText; import android.widget.Switch; import framework.everywaretechnologies.it.icarus.Icarus; +import framework.everywaretechnologies.it.icarus.UserSettingsResource; //classe di test Icarus framework @@ -16,7 +18,13 @@ public class MainActivity extends AppCompatActivity { private final static String CLASS_NAME="MainActivity"; + private SharedPreferences myPrefs; + private boolean lastBoolPref; + private int lastIntPref; + private Switch enteredExitedScreenTrackSwitch; + private Switch boolPrefSwitch; + private Switch intPrefSwitch; private Icarus instance; @Override @@ -28,6 +36,20 @@ public class MainActivity extends AppCompatActivity { instance.setApplicationContext(getApplicationContext()); enteredExitedScreenTrackSwitch=findViewById(R.id.entered_exited_screen_track_switch); + boolPrefSwitch=findViewById(R.id.pref_bool_switch); + intPrefSwitch=findViewById(R.id.pref_int_switch); + + //creo due sharedPreferences fittizie per poter testare il cambio di pref di Icarus + myPrefs=getSharedPreferences("MyPref",0); + lastBoolPref=myPrefs.getBoolean("boolPref",false); + lastIntPref=myPrefs.getInt("intPref",-1); + + //setto gli switch in base allo stato nelle shared preferences + if(lastBoolPref) boolPrefSwitch.setChecked(true); + else boolPrefSwitch.setChecked(false); + + if(lastIntPref==1)intPrefSwitch.setChecked(false); + else intPrefSwitch.setChecked(true); } //------------------------- UI EVENT ----------------------- @@ -43,4 +65,26 @@ public class MainActivity extends AppCompatActivity { instance.trackScreen(MainActivity.this,eventType); } + + public void onBtnUserPrefChanges(View view){ + + Log.d(CLASS_NAME,"on btn log user changes"); + + //prendo i valori degli switch + boolean boolSwitchValue; + int intSwitchValue; + + if(boolPrefSwitch.isChecked()) boolSwitchValue=Boolean.valueOf(boolPrefSwitch.getTextOn().toString()); + else boolSwitchValue=Boolean.valueOf(boolPrefSwitch.getTextOff().toString()); + + if(intPrefSwitch.isChecked()) intSwitchValue=Integer.valueOf(intPrefSwitch.getTextOn().toString()); + else intSwitchValue=Integer.valueOf(intPrefSwitch.getTextOff().toString()); + + UserSettingsResource userSettingsResource=new UserSettingsResource(myPrefs); + + userSettingsResource.addBoolean("boolPref",boolSwitchValue); + userSettingsResource.addInt("intPref",intSwitchValue); + + instance.logUserSettings(userSettingsResource); + } } diff --git a/IcarusAndroid/app/src/main/res/layout/activity_main.xml b/IcarusAndroid/app/src/main/res/layout/activity_main.xml index 3cc99b1a7e64876be5f81b71606e5c206f77cdd5..873f17b6841d845281107943329f949b18599e98 100644 --- a/IcarusAndroid/app/src/main/res/layout/activity_main.xml +++ b/IcarusAndroid/app/src/main/res/layout/activity_main.xml @@ -13,6 +13,7 @@ android:layout_height="wrap_content" android:text="Track screen" android:textColor="@android:color/holo_red_light" + android:textSize="24sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" @@ -26,7 +27,8 @@ android:splitTrack="false" android:text="Tipo di evento" android:textOff="EXITED" - android:textOn="ENTERED" /> + android:textOn="ENTERED" + android:textSize="18sp" />