Skip to content

Commit

Permalink
merging feature feedback into develop
Browse files Browse the repository at this point in the history
merging feature feedback into develop
  • Loading branch information
fSergio101 committed Apr 10, 2016
2 parents fa2047c + 72f3a67 commit fc91358
Show file tree
Hide file tree
Showing 102 changed files with 1,818 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import android.widget.Toast;
import com.applivery.applvsdklib.domain.exceptions.NotForegroundActivityAvailable;
import com.applivery.applvsdklib.network.api.AppliveryApiService;
import com.applivery.applvsdklib.network.api.AppliveryApiServiceBuilder;
import com.applivery.applvsdklib.domain.appconfig.ObtainAppConfigInteractor;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidCurrentAppInfo;
import com.applivery.applvsdklib.tools.androidimplementations.AppliveryActivityLifecycleCallbacks;
import com.applivery.applvsdklib.tools.androidimplementations.ScreenCaptureUtils;
import com.applivery.applvsdklib.tools.utils.Validate;
import com.applivery.applvsdklib.tools.permissions.AndroidPermissionCheckerImpl;
import com.applivery.applvsdklib.tools.permissions.PermissionChecker;
import com.applivery.applvsdklib.ui.model.ScreenCapture;
import com.applivery.applvsdklib.ui.views.feedback.FeedbackView;
import com.applivery.applvsdklib.ui.views.feedback.UserFeedbackView;
import java.util.concurrent.*;

