Simulate back button on receiving presence of other device.
This commit is contained in:
parent
192838b585
commit
ebe4208502
|
|
@ -4,6 +4,8 @@ import android.app.Activity;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
@ -22,11 +24,13 @@ public class QRCodeGeneratorActivity extends Activity {
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
private static Bitmap image = null;
|
private static Bitmap image = null;
|
||||||
private static boolean generating = false;
|
private static boolean generating = false;
|
||||||
|
public static QRCodeGeneratorActivity thsi = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.qr_code_generator);
|
setContentView(R.layout.qr_code_generator);
|
||||||
|
thsi = this;
|
||||||
|
|
||||||
// Keep screen ON
|
// Keep screen ON
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
@ -77,4 +81,10 @@ public class QRCodeGeneratorActivity extends Activity {
|
||||||
Log.i(TAG, "FIN GENERATION QR CODE");
|
Log.i(TAG, "FIN GENERATION QR CODE");
|
||||||
generating = false;
|
generating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void pressBackButton() {
|
||||||
|
if (thsi != null) {
|
||||||
|
thsi.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
|
import fr.chteufleur.mytrackingdog.QRCodeGeneratorActivity;
|
||||||
import fr.chteufleur.mytrackingdog.models.ExportGpx;
|
import fr.chteufleur.mytrackingdog.models.ExportGpx;
|
||||||
import fr.chteufleur.mytrackingdog.models.Gpx;
|
import fr.chteufleur.mytrackingdog.models.Gpx;
|
||||||
import fr.chteufleur.mytrackingdog.models.ImportGpx;
|
import fr.chteufleur.mytrackingdog.models.ImportGpx;
|
||||||
|
|
@ -268,6 +269,8 @@ public class ServiceTrackingDog implements Observer {
|
||||||
currentLocationProvider = LocationProvider.XMPP;
|
currentLocationProvider = LocationProvider.XMPP;
|
||||||
} else if (notification.isAction(ServiceXmpp.NOTIF_STOP_TRAIL)) {
|
} else if (notification.isAction(ServiceXmpp.NOTIF_STOP_TRAIL)) {
|
||||||
currentLocationProvider = LocationProvider.GPS;
|
currentLocationProvider = LocationProvider.GPS;
|
||||||
|
} else if (notification.isAction(ServiceXmpp.NOTIF_NEW_PRESENCE_RECEIVED)) {
|
||||||
|
QRCodeGeneratorActivity.pressBackButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,10 @@ public class ServiceXmpp extends Observable implements PresenceEventListener {
|
||||||
public static final String NOTIF_NEW_OBJECT = ServiceXmpp.class.getName()+".newobject";
|
public static final String NOTIF_NEW_OBJECT = ServiceXmpp.class.getName()+".newobject";
|
||||||
public static final String NOTIF_START_TRAIL = ServiceXmpp.class.getName()+".starttrail";
|
public static final String NOTIF_START_TRAIL = ServiceXmpp.class.getName()+".starttrail";
|
||||||
public static final String NOTIF_STOP_TRAIL = ServiceXmpp.class.getName()+".stoptrail";
|
public static final String NOTIF_STOP_TRAIL = ServiceXmpp.class.getName()+".stoptrail";
|
||||||
|
public static final String NOTIF_NEW_PRESENCE_RECEIVED = ServiceXmpp.class.getName()+".newpresencereceived";
|
||||||
public static final String NOTIF_NEW_OBJECT_VALUE_LOCATION = NOTIF_NEW_OBJECT+".value.location";
|
public static final String NOTIF_NEW_OBJECT_VALUE_LOCATION = NOTIF_NEW_OBJECT+".value.location";
|
||||||
public static final String NOTIF_NEW_LOCATION_VALUE_LOCATION = NOTIF_NEW_LOCATION+".value.location";
|
public static final String NOTIF_NEW_LOCATION_VALUE_LOCATION = NOTIF_NEW_LOCATION+".value.location";
|
||||||
|
public static final String NOTIF_NEW_PRESENCE_RECEIVED_VALUE_JID = NOTIF_NEW_PRESENCE_RECEIVED+".value.jid";
|
||||||
|
|
||||||
private static final String XMPP_NODE_TRAIL_GEOLOC = "trail_geoloc";
|
private static final String XMPP_NODE_TRAIL_GEOLOC = "trail_geoloc";
|
||||||
private static final String XMPP_NODE_OBJECT_GEOLOC = "object_geoloc";
|
private static final String XMPP_NODE_OBJECT_GEOLOC = "object_geoloc";
|
||||||
|
|
@ -184,6 +186,8 @@ public class ServiceXmpp extends Observable implements PresenceEventListener {
|
||||||
} catch (XmppStringprepException e) {
|
} catch (XmppStringprepException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
setChanged();
|
||||||
|
notifyObservers(new Notification(NOTIF_NEW_PRESENCE_RECEIVED).addExtra(NOTIF_NEW_PRESENCE_RECEIVED_VALUE_JID, otherJid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue