Commit 882a447c authored by Mattia Ducci's avatar Mattia Ducci

implementato event track con verifica di funzionalità caching di messaggi e...

implementato event track con verifica di funzionalità caching di messaggi e re-invio non appena ritorna la connessione
parent 547061d4
...@@ -8,6 +8,7 @@ import android.view.View; ...@@ -8,6 +8,7 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Switch; import android.widget.Switch;
import framework.everywaretechnologies.it.icarus.EventTrackResource;
import framework.everywaretechnologies.it.icarus.Icarus; import framework.everywaretechnologies.it.icarus.Icarus;
import framework.everywaretechnologies.it.icarus.UserSettingsResource; import framework.everywaretechnologies.it.icarus.UserSettingsResource;
...@@ -27,6 +28,11 @@ public class MainActivity extends AppCompatActivity { ...@@ -27,6 +28,11 @@ public class MainActivity extends AppCompatActivity {
private Switch intPrefSwitch; private Switch intPrefSwitch;
private Icarus instance; private Icarus instance;
private EditText eventNameEditText;
private EditText eventCategoryEditText;
private EditText eventLabelEditText;
private EditText mostProbableActivityEditText;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -50,6 +56,11 @@ public class MainActivity extends AppCompatActivity { ...@@ -50,6 +56,11 @@ public class MainActivity extends AppCompatActivity {
if(lastIntPref==1)intPrefSwitch.setChecked(false); if(lastIntPref==1)intPrefSwitch.setChecked(false);
else intPrefSwitch.setChecked(true); else intPrefSwitch.setChecked(true);
eventNameEditText=findViewById(R.id.editText_eventName);
eventCategoryEditText=findViewById(R.id.editText_eventCategory);
eventLabelEditText=findViewById(R.id.editText_eventLabel);
mostProbableActivityEditText=findViewById(R.id.editText_mostProbableActivity);
} }
//------------------------- UI EVENT ----------------------- //------------------------- UI EVENT -----------------------
...@@ -87,4 +98,29 @@ public class MainActivity extends AppCompatActivity { ...@@ -87,4 +98,29 @@ public class MainActivity extends AppCompatActivity {
instance.logUserSettings(userSettingsResource,true); instance.logUserSettings(userSettingsResource,true);
} }
public void onBtnEventTrack(View view){
Log.d(CLASS_NAME,"on btn track event");
String eventName,eventCategory,eventLabel,mostProbableActivity;
if(eventNameEditText.getText().length() == 0) eventName="eventoProva";
else eventName=eventNameEditText.getText().toString();
if(eventCategoryEditText.getText().length()==0) eventCategory=Icarus.EventCategories.APPLICATION.toString();
else eventCategory=eventCategoryEditText.getText().toString();
if(eventLabelEditText.getText().length()==0) eventLabel = "labelProva";
else eventLabel=eventLabelEditText.getText().toString();
if(mostProbableActivityEditText.getText().length()==0) mostProbableActivity="activityProva";
else mostProbableActivity=mostProbableActivityEditText.getText().toString();
EventTrackResource eventTrackResource=new EventTrackResource(eventName,eventCategory,eventLabel,90,90,5,
mostProbableActivity,90,false);
instance.logEvent(eventTrackResource,true);
}
} }
...@@ -74,4 +74,44 @@ ...@@ -74,4 +74,44 @@
android:onClick="onBtnUserPrefChanges" android:onClick="onBtnUserPrefChanges"
android:text="Invia pref changes" /> android:text="Invia pref changes" />
<EditText
android:id="@+id/editText_eventName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="18"
android:hint="event name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/editText_eventCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="18"
android:hint="event category"
android:inputType="textPersonName" />
<EditText
android:id="@+id/editText_eventLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="18"
android:hint="event label"
android:inputType="textPersonName" />
<EditText
android:id="@+id/editText_mostProbableActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="18"
android:hint="most probable activity"
android:inputType="textPersonName" />
<Button
android:id="@+id/btn_send_event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onBtnEventTrack"
android:text="Invia event track" />
</android.widget.LinearLayout> </android.widget.LinearLayout>
\ No newline at end of file
...@@ -37,7 +37,7 @@ import java.util.function.Consumer; ...@@ -37,7 +37,7 @@ import java.util.function.Consumer;
public class Icarus { public class Icarus {
enum EventCategories{ //categorie di evento public enum EventCategories{ //categorie di evento
APPLICATION,ACTION,NOTIFICATION; APPLICATION,ACTION,NOTIFICATION;
} }
...@@ -121,8 +121,10 @@ public class Icarus { ...@@ -121,8 +121,10 @@ public class Icarus {
public void logEvent(EventTrackResource eventTrackResource, boolean debug){ public void logEvent(EventTrackResource eventTrackResource, boolean debug){
Log.d(curContext.getString(R.string.icarus_class),"log event"); Log.d(curContext.getString(R.string.icarus_class),"log event -> Volley");
JSONObject eventTrackJSON=eventTrackResource.getEventTrackResourceInJSONFormat();
postIcarusHttpRequest(eventTrackJSON,debug);
} }
......
...@@ -53,7 +53,7 @@ public class UserSettingsResource extends IcarusResource { //classe da non seria ...@@ -53,7 +53,7 @@ public class UserSettingsResource extends IcarusResource { //classe da non seria
} else { //se è la prima volta che l'utente tocca quella pref } else { //se è la prima volta che l'utente tocca quella pref
jsonObject.put("old", null); jsonObject.put("old", null); //TODO: valutare se mettere null come "null" perchè se no nel JSON è come non mettere questo campo, non me lo mette proprio
jsonObject.put("new",newValue); jsonObject.put("new",newValue);
prefsOldNew.put(prefName,jsonObject.toString()); prefsOldNew.put(prefName,jsonObject.toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment