package [Link].
eva;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import static [Link];
import static [Link];
import static [Link].READ_CALENDAR;
import static [Link].RECORD_AUDIO;
import static [Link].SEND_SMS;
import static [Link].SET_ALARM;
public class HomePage extends AppCompatActivity implements RemoveClickListner,AIListener,
[Link] {
private static final int REQ_CODE_SPEECH_INPUT = 100;
private FirebaseAuth mAuth;
private RecyclerView mMyRecyclerView;
private RecyclerAdapter mRecyclerAdapter;
private TextToSpeech mTextToSpeech;
ArrayList<MessageModel>mArrayList=new ArrayList<>();
private AIService mAiService;
private AIDataService mAiDataService;
private AIRequest mAiRequest;
private FloatingActionButton mFab;
private SharedPreferences mSettings;
private float mRate;
private float mPitch;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_home_page);
mFab = findViewById( [Link] );
[Link]( new [Link]() {
@Override
public void onClick(View v) {
showPopup(v);
}
} );
String[] perms = new String[]{SET_ALARM, RECORD_AUDIO, INTERNET,SEND_SMS,READ_CALENDAR,CAMERA };
mAuth = [Link]();
mMyRecyclerView = findViewById([Link]);
final LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
[Link]([Link]);
[Link](linearLayoutManager);
Button mAskButton=findViewById([Link]);
mRecyclerAdapter = new RecyclerAdapter(mArrayList,this);
if () {
[Link](this, "Permission Granted", 5, perms);
}
[Link](mRecyclerAdapter);
[Link](new [Link]() {
@Override
public void onClick(View v) {
[Link]();
speakout();
}
});
//text to speeech
mTextToSpeech = new TextToSpeech(this, new [Link]() {
@Override
public void onInit(int status) {
if(status==[Link]){
[Link]([Link]);
[Link]( mPitch );
[Link]( mRate );
}else {
[Link]([Link], "Language Not Supported", Toast.LENGTH_SHORT).show();
}
}
});//b2feb3c3826449aeaff4f5def4107c3b
//97adf74e53334d2f8b628847e064ca9e
//AIListener
final AIConfiguration config= new AIConfiguration("97adf74e53334d2f8b628847e064ca9e",
[Link],[Link]);
mAiDataService = new AIDataService(config);
mAiRequest = new AIRequest();
mAiService = [Link]( this,config );
[Link]( this );
mSettings = getSharedPreferences( "settings", MODE_PRIVATE );
mRate = [Link]( "rate", 1f );
mPitch = [Link]( "pitch", 1f );
}
private void showPopup(View view) {
PopupMenu popupMenu=new PopupMenu( this,view );
MenuInflater menuInflater=[Link]();
[Link]( [Link].main_menu,[Link]() );
[Link]( this );
[Link]();
}
private void speakout() {
Intent intent=new Intent( RecognizerIntent.ACTION_RECOGNIZE_SPEECH );
[Link]( RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
[Link]( RecognizerIntent.EXTRA_LANGUAGE, [Link]() );
[Link]( RecognizerIntent.EXTRA_PROMPT,"Hi Ask Something" );
try{
startActivityForResult( intent,REQ_CODE_SPEECH_INPUT );
}
catch (ActivityNotFoundException e){
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
[Link](requestCode, resultCode, data);
switch (requestCode){
case REQ_CODE_SPEECH_INPUT:
if(resultCode==RESULT_OK && data !=null){
MessageModel model = new MessageModel();
final ArrayList<String> res=[Link](
RecognizerIntent.EXTRA_RESULTS );
[Link]([Link](0));
[Link]( model);
final String messageIn=[Link](res);
if(){
[Link](messageIn);
new AsyncTask<AIRequest,Void,AIResponse>(){
@Override
protected AIResponse doInBackground(AIRequest... aiRequests) {
final AIRequest request=aiRequests[0];
try{ final AIResponse response=[Link]( mAiRequest );
return response;
} catch (AIServiceException e){
return null;
}
@Override
protected void onPostExecute(AIResponse aiResponse) {
if(aiResponse!=null){
if (aiResponse!=null){
Result result=[Link]();
String action = [Link]();
handleAction( action,result );
String reply = [Link]().getSpeech();
if(){
[Link](reply,TextToSpeech.QUEUE_FLUSH,null);
}
MessageModel messageModel=new MessageModel( );
[Link](reply);
[Link]( messageModel );
runOnUiThread(new Runnable() {
@Override
public void run() {
[Link]();
if([Link]()>1){
[Link]()
.smoothScrollToPosition(mMyRecyclerView,null,[Link]()-1);
}
}
});
}
}
}
}.execute(mAiRequest);
}else {
[Link]();
}
}break;
}}
private void handleAction(String action, Result result) {
HashMap<String, JsonElement> map = [Link]();
switch (action) {
//1.
case "[Link]":
String message=null;
Intent messageIntent=new Intent(Intent.ACTION_SEND);
[Link]("text/plain");
[Link]("sms_body",message);
startActivity(messageIntent);
break;
//2.
case"[Link]":
String searchOn="";
try{
JsonElement query=[Link]("Query");
searchOn=[Link]().getAsString();
}catch (Exception e){
}
Intent intentSearch=new Intent( Intent.ACTION_VIEW,
[Link]( "[Link] ") );
startActivity(intentSearch);
break;
//3.
case"[Link]":
String title=null;
long begin=0;
long end=0;
Intent calender=new Intent(Intent.ACTION_INSERT)
.setData([Link].CONTENT_URI)
.putExtra([Link],title)
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,begin)
.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,end);
startActivity(calender);
break;
case "[Link]":
Intent intentGmail = getPackageManager()
.getLaunchIntentForPackage("[Link]");
startActivity(intentGmail);
break;
//4.
case "[Link]":
String[] addresses={};
String subject=null;
String messagesBody=null;
Intent emailsend=new Intent(Intent.ACTION_SEND);
[Link]("*/*");
[Link](Intent.EXTRA_EMAIL,addresses);
[Link](Intent.EXTRA_SUBJECT,subject);
[Link](Intent.EXTRA_TEXT,messagesBody);
startActivity(emailsend);
break;//5
case "[Link]":
Intent intentWhat=getPackageManager()
.getLaunchIntentForPackage( "[Link]" );
startActivity(intentWhat);
break;
case "open paytm":
Intent intentpay=getPackageManager()
.getLaunchIntentForPackage( "[Link]");
startActivity(intentpay);
break;
case "[Link]":
Intent intentMess=getPackageManager()
.getLaunchIntentForPackage( "[Link]" );
startActivity(intentMess);
break;
//5.//[Link]
case "[Link]":
Intent intentcale=getPackageManager()
.getLaunchIntentForPackage( "[Link]" );
startActivity(intentcale);
break;
case "[Link]":
Intent intentcalender=getPackageManager()
.getLaunchIntentForPackage( "[Link]" );
startActivity(intentcalender);
break;
case "[Link]":
Intent appIntent = new Intent(Intent.ACTION_VIEW)
.setPackage("[Link]");
Intent webIntent = new Intent(Intent.ACTION_VIEW,
[Link]("[Link]
try {
startActivity(appIntent);
} catch (ActivityNotFoundException ex) {
startActivity(webIntent);
}
break;
//6.
case "[Link]":
Uri uriUrl = [Link]( "[Link] );
Intent web = new Intent( Intent.ACTION_VIEW, uriUrl );
startActivity( web );
break;
//7.
case "playmusic":
if (map != null) {
[Link]( this, "music", Toast.LENGTH_SHORT ).show();
}
Intent intent = [Link]( Intent.ACTION_MAIN,
Intent.CATEGORY_APP_MUSIC );
startActivity( intent );
break;
//8.
case "[Link]":
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivity(takeVideoIntent);
break;
//9.
case "[Link]":
Intent recordingIntent =
new Intent([Link].RECORD_SOUND_ACTION);
startActivity(recordingIntent);
break;
//10.
case "[Link]":
Intent intentInsertEdit = new Intent(Intent.ACTION_INSERT_OR_EDIT);
[Link]( [Link].CONTENT_ITEM_TYPE);
startActivity(intentInsertEdit);
break;
//[Link]
case "[Link]":
Intent intentCal = new Intent()
.setAction(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_APP_CALCULATOR)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentCal);
break;
//[Link]
/*case "[Link]":
String appName="";
try{
JsonElement appJ=[Link]( "name" );
appName=[Link]().toString();
}catch(Exception e){
}
Intent openIntent= new Intent(Intent.ACTION_VIEW)
.setPackage("[Link]"+appName);
startActivity(openIntent);
break;*/
//13.
case "[Link]":
String loc = "";
try {
JsonElement placeJ = [Link]( "location" );
loc = [Link]().get( "business-name" ).toString().replaceAll( "\"",
"" );
} catch (Exception e) {
}
Intent placesIntent = new Intent( Intent.ACTION_VIEW, [Link]( "geo:0,0?q=" + loc ) );
[Link]( "[Link]" );
startActivity( placesIntent );
break;
//14.
case "[Link]":
Intent cam = new Intent( MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA );
startActivity( cam );
break;
//[Link]
case "[Link]":
int phonenumber = 0;
try {
JsonElement numJ = [Link]( "number" );
String number = [Link]().getAsString();
phonenumber = [Link]( number );
} catch (Exception e) {
}
Intent phonedialer = new Intent( Intent.ACTION_CALL)
.setData( [Link]( "[Link] + phonenumber ) );
startActivity( phonedialer );
break;
//[Link]
case "[Link]":
String name = "";
try{
JsonElement nameJ=[Link]( "name" );
name=[Link]().getAsString();
if(name!=null){
Uri conatactUri= [Link]( name );
String[] pro=new String[]{[Link]};
Cursor cursor=getContentResolver()
.query( conatactUri,pro, null,null,null);
if(cursor!=null && [Link]()){
int numIndex=[Link](
[Link] );
String num1=[Link]( numIndex );
}
}
}catch (Exception e){
Intent intent1=new Intent( Intent.ACTION_PICK ,[Link]("[Link]
.setType( [Link].CONTENT_TYPE );
startActivity(intent1);
break;
//17.
case "[Link]":
int hour = 0;
int min = 0;
int sec = 0;
try {
JsonElement timeJ = [Link]("time");
String time = [Link]().getAsString();
String[] alarmtime = [Link](":");
hour = [Link](alarmtime[0]);
min = [Link](alarmtime[1]);
sec = [Link](alarmtime[2]);
} catch (Exception e) {
//default time using Calendar
Calendar currentTime=[Link]();
[Link]([Link],hour);
[Link]([Link],min);
[Link]([Link],sec);
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
[Link](AlarmClock.EXTRA_MESSAGE, "New Alarm");
[Link](AlarmClock.EXTRA_HOUR, hour);
[Link](AlarmClock.EXTRA_MINUTES, min);
startActivity(i);
break;
//18.
case "[Link]":
try {
startActivity( new Intent( Intent.ACTION_VIEW, [Link](
"market://details?id=PackageName" ) ) );
}catch(Exception e){
startActivity(new Intent(Intent.ACTION_VIEW,
[Link]("[Link]
}
break;
case "[Link]":
Intent wiki= new Intent( Intent.ACTION_VIEW, [Link]( "[Link] )
);
startActivity( wiki);
break;
case "[Link]":
Intent faceBook=new Intent( Intent.ACTION_VIEW,[Link](
"[Link] ) );
Intent facebookApp=getPackageManager()
.getLaunchIntentForPackage( "[Link]" );
try{
startActivity(facebookApp);
}
catch (Exception e){
startActivity(faceBook);
}
break;
}
}
@Override
public void OnRemoveclick(int index) {
@Override
public void onResult(AIResponse result) {
Result response = [Link]();
// Get parameters
MessageModel model=new MessageModel( );
[Link]("Query:"+[Link]()+"\nAction:"+ [Link]());
[Link]( model );
@Override
public void onError(AIError error) {
@Override
public void onAudioLevel(float level) {
@Override
public void onListeningStarted() {
@Override
public void onListeningCanceled() {
@Override
public void onListeningFinished() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch ([Link]()){
case [Link]:
[Link] builder=new [Link]( this );
LayoutInflater layoutInflater = getLayoutInflater();
View inflate = [Link]( [Link].about_dialog_box, null );
[Link]( inflate );
AlertDialog dialog=[Link]();
[Link]();
return true;
case [Link]:
startActivity(new Intent( this ,[Link] ));
return true;
case [Link]:
gotoProfile();
return true;
case [Link]:
final Intent intent = new Intent(Intent.ACTION_SEND);
[Link]("text/html");
[Link](Intent.EXTRA_EMAIL, new String[]{
getString([Link].mail_feedback_email) });
[Link](Intent.EXTRA_SUBJECT, getString([Link].mail_feedback_subject));
[Link](Intent.EXTRA_TEXT, getString([Link].mail_feedback_message));
startActivity([Link](intent, getString([Link].title_send_feedback)));
return true;
case [Link]:
startActivity(new Intent(Intent.ACTION_VIEW,
[Link]("market://details?id=PackageName")));
return true;
case [Link]:
signOutFunc();
return true;
}
return false;
}
private void gotoProfile() {
startActivity(new Intent(this,[Link] ));
}
private void signOutFunc() {
[Link]();
startActivity(new Intent( this,[Link] ));
finish();
}
@Override
public void onBackPressed() {
[Link] builder = new [Link](this);
[Link]("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new [Link]() {
public void onClick(DialogInterface dialog, int id) {
[Link]();
}
})
.setNegativeButton("No", new [Link]() {
public void onClick(DialogInterface dialog, int id) {
[Link]();
}
});
AlertDialog alert = [Link]();
[Link]();