From 8b9dd6878829a3a86bff70bd67b77303bcac4e5d Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 6 Oct 2021 11:05:40 -0700 Subject: [PATCH] pushing --- .gitignore | 11 ++ .idea/codeStyles/Project.xml | 29 +++ .idea/gradle.xml | 18 ++ .idea/misc.xml | 38 ++++ .idea/runConfigurations.xml | 12 ++ .idea/vcs.xml | 6 + app/.gitignore | 1 + app/build.gradle | 32 ++++ app/proguard-rules.pro | 21 +++ .../ExampleInstrumentedTest.java | 26 +++ app/src/main/AndroidManifest.xml | 25 +++ .../myapplicationtest3/MoodEntryActivity.java | 124 +++++++++++++ .../myapplicationtest3/OpeningPage.java | 14 ++ .../drawable-v24/ic_launcher_foreground.xml | 34 ++++ .../res/drawable/ic_launcher_background.xml | 170 +++++++++++++++++ .../main/res/layout/activity_mood_entry.xml | 28 +++ .../main/res/layout/activity_opening_page.xml | 9 + .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 2963 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 4905 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2060 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2783 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4490 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 6895 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6387 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10413 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9128 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15132 bytes app/src/main/res/raw/credentials.xml | 6 + app/src/main/res/values/colors.xml | 6 + app/src/main/res/values/strings.xml | 3 + app/src/main/res/values/styles.xml | 11 ++ .../myapplicationtest3/ExampleUnitTest.java | 17 ++ build.gradle | 27 +++ gradle.properties | 15 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes gradle/wrapper/gradle-wrapper.properties | 5 + gradlew | 172 ++++++++++++++++++ gradlew.bat | 84 +++++++++ settings.gradle | 1 + 41 files changed, 955 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/com/example/robert/myapplicationtest3/ExampleInstrumentedTest.java create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/com/example/robert/myapplicationtest3/MoodEntryActivity.java create mode 100644 app/src/main/java/com/example/robert/myapplicationtest3/OpeningPage.java create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/layout/activity_mood_entry.xml create mode 100644 app/src/main/res/layout/activity_opening_page.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/raw/credentials.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/test/java/com/example/robert/myapplicationtest3/ExampleUnitTest.java create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd45b12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.iml +.gradle +/local.properties +/.idea/caches/build_file_checksums.ser +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e0d5b93 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..db7c90d --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.example.robert.myapplicationtest3" + minSdkVersion 16 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:design:28.0.0' + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'com.ibm.watson.developer_cloud:java-sdk:3.7.2' + implementation 'commons-io:commons-io:2.5' + implementation 'com.android.support:design:28.0.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/example/robert/myapplicationtest3/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/robert/myapplicationtest3/ExampleInstrumentedTest.java new file mode 100644 index 0000000..981ac29 --- /dev/null +++ b/app/src/androidTest/java/com/example/robert/myapplicationtest3/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.robert.myapplicationtest3; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.robert.myapplicationtest3", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8c3318f --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/robert/myapplicationtest3/MoodEntryActivity.java b/app/src/main/java/com/example/robert/myapplicationtest3/MoodEntryActivity.java new file mode 100644 index 0000000..2bba1ba --- /dev/null +++ b/app/src/main/java/com/example/robert/myapplicationtest3/MoodEntryActivity.java @@ -0,0 +1,124 @@ +package com.example.robert.myapplicationtest3; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.EditText; +import android.widget.Toast; + +import com.ibm.watson.developer_cloud.http.ServiceCallback; +import com.ibm.watson.developer_cloud.tone_analyzer.v3.ToneAnalyzer; +import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.Tone; +import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; +import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions; +import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneScore; + +import java.util.List; + +public class MoodEntryActivity extends AppCompatActivity +{ + ToneAnalyzer toneAnalyzer; + EditText userInput; + + @Override + protected void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_mood_entry); + userInput= (EditText) findViewById(R.id.userInput); + toneAnalyzer= new ToneAnalyzer("2017-07-01"); + + try + {//created new raw file in res. That contains the username, password, and link for the API. + //JSONObject credentials = new JSONObject(IOUtils.toString(getResources().openRawResource(R.raw.credentials), "UTF-8")); // Convert the file into a JSON object + Log.d("appError1","Failure here"); + // Extract the two values + //String username = credentials.getString("username"); + //String password = credentials.getString("password"); + Log.d("appError2","Failure here"); + //toneAnalyzer.setUsernameAndPassword(username, password); + toneAnalyzer.setUsernameAndPassword("ee4c7361-8aa6-4d11-8124-af1357f7ad84", "6kZb6Gigp3a0"); + } + catch(Exception e) + { + e.printStackTrace(); + } + /* + catch (IOException e) + { + Log.d("appError3","Failure here"); + e.printStackTrace(); + } + catch (JSONException e) //problem here + { + Log.d("appError4","Failure here"); + e.printStackTrace(); + } + */ + //setContentView(R.layout.activity_mood_entry); + } + + public void analyze(View view) { + analyzeText(); + } + + private void analyzeText() + { + // config tone analyzer + ToneOptions options = new ToneOptions.Builder().addTone(Tone.EMOTION).html(false).build(); //problem here + Log.d("appError5","Tone Analyzer failed"); + String textToAnalyze = userInput.getText().toString(); + + /* + String textToAnalyze= "I know the times are difficult! Our sales have been " + + "disappointing for the past three quarters for our data analytics " + + "product suite. We have a competitive data analytics product " + + "suite in the industry. But we need to do our job selling it! " + + "We need to acknowledge and fix our sales challenges. " + + "We can’t blame the economy for our lack of execution! " + + "We are missing critical sales opportunities. " + + "Our product is in no way inferior to the competitor products. " + + "Our clients are hungry for analytical tools to improve their " + + "business outcomes. Economy has nothing to do with it."; + */ + + toneAnalyzer.getTone(textToAnalyze, options).enqueue( + new ServiceCallback() + { + @Override + public void onResponse(ToneAnalysis response) + { + // More code here + List scores = response.getDocumentTone().getTones().get(0).getTones(); + String detectedTones = ""; + Log.d("appError6","Tone Analyzer failed"); + for(ToneScore score:scores) + { + if(score.getScore() > 0.5f) + { + detectedTones += score.getName() + " "; + } + } + + final String toastMessage= "The following emotions were detected:\n\n"+ detectedTones.toUpperCase(); + + runOnUiThread(new Runnable() + { + @Override + public void run() + { + Toast.makeText(getBaseContext(),toastMessage, Toast.LENGTH_LONG).show(); + } + }); + } + + @Override + public void onFailure(Exception e) + { + Log.d("appError7","Tone Analyzer failed"); + e.printStackTrace(); + } + }); + } +} diff --git a/app/src/main/java/com/example/robert/myapplicationtest3/OpeningPage.java b/app/src/main/java/com/example/robert/myapplicationtest3/OpeningPage.java new file mode 100644 index 0000000..a872bc7 --- /dev/null +++ b/app/src/main/java/com/example/robert/myapplicationtest3/OpeningPage.java @@ -0,0 +1,14 @@ +package com.example.robert.myapplicationtest3; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +public class OpeningPage extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_opening_page); + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_mood_entry.xml b/app/src/main/res/layout/activity_mood_entry.xml new file mode 100644 index 0000000..c4b812d --- /dev/null +++ b/app/src/main/res/layout/activity_mood_entry.xml @@ -0,0 +1,28 @@ + + + + + +