更新上传音频功能

master
Logical 4 years ago
parent be840f59c8
commit c4ef6240e7

@ -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!

@ -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!

@ -30,7 +30,7 @@ repositories {
flatDir {
dirs 'libs'
}
maven { url "https://www.jitpack.io" }
maven { url "https://jitpack.io" }
}
//noinspection GroovyAssignabilityCheck

@ -97,6 +97,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".fall_dectect.NewListener"
android:icon="@mipmap/icon"
android:theme="@style/Theme.AppCompat">
@ -106,6 +107,7 @@
</intent-filter>
</activity>
<activity android:name=".fall_dectect.FallDialog"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
@ -113,23 +115,35 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".stranger_detect.NewListener"
android:icon="@mipmap/icon"
android:theme="@style/Theme.AppCompat">
<intent-filter>
<action android:name="com.github.rosjava.android_remocons.rocon_remocon.fall_dectect.NewListener" />
<action android:name="com.github.rosjava.android_remocons.rocon_remocon.stranger_detect.NewListener" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".stranger_detect.StrangerDialog"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="com.github.rosjava.android_remocons.rocon_remocon.fall_dectect.FallDialog" />
<action android:name="com.github.rosjava.android_remocons.rocon_remocon.stranger_detect.StrangerDialog" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".stranger_detect.NoStrangerDialog"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="com.github.rosjava.android_remocons.rocon_remocon.stranger_detect.NoStrangerDialog" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".MasterChooser" />
<activity android:name=".NfcLauncherActivity"
android:label="NFC tag launcher">
<intent-filter>
@ -139,6 +153,7 @@
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name="com.github.rosjava.android_remocons.common_tools.nfc.NfcReaderActivity" />
<service android:name="org.ros.android.NodeMainExecutorService" >
@ -184,7 +199,6 @@
</intent-filter>
</activity>
<activity
android:name=".fall_dectect.FallDetectedActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
@ -196,6 +210,30 @@
</activity>
<activity
android:name=".stranger_detect.StrangerlDetectedActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="com.github.rosjava.android_remocons.rocon_remocon.stranger_detect.Stranger"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--
上传音频
-->
<activity
android:name=".audio_upload.upload"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="com.github.rosjava.android_remocons.rocon_remocon.audio_upload.upload"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:theme="@style/AppTheme"
android:name=".TestActivity">

@ -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);

@ -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<SlideMenuItem> 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);
}
});
}
}

@ -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);
}
}
Loading…
Cancel
Save