From d967b4b37644ab6aedac36539f8f6fa5cf3547f2 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 6 May 2019 18:01:50 +0300 Subject: Working on TCC.. --- .../Android_Studio/ColorCapture/app/build.gradle | 2 +- .../colorcapture/dagger/ViewModelsModule.java | 2 +- .../com/twine/colorcapture/mvvm/ActivityBase.java | 109 +-- .../colorcapture/mvvm/ActivityCallbackService.java | 60 +- .../navigation/AndroidNavigationProvider.java | 40 +- .../navigation/INavigationProvider.java | 2 + .../views/capture/CaptureFragmentVM.java | 27 +- .../views/result/ResultFragmentVM.java | 4 +- .../views/sendtoemail/SendToEmailActivity.java | 8 +- .../views/sendtoemail/SendToEmailActivityVM.java | 74 +- .../com/twine/colorcapture/web/ITCCService.java | 4 + .../com/twine/colorcapture/web/IWebServiceAPI.java | 5 + .../com/twine/colorcapture/web/TCCService.java | 33 +- .../web/messages/ResultByEmailRequest.java | 49 ++ .../web/messages/ResultByEmailResponse.java | 5 + .../pmr/tcc/DetectionColorFileOuterClass.java | 834 +++++++++++++++++++++ .../src/main/res/layout/activity_send_to_email.xml | 121 ++- .../app/src/main/res/layout/fragment_result.xml | 2 +- 18 files changed, 1281 insertions(+), 100 deletions(-) create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailRequest.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailResponse.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/tango/pmr/tcc/DetectionColorFileOuterClass.java (limited to 'Software/Android_Studio') diff --git a/Software/Android_Studio/ColorCapture/app/build.gradle b/Software/Android_Studio/ColorCapture/app/build.gradle index ae4fcfeb1..00eadc9a6 100644 --- a/Software/Android_Studio/ColorCapture/app/build.gradle +++ b/Software/Android_Studio/ColorCapture/app/build.gradle @@ -23,7 +23,7 @@ android { buildTypes { debug { - buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://10.100.102.46:45455/api/\"" + buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://192.168.1.229:45455/api/\"" buildConfigField "String", "WEB_SERVICE_APP_ID", "\"Tdf793i4ughsiduf8749509237885ehgfdlkghlT\"" } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java index f83826b21..6b99d7ead 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java @@ -51,7 +51,7 @@ public class ViewModelsModule @Singleton public SendToEmailActivityVM provideSendToEmailActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService) { - return new SendToEmailActivityVM(); + return new SendToEmailActivityVM(eventBus, navigationProvider, notificationProvider, tccService); } @Provides diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityBase.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityBase.java index 7863cac80..4c952bbd6 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityBase.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityBase.java @@ -14,6 +14,7 @@ import android.widget.Toast; import com.mobsandgeeks.saripaar.ValidationError; import com.mobsandgeeks.saripaar.Validator; import com.twine.colorcapture.R; +import com.twine.colorcapture.core.IAction1; import java.lang.reflect.Method; import java.util.List; @@ -23,33 +24,36 @@ import javax.inject.Inject; import butterknife.ButterKnife; import io.reactivex.functions.Consumer; +import static com.twine.colorcapture.App.getContext; + /** * Represents a base activity with extra features. * * @param the type parameter * @param the type parameter */ -public abstract class ActivityBase extends Activity implements IView, Validator.ValidationListener { - +public abstract class ActivityBase extends Activity implements IView, Validator.ValidationListener +{ + /** * The constant ACTIVITY_CALLBACK_INTENT. */ protected static final String ACTIVITY_CALLBACK_INTENT = "ACTIVITY_CALLBACK_INTENT"; - + private Consumer lastValidationConsumer; private Validator validator; - + /** * Holds the standard View Model instance. */ @Inject public VM vm; - + /** * Holds the activity data binding instance. */ public BindingView binding; - + @Override protected void onCreate(Bundle savedInstanceState) { @@ -57,105 +61,122 @@ public abstract class ActivityBase consumer) { + public void validateFields(Consumer consumer) + { lastValidationConsumer = consumer; validator.validate(); } - + @Override - public void onValidationSucceeded() { - try { + public void onValidationSucceeded() + { + try + { lastValidationConsumer.accept(true); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - + @Override - public void onValidationFailed(List errors) { - for (ValidationError error : errors) { + public void onValidationFailed(List errors) + { + for (ValidationError error : errors) + { View view = error.getView(); String message = error.getCollatedErrorMessage(this); - - if (view instanceof EditText) { + + if (view instanceof EditText) + { view.requestFocus(); ((EditText) view).setError(message); - } else { + } + else + { Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); } } - - if (lastValidationConsumer != null) { - try { + + if (lastValidationConsumer != null) + { + try + { lastValidationConsumer.accept(false); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } } - + /** * Gets the activity layout resource id. * * @return the layout id */ protected abstract int getLayoutId(); - + /** * Performs dagger dependency injection. */ protected abstract void inject(); - + /** * Starts an activity and receive a callback from the new activity onCreate method. * - * @param activity the activity * @param callback the callback */ - public void startActivityNotify(Class activity, Runnable callback) { - + public static void startActivityNotify(Intent intent, IAction1 callback) + { String key = ActivityCallbackService.getInstance().putCallback(callback); - Intent i = new Intent(getApplicationContext(), activity); - i.putExtra(ACTIVITY_CALLBACK_INTENT, key); - startActivity(i); + intent.putExtra(ACTIVITY_CALLBACK_INTENT, key); + getContext().startActivity(intent); } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityCallbackService.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityCallbackService.java index 0e47af332..f04f6bcfb 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityCallbackService.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/ActivityCallbackService.java @@ -1,5 +1,7 @@ package com.twine.colorcapture.mvvm; +import com.twine.colorcapture.core.IAction1; + import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -9,51 +11,56 @@ import java.util.UUID; */ public class ActivityCallbackService { - + private static ActivityCallbackService instance; - - private Map callbacks; - - private ActivityCallbackService() { + + private Map> callbacks; + + private ActivityCallbackService() + { callbacks = new HashMap<>(); } - + /** * Gets instance. * * @return the instance */ - public static ActivityCallbackService getInstance() { - if (instance == null) { + public static ActivityCallbackService getInstance() + { + if (instance == null) + { instance = new ActivityCallbackService(); } - + return instance; } - + /** * Put callback. * * @param key the key * @param callback the callback */ - public void putCallback(String key, Runnable callback) { - callbacks.put(key,callback); + public void putCallback(String key, IAction1 callback) + { + callbacks.put(key, callback); } - + /** * Put callback string. * * @param callback the callback * @return the string */ - public String putCallback(Runnable callback) { - + public String putCallback(IAction1 callback) + { + String key = UUID.randomUUID().toString(); - callbacks.put(key,callback); + callbacks.put(key, callback); return key; } - + /** * Remove callback. * @@ -63,26 +70,31 @@ public class ActivityCallbackService { callbacks.remove(key); } - + /** * Run. * * @param key the key */ - public void run(String key) + public void run(String key, ViewModelBase vm) { - callbacks.get(key).run(); + callbacks.get(key).invoke(vm); } - + /** * Run and remove. * * @param key the key */ - public void runAndRemove(String key) + public void runAndRemove(String key, ViewModelBase vm) { - callbacks.get(key).run(); - removeCallback(key); + IAction1 action = callbacks.get(key); + + if (action != null) + { + action.invoke(vm); + removeCallback(key); + } } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/AndroidNavigationProvider.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/AndroidNavigationProvider.java index 07bb16ecc..17904623a 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/AndroidNavigationProvider.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/AndroidNavigationProvider.java @@ -1,6 +1,7 @@ package com.twine.colorcapture.navigation; import android.app.Activity; +import android.app.ActivityManager; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Context; @@ -10,9 +11,11 @@ import android.support.v7.app.AppCompatActivity; import android.util.Log; import com.twine.colorcapture.R; +import com.twine.colorcapture.mvvm.ActivityBase; import com.twine.colorcapture.mvvm.ExtendedObject; import com.twine.colorcapture.mvvm.FragmentBase; import com.twine.colorcapture.core.IAction1; +import com.twine.colorcapture.mvvm.ViewModelBase; import java.lang.annotation.Annotation; import java.util.ArrayList; @@ -141,7 +144,8 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga preventCurrentHistory = NavigationFragment.class.getField(currentFragmentName).getAnnotations().length > 0; } preventNextHistory = NavigationFragment.class.getField(fragmentName).getAnnotations().length > 0; - } catch (NoSuchFieldException e) + } + catch (NoSuchFieldException e) { e.printStackTrace(); } @@ -189,7 +193,8 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga try { fragment = (FragmentBase) Class.forName(fragmentName).newInstance(); - } catch (Exception ex) + } + catch (Exception ex) { //logManager.log(ex,"Fragment " + fragmentName + " not found."); return; @@ -230,7 +235,7 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga { if (fragmentTo.getVM() instanceof INavigationObjectReceiver && navigationObject != null) { - ((INavigationObjectReceiver)fragmentTo.getVM()).onNavigationObjectReceived(navigationObject); + ((INavigationObjectReceiver) fragmentTo.getVM()).onNavigationObjectReceived(navigationObject); } new Handler().postDelayed(() -> @@ -248,8 +253,6 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga }); - - // try // { // //noinspection ConstantConditions @@ -272,6 +275,17 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga @Override public void navigateTo(NavigationActivity activityValue, boolean addToHistory) + { + navigateToActivityInternal(activityValue, addToHistory, null); + } + + @Override + public void navigateWithObjectTo(NavigationActivity activityValue, boolean pushToHistory, T obj) + { + navigateToActivityInternal(activityValue, pushToHistory, obj); + } + + private void navigateToActivityInternal(NavigationActivity activityValue, boolean pushToHistory, Object obj) { String name = activityValue.name(); String activityName = basePackagePath + "." + name.toLowerCase() + "." + name + "Activity"; @@ -281,14 +295,24 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga Intent intent = new Intent(context, cls); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - if (!addToHistory) + if (!pushToHistory) { intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NO_HISTORY); } - context.startActivity(intent); + ActivityBase.startActivityNotify(intent, (vm) -> + { + if (obj != null) + { + if (vm instanceof INavigationObjectReceiver) + { + ((INavigationObjectReceiver) vm).onNavigationObjectReceived(obj); + } + } + }); - } catch (ClassNotFoundException e) + } + catch (ClassNotFoundException e) { e.printStackTrace(); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/INavigationProvider.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/INavigationProvider.java index f5453bd89..da696cf6a 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/INavigationProvider.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/INavigationProvider.java @@ -86,5 +86,7 @@ public interface INavigationProvider void navigateTo(NavigationActivity activityValue, boolean addToHistory); + void navigateWithObjectTo(NavigationActivity activityValue, boolean pushToHistory, T obj); + void addFragmentNavigationListener(FragmentNavigatedListener listener); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java index c0b89fba8..263aad444 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java @@ -8,6 +8,7 @@ import com.squareup.otto.Bus; import com.twine.colorcapture.core.Task.TaskBuilder; import com.twine.colorcapture.dialogs.processing.ProcessingDialog; import com.twine.colorcapture.dialogs.welcome.WelcomeDialog; +import com.twine.colorcapture.logging.LogManager; import com.twine.colorcapture.models.ColorResult; import com.twine.colorcapture.mvvm.DependencyProperty; import com.twine.colorcapture.mvvm.ViewModelBase; @@ -71,7 +72,8 @@ public class CaptureFragmentVM extends ViewModelBase implement try { definition = tccService.getDefinition(); - } catch (Exception e) + } + catch (Exception e) { e.printStackTrace(); } @@ -161,13 +163,30 @@ public class CaptureFragmentVM extends ViewModelBase implement abort.set(true); }); - DetectionResponse response = tccService.detect(sampleBitmap, barcode); + DetectionResponse response = null; + boolean success = false; - ThreadingUtils.sleep(1000); + try + { + response = tccService.detect(sampleBitmap, barcode); + success = true; + } + catch (Exception ex) + { + LogManager.log(ex, "Error on color detection."); + + invokeUI(() -> + { + notificationProvider.showError("Processing error", "An error occurred while processing your color. Please try again later", (x) -> + { + + }); + }); + } isDetecting.set(false); - if (!abort.get()) + if (!abort.get() && success) { LocalDateTime date = LocalDateTime.now(); DateTimeFormatter fmt = DateTimeFormat.forPattern("d MMMM, yyyy, hh:mm:ss").withLocale(Locale.ENGLISH); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java index 2e58e2777..4709cd532 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java @@ -32,6 +32,7 @@ public class ResultFragmentVM extends ViewModelBase implements { private INavigationProvider navigationProvider; private ITCCService tccService; + private Bus eventBus; public ColorResult colorResult; public DependencyProperty isCameraColorToggled; @@ -59,6 +60,7 @@ public class ResultFragmentVM extends ViewModelBase implements sendToMachineCommand = new RelayCommand(this::handleSendToMachineCommand); registerMachineCommand = new RelayCommand(this::handlerRegisterMachineCommand); + this.eventBus = eventBus; eventBus.register(this); } @@ -85,7 +87,7 @@ public class ResultFragmentVM extends ViewModelBase implements private void handleEmailCommand() { - navigationProvider.navigateTo(NavigationActivity.SendToEmail, false); + navigationProvider.navigateWithObjectTo(NavigationActivity.SendToEmail, false, colorResult); } private void toggleCameraColor() diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java index d886de513..deff5b244 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java @@ -7,13 +7,19 @@ import com.twine.colorcapture.App; import com.twine.colorcapture.R; import com.twine.colorcapture.databinding.ActivitySendToEmailBinding; import com.twine.colorcapture.mvvm.ActivityBase; +import com.twine.colorcapture.notification.INotificationProvider; + +import javax.inject.Inject; public class SendToEmailActivity extends ActivityBase implements ISendToEmailActivity { + @Inject + public INotificationProvider notificationProvider; + @Override protected void onCreating(Bundle savedInstanceState) { - + notificationProvider.registerMainActivity(this); } @Override diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java index 77467fff4..6e17dc12d 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java @@ -1,21 +1,91 @@ package com.twine.colorcapture.views.sendtoemail; +import com.squareup.otto.Bus; +import com.squareup.otto.Subscribe; +import com.twine.colorcapture.core.Task; +import com.twine.colorcapture.dialogs.progress.ProgressDialogVM; import com.twine.colorcapture.models.ColorResult; +import com.twine.colorcapture.mvvm.DependencyProperty; import com.twine.colorcapture.mvvm.RelayCommand; import com.twine.colorcapture.mvvm.ViewModelBase; +import com.twine.colorcapture.navigation.INavigationObjectReceiver; +import com.twine.colorcapture.navigation.INavigationProvider; +import com.twine.colorcapture.notification.INotificationProvider; +import com.twine.colorcapture.web.ITCCService; +import com.twine.colorcapture.web.messages.ResultByEmailRequest; -public class SendToEmailActivityVM extends ViewModelBase +import java.util.concurrent.atomic.AtomicBoolean; + +public class SendToEmailActivityVM extends ViewModelBase implements INavigationObjectReceiver { + private INavigationProvider navigationProvider; + private INotificationProvider notificationProvider; + private ITCCService tccService; + public RelayCommand sendCommand; public ColorResult colorResult; + public DependencyProperty to; + public DependencyProperty from; + public DependencyProperty message; - public SendToEmailActivityVM() + public SendToEmailActivityVM(Bus eventBus, INavigationProvider navigationProvider, INotificationProvider notificationProvider, ITCCService tccService) { + this.navigationProvider = navigationProvider; + this.notificationProvider = notificationProvider; + this.tccService = tccService; + + to = new DependencyProperty<>(""); + from = new DependencyProperty<>(""); + message = new DependencyProperty<>(""); + sendCommand = new RelayCommand(this::handleSendCommand); } private void handleSendCommand() { + AtomicBoolean abort = new AtomicBoolean(); + ProgressDialogVM vm = notificationProvider.showProgress("Send to email", "Sending color result to " + to.get(), (x) -> + { + abort.set(true); + }); + + new Task.TaskBuilder().setAction(() -> + { + ResultByEmailRequest request = new ResultByEmailRequest(); + request.setDetectionResponse(colorResult.getDetectionResponse()); + request.setTo(to.get()); + request.setFrom(from.get()); + request.setMessage(message.get()); + tccService.sendResultByEmail(request); + }).setError((ex) -> + { + if (!abort.get()) + { + invokeUI(() -> + { + vm.close(); + notificationProvider.showError("Send to email", "An error occurred. Please try again later.", (x) -> + { + }); + }); + } + }).setContinueWith(() -> + { + if (!abort.get()) + { + vm.close(); + notificationProvider.showSuccess("Send to email", "Color result sent successfully", (x) -> + { + }); + navigationProvider.navigateBack(); + } + }).build().start(); + } + + @Override + public void onNavigationObjectReceived(ColorResult colorResult) + { + this.colorResult = colorResult; } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java index 362abe121..48f2f7a28 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java @@ -6,6 +6,8 @@ import com.twine.colorcapture.web.messages.DefinitionResponse; import com.twine.colorcapture.web.messages.DetectionRequest; import com.twine.colorcapture.web.messages.DetectionResponse; import com.twine.colorcapture.web.messages.MachineRegistrationResponse; +import com.twine.colorcapture.web.messages.ResultByEmailRequest; +import com.twine.colorcapture.web.messages.ResultByEmailResponse; import java.io.IOException; import java.util.List; @@ -18,6 +20,8 @@ public interface ITCCService MachineRegistrationResponse register(String serialNumber) throws Exception; + ResultByEmailResponse sendResultByEmail(ResultByEmailRequest request) throws Exception; + boolean isRegistered(); List getOrganizationMachines(); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java index fe292a839..ee38dac71 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java @@ -8,6 +8,8 @@ import com.twine.colorcapture.web.messages.LoginRequest; import com.twine.colorcapture.web.messages.LoginResponse; import com.twine.colorcapture.web.messages.MachineRegistrationRequest; import com.twine.colorcapture.web.messages.MachineRegistrationResponse; +import com.twine.colorcapture.web.messages.ResultByEmailRequest; +import com.twine.colorcapture.web.messages.ResultByEmailResponse; import io.reactivex.Observable; import retrofit2.Call; @@ -27,4 +29,7 @@ public interface IWebServiceAPI @POST("ColorDetection/Register") Call register(@Body MachineRegistrationRequest request); + + @POST("ColorDetection/SendResultByEmail") + Call sendResultByEmail(@Body ResultByEmailRequest request); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java index 6999d2f0e..13a27bd34 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java @@ -17,6 +17,8 @@ import com.twine.colorcapture.web.messages.LoginRequest; import com.twine.colorcapture.web.messages.LoginResponse; import com.twine.colorcapture.web.messages.MachineRegistrationRequest; import com.twine.colorcapture.web.messages.MachineRegistrationResponse; +import com.twine.colorcapture.web.messages.ResultByEmailRequest; +import com.twine.colorcapture.web.messages.ResultByEmailResponse; import java.io.IOException; import java.util.List; @@ -76,6 +78,8 @@ public class TCCService implements ITCCService @Override public DetectionResponse detect(Bitmap bitmap, String barcode) throws Exception { + LogManager.log("Sending detection request..."); + ensureAuthenticated(); DetectionRequest request = new DetectionRequest(); @@ -83,15 +87,18 @@ public class TCCService implements ITCCService request.setBitmapString(BitmapUtils.getBitmapBase64String(bitmap)); request.setBarcode(barcode); + LogManager.log("Detection Request:", request); + Response response = webAPI.detect(request).execute(); if (response.isSuccessful()) { + LogManager.log("Detection Response:", response.body()); return response.body(); } else { - throw new Exception(response.message()); + throw LogManager.log(new Exception(response.message())); } } @@ -125,6 +132,30 @@ public class TCCService implements ITCCService } } + @Override + public ResultByEmailResponse sendResultByEmail(ResultByEmailRequest request) throws Exception + { + LogManager.log("Sending result by email..."); + + ensureAuthenticated(); + + LogManager.log("Sending result by email request:", request); + + Response response = webAPI.sendResultByEmail(request).execute(); + + if (response.isSuccessful()) + { + ResultByEmailResponse r = response.body(); + LogManager.log("Result by email sent successfully."); + return r; + } + else + { + throw LogManager.log(new Exception(response.message()), "Send result by email has failed."); + } + } + + private void ensureAuthenticated() throws Exception { if (loginResponse == null) diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailRequest.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailRequest.java new file mode 100644 index 000000000..af61e9672 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailRequest.java @@ -0,0 +1,49 @@ +package com.twine.colorcapture.web.messages; + +public class ResultByEmailRequest +{ + private String from; + private String to; + private String message; + private DetectionResponse detectionResponse; + + public String getFrom() + { + return from; + } + + public void setFrom(String from) + { + this.from = from; + } + + public String getTo() + { + return to; + } + + public void setTo(String to) + { + this.to = to; + } + + public String getMessage() + { + return message; + } + + public void setMessage(String message) + { + this.message = message; + } + + public DetectionResponse getDetectionResponse() + { + return detectionResponse; + } + + public void setDetectionResponse(DetectionResponse detectionResponse) + { + this.detectionResponse = detectionResponse; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailResponse.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailResponse.java new file mode 100644 index 000000000..2c4b68770 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/ResultByEmailResponse.java @@ -0,0 +1,5 @@ +package com.twine.colorcapture.web.messages; + +public class ResultByEmailResponse +{ +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/tango/pmr/tcc/DetectionColorFileOuterClass.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/tango/pmr/tcc/DetectionColorFileOuterClass.java new file mode 100644 index 000000000..13521f03f --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/tango/pmr/tcc/DetectionColorFileOuterClass.java @@ -0,0 +1,834 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DetectionColorFile.proto + +package com.twine.tango.pmr.tcc; + +public final class DetectionColorFileOuterClass { + private DetectionColorFileOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface DetectionColorFileOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.TCC.DetectionColorFile) + com.google.protobuf.MessageOrBuilder { + + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + boolean hasRawColor(); + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor getRawColor(); + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder getRawColorOrBuilder(); + + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + boolean hasProcessedColor(); + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor getProcessedColor(); + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder getProcessedColorOrBuilder(); + } + /** + * Protobuf type {@code Tango.PMR.TCC.DetectionColorFile} + */ + public static final class DetectionColorFile extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.TCC.DetectionColorFile) + DetectionColorFileOrBuilder { + private static final long serialVersionUID = 0L; + // Use DetectionColorFile.newBuilder() to construct. + private DetectionColorFile(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DetectionColorFile() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DetectionColorFile( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder subBuilder = null; + if (rawColor_ != null) { + subBuilder = rawColor_.toBuilder(); + } + rawColor_ = input.readMessage(com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(rawColor_); + rawColor_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder subBuilder = null; + if (processedColor_ != null) { + subBuilder = processedColor_.toBuilder(); + } + processedColor_ = input.readMessage(com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(processedColor_); + processedColor_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.internal_static_Tango_PMR_TCC_DetectionColorFile_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.internal_static_Tango_PMR_TCC_DetectionColorFile_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile.class, com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile.Builder.class); + } + + public static final int RAWCOLOR_FIELD_NUMBER = 1; + private com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor rawColor_; + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public boolean hasRawColor() { + return rawColor_ != null; + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor getRawColor() { + return rawColor_ == null ? com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.getDefaultInstance() : rawColor_; + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder getRawColorOrBuilder() { + return getRawColor(); + } + + public static final int PROCESSEDCOLOR_FIELD_NUMBER = 2; + private com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor processedColor_; + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public boolean hasProcessedColor() { + return processedColor_ != null; + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor getProcessedColor() { + return processedColor_ == null ? com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.getDefaultInstance() : processedColor_; + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder getProcessedColorOrBuilder() { + return getProcessedColor(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (rawColor_ != null) { + output.writeMessage(1, getRawColor()); + } + if (processedColor_ != null) { + output.writeMessage(2, getProcessedColor()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (rawColor_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getRawColor()); + } + if (processedColor_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getProcessedColor()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile)) { + return super.equals(obj); + } + com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile other = (com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile) obj; + + boolean result = true; + result = result && (hasRawColor() == other.hasRawColor()); + if (hasRawColor()) { + result = result && getRawColor() + .equals(other.getRawColor()); + } + result = result && (hasProcessedColor() == other.hasProcessedColor()); + if (hasProcessedColor()) { + result = result && getProcessedColor() + .equals(other.getProcessedColor()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasRawColor()) { + hash = (37 * hash) + RAWCOLOR_FIELD_NUMBER; + hash = (53 * hash) + getRawColor().hashCode(); + } + if (hasProcessedColor()) { + hash = (37 * hash) + PROCESSEDCOLOR_FIELD_NUMBER; + hash = (53 * hash) + getProcessedColor().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.TCC.DetectionColorFile} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.TCC.DetectionColorFile) + com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFileOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.internal_static_Tango_PMR_TCC_DetectionColorFile_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.internal_static_Tango_PMR_TCC_DetectionColorFile_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile.class, com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile.Builder.class); + } + + // Construct using com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (rawColorBuilder_ == null) { + rawColor_ = null; + } else { + rawColor_ = null; + rawColorBuilder_ = null; + } + if (processedColorBuilder_ == null) { + processedColor_ = null; + } else { + processedColor_ = null; + processedColorBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.internal_static_Tango_PMR_TCC_DetectionColorFile_descriptor; + } + + public com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile getDefaultInstanceForType() { + return com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile.getDefaultInstance(); + } + + public com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile build() { + com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile buildPartial() { + com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile result = new com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile(this); + if (rawColorBuilder_ == null) { + result.rawColor_ = rawColor_; + } else { + result.rawColor_ = rawColorBuilder_.build(); + } + if (processedColorBuilder_ == null) { + result.processedColor_ = processedColor_; + } else { + result.processedColor_ = processedColorBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile) { + return mergeFrom((com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile other) { + if (other == com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile.getDefaultInstance()) return this; + if (other.hasRawColor()) { + mergeRawColor(other.getRawColor()); + } + if (other.hasProcessedColor()) { + mergeProcessedColor(other.getProcessedColor()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor rawColor_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder> rawColorBuilder_; + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public boolean hasRawColor() { + return rawColorBuilder_ != null || rawColor_ != null; + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor getRawColor() { + if (rawColorBuilder_ == null) { + return rawColor_ == null ? com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.getDefaultInstance() : rawColor_; + } else { + return rawColorBuilder_.getMessage(); + } + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public Builder setRawColor(com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor value) { + if (rawColorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + rawColor_ = value; + onChanged(); + } else { + rawColorBuilder_.setMessage(value); + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public Builder setRawColor( + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder builderForValue) { + if (rawColorBuilder_ == null) { + rawColor_ = builderForValue.build(); + onChanged(); + } else { + rawColorBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public Builder mergeRawColor(com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor value) { + if (rawColorBuilder_ == null) { + if (rawColor_ != null) { + rawColor_ = + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.newBuilder(rawColor_).mergeFrom(value).buildPartial(); + } else { + rawColor_ = value; + } + onChanged(); + } else { + rawColorBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public Builder clearRawColor() { + if (rawColorBuilder_ == null) { + rawColor_ = null; + onChanged(); + } else { + rawColor_ = null; + rawColorBuilder_ = null; + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder getRawColorBuilder() { + + onChanged(); + return getRawColorFieldBuilder().getBuilder(); + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder getRawColorOrBuilder() { + if (rawColorBuilder_ != null) { + return rawColorBuilder_.getMessageOrBuilder(); + } else { + return rawColor_ == null ? + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.getDefaultInstance() : rawColor_; + } + } + /** + * .Tango.PMR.TCC.DetectionColor RawColor = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder> + getRawColorFieldBuilder() { + if (rawColorBuilder_ == null) { + rawColorBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder>( + getRawColor(), + getParentForChildren(), + isClean()); + rawColor_ = null; + } + return rawColorBuilder_; + } + + private com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor processedColor_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder> processedColorBuilder_; + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public boolean hasProcessedColor() { + return processedColorBuilder_ != null || processedColor_ != null; + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor getProcessedColor() { + if (processedColorBuilder_ == null) { + return processedColor_ == null ? com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.getDefaultInstance() : processedColor_; + } else { + return processedColorBuilder_.getMessage(); + } + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public Builder setProcessedColor(com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor value) { + if (processedColorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + processedColor_ = value; + onChanged(); + } else { + processedColorBuilder_.setMessage(value); + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public Builder setProcessedColor( + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder builderForValue) { + if (processedColorBuilder_ == null) { + processedColor_ = builderForValue.build(); + onChanged(); + } else { + processedColorBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public Builder mergeProcessedColor(com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor value) { + if (processedColorBuilder_ == null) { + if (processedColor_ != null) { + processedColor_ = + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.newBuilder(processedColor_).mergeFrom(value).buildPartial(); + } else { + processedColor_ = value; + } + onChanged(); + } else { + processedColorBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public Builder clearProcessedColor() { + if (processedColorBuilder_ == null) { + processedColor_ = null; + onChanged(); + } else { + processedColor_ = null; + processedColorBuilder_ = null; + } + + return this; + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder getProcessedColorBuilder() { + + onChanged(); + return getProcessedColorFieldBuilder().getBuilder(); + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + public com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder getProcessedColorOrBuilder() { + if (processedColorBuilder_ != null) { + return processedColorBuilder_.getMessageOrBuilder(); + } else { + return processedColor_ == null ? + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.getDefaultInstance() : processedColor_; + } + } + /** + * .Tango.PMR.TCC.DetectionColor ProcessedColor = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder> + getProcessedColorFieldBuilder() { + if (processedColorBuilder_ == null) { + processedColorBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColor.Builder, com.twine.tango.pmr.tcc.DetectionColorOuterClass.DetectionColorOrBuilder>( + getProcessedColor(), + getParentForChildren(), + isClean()); + processedColor_ = null; + } + return processedColorBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.TCC.DetectionColorFile) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.TCC.DetectionColorFile) + private static final com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile(); + } + + public static com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DetectionColorFile parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DetectionColorFile(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.tcc.DetectionColorFileOuterClass.DetectionColorFile getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_TCC_DetectionColorFile_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_TCC_DetectionColorFile_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\030DetectionColorFile.proto\022\rTango.PMR.TC" + + "C\032\024DetectionColor.proto\"|\n\022DetectionColo" + + "rFile\022/\n\010RawColor\030\001 \001(\0132\035.Tango.PMR.TCC." + + "DetectionColor\0225\n\016ProcessedColor\030\002 \001(\0132\035" + + ".Tango.PMR.TCC.DetectionColorB\031\n\027com.twi" + + "ne.tango.pmr.tccb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.twine.tango.pmr.tcc.DetectionColorOuterClass.getDescriptor(), + }, assigner); + internal_static_Tango_PMR_TCC_DetectionColorFile_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_TCC_DetectionColorFile_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_TCC_DetectionColorFile_descriptor, + new java.lang.String[] { "RawColor", "ProcessedColor", }); + com.twine.tango.pmr.tcc.DetectionColorOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_send_to_email.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_send_to_email.xml index 2e97be0b5..22daa7b14 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_send_to_email.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_send_to_email.xml @@ -21,8 +21,8 @@ android:id="@+id/frameTitle" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="20dp" - android:background="@color/colorPrimaryBackground"> + android:background="@color/colorPrimaryBackground" + android:padding="20dp"> + android:textSize="17.3sp" + android:textStyle="bold" + bind:command="@{vm.sendCommand}" /> + android:layout_below="@id/frameTitle" + android:background="@color/white" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_result.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_result.xml index 90242ec30..8ca28f881 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_result.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_result.xml @@ -136,7 +136,7 @@ + android:background="@{vm.detectionResponse.getRawColor().getColor()}"/> -- cgit v1.3.1