From 7a606637907476942c1f6686137ada6898d7eb14 Mon Sep 17 00:00:00 2001 From: Teddy Date: Mon, 26 Aug 2013 08:50:47 +0800 Subject: purged the repo --- .../.history/49/10547e20330d00131249f322b63acde8 | 83 ------- .../.history/49/d0e63f99550d00131719b896d543f08c | 241 --------------------- 2 files changed, 324 deletions(-) delete mode 100644 client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde8 delete mode 100644 client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c (limited to 'client/.metadata/.plugins/org.eclipse.core.resources/.history/49') diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde8 deleted file mode 100644 index 6b756f2..0000000 --- a/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde8 +++ /dev/null @@ -1,83 +0,0 @@ -package com.macaroon.piztor; - -import java.util.HashMap; - -import android.annotation.SuppressLint; -import android.content.Intent; -import android.os.Handler; - -@SuppressLint("UseSparseArrays") -public class AppMgr { - // Status - public enum ActivityStatus{ - create, start, resume, restart, stop, pause, destroy - } - static ActivityStatus status; - static PiztorAct nowAct; - //TODO fix - static Handler fromTransam, fromGPS; - static Transam transam = null; - static Thread tTransam, tGPS; - //Event - - final static int noToken = 101; - - - - static HashMap, HashMap>> mp; - - static void setStatus(ActivityStatus st) { - status = st; - } - - static void trigger(int event) { - Intent i = new Intent(); - System.out.println(nowAct.id + " : " + event); - if (mp.get(nowAct.getClass()) == null) - System.out.println("first"); - else if (mp.get(nowAct.getClass()) == null) - System.out.println("second"); - i.setClass(nowAct, mp.get(nowAct.getClass()).get(event)); - nowAct.startActivity(i); - } - - static void add(Class a, Integer event, Class b) { - if (mp.containsKey(a)) - mp.get(a).put(event, b); - else { - HashMap> h = new HashMap>(); - h.put(event, b); - mp.put(a, h); - } - } - - static void addTransition(Class a, int i, Class b) { - if (mp.containsKey(a)) { - HashMap> h = mp.get(a); - h.put(i, b); - mp.put(a, h); - } else { - HashMap> h = new HashMap>(); - h.put(i, b); - mp.put(a, h); - } - } - - static void addStatus(Class a) { - mp.put(a, new HashMap>()); - } - - static void init() { - mp = new HashMap, HashMap>>(); - fromTransam = new Handler(); - transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam); - fromGPS = new Handler(); - tTransam = new Thread(transam); - tTransam.run(); - addStatus(InitAct.class); - addStatus(Login.class); - addStatus(Main.class); - addTransition(InitAct.class, noToken, Login.class); - } - -} diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c deleted file mode 100644 index 34a8b04..0000000 --- a/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c +++ /dev/null @@ -1,241 +0,0 @@ -package com.macaroon.piztor; - -import android.app.AlertDialog; -import android.app.Service; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.location.GpsStatus; -import android.os.Bundle; -import android.os.IBinder; -import android.os.SystemClock; -import android.provider.Settings; -import android.util.Log; - -public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener { - - private final Context mContext; - - // flag for GPS status - boolean isGPSEnabled = false; - - // flag for network status - boolean isNetworkEnabled = false; - - // flag for GPS status - boolean canGetLocation = false; - - Location location; // location - double latitude; // latitude - double longitude; // longitude - - // The minimum distance to change Updates in meters - private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters - - // The minimum time between updates in milliseconds - private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds - - // Declaring a Location Manager - protected LocationManager locationManager; - - // for GPS satellite status listener - Location mLastLocation; - long mLastLocationMillis; - boolean isGPSFix; - - - public GPSTracker(Context context) { - this.mContext = context; - isGPSFix = false; - getLocation(); - } - - public Location getLocation() { - try { - Log.d("getLocation", "Start getting location......"); - - locationManager = (LocationManager) mContext - .getSystemService(LOCATION_SERVICE); - - // getting GPS status - isGPSEnabled = locationManager - .isProviderEnabled(LocationManager.GPS_PROVIDER); - - // getting network status - isNetworkEnabled = locationManager - .isProviderEnabled(LocationManager.NETWORK_PROVIDER); - - if (!isGPSEnabled) { - // no network provider is enabled - } else { - this.canGetLocation = true; - if (isNetworkEnabled) { - locationManager.requestLocationUpdates( - LocationManager.NETWORK_PROVIDER, - MIN_TIME_BW_UPDATES, - MIN_DISTANCE_CHANGE_FOR_UPDATES, this); - - Log.d("Network", "Network Updated"); - - if (locationManager != null) { - location = locationManager - .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); - if (location != null) { - latitude = location.getLatitude(); - longitude = location.getLongitude(); - - Log.d("Network", "Received Network Data"); - System.out.println("***From Network: "+latitude + " " + longitude); - } - } - }// end of network section - // if GPS Enabled get lat/long using GPS Services - if (isGPSEnabled) { - if (true) { - locationManager.requestLocationUpdates( - LocationManager.GPS_PROVIDER, - MIN_TIME_BW_UPDATES, - MIN_DISTANCE_CHANGE_FOR_UPDATES, this); - Log.d("GPS", "GPS Updated"); - if (locationManager != null) { - location = locationManager - .getLastKnownLocation(LocationManager.GPS_PROVIDER); - if (location != null) { - latitude = location.getLatitude(); - longitude = location.getLongitude(); - - Log.d("GPS", "Received GPS Data"); - System.out.println("***From GPS: "+latitude + " " + longitude); - - } - } - } - }// end of GPS section - }// end of fetching data - return location; - } catch (Exception e) { - e.printStackTrace(); - } - return location; - } - - /** - * Stop using GPS listener Calling this function will stop using GPS in your - * app - * */ - public void stopUsingGPS() { - if (locationManager != null) { - locationManager.removeUpdates(GPSTracker.this); - } - } - - /** - * Function to get latitude - * */ - public double getLatitude() { - if (location != null) { - latitude = location.getLatitude(); - } - return latitude; - } - - /** - * Function to get longitude - * */ - public double getLongitude() { - if (location != null) { - longitude = location.getLongitude(); - } - return longitude; - } - - /** - * Function to check GPS/wifi enabled - * - * @return boolean - * */ - public boolean canGetLocation() { - return this.canGetLocation; - } - - public boolean isGPSFix() { - return (this.isGPSFix && location != null); - } - - /** - * Function to show settings alert dialog On pressing Settings button will - * lauch Settings Options - * */ - public void showSettingsAlert() { - AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext); - - // Setting Dialog Title - alertDialog.setTitle("GPS is settings"); - - // Setting Dialog Message - alertDialog - .setMessage("GPS is not enabled. Do you want to go to settings menu?"); - - // On pressing Settings button - alertDialog.setPositiveButton("Settings", - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent( - Settings.ACTION_LOCATION_SOURCE_SETTINGS); - mContext.startActivity(intent); - } - }); - - // on pressing cancel button - alertDialog.setNegativeButton("Cancel", - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - dialog.cancel(); - } - }); - - // Showing Alert Message - alertDialog.show(); - } - - @Override - public void onLocationChanged(Location location) { - if (location == null) return; - mLastLocationMillis = SystemClock.elapsedRealtime(); - mLastLocation = location; - } - - @Override - public void onProviderDisabled(String provider) { - } - - @Override - public void onProviderEnabled(String provider) { - } - - @Override - public void onStatusChanged(String provider, int status, Bundle extras) { - } - - @Override - public IBinder onBind(Intent arg0) { - return null; - } - - @Override - public void onGpsStatusChanged(int event) { - switch (event) { - case GpsStatus.GPS_EVENT_SATELLITE_STATUS: - if(mLastLocation != null) - isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000; - break; - - case GpsStatus.GPS_EVENT_FIRST_FIX: - isGPSFix = true; - break; - } - } -} -- cgit v1.2.3