/**
Expand Down Expand Up @@ -131,6 +134,11 @@ private static void obtainAppConfig(boolean requestConfig) {
}
}

public static String getApplicationId(){
Validate.sdkInitialized();
return applicationId;
}

public static Executor getExecutor() {
synchronized (LOCK) {
if (AppliverySdk.executor == null) {
Expand Down Expand Up @@ -214,8 +222,15 @@ public static void setUpdateCheckingTime(int updateCheckingTime) {
AppliverySdk.updateCheckingTime = new Integer(updateCheckingTime * 1000).longValue();
}

public static void sendFeedbackOnShake() {
Toast.makeText(applicationContext, "You shake your phone", Toast.LENGTH_SHORT).show();
public static void requestForUserFeedBack() {

FeedbackView feedbackView = UserFeedbackView.getInstance(appliveryApiService);

if (feedbackView.isNotShowing()){
ScreenCapture screenCapture = ScreenCaptureUtils.getScreenCapture(getCurrentActivity());
feedbackView.setScreenCapture(screenCapture);
feedbackView.show();
}
}

public static class Logger {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ protected void receivedResponse(BusinessObject obj, Class<T> responseClass) {
@Override public void run() {
Message message = new Message();
message.obj = performRequest();

if (message.obj == null){
message.obj = new ErrorObject();
}

handler.sendMessage(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ObtainAppConfigInteractor extends BaseInteractor<AppConfig> {
private final ObtainAppConfigRequest obtainAppConfigRequest;
private final InteractorCallback appConfigInteractorCallback;

public ObtainAppConfigInteractor(AppliveryApiService apiService, String appId, String authToken,
private ObtainAppConfigInteractor(AppliveryApiService apiService, String appId, String authToken,
CurrentAppInfo currentAppInfo) {
this.obtainAppConfigRequest = new ObtainAppConfigRequest(apiService, appId, authToken);
this.appConfigInteractorCallback = new ObtainAppConfigInteractorCallback(apiService, currentAppInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
*/
public interface CurrentAppInfo {
long getVersionCode();

String getPackageName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.applivery.applvsdklib.domain.download.token.ObtainBuildTokenInteractorCallback;
import com.applivery.applvsdklib.domain.model.AppConfig;
import com.applivery.applvsdklib.network.api.AppliveryApiService;
import com.applivery.applvsdklib.network.api.requests.ExternalStorageReader;
import com.applivery.applvsdklib.domain.download.app.ExternalStorageReader;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidAppInstallerImpl;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidExternalStorageReaderImpl;
import com.applivery.applvsdklib.ui.views.update.UpdateListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import com.applivery.applvsdklib.domain.model.ErrorObject;
import com.applivery.applvsdklib.network.api.AppliveryApiService;
import com.applivery.applvsdklib.network.api.requests.DownloadBuildRequest;
import com.applivery.applvsdklib.network.api.requests.DownloadStatusListener;
import com.applivery.applvsdklib.network.api.requests.ExternalStorageWriter;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidAppInstallerImpl;

/**
Expand All @@ -40,7 +38,7 @@ public class DownloadBuildInteractor extends BaseInteractor<DownloadResult> {
private final DownloadStatusListener downloadStatusListener;
private final AppInstaller appInstaller;

public DownloadBuildInteractor(AppliveryApiService appliveryApiService, String appName,
private DownloadBuildInteractor(AppliveryApiService appliveryApiService, String appName,
BuildTokenInfo buildTokenInfo, final DownloadBuildInteractorCallback interactorCallback,
ExternalStorageWriter externalStorageWriter) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.applivery.applvsdklib.network.api.requests;
package com.applivery.applvsdklib.domain.download.app;

import com.applivery.applvsdklib.domain.model.DownloadResult;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.applivery.applvsdklib.network.api.requests;
package com.applivery.applvsdklib.domain.download.app;

import com.applivery.applvsdklib.tools.androidimplementations.AppPathReceiver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.applivery.applvsdklib.network.api.requests;
package com.applivery.applvsdklib.domain.download.app;

import java.io.InputStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ObtainAppBuildDownloadTokenInteractor extends BaseInteractor<BuildT
private final ObtainBuildDownloadTokenRequest obtainBuildDownloadTokenRequest;
private final InteractorCallback<BuildTokenInfo> infoInteractorCallback;

public ObtainAppBuildDownloadTokenInteractor(AppliveryApiService appliveryApiService,
private ObtainAppBuildDownloadTokenInteractor(AppliveryApiService appliveryApiService,
String buildId, InteractorCallback<BuildTokenInfo> infoInteractorCallback) {

this.obtainBuildDownloadTokenRequest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.applivery.applvsdklib.domain.model.BuildTokenInfo;
import com.applivery.applvsdklib.domain.model.ErrorObject;
import com.applivery.applvsdklib.network.api.AppliveryApiService;
import com.applivery.applvsdklib.network.api.requests.ExternalStorageWriter;
import com.applivery.applvsdklib.domain.download.app.ExternalStorageWriter;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidExternalStorageWriterImpl;
import com.applivery.applvsdklib.ui.views.ShowErrorAlert;
import com.applivery.applvsdklib.ui.views.update.UpdateView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@
* limitations under the License.
*/

package com.applivery.applvsdklib.network.api.requests;
package com.applivery.applvsdklib.domain.feedback;

/**
* Created by Sergio Martinez Rodriguez
* Date 3/1/16.
* Date 10/1/16.
*/
public class ApiFeedbackRequestData {
public interface DeviceDetailsInfo {

//TODO next release stuff
String getOsName();

String getVendor();

String getModel();

String getDeviceType();

String getOsversion();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,38 @@

package com.applivery.applvsdklib.domain.feedback;

import com.applivery.applvsdklib.AppliverySdk;
import com.applivery.applvsdklib.domain.BaseInteractor;
import com.applivery.applvsdklib.domain.InteractorCallback;
import com.applivery.applvsdklib.domain.appconfig.update.CurrentAppInfo;
import com.applivery.applvsdklib.domain.model.BusinessObject;
import com.applivery.applvsdklib.domain.model.ErrorObject;
import com.applivery.applvsdklib.domain.model.Feedback;
import com.applivery.applvsdklib.domain.model.FeedbackResult;
import com.applivery.applvsdklib.domain.model.FeedbackWrapper;
import com.applivery.applvsdklib.network.api.AppliveryApiService;
import com.applivery.applvsdklib.network.api.requests.FeedbackRequest;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidCurrentAppInfo;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidDeviceDetailsInfo;
import com.applivery.applvsdklib.ui.views.feedback.UserFeedbackPresenter;

/**
* Created by Sergio Martinez Rodriguez
* Date 3/1/16.
*/
public class FeedbackInteractor extends BaseInteractor<FeedbackResult> {

//TODO next release stuff

private final FeedbackRequest feedbackRequest;
private final InteractorCallback feedbackCallback;
private final FeedbackWrapper feedbackWrapper;

public FeedbackInteractor(FeedbackRequest feedbackRequest, InteractorCallback feedbackCallback,
Feedback feedback, AppliveryApiService appliveryApiService) {
this.feedbackWrapper = FeedbackWrapper.createWrapper(feedback);
public FeedbackInteractor(AppliveryApiService appliveryApiService, Feedback feedback,
CurrentAppInfo currentAppInfo, DeviceDetailsInfo deviceDetailsInfo,
InteractorCallback interactorCallback) {

this.feedbackWrapper = FeedbackWrapper.createWrapper(feedback, currentAppInfo, deviceDetailsInfo);
this.feedbackRequest = new FeedbackRequest(appliveryApiService, feedbackWrapper);
this.feedbackCallback = feedbackCallback;
this.feedbackCallback = interactorCallback;
}

@Override protected void receivedResponse(BusinessObject result) {
Expand All @@ -58,7 +63,18 @@ public FeedbackInteractor(FeedbackRequest feedbackRequest, InteractorCallback fe
}

@Override protected BusinessObject performRequest() {
//TODO transform fee
return feedbackRequest.execute();
}

public static Runnable getInstance(AppliveryApiService service, Feedback feedback, UserFeedbackPresenter
userFeedbackPresenter) {

CurrentAppInfo currentAppInfo = new AndroidCurrentAppInfo(AppliverySdk.getApplicationContext());
DeviceDetailsInfo deviceDetailsInfo = new AndroidDeviceDetailsInfo();

FeedbackInteractor feedbackInteractor = new FeedbackInteractor(service, feedback,
currentAppInfo, deviceDetailsInfo, userFeedbackPresenter);

return feedbackInteractor;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2016 Applivery
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.applivery.applvsdklib.domain.feedback;

import com.applivery.applvsdklib.domain.InteractorCallback;
import com.applivery.applvsdklib.domain.model.ErrorObject;
import com.applivery.applvsdklib.domain.model.FeedbackResult;

/**
* Created by Sergio Martinez Rodriguez
* Date 9/4/16.
*/
public class FeedbackInteractorCallback implements InteractorCallback<FeedbackResult> {

@Override public void onSuccess(FeedbackResult businessObject) {

}

@Override public void onError(ErrorObject error) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public ErrorObject(ApiAppliveryServerErrorResponse serverResponse) {
isBusinessError = serverResponse.isBusinessError();
}

public ErrorObject() {
businessCode = -99;
message = "Unknown Error";
isBusinessError = false;
}

@Override public ErrorObject getObject() {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016 Applivery
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.applivery.applvsdklib.domain.model;

import com.applivery.applvsdklib.tools.utils.StringValueEnum;

/**
* Created by Sergio Martinez Rodriguez
* Date 10/4/16.
*/
public enum FeedBackType implements StringValueEnum{
FEEDBACK("feedback"),
BUG("bug");

private final String type;

FeedBackType(final String type) {
this.type = type;
}

public String getStringValue() {
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,26 @@

package com.applivery.applvsdklib.domain.model;

import com.applivery.applvsdklib.ui.model.ScreenCapture;

/**
* Created by Sergio Martinez Rodriguez
* Date 3/1/16.
*/
public interface Feedback {
//TODO next release stuff
void setType(FeedBackType bug);

void attachScreenshot(boolean activated);

boolean mustAttachScreenshot();

void setMessage(String feedbackMessage);

String getMessage();

void setScreenCapture(ScreenCapture screenCapture);

String getBase64ScreenCapture();

FeedBackType getType();
}
Loading

0 comments on commit fc91358

Please sign in to comment.