mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Tango: Hide buttons after 5 seconds not touching the screen
This commit is contained in:
@@ -56,6 +56,7 @@ import android.os.Environment;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Message;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
@@ -121,6 +122,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
public static final int SKETCHFAB_ACTIVITY_CODE = 999;
|
public static final int SKETCHFAB_ACTIVITY_CODE = 999;
|
||||||
private String mAuthToken;
|
private String mAuthToken;
|
||||||
|
|
||||||
|
public static final long NOTOUCH_TIMEOUT = 5000; // 5 sec
|
||||||
|
private boolean mHudVisible = true;
|
||||||
|
|
||||||
// UI states
|
// UI states
|
||||||
private static enum State {
|
private static enum State {
|
||||||
STATE_IDLE,
|
STATE_IDLE,
|
||||||
@@ -282,6 +286,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
mGLView.setOnTouchListener(new OnTouchListener() {
|
mGLView.setOnTouchListener(new OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
|
||||||
|
resetNoTouchTimer();
|
||||||
|
|
||||||
mGesDetect.onTouchEvent(event);
|
mGesDetect.onTouchEvent(event);
|
||||||
|
|
||||||
// Pass the touch event to the native layer for camera control.
|
// Pass the touch event to the native layer for camera control.
|
||||||
@@ -432,6 +439,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
stopDisconnectTimer();
|
||||||
|
|
||||||
if(!DISABLE_LOG) Log.i(TAG, "onPause()");
|
if(!DISABLE_LOG) Log.i(TAG, "onPause()");
|
||||||
mOnPause = true;
|
mOnPause = true;
|
||||||
@@ -578,6 +586,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TangoInitializationHelper.bindTangoService(getActivity(), mTangoServiceConnection);
|
TangoInitializationHelper.bindTangoService(getActivity(), mTangoServiceConnection);
|
||||||
|
resetNoTouchTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCamera(int type)
|
private void setCamera(int type)
|
||||||
@@ -628,6 +637,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
resetNoTouchTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAndroidOrientation() {
|
private void setAndroidOrientation() {
|
||||||
@@ -1151,6 +1161,35 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
workingThread.start();
|
workingThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Handler notouchHandler = new Handler(){
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private Runnable notouchCallback = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mHudVisible = false;
|
||||||
|
updateState(mState);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void resetNoTouchTimer(){
|
||||||
|
if(!mHudVisible)
|
||||||
|
{
|
||||||
|
mHudVisible = true;
|
||||||
|
updateState(mState);
|
||||||
|
}
|
||||||
|
mHudVisible = true;
|
||||||
|
|
||||||
|
notouchHandler.removeCallbacks(notouchCallback);
|
||||||
|
notouchHandler.postDelayed(notouchCallback, NOTOUCH_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopDisconnectTimer(){
|
||||||
|
notouchHandler.removeCallbacks(notouchCallback);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateState(State state)
|
private void updateState(State state)
|
||||||
{
|
{
|
||||||
if(mState == State.STATE_VISUALIZING && state == State.STATE_IDLE && mMapNodes > 100)
|
if(mState == State.STATE_VISUALIZING && state == State.STATE_IDLE && mMapNodes > 100)
|
||||||
@@ -1175,10 +1214,10 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
mButtonPause.setVisibility(View.INVISIBLE);
|
mButtonPause.setVisibility(View.INVISIBLE);
|
||||||
break;
|
break;
|
||||||
case STATE_VISUALIZING:
|
case STATE_VISUALIZING:
|
||||||
mButtonLighting.setVisibility(View.VISIBLE);
|
mButtonLighting.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
mButtonCloseVisualization.setVisibility(View.VISIBLE);
|
mButtonCloseVisualization.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
mButtonSaveOnDevice.setVisibility(View.VISIBLE);
|
mButtonSaveOnDevice.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
mButtonShareOnSketchfab.setVisibility(View.VISIBLE);
|
mButtonShareOnSketchfab.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
mItemSave.setEnabled(mButtonPause.isChecked());
|
mItemSave.setEnabled(mButtonPause.isChecked());
|
||||||
mItemExport.setEnabled(mButtonPause.isChecked() && !mItemDataRecorderMode.isChecked());
|
mItemExport.setEnabled(mButtonPause.isChecked() && !mItemDataRecorderMode.isChecked());
|
||||||
mItemOpen.setEnabled(false);
|
mItemOpen.setEnabled(false);
|
||||||
@@ -1201,11 +1240,15 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
mItemSettings.setEnabled(true);
|
mItemSettings.setEnabled(true);
|
||||||
mItemReset.setEnabled(true);
|
mItemReset.setEnabled(true);
|
||||||
mItemModes.setEnabled(true);
|
mItemModes.setEnabled(true);
|
||||||
mButtonPause.setVisibility(View.VISIBLE);
|
mButtonPause.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
mItemDataRecorderMode.setEnabled(mButtonPause.isChecked());
|
mItemDataRecorderMode.setEnabled(mButtonPause.isChecked());
|
||||||
RTABMapLib.postExportation(false);
|
RTABMapLib.postExportation(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
mButtonFirst.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
|
mButtonThird.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
|
mButtonTop.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||||
|
mButtonBackfaceShown.setVisibility(mHudVisible && (mItemRenderingMesh.isChecked() || mItemRenderingTextureMesh.isChecked())?View.VISIBLE:View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pauseMapping() {
|
private void pauseMapping() {
|
||||||
@@ -1800,6 +1843,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
|||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
mExportedOBJ = isOBJ;
|
mExportedOBJ = isOBJ;
|
||||||
|
resetNoTouchTimer();
|
||||||
updateState(State.STATE_VISUALIZING);
|
updateState(State.STATE_VISUALIZING);
|
||||||
RTABMapLib.postExportation(true);
|
RTABMapLib.postExportation(true);
|
||||||
if(mButtonFirst.isChecked())
|
if(mButtonFirst.isChecked())
|
||||||
|
|||||||
Reference in New Issue
Block a user