This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8b9dd68
Showing
41 changed files
with
955 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/example/robert/myapplicationtest3/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.robert.myapplicationtest3"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MoodEntryActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".OpeningPage"></activity> | ||
</application> | ||
|
||
</manifest> |
124 changes: 124 additions & 0 deletions
124
app/src/main/java/com/example/robert/myapplicationtest3/MoodEntryActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ToneAnalysis>() | ||
{ | ||
@Override | ||
public void onResponse(ToneAnalysis response) | ||
{ | ||
// More code here | ||
List<ToneScore> 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(); | ||
} | ||
}); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/example/robert/myapplicationtest3/OpeningPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.