From 9cc18084e2f9db73ce9e2820dfebcab4e50e5730 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 5 May 2019 11:43:19 +0300 Subject: MREGE. --- .../Android_Studio/ColorCapture/app/build.gradle | 61 ++++++- .../ColorCapture/app/src/main/AndroidManifest.xml | 17 +- .../colorcapture/controls/CircleActionButton.java | 91 ++++++++-- .../colorcapture/dagger/ApplicationComponent.java | 9 + .../colorcapture/dagger/ViewModelsModule.java | 40 ++++- .../dialogs/confirm/ConfirmDialog.java | 22 +++ .../dialogs/confirm/ConfirmDialogVM.java | 41 +++++ .../colorcapture/dialogs/error/ErrorDialogVM.java | 20 +-- .../dialogs/progress/ProgressDialogVM.java | 20 +-- .../dialogs/success/SuccessDialogVM.java | 20 +-- .../integration/ExternalBridgeClient.java | 1 + .../com/twine/colorcapture/logging/LogManager.java | 35 ++++ .../com/twine/colorcapture/models/ColorResult.java | 54 ++++++ .../twine/colorcapture/models/ColorResultVM.java | 40 +++++ .../mvvm/MessageDialogViewModelBase.java | 25 +++ .../navigation/AndroidNavigationProvider.java | 1 + .../navigation/NavigationActivity.java | 1 + .../navigation/NavigationFragment.java | 5 +- .../twine/colorcapture/navigation/TabState.java | 8 + .../colorcapture/navigation/TabStateManager.java | 25 +++ .../notification/AndroidNotificationProvider.java | 30 ++++ .../notification/INotificationProvider.java | 13 ++ .../colorcapture/settings/SettingsManager.java | 96 +++++++++++ .../views/capture/CaptureFragmentVM.java | 31 +++- .../colorcapture/views/main/IMainActivity.java | 1 + .../colorcapture/views/main/MainActivity.java | 9 +- .../colorcapture/views/main/MainActivityVM.java | 96 +++++------ .../views/mycolors/MyColorsFragmentVM.java | 70 +++++++- .../views/register/RegisterFragmentVM.java | 2 +- .../colorcapture/views/rename/IRenameFragment.java | 7 + .../colorcapture/views/rename/RenameFragment.java | 62 +++++++ .../views/rename/RenameFragmentVM.java | 50 ++++++ .../views/result/ResultFragmentVM.java | 44 ++++- .../views/sendtoemail/ISendToEmailActivity.java | 7 + .../views/sendtoemail/SendToEmailActivity.java | 30 ++++ .../views/sendtoemail/SendToEmailActivityVM.java | 21 +++ .../sendtomachine/SendToMachineFragmentVM.java | 27 ++- .../com/twine/colorcapture/web/ITCCService.java | 5 + .../com/twine/colorcapture/web/TCCService.java | 50 +++++- .../com/twine/colorcapture/web/WebApiFactory.java | 6 +- .../web/messages/DefinitionResponse.java | 30 ++++ .../app/src/main/res/drawable-hdpi/about.png | Bin 0 -> 1998 bytes .../app/src/main/res/drawable-hdpi/delete_thin.png | Bin 0 -> 2039 bytes .../app/src/main/res/drawable-hdpi/error.png | Bin 0 -> 6542 bytes .../app/src/main/res/drawable-hdpi/how_to.png | Bin 0 -> 2350 bytes .../src/main/res/drawable-hdpi/icon_twine_card.png | Bin 0 -> 1989 bytes .../app/src/main/res/drawable-hdpi/icons_close.png | Bin 0 -> 367 bytes .../src/main/res/drawable-hdpi/icons_delete.png | Bin 0 -> 2140 bytes .../app/src/main/res/drawable-hdpi/info.png | Bin 0 -> 1699 bytes .../app/src/main/res/drawable-hdpi/snapmatch.png | Bin 0 -> 181461 bytes .../src/main/res/drawable-hdpi/twine_card_icon.png | Bin 0 -> 5155 bytes .../app/src/main/res/drawable-mdpi/about.png | Bin 0 -> 1229 bytes .../app/src/main/res/drawable-mdpi/delete_thin.png | Bin 0 -> 1240 bytes .../app/src/main/res/drawable-mdpi/error.png | Bin 0 -> 3836 bytes .../app/src/main/res/drawable-mdpi/how_to.png | Bin 0 -> 1435 bytes .../src/main/res/drawable-mdpi/icon_twine_card.png | Bin 0 -> 1215 bytes .../app/src/main/res/drawable-mdpi/icons_close.png | Bin 0 -> 284 bytes .../src/main/res/drawable-mdpi/icons_delete.png | Bin 0 -> 1278 bytes .../app/src/main/res/drawable-mdpi/info.png | Bin 0 -> 1066 bytes .../app/src/main/res/drawable-mdpi/snapmatch.png | Bin 0 -> 98923 bytes .../src/main/res/drawable-mdpi/twine_card_icon.png | Bin 0 -> 2864 bytes .../app/src/main/res/drawable-xhdpi/about.png | Bin 0 -> 2748 bytes .../src/main/res/drawable-xhdpi/delete_thin.png | Bin 0 -> 2827 bytes .../app/src/main/res/drawable-xhdpi/error.png | Bin 0 -> 9549 bytes .../app/src/main/res/drawable-xhdpi/how_to.png | Bin 0 -> 3118 bytes .../main/res/drawable-xhdpi/icon_twine_card.png | Bin 0 -> 2661 bytes .../src/main/res/drawable-xhdpi/icons_close.png | Bin 0 -> 424 bytes .../src/main/res/drawable-xhdpi/icons_delete.png | Bin 0 -> 3094 bytes .../app/src/main/res/drawable-xhdpi/info.png | Bin 0 -> 2417 bytes .../app/src/main/res/drawable-xhdpi/snapmatch.png | Bin 0 -> 281457 bytes .../main/res/drawable-xhdpi/twine_card_icon.png | Bin 0 -> 7906 bytes .../app/src/main/res/drawable-xxhdpi/about.png | Bin 0 -> 4258 bytes .../src/main/res/drawable-xxhdpi/delete_thin.png | Bin 0 -> 4926 bytes .../app/src/main/res/drawable-xxhdpi/error.png | Bin 0 -> 16261 bytes .../app/src/main/res/drawable-xxhdpi/how_to.png | Bin 0 -> 4930 bytes .../main/res/drawable-xxhdpi/icon_twine_card.png | Bin 0 -> 4793 bytes .../src/main/res/drawable-xxhdpi/icons_close.png | Bin 0 -> 542 bytes .../src/main/res/drawable-xxhdpi/icons_delete.png | Bin 0 -> 5369 bytes .../app/src/main/res/drawable-xxhdpi/info.png | Bin 0 -> 3553 bytes .../app/src/main/res/drawable-xxhdpi/snapmatch.png | Bin 0 -> 550027 bytes .../main/res/drawable-xxhdpi/twine_card_icon.png | Bin 0 -> 14760 bytes .../app/src/main/res/drawable-xxxhdpi/about.png | Bin 0 -> 5859 bytes .../src/main/res/drawable-xxxhdpi/delete_thin.png | Bin 0 -> 7208 bytes .../app/src/main/res/drawable-xxxhdpi/error.png | Bin 0 -> 23926 bytes .../app/src/main/res/drawable-xxxhdpi/how_to.png | Bin 0 -> 6656 bytes .../main/res/drawable-xxxhdpi/icon_twine_card.png | Bin 0 -> 6794 bytes .../src/main/res/drawable-xxxhdpi/icons_close.png | Bin 0 -> 719 bytes .../src/main/res/drawable-xxxhdpi/icons_delete.png | Bin 0 -> 7523 bytes .../app/src/main/res/drawable-xxxhdpi/info.png | Bin 0 -> 5016 bytes .../src/main/res/drawable-xxxhdpi/snapmatch.png | Bin 0 -> 894264 bytes .../main/res/drawable-xxxhdpi/twine_card_icon.png | Bin 0 -> 24126 bytes .../app/src/main/res/layout/activity_main.xml | 30 ++-- .../src/main/res/layout/activity_send_to_email.xml | 66 ++++++++ .../app/src/main/res/layout/color_result_item.xml | 135 +++++++++++++++ .../app/src/main/res/layout/dialog_confirm.xml | 87 ++++++++++ .../app/src/main/res/layout/dialog_error.xml | 18 ++ .../app/src/main/res/layout/dialog_success.xml | 18 ++ .../src/main/res/layout/external_machine_item.xml | 2 +- .../app/src/main/res/layout/fragment_mycolors.xml | 39 +++-- .../app/src/main/res/layout/fragment_rename.xml | 83 +++++++++ .../app/src/main/res/layout/fragment_result.xml | 4 +- .../app/src/main/res/layout/side_menu.xml | 187 +++++++++++++++++---- .../app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 2963 -> 4407 bytes .../src/main/res/mipmap-hdpi/ic_launcher_round.png | Bin 4905 -> 6054 bytes .../app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2060 -> 2304 bytes .../src/main/res/mipmap-mdpi/ic_launcher_round.png | Bin 2783 -> 3179 bytes .../app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4490 -> 6532 bytes .../main/res/mipmap-xhdpi/ic_launcher_round.png | Bin 6895 -> 8926 bytes .../app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 6387 -> 12164 bytes .../main/res/mipmap-xxhdpi/ic_launcher_round.png | Bin 10413 -> 16791 bytes .../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 9128 -> 21793 bytes .../main/res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 15132 -> 27968 bytes .../app/src/main/res/values/strings.xml | 2 +- .../app/src/main/res/values/styles.xml | 1 + 114 files changed, 1665 insertions(+), 230 deletions(-) create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialog.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialogVM.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/logging/LogManager.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResult.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResultVM.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/MessageDialogViewModelBase.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabState.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabStateManager.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/settings/SettingsManager.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/IRenameFragment.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragment.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragmentVM.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/ISendToEmailActivity.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/about.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/delete_thin.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/error.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/how_to.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon_twine_card.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_close.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_delete.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/info.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/snapmatch.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/twine_card_icon.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/about.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/delete_thin.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/error.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/how_to.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon_twine_card.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_close.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_delete.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/info.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/snapmatch.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/twine_card_icon.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/about.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/delete_thin.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/error.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/how_to.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon_twine_card.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_close.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_delete.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/info.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/snapmatch.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/twine_card_icon.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/about.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/delete_thin.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/error.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/how_to.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon_twine_card.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_close.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_delete.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/info.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/snapmatch.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/twine_card_icon.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/about.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/delete_thin.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/error.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/how_to.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon_twine_card.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_close.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_delete.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/info.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/snapmatch.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/twine_card_icon.png create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_send_to_email.xml create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/layout/color_result_item.xml create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_confirm.xml create mode 100644 Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_rename.xml (limited to 'Software/Android_Studio') diff --git a/Software/Android_Studio/ColorCapture/app/build.gradle b/Software/Android_Studio/ColorCapture/app/build.gradle index 7b8adc999..ae4fcfeb1 100644 --- a/Software/Android_Studio/ColorCapture/app/build.gradle +++ b/Software/Android_Studio/ColorCapture/app/build.gradle @@ -17,13 +17,13 @@ android { ndk { // Tells Gradle to build outputs for the following ABIs and package // them into your APK. - abiFilters 'armeabi-v7a' //Supported on most devices. + // abiFilters 'armeabi-v7a' //Supported on most devices. } } buildTypes { debug { - buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://192.168.1.86:45455/api/\"" + buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://10.100.102.46:45455/api/\"" buildConfigField "String", "WEB_SERVICE_APP_ID", "\"Tdf793i4ughsiduf8749509237885ehgfdlkghlT\"" } @@ -51,6 +51,63 @@ android { path "CMakeLists.txt" } } + + splits { + + // Configures multiple APKs based on ABI. + abi { + + // Enables building multiple APKs per ABI. + enable true + + // By default all ABIs are included, so use reset() and include to specify that we only + // want APKs for x86 and x86_64. + + // Resets the list of ABIs that Gradle should create APKs for to none. + reset() + + // Specifies a list of ABIs that Gradle should create APKs for. + include "armeabi-v7a", "arm64-v8a", "x86" + + // Specifies that we do not want to also generate a universal APK that includes all ABIs. + universalApk false + } + } +} + +// Map for the version code that gives each ABI a value. +ext.abiCodes = ['armeabi-v7a':1, 'arm64-v8a':2, 'x86':3] + +import com.android.build.OutputFile + +// For each APK output variant, override versionCode with a combination of +// ext.abiCodes * 1000 + variant.versionCode. In this example, variant.versionCode +// is equal to defaultConfig.versionCode. If you configure product flavors that +// define their own versionCode, variant.versionCode uses that value instead. +android.applicationVariants.all { variant -> + + // Assigns a different version code for each output APK + // other than the universal APK. + variant.outputs.each { output -> + + // Stores the value of ext.abiCodes that is associated with the ABI for this variant. + def baseAbiVersionCode = + // Determines the ABI for this variant and returns the mapped value. + project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) + + // Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes, + // the following code does not override the version code for universal APKs. + // However, because we want universal APKs to have the lowest version code, + // this outcome is desirable. + if (baseAbiVersionCode != null) { + + // Assigns the new version code to versionCodeOverride, which changes the version code + // for only the output APK, not for the variant itself. Skipping this step simply + // causes Gradle to use the value of variant.versionCode for the APK. + output.versionCodeOverride = + baseAbiVersionCode * 1000 + variant.versionCode + } + } } dependencies { diff --git a/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml b/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml index a03d65975..441817928 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml @@ -26,14 +26,27 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="false" android:theme="@style/AppTheme"> - + + + + + + + + + - + + \ No newline at end of file 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 index 242702fe9..afa02c511 100644 --- 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 @@ -4,14 +4,18 @@ import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; import android.content.res.TypedArray; +import android.databinding.BindingAdapter; +import android.databinding.InverseBindingAdapter; 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.util.TypedValue; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.animation.AlphaAnimation; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageView; @@ -27,15 +31,18 @@ public class CircleActionButton extends FrameLayout implements View.OnTouchListe private int initial_circle_width; private ValueAnimator animationDown; private ValueAnimator animationUp; + private AlphaAnimation alphaAnimationDown; + private AlphaAnimation alphaAnimationUp; private Drawable icon; + private AppCompatTextView textView; public CircleActionButton(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); - init(context,attrs); + init(context, attrs); } - private void init(Context context,AttributeSet attrs) + private void init(Context context, AttributeSet attrs) { inflate(context, R.layout.circle_action_button, this); @@ -43,12 +50,19 @@ public class CircleActionButton extends FrameLayout implements View.OnTouchListe circleActionButton = findViewById(R.id.actionButtonCircle); frameAfterPadding = findViewById(R.id.frameAfterPadding); ImageView imageView = findViewById(R.id.circleActionButtonImageView); - AppCompatTextView textView = findViewById(R.id.circleActionButtonTextView); + textView = findViewById(R.id.circleActionButtonTextView); btn.setOnTouchListener(this); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CircleActionButton); + int textSize = a.getDimensionPixelSize(R.styleable.CircleActionButton_textSize, 0); + + if (textSize > 0) + { + textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); + } + icon = getContext().getDrawable(a.getResourceId(R.styleable.CircleActionButton_src, 0)); CharSequence text = a.getText(R.styleable.CircleActionButton_text); @@ -67,7 +81,7 @@ public class CircleActionButton extends FrameLayout implements View.OnTouchListe } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { - animateUp(); + //animateUp(); performClick(); } @@ -83,11 +97,21 @@ public class CircleActionButton extends FrameLayout implements View.OnTouchListe initial_circle_width = circleActionButton.getMeasuredWidth(); } + + alphaAnimationDown = new AlphaAnimation(1f, 0.5f); + alphaAnimationDown.setDuration(50); + alphaAnimationDown.setFillAfter(true); + circleActionButton.startAnimation(alphaAnimationDown); + + final CircleActionButton that = this; + ValueAnimator anim = ValueAnimator.ofInt(initial_circle_width, frameAfterPadding.getMeasuredWidth()); animationDown = anim; - anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() + { @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { + public void onAnimationUpdate(ValueAnimator valueAnimator) + { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = circleActionButton.getLayoutParams(); layoutParams.width = val; @@ -105,7 +129,7 @@ public class CircleActionButton extends FrameLayout implements View.OnTouchListe @Override public void onAnimationEnd(Animator animator) { - + that.animateUp(); } @Override @@ -124,22 +148,31 @@ public class CircleActionButton extends FrameLayout implements View.OnTouchListe anim.start(); } - private void animateUp() + public void animateUp() { cancelAnimations(); + + alphaAnimationUp = new AlphaAnimation(0.5f, 1f); + alphaAnimationUp.setDuration(500); + alphaAnimationUp.setFillAfter(true); + alphaAnimationUp.setStartTime(1000); + circleActionButton.startAnimation(alphaAnimationUp); + ValueAnimator anim = ValueAnimator.ofInt(circleActionButton.getMeasuredWidth(), initial_circle_width); animationUp = anim; - anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() + { @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { + 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.setDuration(500); + anim.setStartDelay(1000); anim.start(); } @@ -156,5 +189,39 @@ public class CircleActionButton extends FrameLayout implements View.OnTouchListe animationUp.cancel(); animationUp = null; } + + if (alphaAnimationDown != null) + { + alphaAnimationDown.cancel(); + alphaAnimationDown = null; + } + + if (alphaAnimationUp != null) + { + alphaAnimationUp.cancel(); + alphaAnimationUp = null; + } + } + + public void setText(String text) + { + this.textView.setText(text); + } + + public String getText() + { + return this.textView.getText().toString(); + } + + @BindingAdapter("text") + public static void setText(CircleActionButton view, String value) + { + view.setText(value); + } + + @InverseBindingAdapter(attribute = "text") + public static String getText(CircleActionButton view) + { + return view.getText(); } } 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 498e3776d..db2848fa1 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,5 +1,6 @@ package com.twine.colorcapture.dagger; +import com.twine.colorcapture.dialogs.confirm.ConfirmDialog; import com.twine.colorcapture.dialogs.error.ErrorDialog; import com.twine.colorcapture.dialogs.processing.ProcessingDialog; import com.twine.colorcapture.dialogs.progress.ProgressDialog; @@ -10,7 +11,9 @@ 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.rename.RenameFragment; import com.twine.colorcapture.views.result.ResultFragment; +import com.twine.colorcapture.views.sendtoemail.SendToEmailActivity; import com.twine.colorcapture.views.sendtomachine.SendToMachineFragment; import javax.inject.Singleton; @@ -48,4 +51,10 @@ public interface ApplicationComponent void inject(SuccessDialog successDialog); void inject(SendToMachineFragment sendToMachineFragment); + + void inject(ConfirmDialog confirmDialog); + + void inject(RenameFragment renameFragment); + + void inject(SendToEmailActivity sendToEmailActivity); } 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 40a49f021..f83826b21 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,7 @@ package com.twine.colorcapture.dagger; import com.squareup.otto.Bus; +import com.twine.colorcapture.dialogs.confirm.ConfirmDialogVM; import com.twine.colorcapture.dialogs.error.ErrorDialogVM; import com.twine.colorcapture.dialogs.processing.ProcessingDialogVM; import com.twine.colorcapture.dialogs.progress.ProgressDialogVM; @@ -13,7 +14,9 @@ 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.rename.RenameFragmentVM; import com.twine.colorcapture.views.result.ResultFragmentVM; +import com.twine.colorcapture.views.sendtoemail.SendToEmailActivityVM; import com.twine.colorcapture.views.sendtomachine.SendToMachineFragmentVM; import com.twine.colorcapture.web.ITCCService; @@ -44,18 +47,25 @@ public class ViewModelsModule return new LoadingActivityVM(eventBus, notificationProvider, navigationProvider, tccService); } + @Provides + @Singleton + public SendToEmailActivityVM provideSendToEmailActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService) + { + return new SendToEmailActivityVM(); + } + @Provides @Singleton public MyColorsFragmentVM provideMyColorsFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider) { - return new MyColorsFragmentVM(navigationProvider); + return new MyColorsFragmentVM(navigationProvider, notificationProvider); } @Provides @Singleton public CaptureFragmentVM provideCaptureFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService) { - return new CaptureFragmentVM(eventBus,tccService, navigationProvider, notificationProvider); + return new CaptureFragmentVM(eventBus, tccService, navigationProvider, notificationProvider); } @Provides @@ -67,23 +77,30 @@ public class ViewModelsModule @Provides @Singleton - public ResultFragmentVM provideResultFragmentVM(Bus eventBus,INavigationProvider navigationProvider) + public ResultFragmentVM provideResultFragmentVM(Bus eventBus, INavigationProvider navigationProvider, ITCCService tccService) { - return new ResultFragmentVM(eventBus,navigationProvider); + return new ResultFragmentVM(eventBus, navigationProvider, tccService); } @Provides @Singleton - public RegisterFragmentVM provideRegisterFragmentVM(INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService,Bus eventBus) + public RegisterFragmentVM provideRegisterFragmentVM(INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService, Bus eventBus) { - return new RegisterFragmentVM(notificationProvider,navigationProvider,tccService,eventBus); + return new RegisterFragmentVM(notificationProvider, navigationProvider, tccService, eventBus); } @Provides @Singleton - public SendToMachineFragmentVM provideSendMachineFragmentVM(INotificationProvider notificationProvider, INavigationProvider navigationProvider) + public RenameFragmentVM provideRenameFragmentVM(INavigationProvider navigationProvider) { - return new SendToMachineFragmentVM(notificationProvider,navigationProvider); + return new RenameFragmentVM(navigationProvider); + } + + @Provides + @Singleton + public SendToMachineFragmentVM provideSendMachineFragmentVM(INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService) + { + return new SendToMachineFragmentVM(notificationProvider, navigationProvider, tccService); } @Provides @@ -107,6 +124,13 @@ public class ViewModelsModule return new SuccessDialogVM(); } + @Provides + @Singleton + public ConfirmDialogVM provideConfirmDialogVM() + { + return new ConfirmDialogVM(); + } + @Provides @Singleton public WelcomeDialogVM provideWelcomeDialogVM() diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialog.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialog.java new file mode 100644 index 000000000..9b67c2a08 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialog.java @@ -0,0 +1,22 @@ +package com.twine.colorcapture.dialogs.confirm; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.DialogConfirmBinding; +import com.twine.colorcapture.mvvm.DialogBase; + +public class ConfirmDialog extends DialogBase +{ + + @Override + public int getLayoutId() + { + return R.layout.dialog_confirm; + } + + @Override + public void inject() + { + App.getComponent().inject(this); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialogVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialogVM.java new file mode 100644 index 000000000..5fa0db57c --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/confirm/ConfirmDialogVM.java @@ -0,0 +1,41 @@ +package com.twine.colorcapture.dialogs.confirm; + +import com.twine.colorcapture.mvvm.DependencyProperty; +import com.twine.colorcapture.mvvm.MessageDialogViewModelBase; +import com.twine.colorcapture.mvvm.RelayCommand; + +public class ConfirmDialogVM extends MessageDialogViewModelBase +{ + private boolean confirmed; + + public DependencyProperty confirmText; + public RelayCommand confirmCommand; + + public ConfirmDialogVM() + { + super(); + confirmText = new DependencyProperty<>("OK"); + confirmCommand = new RelayCommand(this::onConfirmed); + } + + private void onConfirmed() + { + confirmed = true; + close(); + } + + public void setConfirmText(String confirmText) + { + this.confirmText.set(confirmText); + } + + public boolean isConfirmed() + { + return this.confirmed; + } + + public void setConfirmed(Boolean confirmed) + { + this.confirmed = confirmed; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/error/ErrorDialogVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/error/ErrorDialogVM.java index 4bc2dbb36..6dee3dfe1 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/error/ErrorDialogVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/error/ErrorDialogVM.java @@ -2,25 +2,9 @@ package com.twine.colorcapture.dialogs.error; import com.twine.colorcapture.mvvm.DependencyProperty; import com.twine.colorcapture.mvvm.DialogViewModelBase; +import com.twine.colorcapture.mvvm.MessageDialogViewModelBase; -public class ErrorDialogVM extends DialogViewModelBase +public class ErrorDialogVM extends MessageDialogViewModelBase { - public DependencyProperty title; - public DependencyProperty message; - public ErrorDialogVM() - { - title = new DependencyProperty<>(""); - message = new DependencyProperty<>(""); - } - - public void setTitle(String title) - { - this.title.set(title); - } - - public void setMessage(String message) - { - this.message.set(message); - } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/progress/ProgressDialogVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/progress/ProgressDialogVM.java index 4b7dc1d34..24d0da2ea 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/progress/ProgressDialogVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/progress/ProgressDialogVM.java @@ -2,25 +2,9 @@ package com.twine.colorcapture.dialogs.progress; import com.twine.colorcapture.mvvm.DependencyProperty; import com.twine.colorcapture.mvvm.DialogViewModelBase; +import com.twine.colorcapture.mvvm.MessageDialogViewModelBase; -public class ProgressDialogVM extends DialogViewModelBase +public class ProgressDialogVM extends MessageDialogViewModelBase { - public DependencyProperty title; - public DependencyProperty message; - public ProgressDialogVM() - { - title = new DependencyProperty<>(""); - message = new DependencyProperty<>(""); - } - - public void setTitle(String title) - { - this.title.set(title); - } - - public void setMessage(String message) - { - this.message.set(message); - } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/success/SuccessDialogVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/success/SuccessDialogVM.java index b1fb00129..466f32879 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/success/SuccessDialogVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dialogs/success/SuccessDialogVM.java @@ -2,25 +2,9 @@ package com.twine.colorcapture.dialogs.success; import com.twine.colorcapture.mvvm.DependencyProperty; import com.twine.colorcapture.mvvm.DialogViewModelBase; +import com.twine.colorcapture.mvvm.MessageDialogViewModelBase; -public class SuccessDialogVM extends DialogViewModelBase +public class SuccessDialogVM extends MessageDialogViewModelBase { - public DependencyProperty title; - public DependencyProperty message; - public SuccessDialogVM() - { - title = new DependencyProperty<>(""); - message = new DependencyProperty<>(""); - } - - public void setTitle(String title) - { - this.title.set(title); - } - - public void setMessage(String message) - { - this.message.set(message); - } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/integration/ExternalBridgeClient.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/integration/ExternalBridgeClient.java index b2ccc16dc..99436a6b2 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/integration/ExternalBridgeClient.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/integration/ExternalBridgeClient.java @@ -31,6 +31,7 @@ public class ExternalBridgeClient try { Socket tcpClient = new Socket(); + tcpClient.setSoTimeout(10000); tcpClient.connect(new InetSocketAddress(machine.getIpAddress(), EXTERNAL_BRIDGE_PORT), 2000); //Create detection color diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/logging/LogManager.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/logging/LogManager.java new file mode 100644 index 000000000..a15e0752d --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/logging/LogManager.java @@ -0,0 +1,35 @@ +package com.twine.colorcapture.logging; + +import android.util.Log; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class LogManager +{ + private static final String TAG = "TCC"; + + public static void log(String message) + { + Log.d(TAG, message); + } + + public static Exception log(Exception ex) + { + Log.e(TAG, ex.toString()); + return ex; + } + + public static Exception log(Exception ex, String message) + { + Log.e(TAG, message, ex); + return ex; + } + + public static void log(String message, Object obj) + { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + String json = gson.toJson(obj); + Log.d(TAG, message + "\n" + json); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResult.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResult.java new file mode 100644 index 000000000..a4c726ef6 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResult.java @@ -0,0 +1,54 @@ +package com.twine.colorcapture.models; + +import android.databinding.BaseObservable; + +import com.twine.colorcapture.mvvm.ExtendedObject; +import com.twine.colorcapture.web.messages.DetectionColor; +import com.twine.colorcapture.web.messages.DetectionResponse; + +import org.joda.time.DateTime; + +public class ColorResult extends BaseObservable +{ + private DetectionResponse detectionResponse; + private String date; + private String name; + + public DetectionResponse getDetectionResponse() + { + return detectionResponse; + } + + public void setDetectionResponse(DetectionResponse detectionResponse) + { + this.detectionResponse = detectionResponse; + } + + public String getDate() + { + return date; + } + + public void setDate(String date) + { + this.date = date; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + notifyChange(); + } + + public ColorResult(DetectionResponse detectionResponse, String date, String name) + { + this.detectionResponse = detectionResponse; + this.date = date; + this.name = name; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResultVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResultVM.java new file mode 100644 index 000000000..02dd14b8b --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/models/ColorResultVM.java @@ -0,0 +1,40 @@ +package com.twine.colorcapture.models; + +import com.twine.colorcapture.core.IAction1; +import com.twine.colorcapture.mvvm.RelayCommand; +import com.twine.colorcapture.mvvm.ViewModelBase; + +public class ColorResultVM extends ViewModelBase +{ + private ColorResult result; + public RelayCommand deleteCommand; + private IAction1 onDeleteListener; + + public ColorResultVM() + { + deleteCommand = new RelayCommand(this::handleDeleteCommand); + } + + private void handleDeleteCommand() + { + if (onDeleteListener != null) + { + onDeleteListener.invoke(this); + } + } + + public ColorResult getResult() + { + return result; + } + + public void setResult(ColorResult result) + { + this.result = result; + } + + public void setOnDeleteListener(IAction1 listener) + { + onDeleteListener = listener; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/MessageDialogViewModelBase.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/MessageDialogViewModelBase.java new file mode 100644 index 000000000..f2026ecc6 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/mvvm/MessageDialogViewModelBase.java @@ -0,0 +1,25 @@ +package com.twine.colorcapture.mvvm; + +public class MessageDialogViewModelBase extends DialogViewModelBase +{ + public DependencyProperty title; + public DependencyProperty message; + public RelayCommand closeCommand; + + public MessageDialogViewModelBase() + { + title = new DependencyProperty<>(""); + message = new DependencyProperty<>(""); + closeCommand = new RelayCommand(this::close); + } + + public void setTitle(String title) + { + this.title.set(title); + } + + public void setMessage(String message) + { + this.message.set(message); + } +} 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 5924c17d9..07bb16ecc 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 @@ -279,6 +279,7 @@ public class AndroidNavigationProvider extends ExtendedObject implements INaviga { Class cls = Class.forName(activityName); Intent intent = new Intent(context, cls); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (!addToHistory) { diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationActivity.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationActivity.java index b03f688bc..760e0f8b6 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationActivity.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationActivity.java @@ -4,4 +4,5 @@ public enum NavigationActivity { Loading, Main, + SendToEmail, } 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 07474ec3e..0731287e8 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 @@ -8,5 +8,8 @@ public enum NavigationFragment @PreventHistory Register, @PreventHistory - SendToMachine + SendToMachine, + @PreventHistory + Rename + } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabState.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabState.java new file mode 100644 index 000000000..2682ded78 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabState.java @@ -0,0 +1,8 @@ +package com.twine.colorcapture.navigation; + +public enum TabState +{ + Capture, + MyColors, + More +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabStateManager.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabStateManager.java new file mode 100644 index 000000000..89156af17 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/TabStateManager.java @@ -0,0 +1,25 @@ +package com.twine.colorcapture.navigation; + +import com.twine.colorcapture.mvvm.DependencyProperty; + +public class TabStateManager +{ + private static TabStateManager instance; + + public DependencyProperty state; + + public static TabStateManager getInstance() + { + if (instance == null) + { + instance = new TabStateManager(); + } + + return instance; + } + + public TabStateManager() + { + state = new DependencyProperty<>(TabState.Capture); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/AndroidNotificationProvider.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/AndroidNotificationProvider.java index 307fc5edf..528bea2e2 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/AndroidNotificationProvider.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/AndroidNotificationProvider.java @@ -9,6 +9,8 @@ import android.widget.Toast; import com.twine.colorcapture.core.IAction; import com.twine.colorcapture.core.IAction1; +import com.twine.colorcapture.dialogs.confirm.ConfirmDialog; +import com.twine.colorcapture.dialogs.confirm.ConfirmDialogVM; import com.twine.colorcapture.dialogs.error.ErrorDialog; import com.twine.colorcapture.dialogs.error.ErrorDialogVM; import com.twine.colorcapture.dialogs.progress.ProgressDialog; @@ -152,6 +154,34 @@ public class AndroidNotificationProvider implements INotificationProvider vm.setMessage(message); } + @Override + public void showConfirm(String title, String message,String confirmText, IAction1 onDismiss) + { + closeDialog(); + ConfirmDialog dialog = new ConfirmDialog(); + dialog.inject(); + + lastDialog = dialog; + FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); + Fragment prev = activity.getFragmentManager().findFragmentByTag("dialog"); + if (prev != null) { + ft.remove(prev); + } + ft.addToBackStack(null); + + dialog.setOnDismissListener(onDismiss); + + //show the dialog. + dialog.show(ft, "dialog"); + + ConfirmDialogVM vm = dialog.getVM(); + + vm.setConfirmed(false); + vm.setTitle(title); + vm.setMessage(message); + vm.setConfirmText(confirmText); + } + @Override public void closeDialog() { diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/INotificationProvider.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/INotificationProvider.java index b1295a8b4..121ce0919 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/INotificationProvider.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/notification/INotificationProvider.java @@ -4,6 +4,7 @@ import android.app.Activity; import com.twine.colorcapture.core.IAction; import com.twine.colorcapture.core.IAction1; +import com.twine.colorcapture.dialogs.confirm.ConfirmDialogVM; import com.twine.colorcapture.dialogs.error.ErrorDialogVM; import com.twine.colorcapture.dialogs.progress.ProgressDialogVM; import com.twine.colorcapture.dialogs.success.SuccessDialog; @@ -37,6 +38,7 @@ public interface INotificationProvider /** * Displays a progress dialog... + * * @param title * @param message */ @@ -44,6 +46,7 @@ public interface INotificationProvider /** * Displays a success dialog. + * * @param title * @param message * @param onDismiss @@ -52,12 +55,22 @@ public interface INotificationProvider /** * Displays an error dialog. + * * @param title * @param message * @param onDismiss */ void showError(String title, String message, IAction1 onDismiss); + /** + * Displays a confirmation dialog. + * + * @param title + * @param message + * @param onDismiss + */ + void showConfirm(String title, String message, String confirmText, IAction1 onDismiss); + /** * Closes the last dialog. */ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/settings/SettingsManager.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/settings/SettingsManager.java new file mode 100644 index 000000000..b90f11a13 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/settings/SettingsManager.java @@ -0,0 +1,96 @@ +package com.twine.colorcapture.settings; + +import android.content.SharedPreferences; + +import com.google.gson.Gson; +import com.twine.colorcapture.logging.LogManager; +import com.twine.colorcapture.models.ColorResult; + +import java.util.ArrayList; +import java.util.List; + +import static android.content.Context.MODE_PRIVATE; +import static com.twine.colorcapture.App.getContext; + +public class SettingsManager +{ + private static final String SETTINGS_FILE_NAME = "TCC_Settings"; + private static SettingsManager instance; + private boolean isWelcomeScreenShown; + private List results; + + public boolean isWelcomeScreenShown() + { + return isWelcomeScreenShown; + } + + public void setWelcomeScreenShown(boolean welcomeScreenShown) + { + isWelcomeScreenShown = welcomeScreenShown; + } + + public List getResults() + { + return results; + } + + public static SettingsManager getInstance() + { + if (instance == null) + { + instance = load(); + } + + return instance; + } + + public static void save() + { + try + { + LogManager.log("Saving settings..."); + Gson gson = new Gson(); + String value = gson.toJson(getInstance()); + SharedPreferences.Editor editor = getContext().getSharedPreferences(SETTINGS_FILE_NAME, MODE_PRIVATE).edit(); + editor.putString("settings", value); + editor.apply(); + + LogManager.log("Settings:", getInstance()); + } + catch (Exception ex) + { + LogManager.log(ex, "Error saving settings."); + } + } + + private static SettingsManager load() + { + SettingsManager result = new SettingsManager(); + + try + { + LogManager.log("Loading settings..."); + SharedPreferences prefs = getContext().getSharedPreferences(SETTINGS_FILE_NAME, MODE_PRIVATE); + String value = prefs.getString("settings", null); + + if (value != null) + { + Gson gson = new Gson(); + result = gson.fromJson(value, SettingsManager.class); + } + } + catch (Exception ex) + { + LogManager.log(ex, "Error loading settings."); + } + + LogManager.log("Settings:", result); + + return result; + } + + public SettingsManager() + { + results = new ArrayList<>(); + } +} 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 b043bef9f..c0b89fba8 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java @@ -8,12 +8,16 @@ import com.squareup.otto.Bus; import com.twine.colorcapture.core.Task.TaskBuilder; import com.twine.colorcapture.dialogs.processing.ProcessingDialog; import com.twine.colorcapture.dialogs.welcome.WelcomeDialog; +import com.twine.colorcapture.models.ColorResult; 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.navigation.TabState; +import com.twine.colorcapture.navigation.TabStateManager; import com.twine.colorcapture.notification.INotificationProvider; import com.twine.colorcapture.opencv.ImageProcessor; +import com.twine.colorcapture.settings.SettingsManager; import com.twine.colorcapture.utils.ThreadingUtils; import com.twine.colorcapture.views.capture.ICaptureFragment.ICaptureFragmentListener; import com.twine.colorcapture.web.ITCCService; @@ -24,6 +28,11 @@ import com.yanzhenjie.zbar.ImageScanner; import com.yanzhenjie.zbar.Symbol; import com.yanzhenjie.zbar.SymbolSet; +import org.joda.time.LocalDateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; public class CaptureFragmentVM extends ViewModelBase implements ICaptureFragmentListener @@ -42,7 +51,6 @@ public class CaptureFragmentVM extends ViewModelBase implement private DefinitionResponse definition; private INavigationProvider navigationProvider; private INotificationProvider notificationProvider; - private boolean startDialogShown; private boolean preventDetection; private Bus eventBus; @@ -161,8 +169,17 @@ public class CaptureFragmentVM extends ViewModelBase implement if (!abort.get()) { + LocalDateTime date = LocalDateTime.now(); + DateTimeFormatter fmt = DateTimeFormat.forPattern("d MMMM, yyyy, hh:mm:ss").withLocale(Locale.ENGLISH); + String name = date.toString(fmt); + + ColorResult colorResult = new ColorResult(response, date.toString(), name); + + SettingsManager.getInstance().getResults().add(colorResult); + SettingsManager.save(); + notificationProvider.closeDialog(); - navigationProvider.navigateWithObjectTo(NavigationFragment.Result, true, false, response); + navigationProvider.navigateWithObjectTo(NavigationFragment.Result, true, false, colorResult); } else { @@ -203,18 +220,22 @@ public class CaptureFragmentVM extends ViewModelBase implement protected void onNavigatedTo() { super.onNavigatedTo(); + TabStateManager.getInstance().state.set(TabState.Capture); preventDetection = false; - if (!startDialogShown) - { - startDialogShown = true; + boolean showDialog = !SettingsManager.getInstance().isWelcomeScreenShown(); + if (showDialog) + { notificationProvider.showDialog(new WelcomeDialog(), (vm) -> { isCardDetected.set(false); view.startCamera(); }); + + SettingsManager.getInstance().setWelcomeScreenShown(true); + SettingsManager.save(); } else { diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/IMainActivity.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/IMainActivity.java index 866a0ece7..0835d4eef 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/IMainActivity.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/IMainActivity.java @@ -4,4 +4,5 @@ import com.twine.colorcapture.mvvm.IView; public interface IMainActivity extends IView { + void cloneMenu(); } 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 e0eaca38c..f40b78a4b 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 @@ -10,6 +10,7 @@ import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageButton; import android.widget.LinearLayout; import com.twine.colorcapture.App; @@ -38,7 +39,7 @@ public class MainActivity extends ActivityBase private INotificationProvider notificationProvider; private CurrentTab currentTab; - public DependencyProperty isMoreToggled; - public DependencyProperty isCaptureToggled; - public DependencyProperty isMyColorsToggled; + public TabStateManager tabStateManager; + + public RelayCommand captureCommand; + public RelayCommand myColorsCommand; + public RelayCommand moreCommand; + + public RelayCommand howToUseCommand; @Inject public MainActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider) { + tabStateManager = TabStateManager.getInstance(); + this.navigationProvider = navigationProvider; this.notificationProvider = notificationProvider; - isMoreToggled = new DependencyProperty(false, this::onMoreToggled); - isCaptureToggled = new DependencyProperty(false, this::onCaptureToggled); - isMyColorsToggled = new DependencyProperty(false, this::onMyColorsToggled); currentTab = CurrentTab.Capture; - setCurrentTab(currentTab); navigationProvider.addFragmentNavigationListener(this::onNavigation); + + howToUseCommand = new RelayCommand(this::handleHowToUseCommand); + + captureCommand = new RelayCommand(this::handleCaptureCommand); + myColorsCommand = new RelayCommand(this::handleMyColorsCommand); + moreCommand = new RelayCommand(this::handleMoreCommand); } - private void onNavigation(NavigationFragment navigationFragment) + private void handleMoreCommand() + { + + } + + private void handleMyColorsCommand() { - if (navigationFragment == NavigationFragment.Capture || navigationFragment == NavigationFragment.Result && currentTab != CurrentTab.Capture) + if (navigationProvider.getCurrentFragment() != NavigationFragment.MyColors) { - isMoreToggled.setNoCallback(false); - isMyColorsToggled.setNoCallback(false); - isCaptureToggled.setNoCallback(true); + navigationProvider.navigateTo(NavigationFragment.MyColors, true, false); } } - @Override - protected void onViewAttached(IMainActivity view) + private void handleCaptureCommand() { - super.onViewAttached(view); + if (navigationProvider.getCurrentFragment() != NavigationFragment.Capture) + { + navigationProvider.navigateTo(NavigationFragment.Capture, false, true); + } } - private void onMyColorsToggled(DependencyProperty booleanDependencyProperty, Boolean value) + @Override + protected void onNavigatedTo() { - setCurrentTab(CurrentTab.MyColors); + super.onNavigatedTo(); + tabStateManager.state.set(TabState.Capture); } - private void onCaptureToggled(DependencyProperty booleanDependencyProperty, Boolean value) + private void handleHowToUseCommand() { - setCurrentTab(CurrentTab.Capture); + view.cloneMenu(); + notificationProvider.showDialog(new WelcomeDialog(), (vm) -> { }); } - private void onMoreToggled(DependencyProperty booleanDependencyProperty, Boolean value) + private void onNavigation(NavigationFragment navigationFragment) { - setCurrentTab(CurrentTab.More); + } - private void setCurrentTab(CurrentTab tab) + @Override + protected void onViewAttached(IMainActivity view) { - currentTab = tab; - - if (tab == CurrentTab.More) - { - if (isMoreToggled.get()) - { - isCaptureToggled.setNoCallback(false); - isMyColorsToggled.setNoCallback(false); - } - isMoreToggled.setNoCallback(true); - } - else if (tab == CurrentTab.Capture) - { - if (isCaptureToggled.get()) - { - isMoreToggled.setNoCallback(false); - isMyColorsToggled.setNoCallback(false); - navigationProvider.navigateTo(NavigationFragment.Capture, false, true); - } - isCaptureToggled.setNoCallback(true); - } - else if (tab == CurrentTab.MyColors) - { - if (isMyColorsToggled.get()) - { - isMoreToggled.setNoCallback(false); - isCaptureToggled.setNoCallback(false); - navigationProvider.navigateTo(NavigationFragment.MyColors, true, false); - } - isMyColorsToggled.setNoCallback(true); - } + super.onViewAttached(view); } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/mycolors/MyColorsFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/mycolors/MyColorsFragmentVM.java index 9a2358516..6b0fc7b27 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/mycolors/MyColorsFragmentVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/mycolors/MyColorsFragmentVM.java @@ -1,17 +1,83 @@ package com.twine.colorcapture.views.mycolors; +import android.databinding.ObservableArrayList; +import android.databinding.ObservableList; +import android.view.View; +import android.widget.AdapterView; + +import com.twine.colorcapture.BR; +import com.twine.colorcapture.R; +import com.twine.colorcapture.integration.ExternalBridgeMachine; +import com.twine.colorcapture.logging.LogManager; +import com.twine.colorcapture.models.ColorResult; +import com.twine.colorcapture.models.ColorResultVM; import com.twine.colorcapture.mvvm.ViewModelBase; import com.twine.colorcapture.navigation.INavigationProvider; +import com.twine.colorcapture.navigation.NavigationFragment; +import com.twine.colorcapture.navigation.TabState; +import com.twine.colorcapture.navigation.TabStateManager; +import com.twine.colorcapture.notification.INotificationProvider; +import com.twine.colorcapture.settings.SettingsManager; + +import java.util.Collections; import javax.inject.Inject; +import me.tatarka.bindingcollectionadapter2.ItemBinding; + +import static br.com.zbra.androidlinq.Linq.stream; + public class MyColorsFragmentVM extends ViewModelBase { private INavigationProvider navigationProvider; - + private INotificationProvider notificationProvider; + public ObservableList results; + public ItemBinding resultBinding; + @Inject - public MyColorsFragmentVM(INavigationProvider navigationProvider) + public MyColorsFragmentVM(INavigationProvider navigationProvider, INotificationProvider notificationProvider) { + this.notificationProvider = notificationProvider; this.navigationProvider = navigationProvider; + + results = new ObservableArrayList<>(); + resultBinding = ItemBinding.of(BR.result, R.layout.color_result_item); + } + + public void onResultSelected(AdapterView adapterView, View view, int i, long l) + { + ColorResultVM colorResultVM = (ColorResultVM) adapterView.getAdapter().getItem(i); + navigationProvider.navigateWithObjectTo(NavigationFragment.Result, true, false, colorResultVM.getResult()); + } + + @Override + protected void onNavigatedTo() + { + super.onNavigatedTo(); + + TabStateManager.getInstance().state.set(TabState.MyColors); + + results.clear(); + + for (ColorResult result : stream(SettingsManager.getInstance().getResults()).reverse()) + { + ColorResultVM vm = new ColorResultVM(); + vm.setResult(result); + results.add(vm); + vm.setOnDeleteListener(this::onResultDeleted); + } + } + + private void onResultDeleted(ColorResultVM colorResultVM) + { + notificationProvider.showConfirm("Delete color", "Are you sure you want to delete the selected color?", "Delete", (vm) -> + { + if (vm.isConfirmed()) + { + results.remove(colorResultVM); + SettingsManager.getInstance().getResults().remove(colorResultVM.getResult()); + SettingsManager.save(); + } + }); } } 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 index 3641e89ee..3002bf243 100644 --- 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 @@ -81,7 +81,7 @@ public class RegisterFragmentVM extends ViewModelBase catch (Exception ex) { pVM.close(); - //TODO: display error message! + notificationProvider.showError("Registering your system","Device registration failed.\nPlease check your serial number.",(e) -> {}); Log.i("REGISTER", ex.getMessage()); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/IRenameFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/IRenameFragment.java new file mode 100644 index 000000000..9cd9e9a54 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/IRenameFragment.java @@ -0,0 +1,7 @@ +package com.twine.colorcapture.views.rename; + +import com.twine.colorcapture.mvvm.IView; + +public interface IRenameFragment extends IView +{ +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragment.java new file mode 100644 index 000000000..228ccd66d --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragment.java @@ -0,0 +1,62 @@ +package com.twine.colorcapture.views.rename; + +import android.content.Context; +import android.databinding.Bindable; +import android.support.v7.widget.AppCompatEditText; +import android.view.View; +import android.view.inputmethod.InputMethodManager; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.FragmentRenameBinding; +import com.twine.colorcapture.mvvm.FragmentBase; + +import butterknife.BindView; + +public class RenameFragment extends FragmentBase +{ + @BindView(R.id.txtName) + public AppCompatEditText txtName; + + @Override + protected int getLayoutId() + { + return R.layout.fragment_rename; + } + + @Override + protected void inject() + { + App.getComponent().inject(this); + } + + @Override + public String getTitle() + { + return "Rename"; + } + + @Override + protected void onCreated() + { + super.onCreated(); + + InputMethodManager imgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + txtName.requestFocus(); + txtName.selectAll(); + imgr.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); + } + + @Override + public void onPause() + { + super.onPause(); + + // Check if no view has focus: + View view = getActivity().getCurrentFocus(); + if (view != null) { + InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); + } + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragmentVM.java new file mode 100644 index 000000000..e860d0aac --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/rename/RenameFragmentVM.java @@ -0,0 +1,50 @@ +package com.twine.colorcapture.views.rename; + +import com.twine.colorcapture.models.ColorResult; +import com.twine.colorcapture.models.ColorResultVM; +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.TabState; +import com.twine.colorcapture.navigation.TabStateManager; +import com.twine.colorcapture.settings.SettingsManager; + +public class RenameFragmentVM extends ViewModelBase implements INavigationObjectReceiver +{ + private INavigationProvider navigationProvider; + + public DependencyProperty colorResult; + public DependencyProperty name; + public RelayCommand renameCommand; + + public RenameFragmentVM(INavigationProvider navigationProvider) + { + this.navigationProvider = navigationProvider; + colorResult = new DependencyProperty<>(); + renameCommand = new RelayCommand(this::handleRenameCommand); + name = new DependencyProperty<>(""); + } + + private void handleRenameCommand() + { + colorResult.get().setName(name.get()); + SettingsManager.save(); + navigationProvider.navigateBack(); + } + + @Override + protected void onNavigatedTo() + { + super.onNavigatedTo(); + TabStateManager.getInstance().state.set(TabState.MyColors); + } + + @Override + public void onNavigationObjectReceived(ColorResult colorResult) + { + this.colorResult.set(colorResult); + this.name.set(colorResult.getName()); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java index 2e5639154..2e58e2777 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/result/ResultFragmentVM.java @@ -5,19 +5,34 @@ import android.util.Log; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import com.twine.colorcapture.messages.MachineRegisteredMessage; +import com.twine.colorcapture.models.ColorResult; +import com.twine.colorcapture.models.ColorResultVM; 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.NavigationActivity; import com.twine.colorcapture.navigation.NavigationFragment; +import com.twine.colorcapture.navigation.TabState; +import com.twine.colorcapture.navigation.TabStateManager; +import com.twine.colorcapture.settings.SettingsManager; +import com.twine.colorcapture.web.ITCCService; import com.twine.colorcapture.web.messages.DetectionResponse; +import org.joda.time.LocalDateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.util.Locale; + import javax.inject.Inject; -public class ResultFragmentVM extends ViewModelBase implements INavigationObjectReceiver +public class ResultFragmentVM extends ViewModelBase implements INavigationObjectReceiver { private INavigationProvider navigationProvider; + private ITCCService tccService; + public ColorResult colorResult; public DependencyProperty isCameraColorToggled; public DependencyProperty detectionResponse; @@ -28,10 +43,12 @@ public class ResultFragmentVM extends ViewModelBase implements public RelayCommand sendToMachineCommand; public RelayCommand registerMachineCommand; + @Inject - public ResultFragmentVM(Bus eventBus, INavigationProvider navigationProvider) + public ResultFragmentVM(Bus eventBus, INavigationProvider navigationProvider, ITCCService tccService) { this.navigationProvider = navigationProvider; + this.tccService = tccService; isCameraColorToggled = new DependencyProperty<>(false); isMachineRegistred = new DependencyProperty<>(false); @@ -63,11 +80,12 @@ public class ResultFragmentVM extends ViewModelBase implements private void handleRenameCommand() { + navigationProvider.navigateWithObjectTo(NavigationFragment.Rename, true, false, colorResult); } private void handleEmailCommand() { - Log.d("RESULT", "handleEmailCommand: "); + navigationProvider.navigateTo(NavigationActivity.SendToEmail, false); } private void toggleCameraColor() @@ -76,8 +94,24 @@ public class ResultFragmentVM extends ViewModelBase implements } @Override - public void onNavigationObjectReceived(DetectionResponse detectionResponse) + public void onNavigationObjectReceived(ColorResult colorResult) + { + this.colorResult = colorResult; + this.detectionResponse.set(colorResult.getDetectionResponse()); + } + + @Override + protected void onNavigatedTo() { - this.detectionResponse.set(detectionResponse); + super.onNavigatedTo(); + + try + { + isMachineRegistred.set(tccService.getDefinition().isRegistered()); + } + catch (Exception e) + { + e.printStackTrace(); + } } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/ISendToEmailActivity.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/ISendToEmailActivity.java new file mode 100644 index 000000000..980d2eb49 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/ISendToEmailActivity.java @@ -0,0 +1,7 @@ +package com.twine.colorcapture.views.sendtoemail; + +import com.twine.colorcapture.mvvm.IView; + +public interface ISendToEmailActivity extends IView +{ +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java new file mode 100644 index 000000000..d886de513 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivity.java @@ -0,0 +1,30 @@ +package com.twine.colorcapture.views.sendtoemail; + +import android.app.Activity; +import android.os.Bundle; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.ActivitySendToEmailBinding; +import com.twine.colorcapture.mvvm.ActivityBase; + +public class SendToEmailActivity extends ActivityBase implements ISendToEmailActivity +{ + @Override + protected void onCreating(Bundle savedInstanceState) + { + + } + + @Override + protected int getLayoutId() + { + return R.layout.activity_send_to_email; + } + + @Override + protected void inject() + { + App.getComponent().inject(this); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java new file mode 100644 index 000000000..77467fff4 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtoemail/SendToEmailActivityVM.java @@ -0,0 +1,21 @@ +package com.twine.colorcapture.views.sendtoemail; + +import com.twine.colorcapture.models.ColorResult; +import com.twine.colorcapture.mvvm.RelayCommand; +import com.twine.colorcapture.mvvm.ViewModelBase; + +public class SendToEmailActivityVM extends ViewModelBase +{ + public RelayCommand sendCommand; + public ColorResult colorResult; + + public SendToEmailActivityVM() + { + sendCommand = new RelayCommand(this::handleSendCommand); + } + + private void handleSendCommand() + { + + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtomachine/SendToMachineFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtomachine/SendToMachineFragmentVM.java index 0d415b498..a51d0eb71 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtomachine/SendToMachineFragmentVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/sendtomachine/SendToMachineFragmentVM.java @@ -2,8 +2,6 @@ package com.twine.colorcapture.views.sendtomachine; import android.databinding.ObservableArrayList; import android.databinding.ObservableList; -import android.os.Handler; -import android.os.Looper; import android.view.View; import android.widget.AdapterView; @@ -16,6 +14,7 @@ import com.twine.colorcapture.mvvm.ViewModelBase; import com.twine.colorcapture.navigation.INavigationObjectReceiver; import com.twine.colorcapture.navigation.INavigationProvider; import com.twine.colorcapture.notification.INotificationProvider; +import com.twine.colorcapture.web.ITCCService; import com.twine.colorcapture.web.messages.DetectionColor; import java.util.concurrent.atomic.AtomicBoolean; @@ -24,21 +23,25 @@ import javax.inject.Inject; import me.tatarka.bindingcollectionadapter2.ItemBinding; +import static br.com.zbra.androidlinq.Linq.stream; + public class SendToMachineFragmentVM extends ViewModelBase implements INavigationObjectReceiver { private ExternalBridgeScanner scanner; private DetectionColor detectionColor; private INotificationProvider notificationProvider; private INavigationProvider navigationProvider; + private ITCCService tccService; public ObservableList machines; public ItemBinding machineBinding; @Inject - public SendToMachineFragmentVM(INotificationProvider notificationProvider, INavigationProvider navigationProvider) + public SendToMachineFragmentVM(INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService) { this.notificationProvider = notificationProvider; this.navigationProvider = navigationProvider; + this.tccService = tccService; machines = new ObservableArrayList<>(); scanner = new ExternalBridgeScanner(); @@ -50,18 +53,24 @@ public class SendToMachineFragmentVM extends ViewModelBase + if (stream(tccService.getOrganizationMachines()).any(x -> x.equals(machine.getSerialNumber()))) { - machines.remove(machine); - }); + invokeUI(() -> + { + machines.remove(machine); + }); + } } private void onMachineDiscovered(Object o, ExternalBridgeMachine machine) { - invokeUI(() -> + if (stream(tccService.getOrganizationMachines()).any(x -> x.equals(machine.getSerialNumber()))) { - machines.add(0, machine); - }); + invokeUI(() -> + { + machines.add(0, machine); + }); + } } @Override 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 feefe86f8..362abe121 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 @@ -8,6 +8,7 @@ import com.twine.colorcapture.web.messages.DetectionResponse; import com.twine.colorcapture.web.messages.MachineRegistrationResponse; import java.io.IOException; +import java.util.List; public interface ITCCService { @@ -16,4 +17,8 @@ public interface ITCCService DetectionResponse detect(Bitmap bitmap, String barcode) throws Exception; MachineRegistrationResponse register(String serialNumber) throws Exception; + + boolean isRegistered(); + + List getOrganizationMachines(); } 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 6e03755b8..6999d2f0e 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 @@ -7,6 +7,7 @@ import android.provider.Settings; import android.util.Base64; import com.twine.colorcapture.BuildConfig; +import com.twine.colorcapture.logging.LogManager; import com.twine.colorcapture.utils.BitmapUtils; import com.twine.colorcapture.web.messages.DefinitionRequest; import com.twine.colorcapture.web.messages.DefinitionResponse; @@ -18,6 +19,7 @@ import com.twine.colorcapture.web.messages.MachineRegistrationRequest; import com.twine.colorcapture.web.messages.MachineRegistrationResponse; import java.io.IOException; +import java.util.List; import java.util.UUID; import javax.inject.Inject; @@ -34,6 +36,8 @@ public class TCCService implements ITCCService private IWebServiceAPI webAPI; private LoginResponse loginResponse; private static final String DEVICE_ID_PREF_NAME = "DeviceIdFile"; + private boolean isRegistered; + private List organizationMachines; @Inject public TCCService(IWebServiceAPI webServiceAPI) @@ -44,6 +48,8 @@ public class TCCService implements ITCCService @Override public DefinitionResponse getDefinition() throws Exception { + LogManager.log("Retrieving definition..."); + ensureAuthenticated(); if (definition == null) @@ -52,11 +58,15 @@ public class TCCService implements ITCCService if (response.isSuccessful()) { - definition = webAPI.getDefinition(new DefinitionRequest()).execute().body(); + definition = response.body(); + isRegistered = definition.isRegistered(); + organizationMachines = definition.getOrganizationMachines(); + + LogManager.log("Definition retrieved.", definition); } else { - throw new Exception(response.message()); + throw LogManager.log(new Exception(response.message())); } } @@ -88,20 +98,30 @@ public class TCCService implements ITCCService @Override public MachineRegistrationResponse register(String serialNumber) throws Exception { + LogManager.log("Registering machine..."); + ensureAuthenticated(); MachineRegistrationRequest request = new MachineRegistrationRequest(); request.setSerialnumber(serialNumber); + LogManager.log("Sending machine registration request:", request); + Response response = webAPI.register(request).execute(); if (response.isSuccessful()) { - return response.body(); + MachineRegistrationResponse r = response.body(); + + LogManager.log("Machine registration successful.", r); + + isRegistered = true; + organizationMachines = r.getOrganizationMachines(); + return r; } else { - throw new Exception(response.message()); + throw LogManager.log(new Exception(response.message()), "Machine registration failed."); } } @@ -115,37 +135,57 @@ public class TCCService implements ITCCService private LoginResponse login() throws Exception { + LogManager.log("Logging in to TCC service..."); + LoginRequest request = new LoginRequest(); request.setAppId(BuildConfig.WEB_SERVICE_APP_ID); String deviceId; + LogManager.log("Getting device id from shared preferences..."); + SharedPreferences prefs = getContext().getSharedPreferences(DEVICE_ID_PREF_NAME, MODE_PRIVATE); deviceId = prefs.getString("DeviceId", null); if (deviceId == null) { + LogManager.log("Device id was not found in shared preferences. Generating device id..."); deviceId = UUID.randomUUID().toString(); SharedPreferences.Editor editor = getContext().getSharedPreferences(DEVICE_ID_PREF_NAME, MODE_PRIVATE).edit(); editor.putString("DeviceId", deviceId); editor.apply(); } + LogManager.log("Device id: " + deviceId + "."); + request.setDeviceId(deviceId); request.setDevice(Build.MANUFACTURER + " " + Build.MODEL); request.setOsVersion(Build.VERSION_CODES.class.getFields()[android.os.Build.VERSION.SDK_INT].getName()); + LogManager.log("Sending log-in request:", request); + Response response = webAPI.login(request).execute(); if (response.isSuccessful()) { loginResponse = response.body(); + LogManager.log("Login response received:", loginResponse); WebApiFactory.setAuthenticationToken(loginResponse.getAccessToken()); return loginResponse; } else { - throw new Exception(response.message()); + throw LogManager.log(new Exception(response.message()), "LogIn request failed."); } } + + public boolean isRegistered() + { + return isRegistered; + } + + public List getOrganizationMachines() + { + return organizationMachines; + } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java index 3aeaccd14..17c4f2d43 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java @@ -3,6 +3,7 @@ package com.twine.colorcapture.web; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.twine.colorcapture.logging.LogManager; import java.io.IOException; import java.util.concurrent.TimeUnit; @@ -47,6 +48,7 @@ public class WebApiFactory /** * Creates the specified API interface instance. + * * @param cls * @param timeout * @param @@ -55,7 +57,8 @@ public class WebApiFactory private static T createAPI(Class cls, int timeout) { OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); - httpClient.addInterceptor(new Interceptor() { + httpClient.addInterceptor(new Interceptor() + { @Override public Response intercept(Chain chain) throws IOException { @@ -69,6 +72,7 @@ public class WebApiFactory { request = chain.request().newBuilder().build(); } + return chain.proceed(request); } }); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java index 2dde27e09..d5da8ffe6 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java @@ -1,5 +1,8 @@ package com.twine.colorcapture.web.messages; +import java.util.ArrayList; +import java.util.List; + public class DefinitionResponse { private String templateString; @@ -11,6 +14,28 @@ public class DefinitionResponse private double similarityTolerance; private boolean enableDoubleChecking; private boolean enforceBarcodeDetection; + private boolean isRegistered; + private List organizationMachines; + + public boolean isRegistered() + { + return isRegistered; + } + + public void setRegistered(boolean registered) + { + isRegistered = registered; + } + + public List getOrganizationMachines() + { + return organizationMachines; + } + + public void setOrganizationMachines(List organizationMachines) + { + this.organizationMachines = organizationMachines; + } public String getTemplateString() { @@ -102,4 +127,9 @@ public class DefinitionResponse { this.enforceBarcodeDetection = enforceBarcodeDetection; } + + public DefinitionResponse() + { + organizationMachines = new ArrayList<>(); + } } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/about.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/about.png new file mode 100644 index 000000000..69ff01eea Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/about.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/delete_thin.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/delete_thin.png new file mode 100644 index 000000000..c1a9b62a9 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/delete_thin.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/error.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/error.png new file mode 100644 index 000000000..bc9aeb86b Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/error.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/how_to.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/how_to.png new file mode 100644 index 000000000..50aca55cb Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/how_to.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon_twine_card.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon_twine_card.png new file mode 100644 index 000000000..188126db8 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon_twine_card.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_close.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_close.png new file mode 100644 index 000000000..89c3b1653 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_close.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_delete.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_delete.png new file mode 100644 index 000000000..c04a02d4d Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icons_delete.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/info.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/info.png new file mode 100644 index 000000000..79a64c487 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/info.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/snapmatch.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/snapmatch.png new file mode 100644 index 000000000..05656ffdc Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/snapmatch.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/twine_card_icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/twine_card_icon.png new file mode 100644 index 000000000..ec9ae5576 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/twine_card_icon.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/about.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/about.png new file mode 100644 index 000000000..65e278cd4 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/about.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/delete_thin.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/delete_thin.png new file mode 100644 index 000000000..524997a78 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/delete_thin.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/error.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/error.png new file mode 100644 index 000000000..db3db4966 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/error.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/how_to.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/how_to.png new file mode 100644 index 000000000..59ba0e181 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/how_to.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon_twine_card.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon_twine_card.png new file mode 100644 index 000000000..bad44f686 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon_twine_card.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_close.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_close.png new file mode 100644 index 000000000..4e9940432 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_close.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_delete.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_delete.png new file mode 100644 index 000000000..e9a9a108e Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icons_delete.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/info.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/info.png new file mode 100644 index 000000000..a9bec6997 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/info.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/snapmatch.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/snapmatch.png new file mode 100644 index 000000000..bbd2be018 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/snapmatch.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/twine_card_icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/twine_card_icon.png new file mode 100644 index 000000000..e7ff93a39 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/twine_card_icon.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/about.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/about.png new file mode 100644 index 000000000..d5701a483 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/about.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/delete_thin.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/delete_thin.png new file mode 100644 index 000000000..b6b951c0a Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/delete_thin.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/error.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/error.png new file mode 100644 index 000000000..41fa3df55 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/error.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/how_to.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/how_to.png new file mode 100644 index 000000000..fbeb31818 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/how_to.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon_twine_card.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon_twine_card.png new file mode 100644 index 000000000..48e6595fa Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon_twine_card.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_close.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_close.png new file mode 100644 index 000000000..f4e9e1c50 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_close.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_delete.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_delete.png new file mode 100644 index 000000000..55753d24a Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icons_delete.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/info.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/info.png new file mode 100644 index 000000000..3e33de5a6 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/info.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/snapmatch.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/snapmatch.png new file mode 100644 index 000000000..994d77ffe Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/snapmatch.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/twine_card_icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/twine_card_icon.png new file mode 100644 index 000000000..ff3f1c99c Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/twine_card_icon.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/about.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/about.png new file mode 100644 index 000000000..06fedcd88 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/about.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/delete_thin.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/delete_thin.png new file mode 100644 index 000000000..f1e190f1c Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/delete_thin.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/error.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/error.png new file mode 100644 index 000000000..019edf5c7 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/error.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/how_to.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/how_to.png new file mode 100644 index 000000000..bae6374b6 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/how_to.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon_twine_card.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon_twine_card.png new file mode 100644 index 000000000..e399b466b Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon_twine_card.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_close.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_close.png new file mode 100644 index 000000000..91ba9167d Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_close.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_delete.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_delete.png new file mode 100644 index 000000000..8e54c739c Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icons_delete.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/info.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/info.png new file mode 100644 index 000000000..3727e7129 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/info.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/snapmatch.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/snapmatch.png new file mode 100644 index 000000000..198fb9f6f Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/snapmatch.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/twine_card_icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/twine_card_icon.png new file mode 100644 index 000000000..e8c54a75f Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/twine_card_icon.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/about.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/about.png new file mode 100644 index 000000000..85234de5d Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/about.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/delete_thin.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/delete_thin.png new file mode 100644 index 000000000..33b633fcc Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/delete_thin.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/error.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/error.png new file mode 100644 index 000000000..f386b553d Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/error.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/how_to.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/how_to.png new file mode 100644 index 000000000..0569f95f7 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/how_to.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon_twine_card.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon_twine_card.png new file mode 100644 index 000000000..589cf908d Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon_twine_card.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_close.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_close.png new file mode 100644 index 000000000..f37a9bbbc Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_close.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_delete.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_delete.png new file mode 100644 index 000000000..ccc594f43 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icons_delete.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/info.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/info.png new file mode 100644 index 000000000..07af24775 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/info.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/snapmatch.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/snapmatch.png new file mode 100644 index 000000000..7bf802396 Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/snapmatch.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/twine_card_icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/twine_card_icon.png new file mode 100644 index 000000000..e2b2bf09f Binary files /dev/null and b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/twine_card_icon.png differ diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml index d2e2f89c1..7c55188cc 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml @@ -6,6 +6,7 @@ + - + android:background="@drawable/button_transparent_fill_ripple" + android:src="@{vm.tabStateManager.state == TabState.More ? @drawable/more_selected : @drawable/more_normal}" /> - + android:background="@drawable/button_transparent_fill_ripple" + android:src="@{vm.tabStateManager.state == TabState.Capture ? @drawable/twinesnap_selected : @drawable/twinesnap_normal}" + bind:command="@{vm.captureCommand}"/> - + android:background="@drawable/button_transparent_fill_ripple" + android:src="@{vm.tabStateManager.state == TabState.MyColors ? @drawable/selected : @drawable/my_colors}" + bind:command="@{vm.myColorsCommand}"/> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/color_result_item.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/color_result_item.xml new file mode 100644 index 000000000..9be44f3da --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/color_result_item.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +