adjuested feedback model
This commit is contained in:
parent
d7bc56f5f9
commit
1e07168725
@ -1,5 +1,5 @@
|
||||
|
||||
package com.uam.wmi.findmytutor.model;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@ -8,18 +8,53 @@ public class Feedback {
|
||||
@SerializedName("isAnonymous")
|
||||
@Expose
|
||||
private Boolean isAnonymous;
|
||||
@SerializedName("header")
|
||||
@SerializedName("type")
|
||||
@Expose
|
||||
private String header;
|
||||
private String type;
|
||||
@SerializedName("user")
|
||||
@Expose
|
||||
private String user;
|
||||
@SerializedName("deviceOS")
|
||||
@Expose
|
||||
private String deviceOS;
|
||||
@SerializedName("appVersion")
|
||||
@Expose
|
||||
private String appVersion;
|
||||
@SerializedName("deviceModel")
|
||||
@Expose
|
||||
private String deviceModel;
|
||||
@SerializedName("body")
|
||||
@Expose
|
||||
private String body;
|
||||
|
||||
public Feedback(boolean isAnonymous, String header, String body){
|
||||
/**
|
||||
* No args constructor for use in serialization
|
||||
*
|
||||
*/
|
||||
public Feedback() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param body
|
||||
* @param appVersion
|
||||
* @param deviceModel
|
||||
* @param type
|
||||
* @param isAnonymous
|
||||
* @param user
|
||||
* @param deviceOS
|
||||
*/
|
||||
public Feedback(Boolean isAnonymous, String type, String user, String deviceOS, String appVersion, String deviceModel, String body) {
|
||||
super();
|
||||
this.isAnonymous = isAnonymous;
|
||||
this.header = header;
|
||||
this.type = type;
|
||||
this.user = user;
|
||||
this.deviceOS = deviceOS;
|
||||
this.appVersion = appVersion;
|
||||
this.deviceModel = deviceModel;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Boolean getIsAnonymous() {
|
||||
return isAnonymous;
|
||||
}
|
||||
@ -28,12 +63,74 @@ public class Feedback {
|
||||
this.isAnonymous = isAnonymous;
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
public Feedback withIsAnonymous(Boolean isAnonymous) {
|
||||
this.isAnonymous = isAnonymous;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setHeader(String header) {
|
||||
this.header = header;
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Feedback withType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Feedback withUser(String user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDeviceOS() {
|
||||
return deviceOS;
|
||||
}
|
||||
|
||||
public void setDeviceOS(String deviceOS) {
|
||||
this.deviceOS = deviceOS;
|
||||
}
|
||||
|
||||
public Feedback withDeviceOS(String deviceOS) {
|
||||
this.deviceOS = deviceOS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAppVersion() {
|
||||
return appVersion;
|
||||
}
|
||||
|
||||
public void setAppVersion(String appVersion) {
|
||||
this.appVersion = appVersion;
|
||||
}
|
||||
|
||||
public Feedback withAppVersion(String appVersion) {
|
||||
this.appVersion = appVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDeviceModel() {
|
||||
return deviceModel;
|
||||
}
|
||||
|
||||
public void setDeviceModel(String deviceModel) {
|
||||
this.deviceModel = deviceModel;
|
||||
}
|
||||
|
||||
public Feedback withDeviceModel(String deviceModel) {
|
||||
this.deviceModel = deviceModel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
@ -44,4 +141,38 @@ public class Feedback {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Feedback withBody(String body) {
|
||||
this.body = body;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Boolean.toString(this.isAnonymous) + this.type + this.user+this.deviceOS+this.appVersion+this.deviceModel+this.body;
|
||||
}
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return new ToStringBuilder(this).append("isAnonymous", isAnonymous).append("type", type).append("user", user).append("deviceOS", deviceOS).append("appVersion", appVersion).append("deviceModel", deviceModel).append("body", body).toString();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// private Boolean isAnonymous;
|
||||
// @SerializedName("type")
|
||||
// @Expose
|
||||
// private String type;
|
||||
// @SerializedName("user")
|
||||
// @Expose
|
||||
// private String user;
|
||||
// @SerializedName("deviceOS")
|
||||
// @Expose
|
||||
// private String deviceOS;
|
||||
// @SerializedName("appVersion")
|
||||
// @Expose
|
||||
// private String appVersion;
|
||||
// @SerializedName("deviceModel")
|
||||
// @Expose
|
||||
// private String deviceModel;
|
||||
// @SerializedName("body")
|
||||
// @Expose
|
||||
// private String body;
|
@ -10,8 +10,8 @@ import retrofit2.http.POST;
|
||||
|
||||
public interface FeedbackService {
|
||||
@POST("api/Feedback")
|
||||
Observable<Response<Void>> postFeedback(@Body Feedback feedback);
|
||||
Observable<Void> postFeedback(@Body Feedback feedback);
|
||||
|
||||
@GET("api/Feedback")
|
||||
Single<Feedback> getFeedback();
|
||||
Observable<Void> getFeedback();
|
||||
}
|
||||
|
@ -77,31 +77,42 @@ public class FeedbackUtils {
|
||||
private void sendFeedback(String header, String body, boolean mode) {
|
||||
String appVersion = null;
|
||||
String metadata = null;
|
||||
Feedback userFeedback= null;
|
||||
try {
|
||||
appVersion = activityContext.getPackageManager().getPackageInfo(activityContext.getPackageName(), 0).versionName;
|
||||
if( !mode ){
|
||||
metadata = "\n-----------------------------\n" +
|
||||
"User ID: " + PrefUtils.getUserId(activityContext) + "\n" +
|
||||
"Device OS: Android\n" +
|
||||
"Device OS version: " + Build.VERSION.RELEASE + "\n" +
|
||||
"App Version: " + appVersion + "\n" +
|
||||
"Device Model: " + Build.MODEL + "\n" +
|
||||
"Device Manufacturer: " + Build.MANUFACTURER + "\n" +
|
||||
"-----------------------------\n";
|
||||
body = metadata + body;
|
||||
header = header + " - " + PrefUtils.getUserFirstName(activityContext) + " " + PrefUtils.getUserLastName(activityContext);
|
||||
body = PrefUtils.getUserFirstName(activityContext) + " " + PrefUtils.getUserLastName(activityContext) + "\n" + body;
|
||||
userFeedback = new Feedback(mode,
|
||||
header,
|
||||
PrefUtils.getUserId(activityContext),
|
||||
"Android "+ Build.VERSION.RELEASE,
|
||||
appVersion,
|
||||
Build.MODEL,
|
||||
body);
|
||||
Log.d("FEEDBACK non anon", userFeedback.toString());
|
||||
|
||||
}else{
|
||||
userFeedback = new Feedback(mode,
|
||||
header,
|
||||
"anonymous",
|
||||
"Android "+ Build.VERSION.RELEASE,
|
||||
appVersion,
|
||||
Build.MODEL,
|
||||
body);
|
||||
Log.d("FEEDBACK anon",userFeedback.toString());
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
|
||||
}
|
||||
FeedbackService feedbackService = ApiClient.getClient(activityContext).create(FeedbackService.class);
|
||||
Feedback userFeedback = new Feedback(mode,header,body);
|
||||
|
||||
CompositeDisposable disposable = new CompositeDisposable();
|
||||
disposable.add(feedbackService.postFeedback(userFeedback)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
}
|
||||
private void handleResponse(Response<Void> resp) {
|
||||
private void handleResponse( Void resp) {
|
||||
Toast.makeText(activityContext, activityContext.getString(R.string.modal_feedback_thankyou), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@ -113,9 +124,9 @@ public class FeedbackUtils {
|
||||
RestApiHelper.getErrorMessage(responseBody), Toast.LENGTH_SHORT).show();
|
||||
|
||||
} else {
|
||||
Toast.makeText(activityContext,
|
||||
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.d("FEEDBACK",error.getMessage());
|
||||
// Toast.makeText(activityContext,
|
||||
// "Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.d("FEEDBACK handerr ",error.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user