diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-04-14 09:28:15 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-04-14 09:28:15 +0300 |
| commit | 641171e30368056bd97fd53c8dade56889739bc3 (patch) | |
| tree | 883580efb85d1802552c6531bbf890e530ed4a0c | |
| parent | b8df604c464ffb43f1858377cbb08d8f622b9cd1 (diff) | |
| download | Tango-641171e30368056bd97fd53c8dade56889739bc3.tar.gz Tango-641171e30368056bd97fd53c8dade56889739bc3.zip | |
Working on TCC...
109 files changed, 1535 insertions, 161 deletions
diff --git a/Software/Android_Studio/ColorCapture/app/build.gradle b/Software/Android_Studio/ColorCapture/app/build.gradle index abe425ac7..7cfa48485 100644 --- a/Software/Android_Studio/ColorCapture/app/build.gradle +++ b/Software/Android_Studio/ColorCapture/app/build.gradle @@ -82,5 +82,6 @@ dependencies { compile 'com.squareup.retrofit2:converter-gson:2.1.0' implementation 'com.github.yoanngoular:bitmapconverter:0.2.0' compile 'com.github.CardinalNow:Android-CircleProgressIndicator:v0.2' + implementation 'com.github.florent37:shapeofview:1.3.2' } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/Messages/ColorDetectedMessage.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/Messages/ColorDetectedMessage.java new file mode 100644 index 000000000..f249335f7 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/Messages/ColorDetectedMessage.java @@ -0,0 +1,19 @@ +package com.twine.colorcapture.Messages; + +import com.twine.colorcapture.web.messages.DetectionColor; +import com.twine.colorcapture.web.messages.DetectionResponse; + +public class ColorDetectedMessage +{ + private DetectionResponse detectionResponse; + + 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/controls/CircleActionButton.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/controls/CircleActionButton.java new file mode 100644 index 000000000..424671341 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/controls/CircleActionButton.java @@ -0,0 +1,159 @@ +package com.twine.colorcapture.controls; + +import android.animation.Animator; +import android.animation.ValueAnimator; +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.AppCompatTextView; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import com.github.florent37.shapeofview.shapes.RoundRectView; +import com.twine.colorcapture.R; + +public class CircleActionButton extends FrameLayout implements View.OnTouchListener +{ + private RoundRectView circleActionButton; + private Button btn; + private FrameLayout frameAfterPadding; + private int initial_circle_width; + private ValueAnimator animationDown; + private ValueAnimator animationUp; + private Drawable icon; + + public CircleActionButton(@NonNull Context context, @Nullable AttributeSet attrs) + { + super(context, attrs); + init(context,attrs); + } + + private void init(Context context,AttributeSet attrs) + { + inflate(context, R.layout.circle_action_button, this); + + btn = findViewById(R.id.actionButtonCircleButton); + circleActionButton = findViewById(R.id.actionButtonCircle); + frameAfterPadding = findViewById(R.id.frameAfterPadding); + ImageView imageView = findViewById(R.id.circleActionButtonImageView); + AppCompatTextView textView = findViewById(R.id.circleActionButtonTextView); + + btn.setOnTouchListener(this); + + TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CircleActionButton); + + icon = getContext().getDrawable(a.getResourceId(R.styleable.CircleActionButton_src, 0)); + CharSequence text = a.getText(R.styleable.CircleActionButton_text); + + imageView.setImageDrawable(icon); + textView.setText(text); + + a.recycle(); + } + + @Override + public boolean onTouch(View view, MotionEvent motionEvent) + { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) + { + animateDown(); + } + else if (motionEvent.getAction() == MotionEvent.ACTION_UP) + { + animateUp(); + } + + return true; + } + + private void animateDown() + { + cancelAnimations(); + + if (initial_circle_width == 0) + { + initial_circle_width = circleActionButton.getMeasuredWidth(); + } + + ValueAnimator anim = ValueAnimator.ofInt(initial_circle_width, frameAfterPadding.getMeasuredWidth()); + animationDown = anim; + anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + int val = (Integer) valueAnimator.getAnimatedValue(); + ViewGroup.LayoutParams layoutParams = circleActionButton.getLayoutParams(); + layoutParams.width = val; + circleActionButton.setLayoutParams(layoutParams); + } + }); + anim.addListener(new Animator.AnimatorListener() + { + @Override + public void onAnimationStart(Animator animator) + { + + } + + @Override + public void onAnimationEnd(Animator animator) + { + + } + + @Override + public void onAnimationCancel(Animator animator) + { + + } + + @Override + public void onAnimationRepeat(Animator animator) + { + + } + }); + anim.setDuration(50); + anim.start(); + } + + private void animateUp() + { + cancelAnimations(); + ValueAnimator anim = ValueAnimator.ofInt(circleActionButton.getMeasuredWidth(), initial_circle_width); + animationUp = anim; + anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + int val = (Integer) valueAnimator.getAnimatedValue(); + ViewGroup.LayoutParams layoutParams = circleActionButton.getLayoutParams(); + layoutParams.width = val; + circleActionButton.setLayoutParams(layoutParams); + } + }); + anim.setDuration(300); + anim.setStartDelay(200); + anim.start(); + } + + private void cancelAnimations() + { + if (animationDown != null) + { + animationDown.cancel(); + animationDown = null; + } + + if (animationUp != null) + { + animationUp.cancel(); + animationUp = null; + } + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java index f19571b06..219056c1b 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java @@ -41,7 +41,7 @@ public class AnimationsHelper try { onCompleted.invoke(); - } catch (IOException e) + } catch (Exception e) { e.printStackTrace(); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/CountUpTimer.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/CountUpTimer.java new file mode 100644 index 000000000..597b46430 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/CountUpTimer.java @@ -0,0 +1,29 @@ +package com.twine.colorcapture.core; + +import android.os.CountDownTimer; + +public abstract class CountUpTimer extends CountDownTimer +{ + private int duration; + + protected CountUpTimer(int durationMs, long interval) + { + super(durationMs, interval); + this.duration = durationMs; + } + + public abstract void onTick(float milli); + + @Override + public void onTick(long msUntilFinished) + { + float milli = (float) ((duration - msUntilFinished)); + onTick(milli); + } + + @Override + public void onFinish() + { + onTick((float)duration); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java index 35cf21cc4..2a6724efb 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java @@ -10,5 +10,5 @@ public interface IAction /** * Invokes the action. */ - void invoke() throws IOException; + void invoke() throws Exception; } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java index 407de37d3..5148b9e6f 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java @@ -56,7 +56,7 @@ public class Task extends AsyncTask<String, Integer, String> try { continueWithAction.invoke(); - } catch (IOException e) + } catch (Exception e) { e.printStackTrace(); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java index f52f30a53..a6216608f 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java @@ -1,10 +1,14 @@ package com.twine.colorcapture.dagger; +import com.twine.colorcapture.dialogs.processing.ProcessingDialog; +import com.twine.colorcapture.dialogs.registering.RegisteringDialog; import com.twine.colorcapture.dialogs.welcome.WelcomeDialog; import com.twine.colorcapture.views.capture.CaptureFragment; import com.twine.colorcapture.views.mycolors.MyColorsFragment; import com.twine.colorcapture.views.loading.LoadingActivity; import com.twine.colorcapture.views.main.MainActivity; +import com.twine.colorcapture.views.register.RegisterFragment; +import com.twine.colorcapture.views.result.ResultFragment; import javax.inject.Singleton; @@ -27,4 +31,12 @@ public interface ApplicationComponent void inject(CaptureFragment view); void inject(WelcomeDialog welcomeDialog); + + void inject(ResultFragment resultFragment); + + void inject(ProcessingDialog processingDialog); + + void inject(RegisterFragment registerFragment); + + void inject(RegisteringDialog registeringDialog); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/EventBusModule.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/EventBusModule.java index f76e91d70..3e785d304 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/EventBusModule.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/EventBusModule.java @@ -19,6 +19,6 @@ public class EventBusModule { @Singleton public Bus provideEventBus() { - return new Bus(ThreadEnforcer.MAIN); + return new Bus(ThreadEnforcer.ANY); } } 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 0fecad4d8..cb8290bb0 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 @@ -1,6 +1,8 @@ package com.twine.colorcapture.dagger; import com.squareup.otto.Bus; +import com.twine.colorcapture.dialogs.processing.ProcessingDialogVM; +import com.twine.colorcapture.dialogs.registering.RegisteringDialogVM; import com.twine.colorcapture.dialogs.welcome.WelcomeDialogVM; import com.twine.colorcapture.navigation.INavigationProvider; import com.twine.colorcapture.notification.INotificationProvider; @@ -8,6 +10,8 @@ import com.twine.colorcapture.views.capture.CaptureFragmentVM; import com.twine.colorcapture.views.loading.LoadingActivityVM; import com.twine.colorcapture.views.mycolors.MyColorsFragmentVM; import com.twine.colorcapture.views.main.MainActivityVM; +import com.twine.colorcapture.views.register.RegisterFragmentVM; +import com.twine.colorcapture.views.result.ResultFragmentVM; import com.twine.colorcapture.web.ITCCService; import com.twine.colorcapture.web.IWebServiceAPI; @@ -49,7 +53,35 @@ public class ViewModelsModule @Singleton public CaptureFragmentVM provideCaptureFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService) { - return new CaptureFragmentVM(tccService, navigationProvider, notificationProvider); + return new CaptureFragmentVM(eventBus,tccService, navigationProvider, notificationProvider); + } + + @Provides + @Singleton + public ProcessingDialogVM provideProcessingDialogVM() + { + return new ProcessingDialogVM(); + } + + @Provides + @Singleton + public ResultFragmentVM provideResultFragmentVM(Bus eventBus,INavigationProvider navigationProvider) + { + return new ResultFragmentVM(eventBus,navigationProvider); + } + + @Provides + @Singleton + public RegisterFragmentVM provideRegisterFragmentVM(INotificationProvider notificationProvider,ITCCService tccService) + { + return new RegisterFragmentVM(notificationProvider,tccService); + } + + @Provides + @Singleton + public RegisteringDialogVM provideRegisteringDialogVM() + { + return new RegisteringDialogVM(); } @Provides diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/processing/ProcessingDialog.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/processing/ProcessingDialog.java new file mode 100644 index 000000000..eca58f720 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/processing/ProcessingDialog.java @@ -0,0 +1,23 @@ +package com.twine.colorcapture.dialogs.processing; + +import android.app.DialogFragment; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.DialogProcessingBinding; +import com.twine.colorcapture.mvvm.DialogBase; + +public class ProcessingDialog extends DialogBase<DialogProcessingBinding, ProcessingDialogVM> +{ + @Override + public int getLayoutId() + { + return R.layout.dialog_processing; + } + + @Override + public void inject() + { + App.getComponent().inject(this); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/processing/ProcessingDialogVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/processing/ProcessingDialogVM.java new file mode 100644 index 000000000..20848d357 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/processing/ProcessingDialogVM.java @@ -0,0 +1,14 @@ +package com.twine.colorcapture.dialogs.processing; + +import com.twine.colorcapture.mvvm.DialogViewModelBase; + +import javax.inject.Inject; + +public class ProcessingDialogVM extends DialogViewModelBase +{ + @Inject + public ProcessingDialogVM() + { + + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/registering/RegisteringDialog.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/registering/RegisteringDialog.java new file mode 100644 index 000000000..fa18b2fe2 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/registering/RegisteringDialog.java @@ -0,0 +1,22 @@ +package com.twine.colorcapture.dialogs.registering; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.DialogRegisteringBinding; +import com.twine.colorcapture.mvvm.DialogBase; + +public class RegisteringDialog extends DialogBase<DialogRegisteringBinding, RegisteringDialogVM> +{ + + @Override + public int getLayoutId() + { + return R.layout.dialog_registering; + } + + @Override + public void inject() + { + App.getComponent().inject(this); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/registering/RegisteringDialogVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/registering/RegisteringDialogVM.java new file mode 100644 index 000000000..bae4b9bfb --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/registering/RegisteringDialogVM.java @@ -0,0 +1,9 @@ +package com.twine.colorcapture.dialogs.registering; + +import com.twine.colorcapture.mvvm.DialogViewModelBase; +import com.twine.colorcapture.web.ITCCService; + +public class RegisteringDialogVM extends DialogViewModelBase +{ + +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/welcome/WelcomeDialog.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/welcome/WelcomeDialog.java index 5f92fff0e..dbb7fbb0c 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/welcome/WelcomeDialog.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/welcome/WelcomeDialog.java @@ -1,10 +1,20 @@ package com.twine.colorcapture.dialogs.welcome; +import android.graphics.Interpolator; +import android.os.CountDownTimer; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; + import com.twine.colorcapture.App; import com.twine.colorcapture.R; +import com.twine.colorcapture.core.AnimationsHelper; +import com.twine.colorcapture.core.CountUpTimer; import com.twine.colorcapture.mvvm.DialogBase; import com.twine.colorcapture.databinding.DialogWelcomeBinding; +import java.util.Timer; + public class WelcomeDialog extends DialogBase<DialogWelcomeBinding, WelcomeDialogVM> { diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogBase.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogBase.java index 8fa1e7ba1..7f6dfe042 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogBase.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogBase.java @@ -10,20 +10,27 @@ import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; + import com.twine.colorcapture.R; +import com.twine.colorcapture.core.AnimationsHelper; +import com.twine.colorcapture.core.CountUpTimer; import com.twine.colorcapture.core.IAction1; import java.lang.reflect.Method; + import javax.inject.Inject; + import butterknife.ButterKnife; public abstract class DialogBase<BindingView extends ViewDataBinding, VM extends DialogViewModelBase> extends DialogFragment { private boolean isUserDismiss; private IAction1<VM> onDismissListener; + private View rootView; /** @@ -54,7 +61,10 @@ public abstract class DialogBase<BindingView extends ViewDataBinding, VM extends inject(); - binding = DataBindingUtil.inflate(LayoutInflater.from(getActivity()),getLayoutId(), null, false); + binding = DataBindingUtil.inflate(LayoutInflater.from(getActivity()), getLayoutId(), null, false); + + rootView = binding.getRoot(); + //rootView.setAlpha(0); Method method = null; try @@ -71,8 +81,7 @@ public abstract class DialogBase<BindingView extends ViewDataBinding, VM extends ButterKnife.bind(this, binding.getRoot()); return binding.getRoot(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); return null; @@ -101,8 +110,22 @@ public abstract class DialogBase<BindingView extends ViewDataBinding, VM extends public void onStart() { super.onStart(); + getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent); + + View group = this.getView(); + group.post(() -> + { + group.setAlpha(0); - getDialog().getWindow().setBackgroundDrawable(getActivity().getDrawable(R.color.colorBlueMask)); + new CountUpTimer(500,30){ + @Override + public void onTick(float milli) + { + group.setAlpha(milli / 500f); + Log.d("ANIM", Float.toString(milli / 500f)); + } + }.start(); + }); } public abstract int getLayoutId(); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogViewModelBase.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogViewModelBase.java index b1fe7b8ec..99ef24549 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogViewModelBase.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/DialogViewModelBase.java @@ -13,7 +13,7 @@ public abstract class DialogViewModelBase extends ViewModelBase try { closeAction.invoke(); - } catch (IOException e) + } catch (Exception e) { e.printStackTrace(); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/RelayCommand.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/RelayCommand.java index 9574c864f..f46b98c17 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/RelayCommand.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/RelayCommand.java @@ -1,6 +1,7 @@ package com.twine.colorcapture.mvvm; import android.databinding.BindingAdapter; +import android.graphics.Color; import android.view.View; public class RelayCommand 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 96531ab20..923dc41b2 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 @@ -14,6 +14,7 @@ import com.twine.colorcapture.mvvm.ExtendedObject; import com.twine.colorcapture.mvvm.FragmentBase; import com.twine.colorcapture.core.IAction1; +import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -52,21 +53,27 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga } @Override - public void navigateTo(NavigationFragment fragmentValue, boolean addToHistory) + public void navigateTo(NavigationFragment fragmentValue, boolean pushCurrentToHistory, boolean pushNextToHistory) { - navigateTo(fragmentValue.name(), addToHistory); + navigateTo(fragmentValue.name(), pushCurrentToHistory, pushNextToHistory); } @Override - public void navigateTo(NavigationFragment fragmentValue, IAction1<FragmentBase> onCreateListener, boolean addToHistory) + public <T> void navigateWithObjectTo(NavigationFragment fragmentValue, boolean pushCurrentToHistory, boolean pushNextToHistory, T obj) { - navigateTo(fragmentValue.name(), onCreateListener, addToHistory); + navigateToInternal(fragmentValue.name(), null, pushCurrentToHistory, pushNextToHistory, obj); } @Override - public void navigateTo(String fragmentName, boolean addToHistory) + public void navigateTo(NavigationFragment fragmentValue, IAction1<FragmentBase> onCreateListener, boolean pushCurrentToHistory, boolean pushNextToHistory) { - navigateTo(fragmentName, null, addToHistory); + navigateTo(fragmentValue.name(), onCreateListener, pushCurrentToHistory, pushNextToHistory); + } + + @Override + public void navigateTo(String fragmentName, boolean pushCurrentToHistory, boolean pushNextToHistory) + { + navigateTo(fragmentName, null, pushCurrentToHistory, pushNextToHistory); } @Override @@ -74,7 +81,7 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga { if (canNavigateBack()) { - navigateTo(history.pop(), false); + navigateTo(history.pop(), false, false); } } @@ -109,7 +116,12 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga } @Override - public void navigateTo(String fragmentName, IAction1<FragmentBase> onCreateListener, boolean addToHistory) + public void navigateTo(String fragmentName, IAction1<FragmentBase> onCreateListener, boolean pushCurrentToHistory, boolean pushNextToHistory) + { + navigateToInternal(fragmentName, onCreateListener, pushCurrentToHistory, pushNextToHistory, null); + } + + public void navigateToInternal(String fragmentName, IAction1<FragmentBase> onCreateListener, boolean pushCurrentToHistory, boolean pushNextToHistory, Object navigationObject) { if (activity == null || fragmentName == currentFragmentName) { @@ -119,17 +131,39 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga boolean reverseAnimation = false; + boolean preventCurrentHistory = false; + boolean preventNextHistory = false; - if (currentFragmentName != null) + try { - if (addToHistory) + if (currentFragmentName != null) { - if (!history.contains(NavigationFragment.valueOf(currentFragmentName))) - { - history.push(NavigationFragment.valueOf(currentFragmentName)); - } + preventCurrentHistory = NavigationFragment.class.getField(currentFragmentName).getAnnotations().length > 0; + } + preventNextHistory = NavigationFragment.class.getField(fragmentName).getAnnotations().length > 0; + } catch (NoSuchFieldException e) + { + e.printStackTrace(); + } + + if (pushCurrentToHistory && currentFragmentName != null && !preventCurrentHistory) + { + if (!history.contains(NavigationFragment.valueOf(currentFragmentName))) + { + history.push(NavigationFragment.valueOf(currentFragmentName)); } + } + if (pushNextToHistory && !preventNextHistory) + { + if (!history.contains(NavigationFragment.valueOf(fragmentName))) + { + history.push(NavigationFragment.valueOf(fragmentName)); + } + } + + if (currentFragmentName != null) + { List<NavigationFragment> values = Arrays.asList(NavigationFragment.values()); int newIndex = values.indexOf(NavigationFragment.valueOf(fragmentName)); @@ -190,17 +224,26 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga final FragmentBase fragmentTo = fragment; final FragmentBase fragmentFrom = currentFragment; - new Handler().postDelayed(() -> + activity.runOnUiThread(() -> { - - fragmentTo.getVM().notifyNavigatedTo(); - - if (fragmentFrom != null && !fragmentTo.getClass().getSimpleName().equals(fragmentFrom.getClass().getSimpleName())) + if (fragmentTo.getVM() instanceof INavigationObjectReceiver) { - fragmentFrom.getVM().notifyNavigatedFrom(); + ((INavigationObjectReceiver)fragmentTo.getVM()).onNavigationObjectReceived(navigationObject); } - }, 300); + new Handler().postDelayed(() -> + { + + fragmentTo.getVM().notifyNavigatedTo(); + + if (fragmentFrom != null && !fragmentTo.getClass().getSimpleName().equals(fragmentFrom.getClass().getSimpleName())) + { + fragmentFrom.getVM().notifyNavigatedFrom(); + } + + }, 300); + }); + // try // { @@ -220,7 +263,6 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga { listener.onNavigated(f); } - } @Override diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/INavigationObjectReceiver.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/INavigationObjectReceiver.java new file mode 100644 index 000000000..1dad1d735 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/INavigationObjectReceiver.java @@ -0,0 +1,6 @@ +package com.twine.colorcapture.navigation; + +public interface INavigationObjectReceiver<T> +{ + void onNavigationObjectReceived(T obj); +} 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 6f42cfcfb..f5453bd89 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 @@ -22,13 +22,13 @@ public interface INavigationProvider * @param fragmentContainerId the fragment container id */ void registerNavigationActivity(Activity activity, int fragmentContainerId); - + /** * Navigate to the specified fragment name. * * @param fragmentName the fragment name */ - void navigateTo(String fragmentName, boolean addToHistory); + void navigateTo(String fragmentName, boolean pushCurrentToHistory, boolean pushNextToHistory); /** * Navigates to the previous fragment. @@ -42,12 +42,14 @@ public interface INavigationProvider /** * Gets the current navigation fragment. + * * @return */ NavigationFragment getCurrentFragment(); /** * Gets a value determining whether there is any fragment to navigate back to in the history. + * * @return */ boolean canNavigateBack(); @@ -56,29 +58,31 @@ public interface INavigationProvider * Resets the navigation manager. (call on navigation activity destroyed) */ void reset(); - + /** * Navigate to to the specified fragment name. * * @param fragmentName the fragment name * @param onCreateListener the on create listener */ - void navigateTo(String fragmentName, IAction1<FragmentBase> onCreateListener, boolean addToHistory); - + void navigateTo(String fragmentName, IAction1<FragmentBase> onCreateListener, boolean pushCurrentToHistory, boolean pushNextToHistory); + /** * Navigate to to the specified enum value fragment name. * * @param fragmentValue the fragment value */ - void navigateTo(NavigationFragment fragmentValue, boolean addToHistory); - + void navigateTo(NavigationFragment fragmentValue, boolean pushCurrentToHistory, boolean pushNextToHistory); + + <T> void navigateWithObjectTo(NavigationFragment fragmentValue, boolean pushCurrentToHistory, boolean pushNextToHistory, T obj); + /** * Navigate to to the specified enum value fragment name. * * @param fragmentValue the fragment value * @param onCreateListener the on create listener */ - void navigateTo(NavigationFragment fragmentValue, IAction1<FragmentBase> onCreateListener, boolean addToHistory); + void navigateTo(NavigationFragment fragmentValue, IAction1<FragmentBase> onCreateListener, boolean pushCurrentToHistory, boolean pushNextToHistory); void navigateTo(NavigationActivity activityValue, boolean addToHistory); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java index 65a6d38e7..2aab6c0fc 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java @@ -4,4 +4,7 @@ public enum NavigationFragment { MyColors, Capture, + Result, + @PreventHistory + Register, } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/PreventHistory.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/PreventHistory.java new file mode 100644 index 000000000..331d13597 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/PreventHistory.java @@ -0,0 +1,13 @@ +package com.twine.colorcapture.navigation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +public @interface PreventHistory +{ + +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/utils/ThreadingUtils.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/utils/ThreadingUtils.java new file mode 100644 index 000000000..bbb0fecf4 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/utils/ThreadingUtils.java @@ -0,0 +1,15 @@ +package com.twine.colorcapture.utils; + +public class ThreadingUtils +{ + public static void sleep(int millis) + { + try + { + Thread.sleep(millis); + } catch (InterruptedException e) + { + e.printStackTrace(); + } + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java index bf5ff63a8..b9dddc6f2 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragment.java @@ -246,70 +246,64 @@ public class CaptureFragment extends FragmentBase<FragmentCaptureBinding, Captur { if (granted) { - new TaskBuilder().setAction(() -> + try { - - try + int numberOfCameras = Camera.getNumberOfCameras(); + for (int i = 0; i < numberOfCameras; i++) { - int numberOfCameras = Camera.getNumberOfCameras(); - for (int i = 0; i < numberOfCameras; i++) + CameraInfo info = new CameraInfo(); + Camera.getCameraInfo(i, info); + if (info.facing == CameraInfo.CAMERA_FACING_BACK) { - CameraInfo info = new CameraInfo(); - Camera.getCameraInfo(i, info); - if (info.facing == CameraInfo.CAMERA_FACING_BACK) - { - cameraId = i; - break; - } + cameraId = i; + break; } + } - camera = Camera.open(cameraId); + camera = Camera.open(cameraId); - camera.setPreviewDisplay(surfaceHolder); - camera.setPreviewCallback(this); + camera.setPreviewDisplay(surfaceHolder); + camera.setPreviewCallback(this); - Camera.Parameters parameters; + Camera.Parameters parameters; - setCameraDisplayOrientation(); + setCameraDisplayOrientation(); - parameters = camera.getParameters(); + parameters = camera.getParameters(); - List<Size> sizes = parameters.getSupportedPreviewSizes(); + List<Size> sizes = parameters.getSupportedPreviewSizes(); - for (Camera.Size size : parameters.getSupportedPreviewSizes()) + for (Camera.Size size : parameters.getSupportedPreviewSizes()) + { + if (size.width >= 1200 & size.width <= 1280) { - if (size.width >= 1200 & size.width <= 1280) - { - parameters.setPreviewSize(1280, 720); - parameters.setPictureSize(1280, 720); - break; - } + parameters.setPreviewSize(1280, 720); + parameters.setPictureSize(1280, 720); + break; } + } - imageFormat = parameters.getPreviewFormat(); - - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); - - camera.setParameters(parameters); + imageFormat = parameters.getPreviewFormat(); - parameters = camera.getParameters(); + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); - int width = parameters.getPreviewSize().width; - int height = parameters.getPreviewSize().height; + camera.setParameters(parameters); - listener.onPreviewSettingsAvailable(width, height); + parameters = camera.getParameters(); - camera.startPreview(); + int width = parameters.getPreviewSize().width; + int height = parameters.getPreviewSize().height; - isCameraStarted = true; - } catch (Exception ex) - { - camera.release(); - camera = null; - } + listener.onPreviewSettingsAvailable(width, height); - }).build().start(); + camera.startPreview(); + isCameraStarted = true; + } catch (Exception ex) + { + camera.release(); + camera = null; + } } }); } @@ -319,14 +313,12 @@ public class CaptureFragment extends FragmentBase<FragmentCaptureBinding, Captur { if (isCameraStarted) { - new TaskBuilder().setAction(() -> - { - camera.setPreviewCallback(null); - camera.stopPreview(); - camera.release(); - camera = null; - isCameraStarted = false; - }).build().start(); + isCameraStarted = false; + + camera.setPreviewCallback(null); + camera.stopPreview(); + camera.release(); + camera = null; } } 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 e566fe159..20ff070bf 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 @@ -1,26 +1,32 @@ package com.twine.colorcapture.views.capture; import android.graphics.Bitmap; -import android.media.AudioManager; -import android.media.ToneGenerator; +import android.media.MediaActionSound; import android.util.Log; +import com.squareup.otto.Bus; +import com.twine.colorcapture.Messages.ColorDetectedMessage; 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.mvvm.DependencyProperty; import com.twine.colorcapture.mvvm.ViewModelBase; import com.twine.colorcapture.navigation.INavigationProvider; +import com.twine.colorcapture.navigation.NavigationFragment; import com.twine.colorcapture.notification.INotificationProvider; import com.twine.colorcapture.opencv.ImageProcessor; +import com.twine.colorcapture.utils.ThreadingUtils; import com.twine.colorcapture.views.capture.ICaptureFragment.ICaptureFragmentListener; import com.twine.colorcapture.web.ITCCService; import com.twine.colorcapture.web.messages.DefinitionResponse; +import com.twine.colorcapture.web.messages.DetectionResponse; import com.yanzhenjie.zbar.Image; import com.yanzhenjie.zbar.ImageScanner; import com.yanzhenjie.zbar.Symbol; import com.yanzhenjie.zbar.SymbolSet; import java.io.IOException; +import java.util.concurrent.atomic.AtomicBoolean; public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implements ICaptureFragmentListener { @@ -40,12 +46,15 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement private INotificationProvider notificationProvider; private boolean startDialogShown; private boolean preventDetection; + private Bus eventBus; public DependencyProperty<Boolean> isCardDetected; public DependencyProperty<Boolean> isDetecting; - public CaptureFragmentVM(ITCCService tccService, INavigationProvider navigationProvider, INotificationProvider notificationProvider) + public CaptureFragmentVM(Bus eventBus, ITCCService tccService, INavigationProvider navigationProvider, INotificationProvider notificationProvider) { + this.eventBus = eventBus; + isCardDetected = new DependencyProperty<Boolean>(); isDetecting = new DependencyProperty<Boolean>(); this.navigationProvider = navigationProvider; @@ -56,7 +65,7 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement try { definition = tccService.getDefinition(); - } catch (IOException e) + } catch (Exception e) { e.printStackTrace(); } @@ -123,35 +132,44 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement Log.d("BARCODE", "Barcode text is: " + text); - ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); - toneGen1.startTone(ToneGenerator.TONE_CDMA_PIP,150); + //ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); + //toneGen1.startTone(ToneGenerator.TONE_CDMA_PIP, 150); + + MediaActionSound sound = new MediaActionSound(); + sound.play(MediaActionSound.SHUTTER_CLICK); isCardDetected.set(true); preventDetection = true; view.onFrameResult(frameBitmap, sampleBitmap, barcode); view.stopCamera(); - try - { - Thread.sleep(2000); - } catch (InterruptedException e) - { - e.printStackTrace(); - } + ThreadingUtils.sleep(1000); isDetecting.set(true); - //DetectionResponse response = tccService.detect(sampleBitmap, barcode); + AtomicBoolean abort = new AtomicBoolean(false); - try + notificationProvider.showDialog(new ProcessingDialog(), (vm) -> { - Thread.sleep(5000); - } catch (InterruptedException e) - { - e.printStackTrace(); - } + //TODO: Cancel and return to capture + abort.set(true); + }); + + DetectionResponse response = tccService.detect(sampleBitmap, barcode); + + ThreadingUtils.sleep(5000); isDetecting.set(false); + + if (!abort.get()) + { + notificationProvider.closeDialog(); + navigationProvider.navigateWithObjectTo(NavigationFragment.Result, true, false, response); + } + else + { + onNavigatedTo(); + } } } @@ -195,14 +213,14 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement notificationProvider.showDialog(new WelcomeDialog(), (vm) -> { - view.startCamera(); isCardDetected.set(false); + view.startCamera(); }); } else { - view.startCamera(); isCardDetected.set(false); + view.startCamera(); } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java index 8cf9c1ef6..99bb0846d 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java @@ -14,6 +14,7 @@ import com.twine.colorcapture.navigation.INavigationProvider; import com.twine.colorcapture.navigation.NavigationActivity; import com.twine.colorcapture.navigation.NavigationFragment; import com.twine.colorcapture.notification.INotificationProvider; +import com.twine.colorcapture.utils.ThreadingUtils; import com.twine.colorcapture.web.ITCCService; import com.twine.colorcapture.web.IWebServiceAPI; import com.twine.colorcapture.web.WebApiFactory; @@ -58,6 +59,7 @@ public class LoadingActivityVM extends ViewModelBase<ILoadingActivity> new Task.TaskBuilder().setAction(() -> { tccService.getDefinition(); + ThreadingUtils.sleep(3000); }).setContinueWith(() -> { initialized = true; diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivity.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivity.java index 30b918f53..e0eaca38c 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivity.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivity.java @@ -67,7 +67,7 @@ public class MainActivity extends ActivityBase<ActivityMainBinding, MainActivity drawerLayout.openDrawer(Gravity.START); }); - navigationProvider.navigateTo(NavigationFragment.Capture, false); + navigationProvider.navigateTo(NavigationFragment.Capture, false, true); passOnCreate = true; } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java index 20905b94d..38d917a7e 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java @@ -32,9 +32,9 @@ public class MainActivityVM extends ViewModelBase<IMainActivity> { this.navigationProvider = navigationProvider; this.notificationProvider = notificationProvider; - isMoreToggled = new DependencyProperty<Boolean>(false,this::onMoreToggled); - isCaptureToggled = new DependencyProperty<Boolean>(false,this::onCaptureToggled); - isMyColorsToggled = new DependencyProperty<Boolean>(false,this::onMyColorsToggled); + isMoreToggled = new DependencyProperty<Boolean>(false, this::onMoreToggled); + isCaptureToggled = new DependencyProperty<Boolean>(false, this::onCaptureToggled); + isMyColorsToggled = new DependencyProperty<Boolean>(false, this::onMyColorsToggled); currentTab = CurrentTab.Capture; setCurrentTab(currentTab); navigationProvider.addFragmentNavigationListener(this::onNavigation); @@ -42,7 +42,7 @@ public class MainActivityVM extends ViewModelBase<IMainActivity> private void onNavigation(NavigationFragment navigationFragment) { - if (navigationFragment == NavigationFragment.Capture && currentTab != CurrentTab.Capture) + if (navigationFragment == NavigationFragment.Capture || navigationFragment == NavigationFragment.Result && currentTab != CurrentTab.Capture) { isMoreToggled.setNoCallback(false); isMyColorsToggled.setNoCallback(false); @@ -90,16 +90,17 @@ public class MainActivityVM extends ViewModelBase<IMainActivity> { isMoreToggled.setNoCallback(false); isMyColorsToggled.setNoCallback(false); - navigationProvider.navigateTo(NavigationFragment.Capture,false); + navigationProvider.navigateTo(NavigationFragment.Capture, false, true); } isCaptureToggled.setNoCallback(true); } else if (tab == CurrentTab.MyColors) { - if (isMyColorsToggled.get()) { + if (isMyColorsToggled.get()) + { isMoreToggled.setNoCallback(false); isCaptureToggled.setNoCallback(false); - navigationProvider.navigateTo(NavigationFragment.MyColors,true); + navigationProvider.navigateTo(NavigationFragment.MyColors, true, false); } isMyColorsToggled.setNoCallback(true); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/IRegisterFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/IRegisterFragment.java new file mode 100644 index 000000000..7780bb52f --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/IRegisterFragment.java @@ -0,0 +1,7 @@ +package com.twine.colorcapture.views.register; + +import com.twine.colorcapture.mvvm.IView; + +public interface IRegisterFragment extends IView +{ +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/RegisterFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/RegisterFragment.java new file mode 100644 index 000000000..afa551345 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/RegisterFragment.java @@ -0,0 +1,30 @@ +package com.twine.colorcapture.views.register; + +import android.app.Fragment; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.FragmentRegisterBinding; +import com.twine.colorcapture.mvvm.FragmentBase; + +public class RegisterFragment extends FragmentBase<FragmentRegisterBinding,RegisterFragmentVM> +{ + + @Override + protected int getLayoutId() + { + return R.layout.fragment_register; + } + + @Override + protected void inject() + { + App.getComponent().inject(this); + } + + @Override + public String getTitle() + { + return "Register"; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/RegisterFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/RegisterFragmentVM.java new file mode 100644 index 000000000..79f02c866 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/register/RegisterFragmentVM.java @@ -0,0 +1,71 @@ +package com.twine.colorcapture.views.register; + +import android.util.Log; + +import com.twine.colorcapture.core.Task; +import com.twine.colorcapture.dialogs.registering.RegisteringDialog; +import com.twine.colorcapture.mvvm.DependencyProperty; +import com.twine.colorcapture.mvvm.RelayCommand; +import com.twine.colorcapture.mvvm.ViewModelBase; +import com.twine.colorcapture.notification.INotificationProvider; +import com.twine.colorcapture.views.result.IResultFragment; +import com.twine.colorcapture.web.ITCCService; + +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.inject.Inject; + +public class RegisterFragmentVM extends ViewModelBase<IResultFragment> +{ + private INotificationProvider notificationProvider; + private ITCCService tccService; + public DependencyProperty<String> serialNumber; + public RelayCommand registerCommand; + + @Inject + public RegisterFragmentVM(INotificationProvider notificationProvider, ITCCService tccService) + { + this.tccService = tccService; + this.notificationProvider = notificationProvider; + serialNumber = new DependencyProperty<>(""); + registerCommand = new RelayCommand(this::handleRegisterCommand); + } + + private void handleRegisterCommand() + { + AtomicBoolean abort = new AtomicBoolean(false); + + notificationProvider.showDialog(new RegisteringDialog(), (vm) -> + { + abort.set(true); + }); + + new Task.TaskBuilder().setAction(() -> + { + + try + { + tccService.register(serialNumber.get()); + + if (!abort.get()) + { + Log.i("REGISTER", "Registered !"); + } + else + { + Log.i("REGISTER", "Aborted !"); + } + } + catch (Exception ex) + { + //TODO: display error message! + Log.i("REGISTER", ex.getMessage()); + } + finally + { + notificationProvider.closeDialog(); + } + + }).build().start(); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/IResultFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/IResultFragment.java new file mode 100644 index 000000000..2b7c40414 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/IResultFragment.java @@ -0,0 +1,7 @@ +package com.twine.colorcapture.views.result; + +import com.twine.colorcapture.mvvm.IView; + +public interface IResultFragment extends IView +{ +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragment.java new file mode 100644 index 000000000..d634d2634 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragment.java @@ -0,0 +1,28 @@ +package com.twine.colorcapture.views.result; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.FragmentResultBinding; +import com.twine.colorcapture.mvvm.FragmentBase; + +public class ResultFragment extends FragmentBase<FragmentResultBinding,ResultFragmentVM> +{ + + @Override + protected int getLayoutId() + { + return R.layout.fragment_result; + } + + @Override + protected void inject() + { + App.getComponent().inject(this); + } + + @Override + public String getTitle() + { + return "Result"; + } +} 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 new file mode 100644 index 000000000..63b0aa476 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java @@ -0,0 +1,74 @@ +package com.twine.colorcapture.views.result; + +import android.util.Log; + +import com.squareup.otto.Bus; +import com.squareup.otto.Subscribe; +import com.twine.colorcapture.Messages.ColorDetectedMessage; +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.navigation.NavigationFragment; +import com.twine.colorcapture.web.messages.DetectionResponse; + +import javax.inject.Inject; + +public class ResultFragmentVM extends ViewModelBase<IResultFragment> implements INavigationObjectReceiver<DetectionResponse> +{ + private INavigationProvider navigationProvider; + + public DependencyProperty<Boolean> isCameraColorToggled; + public DependencyProperty<DetectionResponse> detectionResponse; + public RelayCommand toggleCameraColorCommand; + public RelayCommand emailCommand; + public RelayCommand renameCommand; + public RelayCommand sendToMachineCommand; + public RelayCommand registerMachineCommand; + + @Inject + public ResultFragmentVM(Bus eventBus, INavigationProvider navigationProvider) + { + this.navigationProvider = navigationProvider; + + isCameraColorToggled = new DependencyProperty<>(false); + detectionResponse = new DependencyProperty<>(new DetectionResponse()); + toggleCameraColorCommand = new RelayCommand(this::toggleCameraColor); + emailCommand = new RelayCommand(this::handleEmailCommand); + renameCommand = new RelayCommand(this::handleRenameCommand); + sendToMachineCommand = new RelayCommand(this::handleSendToMachineCommand); + registerMachineCommand = new RelayCommand(this::handlerRegisterMachineCommand); + + eventBus.register(this); + } + + private void handlerRegisterMachineCommand() + { + navigationProvider.navigateTo(NavigationFragment.Register, true, false); + } + + private void handleSendToMachineCommand() + { + } + + private void handleRenameCommand() + { + } + + private void handleEmailCommand() + { + Log.d("RESULT", "handleEmailCommand: "); + } + + private void toggleCameraColor() + { + isCameraColorToggled.set(!isCameraColorToggled.get()); + } + + @Override + public void onNavigationObjectReceived(DetectionResponse detectionResponse) + { + this.detectionResponse.set(detectionResponse); + } +} 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 065faf106..feefe86f8 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 @@ -5,12 +5,15 @@ import android.graphics.Bitmap; 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 java.io.IOException; public interface ITCCService { - DefinitionResponse getDefinition() throws IOException; + DefinitionResponse getDefinition() throws Exception; - DetectionResponse detect(Bitmap bitmap, String barcode) throws IOException; + DetectionResponse detect(Bitmap bitmap, String barcode) throws Exception; + + MachineRegistrationResponse register(String serialNumber) throws Exception; } 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 6fa84c556..fe292a839 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 @@ -6,6 +6,8 @@ import com.twine.colorcapture.web.messages.DetectionRequest; import com.twine.colorcapture.web.messages.DetectionResponse; 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 io.reactivex.Observable; import retrofit2.Call; @@ -22,4 +24,7 @@ public interface IWebServiceAPI @POST("ColorDetection/Detect") Call<DetectionResponse> detect(@Body DetectionRequest request); + + @POST("ColorDetection/Register") + Call<MachineRegistrationResponse> register(@Body MachineRegistrationRequest 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 98000f3dd..6ecb815b7 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 @@ -11,11 +11,16 @@ import com.twine.colorcapture.web.messages.DetectionRequest; import com.twine.colorcapture.web.messages.DetectionResponse; 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 java.io.IOException; import javax.inject.Inject; +import retrofit2.HttpException; +import retrofit2.Response; + public class TCCService implements ITCCService { private DefinitionResponse definition; @@ -29,20 +34,29 @@ public class TCCService implements ITCCService } @Override - public DefinitionResponse getDefinition() throws IOException + public DefinitionResponse getDefinition() throws Exception { ensureAuthenticated(); if (definition == null) { - definition = webAPI.getDefinition(new DefinitionRequest()).execute().body(); + Response<DefinitionResponse> response = webAPI.getDefinition(new DefinitionRequest()).execute(); + + if (response.isSuccessful()) + { + definition = webAPI.getDefinition(new DefinitionRequest()).execute().body(); + } + else + { + throw new Exception(response.message()); + } } return definition; } @Override - public DetectionResponse detect(Bitmap bitmap, String barcode) throws IOException + public DetectionResponse detect(Bitmap bitmap, String barcode) throws Exception { ensureAuthenticated(); @@ -51,12 +65,39 @@ public class TCCService implements ITCCService request.setBitmapString(BitmapUtils.getBitmapBase64String(bitmap)); request.setBarcode(barcode); - DetectionResponse response = webAPI.detect(request).execute().body(); + Response<DetectionResponse> response = webAPI.detect(request).execute(); + + if (response.isSuccessful()) + { + return response.body(); + } + else + { + throw new Exception(response.message()); + } + } + + @Override + public MachineRegistrationResponse register(String serialNumber) throws Exception + { + ensureAuthenticated(); + + MachineRegistrationRequest request = new MachineRegistrationRequest(); + request.setSerialnumber(serialNumber); + + Response<MachineRegistrationResponse> response = webAPI.register(request).execute(); - return response; + if (response.isSuccessful()) + { + return response.body(); + } + else + { + throw new Exception(response.message()); + } } - private void ensureAuthenticated() throws IOException + private void ensureAuthenticated() throws Exception { if (loginResponse == null) { @@ -64,13 +105,23 @@ public class TCCService implements ITCCService } } - private LoginResponse login() throws IOException + private LoginResponse login() throws Exception { LoginRequest request = new LoginRequest(); request.setAppId(BuildConfig.WEB_SERVICE_APP_ID); request.setDeviceId("1234"); - loginResponse = webAPI.login(request).execute().body(); - WebApiFactory.setAuthenticationToken(loginResponse.getAccessToken()); - return loginResponse; + + Response<LoginResponse> response = webAPI.login(request).execute(); + + if (response.isSuccessful()) + { + loginResponse = response.body(); + WebApiFactory.setAuthenticationToken(loginResponse.getAccessToken()); + return loginResponse; + } + else + { + throw new Exception(response.message()); + } } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java index 05e2d2c9f..f464b61a9 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java @@ -1,5 +1,7 @@ package com.twine.colorcapture.web.messages; +import android.graphics.Color; + public class DetectionColor { private int r; @@ -35,4 +37,20 @@ public class DetectionColor { this.b = b; } + + public String getName() + { + return String.format("%d, %d, %d", r, g, b); + } + + @Override + public String toString() + { + return getName(); + } + + public int getColor() + { + return Color.rgb(r, g, b); + } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/MachineRegistrationRequest.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/MachineRegistrationRequest.java new file mode 100644 index 000000000..1adb8b21b --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/MachineRegistrationRequest.java @@ -0,0 +1,16 @@ +package com.twine.colorcapture.web.messages; + +public class MachineRegistrationRequest +{ + public String getSerialnumber() + { + return serialnumber; + } + + public void setSerialnumber(String serialnumber) + { + this.serialnumber = serialnumber; + } + + private String serialnumber; +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/MachineRegistrationResponse.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/MachineRegistrationResponse.java new file mode 100644 index 000000000..8430eab94 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/MachineRegistrationResponse.java @@ -0,0 +1,24 @@ +package com.twine.colorcapture.web.messages; + +import java.util.ArrayList; +import java.util.List; + +public class MachineRegistrationResponse +{ + private List<String> organizationMachines; + + public List<String> getOrganizationMachines() + { + return organizationMachines; + } + + public void setOrganizationMachines(List<String> organizationMachines) + { + this.organizationMachines = organizationMachines; + } + + public MachineRegistrationResponse() + { + organizationMachines = new ArrayList<>(); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/down.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/down.png Binary files differnew file mode 100644 index 000000000..47438d35c --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/down.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/email.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/email.png Binary files differnew file mode 100644 index 000000000..d30bd11a9 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/email.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon.png Binary files differnew file mode 100644 index 000000000..5920654e4 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_arrow_up.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..0e55fd7af --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_arrow_up.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_rename.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..203838382 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_rename.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/down.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/down.png Binary files differnew file mode 100644 index 000000000..833f12050 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/down.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/email.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/email.png Binary files differnew file mode 100644 index 000000000..2220595bf --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/email.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon.png Binary files differnew file mode 100644 index 000000000..f0889f9a3 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_arrow_up.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..ce8da1355 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_arrow_up.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_rename.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..6c7dc083a --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_rename.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/down.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/down.png Binary files differnew file mode 100644 index 000000000..b1e67433d --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/down.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/email.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/email.png Binary files differnew file mode 100644 index 000000000..341d122a6 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/email.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon.png Binary files differnew file mode 100644 index 000000000..40e46cd1f --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_arrow_up.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..dc4d23f98 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_arrow_up.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_rename.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..070a2f6e7 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_rename.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/down.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/down.png Binary files differnew file mode 100644 index 000000000..a9950dd2f --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/down.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/email.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/email.png Binary files differnew file mode 100644 index 000000000..390972794 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/email.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon.png Binary files differnew file mode 100644 index 000000000..968ebf639 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_arrow_up.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..610a339b8 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_arrow_up.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_rename.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..eadb2e698 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_rename.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/down.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/down.png Binary files differnew file mode 100644 index 000000000..357f74139 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/down.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/email.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/email.png Binary files differnew file mode 100644 index 000000000..29a9ed75a --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/email.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon.png Binary files differnew file mode 100644 index 000000000..25650a2ff --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_arrow_up.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..4beb10f63 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_arrow_up.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_rename.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..640161cce --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_rename.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/border_primary_background.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/border_primary_background.xml new file mode 100644 index 000000000..51861f9fe --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/border_primary_background.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item> + <layer-list> + <item android:bottom="5dp"> + <shape android:shape="rectangle"> + <solid android:color="@color/colorPrimaryBackground"/> + <corners android:radius="5dp" /> + </shape> + </item> + </layer-list> + </item> +</selector>
\ No newline at end of file diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/button_empty_border.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/button_empty_border.xml new file mode 100644 index 000000000..39d77fb44 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/button_empty_border.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <corners android:radius="30dp" /> + <stroke android:width="2px" android:color="#ffffff"/> + +</shape>
\ No newline at end of file diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/button_transparent_fill_ripple.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/button_transparent_fill_ripple.xml new file mode 100644 index 000000000..26f3f959c --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/button_transparent_fill_ripple.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<ripple xmlns:android="http://schemas.android.com/apk/res/android" + android:color="?android:colorControlHighlight" + android:exitFadeDuration="@android:integer/config_shortAnimTime"> + <!-- Use this to define the shape of the ripple effect (rectangle, oval, ring or line). The color specified here isn't used anyway --> + <item android:id="@android:id/mask"> + <shape android:shape="rectangle"> + <corners android:radius="3dp"/> + <!-- This color is needed to be set - doesn't affect anything --> + <solid android:color="@android:color/white"/> + </shape> + </item> + <!-- This is the background for your button --> + <item> + <!-- Use the shape you want here --> + <shape android:shape="rectangle"> + <!-- Use the solid tag to define the background color you want --> + <solid android:color="@android:color/transparent"/> + </shape> + </item> +</ripple>
\ No newline at end of file diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_loading.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_loading.xml index 8ab79ffe2..4e6183a4a 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_loading.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_loading.xml @@ -52,6 +52,17 @@ android:layout_centerInParent="true" android:layout_centerHorizontal="true" android:src="@drawable/twine_logo" /> + + <ProgressBar + android:id="@+id/progress" + android:layout_marginTop="30dp" + android:layout_below="@id/imageView2" + android:layout_centerInParent="true" + android:layout_width="80dp" + android:layout_height="80dp" + android:indeterminate="true" + android:indeterminateDuration="500" + android:indeterminateDrawable="@drawable/progress_ring_background"/> </RelativeLayout> </FrameLayout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/circle_action_button.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/circle_action_button.xml new file mode 100644 index 000000000..0f34acc8f --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/circle_action_button.xml @@ -0,0 +1,81 @@ +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bind="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <com.github.florent37.shapeofview.shapes.RoundRectView + android:layout_width="match_parent" + android:layout_height="match_parent" + bind:shape_roundRect_borderColor="#ffffff" + bind:shape_roundRect_borderWidth="1dp" + bind:shape_roundRect_bottomLeftRadius="40dp" + bind:shape_roundRect_bottomRightRadius="40dp" + bind:shape_roundRect_topLeftRadius="40dp" + bind:shape_roundRect_topRightRadius="40dp"> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="5dp"> + + <FrameLayout + android:id="@+id/frameAfterPadding" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/circleActionButtonTextView" + android:layout_gravity="center" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="17.3sp" + android:letterSpacing="0.07" + android:fontFamily="@font/flexo_medium" + android:text="Email"/> + + <com.github.florent37.shapeofview.shapes.RoundRectView + android:id="@+id/actionButtonCircle" + android:layout_width="39dp" + android:layout_height="39dp" + bind:shape_roundRect_borderColor="#ffffff" + bind:shape_roundRect_borderWidth="0dp" + bind:shape_roundRect_bottomLeftRadius="40dp" + bind:shape_roundRect_bottomRightRadius="40dp" + bind:shape_roundRect_topLeftRadius="40dp" + bind:shape_roundRect_topRightRadius="40dp"> + + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/button_gradient_fill"> + + + <ImageView + android:id="@+id/circleActionButtonImageView" + android:layout_width="33dp" + android:layout_height="28dp" + android:layout_gravity="center" + android:layout_marginTop="2dp" + android:src="@drawable/email" /> + + </FrameLayout> + </com.github.florent37.shapeofview.shapes.RoundRectView> + + </FrameLayout> + + <Button + android:id="@+id/actionButtonCircleButton" + android:layout_width="match_parent" + android:layout_height="37dp" + android:minHeight="0dp" + android:padding="0dp" + android:background="@drawable/button_transparent_fill_ripple"/> + + </FrameLayout> + + + </com.github.florent37.shapeofview.shapes.RoundRectView> + +</FrameLayout>
\ No newline at end of file diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_processing.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_processing.xml new file mode 100644 index 000000000..2d891b99b --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_processing.xml @@ -0,0 +1,39 @@ +<layout xmlns:tools="http://schemas.android.com/tools" + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:bind="http://schemas.android.com/apk/res-auto"> + + <data> + <variable + name="vm" + type="com.twine.colorcapture.dialogs.processing.ProcessingDialogVM" /> + </data> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorBlueMask"> + + <ProgressBar + android:id="@+id/progress" + android:layout_centerInParent="true" + android:layout_width="80dp" + android:layout_height="80dp" + android:indeterminate="true" + android:indeterminateDuration="500" + android:indeterminateDrawable="@drawable/progress_ring_background"/> + + + <android.support.v7.widget.AppCompatTextView + android:layout_below="@id/progress" + android:layout_centerHorizontal="true" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="20dp" + android:gravity="center" + android:textSize="13.4sp" + android:letterSpacing="0.07" + android:fontFamily="@font/flexo_medium" + android:text="@string/processing_message"/> + </RelativeLayout> +</layout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_registering.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_registering.xml new file mode 100644 index 000000000..4b4044bcf --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_registering.xml @@ -0,0 +1,62 @@ +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bind="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + <data> + + <variable + name="vm" + type="com.twine.colorcapture.dialogs.registering.RegisteringDialogVM" /> + </data> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorBlueMask"> + + <RelativeLayout + android:layout_width="313.9dp" + android:layout_height="202.6dp" + android:layout_centerVertical="true" + android:layout_centerHorizontal="true" + android:background="@drawable/border_primary_background"> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txtTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_marginTop="15dp" + android:fontFamily="@font/flexo_bold" + android:gravity="center" + android:letterSpacing="0.07" + android:textSize="13.4sp" + android:text="Register your system" /> + + <ProgressBar + android:id="@+id/progress" + android:layout_width="80dp" + android:layout_height="80dp" + android:layout_below="@id/txtTitle" + android:layout_centerHorizontal="true" + android:layout_marginTop="10dp" + android:indeterminate="true" + android:indeterminateDrawable="@drawable/progress_ring_background" + android:indeterminateDuration="500" /> + + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/progress" + android:layout_centerHorizontal="true" + android:layout_marginTop="20dp" + android:fontFamily="@font/flexo_light" + android:gravity="center" + android:letterSpacing="0.07" + android:textSize="13.4sp" + android:text="Please wait while we register\nyour system..."/> + + </RelativeLayout> + </RelativeLayout> +</layout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml index cacc97715..bcc964288 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml @@ -10,9 +10,12 @@ </data> <RelativeLayout + android:id="@+id/main_relative" android:layoutDirection="ltr" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/colorBlueMask" + tools:context="com.twine.colorcapture.dialogs.welcome.WelcomeDialog"> <RelativeLayout diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_capture.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_capture.xml index c4b776143..a6ea50d88 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_capture.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_capture.xml @@ -131,33 +131,5 @@ </FrameLayout> </LinearLayout> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/colorBlueMask" - android:visibility="@{vm.isDetecting ? View.VISIBLE : View.GONE}"> - - <ProgressBar - android:id="@+id/progress" - android:layout_centerInParent="true" - android:layout_width="80dp" - android:layout_height="80dp" - android:indeterminate="true" - android:indeterminateDrawable="@drawable/progress_ring_background"/> - - - <android.support.v7.widget.AppCompatTextView - android:layout_below="@id/progress" - android:layout_centerHorizontal="true" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="20dp" - android:gravity="center" - android:textSize="13.4sp" - android:letterSpacing="0.07" - android:fontFamily="@font/flexo_medium" - android:text="@string/processing_message"/> - </RelativeLayout> </FrameLayout> </layout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_register.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_register.xml new file mode 100644 index 000000000..51e174e29 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_register.xml @@ -0,0 +1,83 @@ +<layout xmlns:tools="http://schemas.android.com/tools" + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bind="http://schemas.android.com/apk/res-auto"> + + <data> + <variable + name="vm" + type="com.twine.colorcapture.views.register.RegisterFragmentVM" /> + </data> + + <RelativeLayout + android:layoutDirection="ltr" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingLeft="20dp" + android:paddingRight="20dp" + android:background="@color/colorDarkBackground" + tools:context="com.twine.colorcapture.views.register.RegisterFragment"> + + + <FrameLayout + android:id="@+id/frameTitle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp"> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txtTitlef" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/flexo_bold" + android:letterSpacing="0.07" + android:layout_gravity="left|center" + android:text="Register your system" + android:textSize="17.3sp" /> + + + <android.support.v7.widget.AppCompatButton + android:id="@+id/btnDone" + android:background="@drawable/button_transparent_fill_ripple" + android:layout_gravity="right" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="17.3sp" + android:letterSpacing="0.07" + android:textStyle="bold" + android:text="Done" + android:layout_marginRight="-10dp" + android:fontFamily="@font/flexo_bold" + android:textAllCaps="false" + bind:command="@{vm.registerCommand}"/> + </FrameLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/frameTitle" + android:layout_marginTop="50dp" + android:orientation="vertical"> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/flexo_light" + android:letterSpacing="0.07" + android:textSize="13.4sp" + android:text="Machine Serial Number:" /> + + <android.support.v7.widget.AppCompatEditText + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="5dp" + android:fontFamily="@font/flexo_light" + android:letterSpacing="0.07" + android:textSize="15.4sp" + android:textDirection="ltr" + android:inputType="textCapCharacters" + android:text="@={vm.serialNumber}"/> + + </LinearLayout> + + </RelativeLayout> +</layout> 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 new file mode 100644 index 000000000..07091267b --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_result.xml @@ -0,0 +1,237 @@ +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bind="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + <data> + + <import type="android.view.View" /> + + <variable + name="vm" + type="com.twine.colorcapture.views.result.ResultFragmentVM" /> + </data> + + <RelativeLayout + android:id="@+id/result_main_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorDarkBackground" + android:layoutDirection="ltr" + android:paddingLeft="20dp" + android:paddingRight="20dp" + tools:context="com.twine.colorcapture.views.result.ResultFragment"> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txtTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_marginTop="15dp" + android:fontFamily="@font/flexo_bold" + android:gravity="center" + android:letterSpacing="0.07" + android:text="@string/my_color" + android:textSize="17.3sp" /> + + <com.github.florent37.shapeofview.shapes.RoundRectView + android:id="@+id/resultRect" + android:layout_width="match_parent" + android:layout_height="84.5dp" + android:layout_below="@id/txtTitle" + android:layout_marginTop="15dp" + android:elevation="4dp" + bind:shape_roundRect_borderColor="@android:color/black" + bind:shape_roundRect_borderWidth="0dp" + bind:shape_roundRect_bottomLeftRadius="5dp" + bind:shape_roundRect_bottomRightRadius="5dp" + bind:shape_roundRect_topLeftRadius="5dp" + bind:shape_roundRect_topRightRadius="5dp"> + + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@{vm.detectionResponse.getProcessedColor().getColor()}"></FrameLayout> + + </com.github.florent37.shapeofview.shapes.RoundRectView> + + <LinearLayout + android:id="@+id/rgbContainer" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/resultRect" + android:layout_marginTop="15dp" + android:orientation="horizontal"> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/flexo_bold" + android:letterSpacing="0.11" + android:text="RGB:" + android:textSize="17.4sp" /> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="5dp" + android:fontFamily="@font/flexo_bold" + android:letterSpacing="0.11" + android:text="@{vm.detectionResponse.getProcessedColor().toString()}" + android:textSize="17.4sp" /> + </LinearLayout> + + <FrameLayout + android:id="@+id/frameToggleBtn" + android:layout_width="match_parent" + android:layout_height="25dp" + android:layout_below="@id/rgbContainer" + android:layout_marginTop="15dp"> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:fontFamily="@font/flexo_light" + android:letterSpacing="0.07" + android:text="See how your camera got this" + android:textSize="15.4sp" /> + + <ImageView + android:layout_width="17dp" + android:layout_height="10dp" + android:layout_gravity="right" + android:layout_marginTop="5dp" + android:src="@{vm.isCameraColorToggled ? @drawable/icons_arrow_up : @drawable/down}" /> + + <Button + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/button_transparent_fill_ripple" + android:minHeight="0dp" + android:padding="0dp" + bind:command="@{vm.toggleCameraColorCommand}" /> + </FrameLayout> + + <FrameLayout + android:id="@+id/frameCameraRgbContainer" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/frameToggleBtn" + android:layout_marginTop="5dp" + android:layout_marginBottom="10dp" + android:visibility="@{vm.isCameraColorToggled ? View.VISIBLE : View.GONE}"> + + <com.github.florent37.shapeofview.shapes.RoundRectView + android:layout_width="67.2dp" + android:layout_height="59.5dp" + android:layout_below="@id/txtTitle" + bind:shape_roundRect_borderColor="@android:color/black" + bind:shape_roundRect_borderWidth="0dp" + bind:shape_roundRect_bottomLeftRadius="5dp" + bind:shape_roundRect_bottomRightRadius="5dp" + bind:shape_roundRect_topLeftRadius="5dp" + bind:shape_roundRect_topRightRadius="5dp"> + + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@{vm.detectionResponse.getRawColor().getColor()}"></FrameLayout> + + </com.github.florent37.shapeofview.shapes.RoundRectView> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center|center_horizontal" + android:layout_marginLeft="20dp" + android:orientation="horizontal"> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/flexo_light" + android:letterSpacing="0.11" + android:text="RGB:" + android:textSize="15.4sp" /> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="5dp" + android:fontFamily="@font/flexo_light" + android:letterSpacing="0.11" + android:text="@{vm.detectionResponse.getRawColor().toString()}" + android:textSize="15.4sp" /> + </LinearLayout> + + </FrameLayout> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="2dp" + android:layout_below="@id/frameCameraRgbContainer" + android:background="@drawable/button_gradient_fill"></FrameLayout> + + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:orientation="vertical" + android:paddingBottom="20dp" + android:paddingLeft="40dp" + android:paddingRight="40dp"> + + <com.twine.colorcapture.controls.CircleActionButton + android:layout_width="match_parent" + android:layout_height="wrap_content" + bind:src="@drawable/email" + bind:text="Email" + android:clickable="true" + bind:command="@{vm.emailCommand}"/> + + <com.twine.colorcapture.controls.CircleActionButton + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp" + bind:src="@drawable/icons_rename" + bind:text="Rename" + android:clickable="true" + bind:command="@{vm.renameCommand}"/> + + <FrameLayout + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp"> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right|bottom" + android:fontFamily="@font/flexo_bold" + android:letterSpacing="0.07" + android:textSize="15.4sp" + android:text="@string/have_a_twine_system"/> + + <ImageView + android:layout_width="40dp" + android:layout_height="32dp" + android:layout_gravity="left" + android:src="@drawable/icon" /> + + <Button + android:layout_width="match_parent" + android:layout_height="30dp" + android:background="@drawable/button_transparent_fill_ripple" + android:minHeight="0dp" + android:padding="0dp" + bind:command="@{vm.registerMachineCommand}" /> + + </FrameLayout> + </LinearLayout> + + </RelativeLayout> +</layout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml index 5cb322d20..f3be907a5 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml @@ -10,6 +10,7 @@ <color name="colorTransparent">#00000000</color> <color name="colorPrimaryBackground">#0e2340</color> + <color name="colorDarkBackground">#07101e</color> <color name="colorBlueMask">#EB09172A</color> <color name="colorWhiteMask">#B71D3150</color> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml index d10b0fa91..fe1ec6d7c 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml @@ -13,4 +13,8 @@ <string name="welcome_have_a_twine_card_message"><u>Don’t have a Twine TCC™ card?</u></string> <string name="processing_message">Our color algorithm is working on it…</string> + + <string name="my_color">My Color</string> + + <string name="have_a_twine_system"><u>Have a Twine system?</u></string> </resources> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/values/styles.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/values/styles.xml index 10dfcc040..608b5ed13 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/values/styles.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/values/styles.xml @@ -15,6 +15,7 @@ <!--<item name="colorPrimary">@color/colorPrimary</item>--> <!--<item name="colorPrimaryDark">@color/colorPrimaryDark</item>--> <!--<item name="colorAccent">@color/colorAccent</item>--> + <item name="android:textColor">#ffffffff</item> </style> @@ -25,4 +26,9 @@ <attr name="checkedImage" format="reference" /> </declare-styleable> + <declare-styleable name="CircleActionButton"> + <attr name="text" format="string" /> + <attr name="src" format="reference" /> + </declare-styleable> + </resources> diff --git a/Software/Graphics/Mobile/zeplin/drawable-hdpi/down.png b/Software/Graphics/Mobile/zeplin/drawable-hdpi/down.png Binary files differnew file mode 100644 index 000000000..47438d35c --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-hdpi/down.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-hdpi/email.png b/Software/Graphics/Mobile/zeplin/drawable-hdpi/email.png Binary files differnew file mode 100644 index 000000000..d30bd11a9 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-hdpi/email.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-hdpi/icon.png b/Software/Graphics/Mobile/zeplin/drawable-hdpi/icon.png Binary files differnew file mode 100644 index 000000000..5920654e4 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-hdpi/icon.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-hdpi/icons_arrow_up.png b/Software/Graphics/Mobile/zeplin/drawable-hdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..0e55fd7af --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-hdpi/icons_arrow_up.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-hdpi/icons_rename.png b/Software/Graphics/Mobile/zeplin/drawable-hdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..203838382 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-hdpi/icons_rename.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-mdpi/down.png b/Software/Graphics/Mobile/zeplin/drawable-mdpi/down.png Binary files differnew file mode 100644 index 000000000..833f12050 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-mdpi/down.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-mdpi/email.png b/Software/Graphics/Mobile/zeplin/drawable-mdpi/email.png Binary files differnew file mode 100644 index 000000000..2220595bf --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-mdpi/email.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-mdpi/icon.png b/Software/Graphics/Mobile/zeplin/drawable-mdpi/icon.png Binary files differnew file mode 100644 index 000000000..f0889f9a3 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-mdpi/icon.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-mdpi/icons_arrow_up.png b/Software/Graphics/Mobile/zeplin/drawable-mdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..ce8da1355 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-mdpi/icons_arrow_up.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-mdpi/icons_rename.png b/Software/Graphics/Mobile/zeplin/drawable-mdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..6c7dc083a --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-mdpi/icons_rename.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xhdpi/down.png b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/down.png Binary files differnew file mode 100644 index 000000000..b1e67433d --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/down.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xhdpi/email.png b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/email.png Binary files differnew file mode 100644 index 000000000..341d122a6 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/email.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icon.png b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icon.png Binary files differnew file mode 100644 index 000000000..40e46cd1f --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icon.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icons_arrow_up.png b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..dc4d23f98 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icons_arrow_up.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icons_rename.png b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..070a2f6e7 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xhdpi/icons_rename.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/down.png b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/down.png Binary files differnew file mode 100644 index 000000000..a9950dd2f --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/down.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/email.png b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/email.png Binary files differnew file mode 100644 index 000000000..390972794 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/email.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icon.png b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icon.png Binary files differnew file mode 100644 index 000000000..968ebf639 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icon.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icons_arrow_up.png b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..610a339b8 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icons_arrow_up.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icons_rename.png b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..eadb2e698 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxhdpi/icons_rename.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/down.png b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/down.png Binary files differnew file mode 100644 index 000000000..357f74139 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/down.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/email.png b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/email.png Binary files differnew file mode 100644 index 000000000..29a9ed75a --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/email.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icon.png b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icon.png Binary files differnew file mode 100644 index 000000000..25650a2ff --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icon.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icons_arrow_up.png b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icons_arrow_up.png Binary files differnew file mode 100644 index 000000000..4beb10f63 --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icons_arrow_up.png diff --git a/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icons_rename.png b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icons_rename.png Binary files differnew file mode 100644 index 000000000..640161cce --- /dev/null +++ b/Software/Graphics/Mobile/zeplin/drawable-xxxhdpi/icons_rename.png diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj b/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj index 7d677edc3..733e2ba9f 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj @@ -73,6 +73,8 @@ <Compile Include="Web\DefinitionResponse.cs" /> <Compile Include="Web\LoginRequest.cs" /> <Compile Include="Web\LoginResponse.cs" /> + <Compile Include="Web\MachineRegistrationRequest.cs" /> + <Compile Include="Web\MachineRegistrationResponse.cs" /> </ItemGroup> <ItemGroup> <Content Include="..\Benchmarks\benchmarks_rgb_lab.csv"> diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/MachineRegistrationRequest.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/MachineRegistrationRequest.cs new file mode 100644 index 000000000..5a0f86917 --- /dev/null +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/MachineRegistrationRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.TCC.BL.Web +{ + public class MachineRegistrationRequest : WebRequestMessage + { + public String SerialNumber { get; set; } + } +} diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/MachineRegistrationResponse.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/MachineRegistrationResponse.cs new file mode 100644 index 000000000..88ff6599f --- /dev/null +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/MachineRegistrationResponse.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.TCC.BL.Web +{ + public class MachineRegistrationResponse : WebResponseMessage + { + public List<String> OrganizationMachines { get; set; } + + public MachineRegistrationResponse() + { + OrganizationMachines = new List<string>(); + } + } +} diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs index eb4600788..fc0272c02 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs @@ -61,6 +61,7 @@ namespace Tango.TCC.Service.Controllers }; } + [JwtTokenFilter] [HttpPost] public ColorDetectionResponse Detect(ColorDetectionRequest request) { @@ -103,5 +104,18 @@ namespace Tango.TCC.Service.Controllers }; } } + + [JwtTokenFilter] + [HttpPost] + public MachineRegistrationResponse Register(MachineRegistrationRequest request) + { + MachineRegistrationResponse response = new MachineRegistrationResponse(); + + response.OrganizationMachines.Add("0002"); + + //throw new AuthenticationException("No such serial number..."); + + return response; + } } } |
