Exemplo n.º 1
0
 @Override
 public void onPause() {
   super.onPause();
   Config.saveFilter(this, athenaFilterButton.getPlaceType(), athenaFilterButton.isChecked());
   Config.saveFilter(
       this, classroomFilterButton.getPlaceType(), classroomFilterButton.isChecked());
   Config.saveFilter(this, brMaleFilterButton.getPlaceType(), brMaleFilterButton.isChecked());
   Config.saveFilter(this, brFemaleFilterButton.getPlaceType(), brFemaleFilterButton.isChecked());
   int pixelsX = mapView.getWidth() / 2;
   int pixelsY = mapView.getHeight() / 2;
   GeoPoint point = mapView.getProjection().fromPixels(pixelsX, pixelsY);
   Config.saveLocation(
       this,
       point.getLatitudeE6(),
       point.getLongitudeE6(),
       floorMapView.getSeekBar().getUserSetFloor());
   LocationSetter.getInstance(this, null).pause();
 }
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.map_main);
    floorMapView = (FloorMapView) findViewById(R.id.floormapview);
    mapView = (PtolemyMapView) floorMapView.getMapView();
    configureFloorMapView(floorMapView);

    ActionBar.setTitle(this, ACTIVITY_TITLE);

    // Set up meOverlay:
    // Show user
    meOverlay = new XPSOverlay(mapView);
    mapView.getOverlays().add(meOverlay);

    // Start Location data
    LocationSetter.getInstance(this, meOverlay).resume();

    final ImageButton compassButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    compassButton.setImageResource(R.drawable.ic_menu_compass);
    compassButton.setContentDescription(getString(R.string.centre));
    final Context c = this;
    compassButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            final APGeoPoint gp =
                LocationSetter.getInstance(PtolemyMapActivity.this, null).getPoint(c);
            if (gp != null) {
              mapView
                  .getController()
                  .animateTo(
                      gp,
                      new Runnable() {
                        @Override
                        public void run() {
                          floorMapView.updateToFloor(gp.getFloor());
                        }
                      });
            }
          }
        });

    final ImageButton searchButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    searchButton.setImageResource(R.drawable.ic_menu_search);
    searchButton.setContentDescription(getString(R.string.search));
    searchButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            onSearchRequested();
          }
        });

    final ImageButton bookmarksButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    bookmarksButton.setImageResource(R.drawable.ic_menu_bookmark);
    bookmarksButton.setContentDescription(getString(R.string.bookmarks));
    bookmarksButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            startActivityForResult(
                new Intent(v.getContext(), BookmarksActivity.class), BOOKMARKS_RESULT);
          }
        });

    final ImageButton nearestButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    nearestButton.setImageResource(R.drawable.ic_menu_goto);
    nearestButton.setContentDescription(getString(R.string.bookmarks));
    nearestButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {

            Intent intent = new Intent(v.getContext(), NearbyActivity.class);
            LocationSetter setter = LocationSetter.getInstance(v.getContext(), null);
            APGeoPoint p = setter.getPoint(v.getContext());
            if (p != null) {
              intent.putExtra(NearbyActivity.LAT, p.getLatitudeE6());
              intent.putExtra(NearbyActivity.LON, p.getLongitudeE6());
              intent.putExtra(NearbyActivity.FLOOR, p.getFloor());
            }
            startActivityForResult(intent, NEAREST_RESULT);
          }
        });

    ActionBar.setButtons(
        this, new View[] {compassButton, nearestButton, searchButton, bookmarksButton});

    athenaFilterButton = (PlaceFilterButton) findViewById(R.id.athena_filter_btn);
    setupFilterButton(athenaFilterButton, PlaceType.ATHENA);
    athenaFilterButton.setChecked(Config.getFilter(this, PlaceType.ATHENA));

    classroomFilterButton = (PlaceFilterButton) findViewById(R.id.classroom_filter_btn);
    setupFilterButton(classroomFilterButton, PlaceType.CLASSROOM);
    classroomFilterButton.setChecked(Config.getFilter(this, PlaceType.CLASSROOM));

    brMaleFilterButton = (PlaceFilterButton) findViewById(R.id.br_male_filter_btn);
    setupFilterButton(brMaleFilterButton, PlaceType.MTOILET);
    brMaleFilterButton.setChecked(Config.getFilter(this, PlaceType.MTOILET));

    brFemaleFilterButton = (PlaceFilterButton) findViewById(R.id.br_female_filter_btn);
    setupFilterButton(brFemaleFilterButton, PlaceType.FTOILET);
    brFemaleFilterButton.setChecked(Config.getFilter(this, PlaceType.FTOILET));

    if (!handleIntent(getIntent())) {
      mapView.getController().setCenter(Config.DEFAULT_POINT);
    }

    if (!Config.isTourTaken(this)) {
      // Prevent user from clicking a button until the first
      // tutorial page comes up.
      compassButton.setClickable(false);
      searchButton.setClickable(false);
      bookmarksButton.setClickable(false);
      new Thread(
              new Runnable() {
                public void run() {
                  try {
                    Thread.sleep(1000);
                  } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
                  PtolemyMapActivity.this.runOnUiThread(
                      new Runnable() {
                        public void run() {
                          startActivityForResult(
                              new Intent(PtolemyMapActivity.this, TourActivity.class),
                              TUTORIAL_INTRO_RESULT);
                          compassButton.setClickable(true);
                          searchButton.setClickable(true);
                          bookmarksButton.setClickable(true);
                        }
                      });
                }
              })
          .start();
    }
    APGeoPoint point = Config.getLocation(this);
    mapView.getController().setCenter(new GeoPoint(point.getLatitudeE6(), point.getLongitudeE6()));
    floorMapView.getSeekBar().setFloor(point.getFloor());
  }
Exemplo n.º 3
0
 @Override
 public void onResume() {
   super.onResume();
   LocationSetter.getInstance(this, null).resume();
 }
Exemplo n.º 4
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   LocationSetter.getInstance(this, null).stop();
   mapView.stop();
 }
Exemplo n.º 5
0
 @Override
 public void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   handleIntent(intent);
 }