Commit 3e41b200 authored by Koralage H.C's avatar Koralage H.C

Merge branch 'Hesadi' of http://gitlab.sliit.lk/2023-269/2023-269 into Hesadi

pushing backend
parents b9ffab60 7b884ba5
Pipeline #7140 canceled with stages
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
# 2023-269
IHear: Mobile Application for Hearing Impaired children to facilitate their hearing and speech capabilities.
Main Objective - The primary objective of this research is to develop a user-friendly and engaging learning application that empowers speech and hearing-impaired children aged 6-10 years. 
Main Research Questions-How to help hearing impaired children in knowledge gathering?
IT20149758 -Koralage H.C
Individual Research Question - How to facilitate hearing - impaired students ability to identify sounds?
Individual Research Objective - To develop a sound classification function that helps children aged 6-10 identify noises around them and incorperating the learning aspect to it.​
IT20075712 -G.N.J.Liyanage
Individual Research Question -How to develop a game for hearing screening ?
Individual Research Objective -Develop a effective hearing screening method for Identifying hearing stages of children.
IT20468460 - M.H.M.I.D.Mapa
Individual Research Question - How can sound amplification help for hearing impaired persons for the user?
Individual Research Objective - It would allow customizing amplification of verbal soundtrack and live transcription option with saving and downloading the transcription.
IT20024604 - Senanayake S.V.M
Individual Research Question -.How do hearing-impaired children interact with video games, and what are their preferences and needs in terms of accessibility features?
Individual Research Objective - To investigate the impact of incorporating accessibility features in video games on the gaming experience, cognitive and verbal development, and social inclusion of hearing-impaired children.
Other Necessary Information-
Supervisor - Ms. Buddhima Aththanayaka
Co-Supervisor - Ms.Hansika Mahaadikara
External Supervisor - Yasith Arunashantha
Data collected from - Internet Sources
/build
\ No newline at end of file
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
namespace 'com.hesiii.i_hear'
compileSdk 33
buildFeatures {
viewBinding true
}
defaultConfig {
applicationId "com.hesiii.i_hear"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-auth:21.1.0'
implementation 'com.google.firebase:firebase-database:20.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation 'com.github.squti:Android-Wave-Recorder:1.7.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
\ No newline at end of file
{
"project_info": {
"project_number": "63411419394",
"project_id": "i-hear-new",
"storage_bucket": "i-hear-new.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:63411419394:android:38e8ee8c796f7aa7676a1b",
"android_client_info": {
"package_name": "com.hesiii.i_hear"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDKs0AHXAEXJjwtysFIUomOUo47g9LhIEU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
# 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
\ No newline at end of file
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.hesiii.i_hear",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
\ No newline at end of file
package com.hesiii.i_hear;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext();
assertEquals("com.hesiii.i_hear", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.I_Hear_New"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".HearingScreening.ResultActivity"
android:exported="false" />
<activity
android:name=".HearingScreening.TestActivity"
android:exported="false" />
<activity
android:name=".HearingScreening.PreparationActivity"
android:exported="false" />
<activity
android:name=".SignFunction.SignFunctionActivity"
android:exported="false" />
<activity
android:name=".Game.GameActivity"
android:exported="false" />
<activity
android:name=".Game.CategoryActivity"
android:exported="false" />
<activity
android:name=".Summarization.SummarizationActivity"
android:exported="false" />
<activity
android:name=".Amplification.SoundAmplificationActivity"
android:exported="false" />
<activity
android:name=".SoundClassification.SoundClassificationActivity"
android:exported="false" />
<activity
android:name=".Activities.SignInActivity"
android:exported="false" />
<activity
android:name=".Activities.HomeActivity"
android:theme="@style/SplashTheme"
android:exported="false" />
<activity
android:name=".Activities.SignUpActivity"
android:exported="false"
android:theme="@style/SplashTheme" />
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.hesiii.file_provider"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider" />
</provider>
</application>
</manifest>
\ No newline at end of file
package com.hesiii.i_hear.API;
import com.hesiii.i_hear.ResponseModels.ClassificationResponse;
import com.hesiii.i_hear.ResponseModels.PronunciationAccuracyResponse;
import com.hesiii.i_hear.ResponseModels.SignResponse;
import com.hesiii.i_hear.ResponseModels.SummarizationResponse;
import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
public interface ApiServices {
// Multipart
// @POST("your/upload/endpoint")
// Call<ClassificationResponse> uploadAudio(@Part MultipartBody.Part file);
// @Multipart
// @POST("/api/v1.0/classify-sound")
// Call<ClassificationResponse> uploadAudio(@Part("audio") RequestBody file);
// noise sounddetect
@Multipart
@POST("/noise")
Call<ClassificationResponse>uploadAudio(@Part MultipartBody.Part audio);
@Headers("Accept: application/json")
@FormUrlEncoded
@POST("/v1/summerize")
Call<SummarizationResponse> getSummarization(@Field("paragraph") String paragraph);
@Headers("Accept: application/json")
@Multipart
@POST("/v1/pronouncationaccuracy")
Call<PronunciationAccuracyResponse> getPronunciationAccuracy(
@Part("element") String element,
@Part MultipartBody.Part audio
);
@Multipart
@POST("/v1/sign")
Call<SignResponse> getSignResult(
@Part("sign") String sign,
@Part MultipartBody.Part image_path
);
// @Multipart
// @POST("/api/v1.0/pronounciation")
// Call<PronounciationResponse> getPronounciation(
// @Part MultipartBody.Part audio,
// @Part("word") RequestBody word
// );
}
package com.hesiii.i_hear.API;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class RetroServer {
// https://7e77-175-157-23-144.ngrok-free.app/ http://13.126.222.46:5000
private static final String BASE_URL = "http://13.126.222.46:5000";
private static Retrofit retrofit;
public static Retrofit getRetrofitInstance() {
if (retrofit == null) {
// Create an OkHttp client with logging interceptor
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY); // Set log level to BODY for full logging
httpClient.addInterceptor(logging);
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(httpClient.build())
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
package com.hesiii.i_hear.Activities;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.hesiii.i_hear.Amplification.SoundAmplificationActivity;
import com.hesiii.i_hear.Game.CategoryActivity;
import com.hesiii.i_hear.HearingScreening.PreparationActivity;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.SignFunction.SignFunctionActivity;
import com.hesiii.i_hear.SoundClassification.SoundClassificationActivity;
import com.hesiii.i_hear.Summarization.SummarizationActivity;
import com.hesiii.i_hear.databinding.ActivityHomeBinding;
public class HomeActivity extends AppCompatActivity {
private ActivityHomeBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityHomeBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
binding.soundClassificationLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(HomeActivity.this, SoundClassificationActivity.class));
}
});
binding.soundAmplificationLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(HomeActivity.this, SoundAmplificationActivity.class));
}
});
binding.summarizationLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(HomeActivity.this, SummarizationActivity.class));
}
});
binding.learningGamesLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(HomeActivity.this, CategoryActivity.class));
}
});
binding.signLanguageRecognitionLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(HomeActivity.this, SignFunctionActivity.class));
}
});
binding.hearingScreeningLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(HomeActivity.this, PreparationActivity.class));
}
});
}
}
\ No newline at end of file
package com.hesiii.i_hear.Activities;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.databinding.ActivitySignInBinding;
public class SignInActivity extends AppCompatActivity {
private FirebaseAuth auth;
private ActivitySignInBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivitySignInBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
auth = FirebaseAuth.getInstance();
binding.signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
signInButtonProcess();
}
});
}
private void signInButtonProcess() {
String email = binding.emailText.getText().toString().toLowerCase();
String password = binding.passwordText.getText().toString();
if (email.isEmpty()) {
binding.emailText.setError("Enter Valid Email");
} else if (password.isEmpty()){
binding.passwordText.setError("Enter Correct Password");
} else {
binding.signInButton.setEnabled(false);
binding.progressBar.setVisibility(View.VISIBLE);
//pass email & password to server and log user
userLogin(email, password);
}
}
private void userLogin(String email, String password) {
auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(SignInActivity.this, "Successfully Logged In!", Toast.LENGTH_LONG).show();
Intent intent = new Intent(SignInActivity.this, HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else {
Toast.makeText(SignInActivity.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
binding.signInButton.setEnabled(true);
binding.progressBar.setVisibility(View.GONE);
}
});
}
}
\ No newline at end of file
package com.hesiii.i_hear.Activities;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.FirebaseDatabase;
import com.hesiii.i_hear.Models.User;
import com.hesiii.i_hear.databinding.ActivitySignUpBinding;
public class SignUpActivity extends AppCompatActivity {
private ActivitySignUpBinding binding;
private FirebaseAuth auth;
private FirebaseDatabase database;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivitySignUpBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
auth = FirebaseAuth.getInstance();
database = FirebaseDatabase.getInstance();
binding.submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
submitButtonProcess();
}
});
}
private void submitButtonProcess() {
String email = binding.emailText.getText().toString();
String password = binding.passwordText.getText().toString();
String name = binding.fullNameText.getText().toString();
if (email.isEmpty()) {
Toast.makeText(this, "Enter Email", Toast.LENGTH_SHORT).show();
} else if (password.isEmpty()) {
Toast.makeText(this, "Enter Password", Toast.LENGTH_SHORT).show();
} else if (name.isEmpty()) {
Toast.makeText(this, "Enter Name", Toast.LENGTH_SHORT).show();
} else {
binding.progressBar.setVisibility(View.VISIBLE);
binding.submitButton.setEnabled(false);
signUpProcess(email, password, name);
}
}
private void signUpProcess(String email, String password, String name) {
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
writeDataToDB(email, name);
} else {
Toast.makeText(SignUpActivity.this, "Error - "+task.getException().getMessage(), Toast.LENGTH_LONG).show();
binding.progressBar.setVisibility(View.GONE);
binding.submitButton.setEnabled(true);
}
}
});
}
private void writeDataToDB(String email, String name) {
User user = new User(auth.getCurrentUser().getUid(), email, name);
database.getReference().child("Users").child(auth.getCurrentUser().getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(SignUpActivity.this, "Successfully Registered!", Toast.LENGTH_LONG).show();
Intent intent = new Intent(SignUpActivity.this, HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else {
Toast.makeText(SignUpActivity.this, "Error - "+task.getException().getMessage(), Toast.LENGTH_LONG).show();
}
binding.progressBar.setVisibility(View.GONE);
binding.submitButton.setEnabled(true);
}
});
}
}
\ No newline at end of file
package com.hesiii.i_hear.Adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.hesiii.i_hear.Interfaces.CategoryEvents;
import com.hesiii.i_hear.Models.Category;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.databinding.CategoryViewBinding;
import java.util.List;
public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.CategoryViewHolder> {
private Context context;
private List<Category>categoryList;
private CategoryEvents categoryEvents;
public CategoryAdapter(Context context, List<Category> categoryList, CategoryEvents categoryEvents) {
this.context = context;
this.categoryList = categoryList;
this.categoryEvents = categoryEvents;
}
@NonNull
@Override
public CategoryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new CategoryViewHolder(LayoutInflater.from(context).inflate(R.layout.category_view, parent, false));
}
@Override
public void onBindViewHolder(@NonNull CategoryViewHolder holder, int position) {
Category category = categoryList.get(position);
holder.viewBinding.categoryImage.setImageResource(category.getIcon());
holder.viewBinding.categoryText.setText(category.getCategoryTitle());
}
@Override
public int getItemCount() {
return categoryList.size();
}
public class CategoryViewHolder extends RecyclerView.ViewHolder{
public CategoryViewBinding viewBinding;
public CategoryViewHolder(@NonNull View itemView) {
super(itemView);
viewBinding = CategoryViewBinding.bind(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
categoryEvents.onCategoryClick(getAdapterPosition());
}
});
}
}
}
package com.hesiii.i_hear.Amplification;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.Toast;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.databinding.ActivitySoundAmplificationBinding;
public class SoundAmplificationActivity extends AppCompatActivity {
private ActivitySoundAmplificationBinding binding;
private ValueCallback<Uri> mUploadMessage;
private ValueCallback<Uri[]> mFilePathCallback;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivitySoundAmplificationBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
try {
binding.webView.getSettings().setJavaScriptEnabled(true);
binding.webView.getSettings().setAllowFileAccess(true);
binding.webView.getSettings().setAllowFileAccessFromFileURLs(true);
binding.webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
binding.webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
binding.webView.loadUrl("http://falconvideo.lk/test/");
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
binding.webView.setWebChromeClient(new WebChromeClient() {
// For Android 3.0+
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
// Create an intent to allow the user to select a file
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
startActivityForResult(Intent.createChooser(i, "File Chooser"), 1);
mUploadMessage = uploadMsg;
}
// For Android 4.1+
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
openFileChooser(uploadMsg, acceptType);
}
// For Android 5.0+
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
// Create an intent to allow the user to select a file
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
startActivityForResult(Intent.createChooser(i, "File Chooser"), 1);
mFilePathCallback = filePathCallback;
return true;
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// Handle the file upload request result
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
Uri uri = intent.getData();
if (mUploadMessage != null) {
mUploadMessage.onReceiveValue(uri);
mUploadMessage = null;
} else if (mFilePathCallback != null) {
Uri[] results = new Uri[]{uri};
mFilePathCallback.onReceiveValue(results);
mFilePathCallback = null;
}
} else {
if (mUploadMessage != null) {
mUploadMessage.onReceiveValue(null);
mUploadMessage = null;
} else if (mFilePathCallback != null) {
mFilePathCallback.onReceiveValue(null);
mFilePathCallback = null;
}
}
}
}
}
\ No newline at end of file
package com.hesiii.i_hear.ClassificationAPI;
import com.hesiii.i_hear.ResponseModels.ClassificationResponse;
import com.hesiii.i_hear.ResponseModels.PronunciationAccuracyResponse;
import com.hesiii.i_hear.ResponseModels.SignResponse;
import com.hesiii.i_hear.ResponseModels.SummarizationResponse;
import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
public interface ClassificationApiServices {
// noise sounddetect
@Multipart
@POST("/noise")
Call<ClassificationResponse>uploadAudio(@Part MultipartBody.Part audio);
}
package com.hesiii.i_hear.ClassificationAPI;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ClassificationRetroServer {
private static final String BASE_URL = "https://0616-2402-4000-b131-25a3-95af-19ca-cb7d-655e.ngrok.io";
private static Retrofit retrofit;
public static Retrofit getRetrofitInstance() {
if (retrofit == null) {
// Create an OkHttp client with logging interceptor
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY); // Set log level to BODY for full logging
httpClient.addInterceptor(logging);
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(httpClient.build())
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
package com.hesiii.i_hear.Game;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import android.content.Intent;
import android.os.Bundle;
import com.hesiii.i_hear.Adapters.CategoryAdapter;
import com.hesiii.i_hear.Interfaces.CategoryEvents;
import com.hesiii.i_hear.Models.Category;
import com.hesiii.i_hear.Models.Data;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.databinding.ActivityCategoryBinding;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CategoryActivity extends AppCompatActivity {
private ActivityCategoryBinding binding;
private List<Category> categoryList;
private CategoryAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityCategoryBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
setDataToRecyclerView();
}
private void setDataToRecyclerView() {
adapter = new CategoryAdapter(this, getCategoryList(), new CategoryEvents() {
@Override
public void onCategoryClick(int position) {
//Toast.makeText(GameCategoryActivity.this, getCategoryList().get(position).getCategoryTitle(), Toast.LENGTH_SHORT).show();
//startActivity(new Intent(getApplicationContext(), DiceActivity.class));
String categoryName = getCategoryList().get(position).getCategoryName();
if (categoryName.equals("people")) {
Intent intent = new Intent(CategoryActivity.this, GameActivity.class);
intent.putExtra("data", peopleData());
startActivity(intent);
} else if (categoryName.equals("vehicles")) {
Intent intent = new Intent(CategoryActivity.this, GameActivity.class);
intent.putExtra("data", vehiclesData());
startActivity(intent);
} else if (categoryName.equals("fruits")) {
Intent intent = new Intent(CategoryActivity.this, GameActivity.class);
intent.putExtra("data", fruitsData());
startActivity(intent);
} else if (categoryName.equals("animals")) {
Intent intent = new Intent(CategoryActivity.this, GameActivity.class);
intent.putExtra("data", animalsData());
startActivity(intent);
} else if (categoryName.equals("objects")) {
Intent intent = new Intent(CategoryActivity.this, GameActivity.class);
intent.putExtra("data", objectsData());
startActivity(intent);
} else if (categoryName.equals("shuffle")) {
Intent intent = new Intent(CategoryActivity.this, GameActivity.class);
intent.putExtra("data", shuffleData());
startActivity(intent);
}
}
});
binding.categoryRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
binding.categoryRecyclerView.setHasFixedSize(true);
binding.categoryRecyclerView.setAdapter(adapter);
}
private List<Category> getCategoryList() {
List<Category> categoryList = new ArrayList<>();
categoryList.add(new Category(R.drawable.people, "People", "people"));
categoryList.add(new Category(R.drawable.vehicles, "Vehicles", "vehicles"));
categoryList.add(new Category(R.drawable.fruits, "Fruits", "fruits"));
categoryList.add(new Category(R.drawable.animals, "Animals", "animals"));
categoryList.add(new Category(R.drawable.objects, "Objects", "objects"));
categoryList.add(new Category(R.drawable.shuffle, "Shuffle", "shuffle"));
return categoryList;
}
private ArrayList<Data>peopleData() {
ArrayList<Data>dataList = new ArrayList<>();
dataList.add(new Data(R.drawable.nurse, "nurse"));
dataList.add(new Data(R.drawable.doctor, "doctor"));
dataList.add(new Data(R.drawable.farmer, "farmer"));
dataList.add(new Data(R.drawable.teacher, "teacher"));
dataList.add(new Data(R.drawable.waiter, "waiter"));
Collections.shuffle(dataList);
return dataList;
}
private ArrayList<Data>vehiclesData() {
ArrayList<Data>dataList = new ArrayList<>();
dataList.add(new Data(R.drawable.bicycle, "bicycle"));
dataList.add(new Data(R.drawable.bus, "bus"));
dataList.add(new Data(R.drawable.car, "car"));
dataList.add(new Data(R.drawable.ship, "ship"));
dataList.add(new Data(R.drawable.train, "train"));
Collections.shuffle(dataList);
return dataList;
}
private ArrayList<Data>fruitsData() {
ArrayList<Data>dataList = new ArrayList<>();
dataList.add(new Data(R.drawable.apple, "apple"));
dataList.add(new Data(R.drawable.banana, "banana"));
dataList.add(new Data(R.drawable.orange, "orange"));
dataList.add(new Data(R.drawable.pineapple, "pineapple"));
dataList.add(new Data(R.drawable.strawberry, "strawberry"));
Collections.shuffle(dataList);
return dataList;
}
private ArrayList<Data>animalsData() {
ArrayList<Data>dataList = new ArrayList<>();
dataList.add(new Data(R.drawable.bird, "bird"));
dataList.add(new Data(R.drawable.cow, "cow"));
dataList.add(new Data(R.drawable.dog, "dog"));
dataList.add(new Data(R.drawable.fish, "fish"));
dataList.add(new Data(R.drawable.horse, "horse"));
Collections.shuffle(dataList);
return dataList;
}
private ArrayList<Data>objectsData() {
ArrayList<Data>dataList = new ArrayList<>();
dataList.add(new Data(R.drawable.bag, "bag"));
dataList.add(new Data(R.drawable.book, "book"));
dataList.add(new Data(R.drawable.chair, "chair"));
dataList.add(new Data(R.drawable.pencil, "pencil"));
dataList.add(new Data(R.drawable.table, "table"));
Collections.shuffle(dataList);
return dataList;
}
private ArrayList<Data>shuffleData() {
ArrayList<Data>dataList = new ArrayList<>();
dataList.add(new Data(R.drawable.bird, "bird"));
dataList.add(new Data(R.drawable.table, "table"));
dataList.add(new Data(R.drawable.orange, "orange"));
dataList.add(new Data(R.drawable.train, "train"));
dataList.add(new Data(R.drawable.farmer, "farmer"));
Collections.shuffle(dataList);
return dataList;
}
}
\ No newline at end of file
This diff is collapsed.
package com.hesiii.i_hear.HearingScreening;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.databinding.ActivityPreparationBinding;
public class PreparationActivity extends AppCompatActivity {
private ActivityPreparationBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityPreparationBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getSupportActionBar() != null ){
getSupportActionBar().hide();
}
binding.continueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(PreparationActivity.this, TestActivity.class));
//startActivity(new Intent(PreparationActivity.this, SignFunctionActivity.class));
}
});
}
}
\ No newline at end of file
package com.hesiii.i_hear.HearingScreening;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Color;
import android.os.Bundle;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.hesiii.i_hear.Models.Status;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.databinding.ActivityResultBinding;
import java.util.ArrayList;
import java.util.List;
public class ResultActivity extends AppCompatActivity {
private ArrayList<Status> statusList;
private ActivityResultBinding binding;
private String status;
private String description;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityResultBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getSupportActionBar() != null ){
getSupportActionBar().setTitle("Audio Diagram");
}
statusList = (ArrayList<Status>) getIntent().getSerializableExtra("resultList");
status = getIntent().getStringExtra("status");
binding.yourStatus.setText(status);
if (status.equals("Normal Hearing Level")) {
description = "Your hearing level is normal. You can hear a wide range of sounds with clarity!";
} else if (status.equals("Mild to Moderate Level")) {
description = "You are in mild to moderate hearing stage. Communication can be significantly impacted. " +
"You may require specialized devices or support!";
} else {
description = "You have a profound hearing loss. Communication is very challenging without sign language or cochlear implants. " +
"Consider consulting an healthcare professional for personalized solutions!";
}
binding.descriptionText.setText(description);
for (int i = 0; i < statusList.size(); i++) {
System.out.println(String.valueOf(i+1)+" Result - DB : "+statusList.get(i).getDb()+" / HZ : "+statusList.get(i).getHz());
}
// Customization
binding.resultsLineChart.getDescription().setEnabled(false);
binding.resultsLineChart.setTouchEnabled(true);
binding.resultsLineChart.setDragEnabled(true);
binding.resultsLineChart.setScaleEnabled(true);
binding.resultsLineChart.setPinchZoom(true);
binding.resultsLineChart.setDrawGridBackground(true);
XAxis xAxis = binding.resultsLineChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setGranularity(1f);
xAxis.setAxisMinimum(100f);
xAxis.setAxisMaximum(2000f);
xAxis.enableGridDashedLine(10f, 10f, 0f);
YAxis leftAxis = binding.resultsLineChart.getAxisLeft();
leftAxis.setAxisMinimum(0f);
leftAxis.setAxisMaximum(120f);
leftAxis.enableGridDashedLine(10f, 10f, 0f);
List<Entry> entries = new ArrayList<>();
for (int i = 0; i < statusList.size(); i++) {
entries.add(new Entry(statusList.get(i).getHz(), statusList.get(i).getDb()));
}
LineDataSet lineDataSet = new LineDataSet(entries, "Hearing Test");
lineDataSet.setColor(Color.parseColor("#3390FF"));
lineDataSet.setLineWidth(2f);
lineDataSet.setCircleColor(Color.parseColor("#3390FF"));
lineDataSet.setCircleRadius(5f);
lineDataSet.setDrawCircleHole(true);
lineDataSet.setDrawValues(true);
LineData lineData = new LineData(lineDataSet);
binding.resultsLineChart.setData(lineData);
binding.resultsLineChart.invalidate(); // Refresh the chart to display the data
}
}
\ No newline at end of file
package com.hesiii.i_hear.HearingScreening;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.SeekBar;
import com.hesiii.i_hear.Models.Status;
import com.hesiii.i_hear.R;
import com.hesiii.i_hear.databinding.ActivityTestBinding;
import java.util.ArrayList;
public class TestActivity extends AppCompatActivity {
private ActivityTestBinding binding;
int [] musics;
private MediaPlayer mediaPlayer;
private final Handler handler = new Handler();
private int currentPosition = 0;
private ArrayList<Status> resultList;
private boolean firstTone = false;
private boolean secondTone = false;
private boolean thirdTone = false;
private boolean fourthTone = false;
private String status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityTestBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getSupportActionBar() != null ){
getSupportActionBar().hide();
}
musics = new int[] {R.raw.a, R.raw.b, R.raw.c, R.raw.d, R.raw.e, R.raw.f, R.raw.g};
resultList = new ArrayList<>();
binding.startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startButtonProcess();
}
});
binding.notHearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (currentPosition == 0) {
firstTone = false;
//resultList.add(10);
resultList.add(new Status(10, 125));
} else if (currentPosition == 1) {
secondTone = false;
//resultList.add(30);
resultList.add(new Status(30, 250));
} else if (currentPosition == 2) {
thirdTone = false;
//resultList.add(60);
resultList.add(new Status(60, 500));
} else if (currentPosition == 3) {
fourthTone = false;
//resultList.add(80);
resultList.add(new Status(80, 1000));
} else if (currentPosition == 4) {
//resultList.add(100);
resultList.add(new Status(100, 2000));
}
heardButtonProcess();
}
});
binding.heardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (currentPosition == 0) {
firstTone = true;
//resultList.add(0);
resultList.add(new Status(0, 125));
} else if (currentPosition == 1) {
secondTone = true;
//resultList.add(20);
resultList.add(new Status(20, 250));
} else if (currentPosition == 2) {
thirdTone = true;
//resultList.add(40);
resultList.add(new Status(40, 500));
} else if (currentPosition == 3) {
fourthTone = true;
//resultList.add(70);
resultList.add(new Status(70, 1000));
} else if (currentPosition == 4) {
//resultList.add(90);
resultList.add(new Status(90, 2000));
}
heardButtonProcess();
}
});
}
private void heardButtonProcess() {
currentPosition++;
if (currentPosition != 5) {
startButtonProcess();
System.out.println("currentPosition "+currentPosition);
} else {
// for (int i = 0; i < resultList.size(); i++) {
//
// System.out.println(String.valueOf(i+1)+" Result - "+resultList.get(i));
//
// }
if (firstTone || secondTone) {
status = "Normal Hearing Level";
} else if (thirdTone || fourthTone) {
status = "Mild to Moderate Level";
} else {
status = "Profound Level";
}
Intent intent = new Intent(this, ResultActivity.class);
intent.putExtra("resultList", resultList);
intent.putExtra("status", status);
startActivity(intent);
}
}
private void startButtonProcess() {
mediaPlayer = null;
binding.startButton.setVisibility(View.GONE);
mediaPlayer = MediaPlayer.create(this, musics[currentPosition]);
//mediaPlayer.setLooping(true);
mediaPlayer.setVolume(1.0f, 1.0f);
binding.musicControlLayout.setVisibility(View.VISIBLE);
binding.seekBar.setProgress(0);
binding.seekBar.setMax(mediaPlayer.getDuration());
//mediaPlayer.prepare();
mediaPlayer.start();
String test = "Test " + String.valueOf(currentPosition + 1);
binding.testCount.setText(test);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mediaPlayer != null) {
binding.seekBar.setProgress(mediaPlayer.getCurrentPosition());
}
new Handler().postDelayed(this, 100);
}
});
binding.seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (mediaPlayer != null && b) {
mediaPlayer.seekTo(i);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
binding.seekBar.setProgress(0);
System.out.println("setOnCompletionListener");
// Update UI or perform any other actions after music ends
}
});
}
}
\ No newline at end of file
package com.hesiii.i_hear.Interfaces;
public interface CategoryEvents {
void onCategoryClick(int position);
}
package com.hesiii.i_hear;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.Handler;
import com.google.firebase.auth.FirebaseAuth;
import com.hesiii.i_hear.Activities.HomeActivity;
import com.hesiii.i_hear.Activities.SignUpActivity;
public class MainActivity extends AppCompatActivity {
private FirebaseAuth auth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Define the colors
int topLeftColor = Color.parseColor("#738FCE");
int topRightColor = Color.parseColor("#865FBF");
int centerColor = Color.parseColor("#8366C1");
int bottomLeftColor = Color.parseColor("#865FBF");
int bottomRightColor = Color.parseColor("#992FB0");
// Create a gradient drawable
GradientDrawable gradientDrawable = new GradientDrawable(
GradientDrawable.Orientation.TL_BR,
new int[]{topLeftColor, topRightColor, centerColor, bottomLeftColor, bottomRightColor}
);
auth = FirebaseAuth.getInstance();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (auth.getCurrentUser() != null) {
startActivity(new Intent(MainActivity.this, HomeActivity.class));
} else {
startActivity(new Intent(MainActivity.this, SignUpActivity.class));
}
finishAffinity();
}
}, 3000);
}
}
\ No newline at end of file
package com.hesiii.i_hear.Models;
public class Category {
private int icon;
private String categoryTitle;
private String categoryName;
public Category() {
}
public Category(int icon, String categoryTitle, String categoryName) {
this.icon = icon;
this.categoryTitle = categoryTitle;
this.categoryName = categoryName;
}
public int getIcon() {
return icon;
}
public String getCategoryTitle() {
return categoryTitle;
}
public String getCategoryName() {
return categoryName;
}
}
package com.hesiii.i_hear.Models;
import java.io.Serializable;
public class Data implements Serializable {
private int image;
private String name;
public Data() {
}
public Data(int image, String name) {
this.image = image;
this.name = name;
}
public int getImage() {
return image;
}
public String getName() {
return name;
}
}
package com.hesiii.i_hear.Models;
import java.io.Serializable;
public class Status implements Serializable {
private int db;
private int hz;
public Status() {
}
public Status(int db, int hz) {
this.db = db;
this.hz = hz;
}
public int getDb() {
return db;
}
public int getHz() {
return hz;
}
}
package com.hesiii.i_hear.Models;
public class User {
private String uid;
private String email;
private String userName;
public User() {
}
public User(String uid, String email, String userName) {
this.uid = uid;
this.email = email;
this.userName = userName;
}
public String getUid() {
return uid;
}
public String getEmail() {
return email;
}
public String getUserName() {
return userName;
}
}
package com.hesiii.i_hear.ResponseModels;
import com.google.gson.annotations.SerializedName;
public class ClassificationResponse {
@SerializedName("noise_class")
private String prediction;
public ClassificationResponse() {
}
public ClassificationResponse(String prediction) {
this.prediction = prediction;
}
public String getPrediction() {
return prediction;
}
}
package com.hesiii.i_hear.ResponseModels;
import com.google.gson.annotations.SerializedName;
public class PronunciationAccuracyResponse {
@SerializedName("hit")
private String hit;
@SerializedName("similarity")
private double similarity;
public PronunciationAccuracyResponse() {
}
public PronunciationAccuracyResponse(String hit, double similarity) {
this.hit = hit;
this.similarity = similarity;
}
public String getHit() {
return hit;
}
public double getSimilarity() {
return similarity;
}
}
package com.hesiii.i_hear.ResponseModels;
public class SignResponse {
private String PredSignType;
private String TrueSignType;
private String matched;
private String probability;
public SignResponse() {
}
public SignResponse(String predSignType, String trueSignType, String matched, String probability) {
PredSignType = predSignType;
TrueSignType = trueSignType;
this.matched = matched;
this.probability = probability;
}
public String getPreSignType() {
return PredSignType;
}
public String getTrueSignType() {
return TrueSignType;
}
public String getMatched() {
return matched;
}
public String getProbability() {
return probability;
}
}
package com.hesiii.i_hear.ResponseModels;
import com.google.gson.annotations.SerializedName;
public class SummarizationResponse {
@SerializedName("original")
private String original;
@SerializedName("summerized")
private String summerized;
public SummarizationResponse() {
}
public SummarizationResponse(String original, String summerized) {
this.original = original;
this.summerized = summerized;
}
public String getOriginal() {
return original;
}
public String getSummerized() {
return summerized;
}
}
package com.hesiii.i_hear.Summarization;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.view.View;
import android.widget.Toast;
import com.hesiii.i_hear.API.ApiServices;
import com.hesiii.i_hear.API.RetroServer;
import com.hesiii.i_hear.ResponseModels.SummarizationResponse;
import com.hesiii.i_hear.databinding.ActivitySummarizationBinding;
import java.util.ArrayList;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class SummarizationActivity extends AppCompatActivity {
private ActivitySummarizationBinding binding;
private static final int SPEECH_REQUEST_CODE = 100;
private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivitySummarizationBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("Summarization");
}
binding.recordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
recordButton();
}
});
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Please Wait...");
progressDialog.setCancelable(false);
}
private void recordButton() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Just Speak...");
try {
startActivityForResult(intent, SPEECH_REQUEST_CODE);
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SPEECH_REQUEST_CODE) {
if (resultCode == RESULT_OK && data != null) {
progressDialog.show();
ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
getResultFromAPI(result.get(0));
}
}
}
private void getResultFromAPI(String input) {
progressDialog.show();
ApiServices apiServices = RetroServer.getRetrofitInstance().create(ApiServices.class);
Call<SummarizationResponse>call = apiServices.getSummarization(input);
call.enqueue(new Callback<SummarizationResponse>() {
@Override
public void onResponse(@NonNull Call<SummarizationResponse> call, @NonNull Response<SummarizationResponse> response) {
if (response.isSuccessful()) {
if (response.body() != null) {
if (response.body().getSummerized() != null && !response.body().getSummerized().isEmpty()) {
System.out.println("Summerized : "+response.body().getSummerized());
binding.predictionText.setText(response.body().getSummerized());
} else {
Toast.makeText(SummarizationActivity.this, "Something Went Wrong!", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(SummarizationActivity.this, "Something Went Wrong!", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(SummarizationActivity.this, "Error - "+response.code(), Toast.LENGTH_SHORT).show();
}
progressDialog.dismiss();
}
@Override
public void onFailure(@NonNull Call<SummarizationResponse> call, @NonNull Throwable t) {
progressDialog.dismiss();
Toast.makeText(SummarizationActivity.this, "Error - "+t.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
</vector>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:startColor="#4169B9"
android:endColor="#7292CF"
android:type="linear"/>
</shape>
\ No newline at end of file
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:startColor="#7091CE"
android:endColor="#4970BD"
android:type="linear"/>
</shape>
\ No newline at end of file
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#D9D9D9" /> <!-- Background color -->
<corners android:radius="75dp" /> <!-- Half of the width/height for a perfect circle -->
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<corners
android:topLeftRadius="40dp"
android:topRightRadius="40dp"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white"/>
<corners android:radius="6dp"/>
<stroke android:width="1dp" android:color="#3963B6"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<vector android:height="32dp" android:viewportHeight="515.556"
android:viewportWidth="515.556" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFF" android:pathData="m257.778,0c-142.137,0 -257.778,115.641 -257.778,257.778s115.641,257.778 257.778,257.778 257.778,-115.641 257.778,-257.778 -115.642,-257.778 -257.778,-257.778zM257.778,451.111c-106.61,0 -193.333,-86.723 -193.333,-193.333s86.723,-193.334 193.333,-193.334 193.333,86.723 193.333,193.333 -86.723,193.334 -193.333,193.334z"/>
<path android:fillColor="#FFF" android:pathData="m257.778,128.889c-71.068,0 -128.889,57.805 -128.889,128.889s57.821,128.889 128.889,128.889 128.889,-57.805 128.889,-128.889 -57.821,-128.889 -128.889,-128.889z"/>
</vector>
<vector android:height="32dp" android:viewportHeight="493.56"
android:viewportWidth="493.56" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFF" android:pathData="M438.254,0H58.974C27.502,0 0.006,25.992 0.006,57.472v379.256c0,31.48 27.496,56.832 58.968,56.832h379.28c31.468,0 55.3,-25.352 55.3,-56.832V57.472C493.554,25.992 469.722,0 438.254,0z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Top-Left to Top-Right -->
<item android:left="0dp" android:right="50dp">
<shape>
<gradient
android:type="linear"
android:startColor="#738FCE"
android:endColor="#865FBF"
android:angle="180"
/>
</shape>
</item>
<!-- Center Color -->
<item android:left="50dp" android:right="50dp">
<shape>
<gradient
android:type="linear"
android:startColor="#8366C1"
android:centerColor="#8366C1"
android:endColor="#8366C1"
android:angle="0"
/>
</shape>
</item>
<!-- Bottom-Left to Bottom-Right -->
<item android:left="50dp" android:right="0dp">
<shape>
<gradient
android:type="linear"
android:startColor="#865FBF"
android:endColor="#992FB0"
android:angle="0"
/>
</shape>
</item>
</layer-list>
\ No newline at end of file
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="@color/white" >
</solid>
<stroke
android:width="2dp"
android:color="@color/black" >
</stroke>
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" >
</padding>
<corners
android:radius="11dp" >
</corners>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/cyan">
<item>
<shape
android:shape="oval">
<solid
android:color="@color/cyan"/>
</shape>
</item>
</ripple>
\ No newline at end of file
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="#004AAD" >
</solid>
<stroke
android:width="2dp"
android:color="@color/white" >
</stroke>
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" >
</padding>
<corners
android:radius="11dp" >
</corners>
</shape>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment