From c4ef6240e7efad2726dc9df1f2c1fae517362ba5 Mon Sep 17 00:00:00 2001 From: Logical <598669236@qq.com> Date: Wed, 30 Jun 2021 00:52:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8A=E4=BC=A0=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graveyard/common_tools/AppLauncher.java | 2 +- .../common_tools/rocon/AppLauncher.java | 32 +++++----- .../rocon_remocon/build.gradle | 2 +- .../src/main/AndroidManifest.xml | 44 ++++++++++++- .../rocon_remocon/Remocon.java | 24 ++++++-- .../rocon_remocon/audio_upload/upload.java | 61 +++++++++++++++++++ .../stranger_detect/NoStrangerDialog.java | 27 ++++++++ 7 files changed, 168 insertions(+), 24 deletions(-) create mode 100644 src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/audio_upload/upload.java create mode 100644 src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/stranger_detect/NoStrangerDialog.java diff --git a/src/AndroidApp/android_remocons/common_tools/graveyard/common_tools/AppLauncher.java b/src/AndroidApp/android_remocons/common_tools/graveyard/common_tools/AppLauncher.java index d4c22a2..8d37d6e 100644 --- a/src/AndroidApp/android_remocons/common_tools/graveyard/common_tools/AppLauncher.java +++ b/src/AndroidApp/android_remocons/common_tools/graveyard/common_tools/AppLauncher.java @@ -203,7 +203,7 @@ public class AppLauncher { } catch (MalformedURLException e) { - return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage() + "It's a wrong!"); + return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage()); } catch (ActivityNotFoundException e) { // This cannot happen for a web site, right? must mean that I have no web browser! diff --git a/src/AndroidApp/android_remocons/common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/rocon/AppLauncher.java b/src/AndroidApp/android_remocons/common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/rocon/AppLauncher.java index b571cdb..0d5d39f 100644 --- a/src/AndroidApp/android_remocons/common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/rocon/AppLauncher.java +++ b/src/AndroidApp/android_remocons/common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/rocon/AppLauncher.java @@ -35,6 +35,7 @@ */ package com.github.rosjava.android_remocons.common_tools.rocon; + import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -98,6 +99,7 @@ public class AppLauncher { Log.i("AppLaunch", "launching concert app " + app.getDisplayName() + " on service " + app.getNamespace()); // On android apps, app name will be an intent action, while for web apps it will be its URL AppType app_type = checkAppType(app.getName()); + /** if(app_type == AppType.URL){ return launchUrl(parent, concert, app); } @@ -116,6 +118,13 @@ public class AppLauncher { else{ return Result.NOTHING; } + */ + if (app.getName()=="com.github.rosjava.android_remocons.rocon_remocon.linphone.LinphoneLauncherActivity"){ + return launchWebApp(parent, concert, app); + } + else { + return launchAndroidApp(parent, concert, app); + } } /** * Check the application name whether web_url(*) or web_app(*) @@ -123,7 +132,7 @@ public class AppLauncher { static public AppType checkAppType(String app_name){ String web_url_desc = "web_url("; String web_app_desc = "web_app("; - if (Patterns.WEB_URL.matcher(app_name).matches()) { + if (Patterns.WEB_URL.matcher(app_name).matches() == true) { return AppType.URL; } else if(app_name.length() == 0){ @@ -262,15 +271,12 @@ public class AppLauncher { */ static private Result launchUrl (final Activity parent, final RoconDescription concert, final rocon_interaction_msgs.Interaction app) { - try //rocon app的bug在这个方法中 + try { // Validate the URL before starting anything String app_name = ""; app_name = app.getName(); - Log.i("app_name:", app_name); - //没有调用到appURL,第273行注释掉了。by lcp URL appURL = new URL(app_name); - Log.i("successfully URL:",app_name); //2014.12.03 comment by dwlee //reason of blocking, Not necessary in web app launcher. /* @@ -301,17 +307,15 @@ public class AppLauncher { // Create an action view intent and pass rapp's name + extra information as URI Intent intent = new Intent(Intent.ACTION_VIEW, appURI); intent.putExtra(Constants.ACTIVITY_SWITCHER_ID + "." + InteractionMode.CONCERT + "_app_name",app_name); + Log.i("AppLaunch", "trying to start web app (URI: " + appUriStr + ")"); parent.startActivity(intent); return Result.SUCCESS; } - /** - * 没有用到url,直接注释掉. by lcp 2021/4/20 catch (MalformedURLException e) - {//rocon app的no protocol bug - return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage() + " It's in launchUrl."); + { + return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage()); } - */ catch (ActivityNotFoundException e) { // This cannot happen for a web site, right? must mean that I have no web browser! return Result.NOT_INSTALLED.withMsg("Activity not found for view action??? muoia???"); @@ -333,7 +337,7 @@ public class AppLauncher { String app_type = "web_url"; app_name = app.getName().substring(app_type.length()+1,app.getName().length()-1); - //URL appURL = new URL(app_name); + URL appURL = new URL(app_name); //2014.12.03 comment by dwlee //reason of blocking, Not necessary in web app launcher. @@ -370,12 +374,10 @@ public class AppLauncher { parent.startActivity(intent); return Result.SUCCESS; } - /** catch (MalformedURLException e) { - return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage() + " It's in launchWebUrl."); + return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage()); } - */ catch (ActivityNotFoundException e) { // This cannot happen for a web site, right? must mean that I have no web browser! return Result.NOT_INSTALLED.withMsg("Activity not found for view action??? muoia???"); @@ -482,7 +484,7 @@ public class AppLauncher { } catch (MalformedURLException e) { - return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage() + " It's in launchWebApp."); + return Result.MALFORMED_URI.withMsg("App URL is not valid. " + e.getMessage()); } catch (ActivityNotFoundException e) { // This cannot happen for a web site, right? must mean that I have no web browser! diff --git a/src/AndroidApp/android_remocons/rocon_remocon/build.gradle b/src/AndroidApp/android_remocons/rocon_remocon/build.gradle index 3b947f9..6942c47 100644 --- a/src/AndroidApp/android_remocons/rocon_remocon/build.gradle +++ b/src/AndroidApp/android_remocons/rocon_remocon/build.gradle @@ -30,7 +30,7 @@ repositories { flatDir { dirs 'libs' } - maven { url "https://www.jitpack.io" } + maven { url "https://jitpack.io" } } //noinspection GroovyAssignabilityCheck diff --git a/src/AndroidApp/android_remocons/rocon_remocon/src/main/AndroidManifest.xml b/src/AndroidApp/android_remocons/rocon_remocon/src/main/AndroidManifest.xml index f054738..ea88f04 100644 --- a/src/AndroidApp/android_remocons/rocon_remocon/src/main/AndroidManifest.xml +++ b/src/AndroidApp/android_remocons/rocon_remocon/src/main/AndroidManifest.xml @@ -97,6 +97,7 @@ + @@ -106,6 +107,7 @@ + @@ -113,23 +115,35 @@ + - + + - + + + + + + + + + + @@ -139,6 +153,7 @@ + @@ -184,7 +199,6 @@ - @@ -196,6 +210,30 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/Remocon.java b/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/Remocon.java index e8114e8..940d207 100644 --- a/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/Remocon.java +++ b/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/Remocon.java @@ -67,6 +67,12 @@ import com.github.rosjava.android_remocons.common_tools.system.WifiChecker; import com.github.rosjava.android_remocons.rocon_remocon.dialogs.AlertDialogWrapper; import com.github.rosjava.android_remocons.rocon_remocon.dialogs.LaunchInteractionDialog; import com.github.rosjava.android_remocons.rocon_remocon.dialogs.ProgressDialogWrapper; +import com.github.rosjava.android_remocons.rocon_remocon.fall_dectect.FallDetectedActivity; +import com.github.rosjava.android_remocons.rocon_remocon.fall_dectect.FallDialog; +import com.github.rosjava.android_remocons.rocon_remocon.fall_dectect.NewListener; +import com.github.rosjava.android_remocons.rocon_remocon.follower.FollowerActivity; +import com.github.rosjava.android_remocons.rocon_remocon.motion_control.MotionControl; +import com.github.rosjava.android_remocons.rocon_remocon.panorama.PanoramaActivity; import com.google.common.base.Preconditions; import org.ros.android.RosActivity; @@ -154,7 +160,7 @@ public class Remocon extends RosActivity { } @Override - protected void onStart() { + protected void onStart() { //重载函数,由不可见变为可见时调用 super.onResume(); if ( getIntent().getExtras() != null ) { Log.i("Remocon", "onStart: " + Constants.ACTIVITY_SWITCHER_ID + "." + InteractionMode.CONCERT + "_app_name"); @@ -257,7 +263,7 @@ public class Remocon extends RosActivity { public void run() { AppLauncher.Result result = - AppLauncher.launch(Remocon.this, roconDescription, selectedInteraction);//启动App的返回结果 + AppLauncher.launch(Remocon.this, roconDescription, selectedInteraction); //启动App的返回结果 if (result == AppLauncher.Result.SUCCESS) { // App successfully launched! Notify the concert and finish this activity //statusPublisher.update(true, selectedInteraction.getHash(), selectedInteraction.getName()); @@ -299,7 +305,7 @@ public class Remocon extends RosActivity { else { AlertDialog.Builder dialog = new AlertDialog.Builder(Remocon.this); dialog.setIcon(R.drawable.failure_small); - dialog.setTitle("Cannot start app: " + result.toString());//加上result的具体结果,便于调试错误 by lcp + dialog.setTitle("Cannot start app"); dialog.setMessage(result.message); dialog.setPositiveButton("Accept", new DialogInterface.OnClickListener() { @Override @@ -495,7 +501,7 @@ public class Remocon extends RosActivity { * it directly to the concert validation and initialisation steps. */ @Override - public void startMasterChooser() { + public void startMasterChooser() { if (!fromApplication && !fromNfcLauncher) { super.startActivityForResult(new Intent(this, MasterChooser.class), @@ -503,6 +509,16 @@ public class Remocon extends RosActivity { } } + @Override + public void startMasterChooser() { + if (!fromApplication && !fromNfcLauncher) { + super.startActivityForResult(new Intent(this, + MainActivity.class), + CONCERT_MASTER_CHOOSER_REQUEST_CODE); + Log.d("remocon","startMasterChooser: "); + } + } + public void validateConcert(final MasterId id) { // TODO: why built here? and why recreate a builder, if wrapper already has? launchInteractionDialog = new LaunchInteractionDialog(this); diff --git a/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/audio_upload/upload.java b/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/audio_upload/upload.java new file mode 100644 index 0000000..a69933b --- /dev/null +++ b/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/audio_upload/upload.java @@ -0,0 +1,61 @@ +package com.github.rosjava.android_remocons.rocon_remocon.audio_upload; + + +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.net.Uri; +import com.github.rosjava.android_remocons.rocon_remocon.R; +import com.github.rosjava.android_remocons.rocon_remocon.fall_dectect.fragment.ContentFragment; + +import java.util.ArrayList; +import java.util.List; + +import yalantis.com.sidemenu.model.SlideMenuItem; +import yalantis.com.sidemenu.util.ViewAnimator; + +public class upload { + private DrawerLayout drawerLayout; //抽屉布局 + private ActionBarDrawerToggle drawerToggle; + private List list = new ArrayList<>(); + private ContentFragment contentFragment; + private ViewAnimator viewAnimator; + private int res = R.drawable.fall_pic2;//设置图片 + private LinearLayout linearLayout; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fall_detect);//启动上传音频的界面 + contentFragment = ContentFragment.newInstance(R.drawable.fall_pic2); + getSupportFragmentManager().beginTransaction() + .replace(R.id.content_frame, contentFragment) + .commit(); + drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + drawerLayout.setScrimColor(Color.TRANSPARENT); + linearLayout = (LinearLayout) findViewById(R.id.left_drawer); + linearLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + drawerLayout.closeDrawers(); + } + }); + + viewAnimator = new ViewAnimator<>(this, list, contentFragment, drawerLayout, this); + + Button buttonStartDetect=(Button)findViewById(R.id.StartFallDetect); + buttonStartDetect.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + Intent intent = new Intent(Intent.ACTION_VIEW); + String urlString = "http://192.168.8.127:8000/"; + intent.setData(Uri.parse(urlString)); + startActivity(intent); + } + }); + } +} \ No newline at end of file diff --git a/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/stranger_detect/NoStrangerDialog.java b/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/stranger_detect/NoStrangerDialog.java new file mode 100644 index 0000000..084fa17 --- /dev/null +++ b/src/AndroidApp/android_remocons/rocon_remocon/src/main/java/com/github/rosjava/android_remocons/rocon_remocon/stranger_detect/NoStrangerDialog.java @@ -0,0 +1,27 @@ +package com.github.rosjava.android_remocons.rocon_remocon.stranger_detect; +import android.content.DialogInterface; +import android.content.Intent; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; + +import com.github.rosjava.android_remocons.rocon_remocon.R; +import com.github.rosjava.android_remocons.rocon_remocon.Remocon; +import com.github.rosjava.android_remocons.rocon_remocon.WelcomActivity; + +public class NoStrangerDialog extends AppCompatActivity { + /*本类实现检测到陌生人后弹出提示对话框的功能*/ + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + //生成一个对话框 + AlertDialog.Builder alertdialogbuilder = new AlertDialog.Builder(this); + alertdialogbuilder.setMessage("有熟人进入"); + //alertdialogbuilder.setPositiveButton("我知道了", click1); + //alertdialogbuilder.setNegativeButton("继续监视", click2); + AlertDialog alertdialog1 = alertdialogbuilder.create(); + alertdialog1.show(); + //setContentView(R.layout.fall_alert); + } +}