Skip to content

Commit

Permalink
Tango: added asking Motion Tracking permission
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Mar 18, 2016
1 parent 3f48b39 commit 1b4539a
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions app/android/src/com/introlab/rtabmap/RTABMapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import android.widget.TextView;
import android.widget.Toast;

import com.google.atap.tangoservice.Tango;

// The main activity of the application. This activity shows debug information
// and a glSurfaceView that renders graphic content.
public class RTABMapActivity extends Activity implements OnClickListener {
Expand Down Expand Up @@ -116,7 +118,7 @@ protected void onCreate(Bundle savedInstanceState) {
Toast.makeText(this, "Tango Core out dated, please update in Play Store", Toast.LENGTH_LONG).show();
finish();
return;
}
}

mOpenedDatabasePath = "";
mTempDatabasePath = "";
Expand Down Expand Up @@ -149,21 +151,51 @@ protected void onCreate(Bundle savedInstanceState) {
RTABMapLib.initialize(this);
RTABMapLib.openDatabase(mTempDatabasePath);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == Tango.TANGO_INTENT_ACTIVITYCODE) {
// Make sure the request was successful
if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Motion Tracking Permissions Required!",
Toast.LENGTH_SHORT).show();
finish();
}
}
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();

mTotalLoopClosures = 0;
if(mItemOpen != null)
{
mItemOpen.setEnabled(false);
mItemPause.setChecked(false);
mItemSave.setEnabled(false);
mItemExport.setEnabled(false);
Log.i(TAG, String.format("onResume()"));

if (Tango.hasPermission(this, Tango.PERMISSIONTYPE_MOTION_TRACKING)) {

mGLView.onResume();

mTotalLoopClosures = 0;
if(mItemOpen != null)
{
mItemOpen.setEnabled(false);
mItemPause.setChecked(false);
mItemSave.setEnabled(false);
mItemExport.setEnabled(false);
}

if(RTABMapLib.onResume()!=0)
{
Toast.makeText(getApplicationContext(),
String.format("Failed to connect with Tango!"), Toast.LENGTH_SHORT).show();
}

} else {
Log.i(TAG, String.format("Asking for motion tracking permission"));
startActivityForResult(
Tango.getRequestPermissionIntent(Tango.PERMISSIONTYPE_MOTION_TRACKING),
Tango.TANGO_INTENT_ACTIVITYCODE);
}
RTABMapLib.onResume();
}

@Override
Expand Down

0 comments on commit 1b4539a

Please sign in to comment.