Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
aa516b2
Initial commit
deekshithreddyr Jul 10, 2019
ad096da
Addressed review comments
deekshithreddyr Jul 16, 2019
2a0b27f
Added README File
deekshithreddyr Jul 16, 2019
bbd9f4e
Update README.md
deekshithreddyr Jul 17, 2019
a4f9ba8
Update README.md
deekshithreddyr Jul 17, 2019
b33d644
Update README.md
deekshithreddyr Jul 17, 2019
6ce8859
refactor: refactoring the code
deekshithreddyr Jul 21, 2019
0f862d4
Merge branch 'master' of https://github.com/deekshithreddyr/android-d…
deekshithreddyr Jul 21, 2019
2e38050
Add stopwatchagent.zip file
deekshithreddyr Jul 21, 2019
c3c2b78
Update README.md
deekshithreddyr Jul 22, 2019
bba436b
Update README.md
deekshithreddyr Jul 22, 2019
b168253
Changes has per Github comments
deekshithreddyr Jul 23, 2019
e7d5487
Combine the three requests into one. Dropdown instead of multi-selec…
deekshithreddyr Aug 6, 2019
9dcf0d1
Addressed review comments
deekshithreddyr Aug 8, 2019
9ddd430
Using the Audio returned from Dialogflow.
deekshithreddyr Aug 11, 2019
1c2b79f
Addressed review comments
deekshithreddyr Aug 13, 2019
462db73
Separated the Authentication code from AppController.java to AuthUtil…
deekshithreddyr Aug 14, 2019
c8371eb
Code Refinement
deekshithreddyr Aug 18, 2019
20b798a
Update README.md
deekshithreddyr Aug 18, 2019
d31ecb6
Update README.md
deekshithreddyr Aug 19, 2019
cafff50
Addressed review comments
deekshithreddyr Aug 26, 2019
6b8e4bd
Merge branch 'master' of https://github.com/deekshithreddyr/android-d…
deekshithreddyr Aug 26, 2019
4dd38b9
function to convert the time from UTC to local TimeZone added
deekshithreddyr Aug 26, 2019
73edd3f
Code readability update
deekshithreddyr Aug 30, 2019
12e2d39
Update README.md
deekshithreddyr Aug 30, 2019
26599e8
Speech2speech Initial commit
deekshithreddyr Aug 30, 2019
32020e9
Merge branch 'master' of https://github.com/deekshithreddyr/android-d…
deekshithreddyr Aug 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
Comment thread
nnegrey marked this conversation as resolved.
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mlapitest"
Comment thread
nnegrey marked this conversation as resolved.
Outdated
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/io.netty.versions.properties'
}
}

dependencies {

configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:25.3.0'
}
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.firebase:firebase-functions:18.0.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.cloud:google-cloud-dialogflow:0.96.0-alpha'
implementation group: 'io.grpc', name: 'grpc-okhttp', version: '1.21.0'
implementation group: 'io.grpc', name: 'grpc-netty', version: '1.21.0'

implementation "com.google.firebase:firebase-database:18.0.0"
Comment thread
nnegrey marked this conversation as resolved.
Outdated
}


apply plugin: 'com.google.gms.google-services'
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.mlapitest;

import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.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() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.example.mlapitest", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.mlapitest">

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".AppController"
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=".ui.ChatActivity" />
<activity android:name=".ui.WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.MainActivity" />
<service
android:name=".service.MyFirebaseMessagingService"
Comment thread
nnegrey marked this conversation as resolved.
Outdated
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>

</manifest>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.example.mlapitest;

import android.app.Application;

import com.google.firebase.functions.FirebaseFunctions;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class AppController extends Application {

public static final String TOKEN_RECEIVED = "TOKEN_RECEIVED";
public static final String PROJECT_ID = "PROJECT_ID";
public static final String SESSION_ID = "sessionId";
public static String firebaseInstanceId = "";

public static String token = "";
public static Date exipryTime;

/**
* function to call the firebase function which will send the fcm message containing token and expiry time to the device
*/
public static void callFirebaseFunction() {
Map<String, Object> data = new HashMap<>();
data.put("deviceId", AppController.firebaseInstanceId);
FirebaseFunctions firebaseFunctions;
firebaseFunctions = FirebaseFunctions.getInstance();

firebaseFunctions
.getHttpsCallable("getOAuthToken")
.call(data);
}

/**
* function to convert string to date
* @param dt : string date
* @return : converted date object
*/
public static Date getDateFromStrinng(String dt) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
try {
Date date = format.parse(dt);
return date;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.example.mlapitest.adapter;

import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.mlapitest.R;
import com.example.mlapitest.model.ChatMsgModel;

import java.util.ArrayList;

public class ChatRecyclerViewAdapter extends RecyclerView.Adapter<ChatRecyclerViewAdapter.MyViewHolder> {

private ArrayList<ChatMsgModel> chatMsgModels;
private Context context;

public ChatRecyclerViewAdapter(Context context, ArrayList<ChatMsgModel> chatMsgModels) {
this.context = context;
this.chatMsgModels = chatMsgModels;

}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.custom_chat_recyclerview_item, parent, false);

return new MyViewHolder(itemView);
}

@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
final ChatMsgModel chatMsgModel = chatMsgModels.get(position);

if(chatMsgModel.getType()==1) { // Message Sent
holder.tvMsgSent.setText(chatMsgModel.getMsg());
holder.tvMsgSent.setVisibility(View.VISIBLE);
holder.tvMsgReceived.setVisibility(View.GONE);
} else {
holder.tvMsgReceived.setText(chatMsgModel.getMsg());
holder.tvMsgReceived.setVisibility(View.VISIBLE);
holder.tvMsgSent.setVisibility(View.GONE);
}


}

@Override
public int getItemCount() {
return chatMsgModels.size();
}

public class MyViewHolder extends RecyclerView.ViewHolder {
RelativeLayout rlMain;
TextView tvMsgSent;
TextView tvMsgReceived;

public MyViewHolder(View view) {
super(view);
rlMain = view.findViewById(R.id.rlMain);
tvMsgSent = view.findViewById(R.id.tvMsgSent);
tvMsgReceived = view.findViewById(R.id.tvMsgReceived);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.mlapitest.model;

public class ChatMsgModel {

private String msg;
private int type;

public ChatMsgModel(String msg, int type) {
this.msg = msg;
this.type = type;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

public int getType() {
return type;
}

public void setType(int type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.mlapitest.service;

import com.example.mlapitest.AppController;
import com.google.firebase.messaging.FirebaseMessagingService;

public class MyFirebaseInstanceIDService extends FirebaseMessagingService {
private static final String TAG = MyFirebaseInstanceIDService.class.getSimpleName();

@Override
public void onNewToken(String s) {
super.onNewToken(s);
String refreshedToken = s;

AppController.firebaseInstanceId = refreshedToken;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.example.mlapitest.service;

import android.content.Intent;
import android.util.Log;

import com.example.mlapitest.AppController;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import org.json.JSONObject;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e("FirebaseMessage", "From: " + remoteMessage.getFrom());

if (remoteMessage == null)
return;

// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
handleNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
}
}

/**
* function to save the token data in the AppController
* @param title : expiry time received from FCM
* @param message : token received from FCM
*/
private void handleNotification(String title, String message) {
AppController.exipryTime = AppController.getDateFromStrinng(title);
AppController.token = message;

Intent intent = new Intent(AppController.TOKEN_RECEIVED);
sendBroadcast(intent);
}

private void handleDataMessage(JSONObject json) {
Log.e(TAG, "push json: " + json.toString());
}
}
Loading