@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // init
    activity = this;
    res = this.getResources();
    app = (cgeoapplication) this.getApplication();
    settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
    base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
    warning = new cgWarning(this);

    // set layout
    if (settings.skin == 1) {
      setTheme(R.style.light);
    } else {
      setTheme(R.style.dark);
    }
    setContentView(R.layout.waypoint);
    base.setTitle(activity, "waypoint");

    // google analytics
    tracker = GoogleAnalyticsTracker.getInstance();
    tracker.start(cgSettings.analytics, this);
    tracker.dispatch();
    base.sendAnal(activity, tracker, "/waypoint/detail");

    // get parameters
    Bundle extras = getIntent().getExtras();

    // try to get data from extras
    if (extras != null) {
      id = extras.getInt("waypoint");
      geocode = extras.getString("geocode");
    }

    if (id <= 0) {
      warning.showToast(res.getString(R.string.err_waypoint_unknown));
      finish();
      return;
    }

    if (geo == null) {
      geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
    }

    waitDialog = ProgressDialog.show(this, null, res.getString(R.string.waypoint_loading), true);
    waitDialog.setCancelable(true);

    (new loadWaypoint()).start();
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    final int menuItem = item.getItemId();

    if (menuItem == MENU_ID_MAP) {
      showOnMap();
      return true;
    } else if (menuItem == MENU_ID_COMPASS) {
      goCompass(null);
      return true;
    } else if (menuItem == MENU_ID_RADAR) {
      radarTo();
      return true;
    } else if (menuItem == MENU_ID_TURNBYTURN) {
      if (geo != null) {
        base.runNavigation(
            activity,
            res,
            settings,
            warning,
            tracker,
            waypoint.latitude,
            waypoint.longitude,
            geo.latitudeNow,
            geo.longitudeNow);
      } else {
        base.runNavigation(
            activity, res, settings, warning, tracker, waypoint.latitude, waypoint.longitude);
      }

      return true;
    } else if (menuItem == MENU_ID_CACHES_AROUND) {
      cachesAround();
      return true;
    } else if (menuItem == MENU_ID_LOCUS) {
      base.runExternalMap(cgBase.mapAppLocus, activity, res, warning, tracker, waypoint); // locus
      return true;
    } else if (menuItem == MENU_ID_RMAPS) {
      base.runExternalMap(cgBase.mapAppRmaps, activity, res, warning, tracker, waypoint); // rmaps
      return true;
    } else if (menuItem == MENU_ID_EXTERN) {
      base.runExternalMap(cgBase.mapAppAny, activity, res, warning, tracker, waypoint); // extern
      return true;
    }

    return false;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_ID_COMPASS, 0, res.getString(R.string.cache_menu_compass))
        .setIcon(android.R.drawable.ic_menu_compass); // compass

    SubMenu subMenu =
        menu.addSubMenu(1, MENU_ID_NAVIGATION, 0, res.getString(R.string.cache_menu_navigate))
            .setIcon(android.R.drawable.ic_menu_more);
    subMenu.add(0, MENU_ID_RADAR, 0, res.getString(R.string.cache_menu_radar)); // radar
    subMenu.add(0, MENU_ID_MAP, 0, res.getString(R.string.cache_menu_map)); // c:geo map
    if (base.isLocus(activity)) {
      subMenu.add(0, MENU_ID_LOCUS, 0, res.getString(R.string.cache_menu_locus)); // ext.: locus
    }
    if (base.isRmaps(activity)) {
      subMenu.add(0, MENU_ID_RMAPS, 0, res.getString(R.string.cache_menu_rmaps)); // ext.: rmaps
    }
    subMenu.add(0, MENU_ID_EXTERN, 0, res.getString(R.string.cache_menu_map_ext)); // ext.: other
    subMenu.add(0, MENU_ID_TURNBYTURN, 0, res.getString(R.string.cache_menu_tbt)); // turn-by-turn

    menu.add(0, MENU_ID_CACHES_AROUND, 0, res.getString(R.string.cache_menu_around))
        .setIcon(android.R.drawable.ic_menu_rotate); // caches around

    return true;
  }
Example #4
0
 public void goHome(View view) {
   base.goHome(activity);
 }
Example #5
0
        @Override
        public void handleMessage(Message msg) {
          try {
            if (waypoint == null) {
              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }

              warning.showToast(res.getString(R.string.err_waypoint_load_failed));

              finish();
              return;
            } else {
              final TextView identification = (TextView) findViewById(R.id.identification);
              final TextView coords = (TextView) findViewById(R.id.coordinates);
              final TextView note = (TextView) findViewById(R.id.note);
              final LinearLayout navigationPart = (LinearLayout) findViewById(R.id.navigation_part);

              if (waypoint.name != null && waypoint.name.length() > 0) {
                base.setTitle(activity, Html.fromHtml(waypoint.name.trim()).toString());
              } else {
                base.setTitle(activity, res.getString(R.string.waypoint_title));
              }

              if (waypoint.prefix.equalsIgnoreCase("OWN") == false) {
                identification.setText(waypoint.prefix.trim() + "/" + waypoint.lookup.trim());
              } else {
                identification.setText(res.getString(R.string.waypoint_custom));
              }

              if (waypoint.latitude != null && waypoint.longitude != null) {
                coords.setText(
                    Html.fromHtml(
                        base.formatCoordinate(waypoint.latitude, "lat", true)
                            + " | "
                            + base.formatCoordinate(waypoint.longitude, "lon", true)),
                    TextView.BufferType.SPANNABLE);
              } else {
                coords.setText(res.getString(R.string.waypoint_unknown_coordinates));
              }

              if (waypoint.note != null && waypoint.note.length() > 0) {
                note.setText(Html.fromHtml(waypoint.note.trim()), TextView.BufferType.SPANNABLE);
              }

              if (waypoint.latitude != null && waypoint.longitude != null) {
                Button buttonCompass = (Button) findViewById(R.id.compass);
                buttonCompass.setOnClickListener(
                    new navigateToListener(
                        waypoint.latitude, waypoint.longitude, waypoint.name, ""));

                Button buttonRadar = (Button) findViewById(R.id.radar);
                if (base.isIntentAvailable(activity, "com.google.android.radar.SHOW_RADAR")
                    == true) {
                  buttonRadar.setEnabled(true);
                  buttonRadar.setOnClickListener(
                      new radarToListener(waypoint.latitude, waypoint.longitude));
                } else {
                  buttonRadar.setEnabled(false);
                }

                Button buttonMap = (Button) findViewById(R.id.map);
                buttonMap.setOnClickListener(
                    new mapToListener(waypoint.latitude, waypoint.longitude));

                Button buttonMapExt = (Button) findViewById(R.id.map_ext);
                buttonMapExt.setOnClickListener(new mapExtToListener(waypoint));

                Button buttonTurn = (Button) findViewById(R.id.turn);
                buttonTurn.setOnClickListener(
                    new turnToListener(waypoint.latitude, waypoint.longitude));

                navigationPart.setVisibility(View.VISIBLE);
              }

              Button buttonEdit = (Button) findViewById(R.id.edit);
              buttonEdit.setOnClickListener(new editWaypointListener(waypoint.id));

              Button buttonDelete = (Button) findViewById(R.id.delete);
              if (waypoint.type != null && waypoint.type.equalsIgnoreCase("own") == true) {
                buttonDelete.setOnClickListener(new deleteWaypointListener(waypoint.id));
                buttonDelete.setVisibility(View.VISIBLE);
              }

              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }
            }
          } catch (Exception e) {
            if (waitDialog != null) {
              waitDialog.dismiss();
              waitDialog = null;
            }
            Log.e(cgSettings.tag, "cgeowaypoint.loadWaypointHandler: " + e.toString());
          }
        }
        @Override
        public void handleMessage(Message msg) {
          try {
            if (waypoint == null) {
              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }

              warning.showToast(res.getString(R.string.err_waypoint_load_failed));

              finish();
              return;
            } else {
              final TextView identification = (TextView) findViewById(R.id.identification);
              final TextView coords = (TextView) findViewById(R.id.coordinates);
              final TextView note = (TextView) findViewById(R.id.note);
              final ImageView compass = (ImageView) findViewById(R.id.compass);
              final View separator = (View) findViewById(R.id.separator);

              if (waypoint.name != null && waypoint.name.length() > 0) {
                base.setTitle(activity, Html.fromHtml(waypoint.name.trim()).toString());
              } else {
                base.setTitle(activity, res.getString(R.string.waypoint_title));
              }

              if (waypoint.prefix.equalsIgnoreCase("OWN") == false) {
                identification.setText(waypoint.prefix.trim() + "/" + waypoint.lookup.trim());
              } else {
                identification.setText(res.getString(R.string.waypoint_custom));
              }

              if (waypoint.latitude != null && waypoint.longitude != null) {
                coords.setText(
                    Html.fromHtml(
                        base.formatCoordinate(waypoint.latitude, "lat", true)
                            + " | "
                            + base.formatCoordinate(waypoint.longitude, "lon", true)),
                    TextView.BufferType.SPANNABLE);
                compass.setVisibility(View.VISIBLE);
                separator.setVisibility(View.VISIBLE);
              } else {
                coords.setText(res.getString(R.string.waypoint_unknown_coordinates));
                compass.setVisibility(View.GONE);
                separator.setVisibility(View.GONE);
              }

              if (waypoint.note != null && waypoint.note.length() > 0) {
                note.setText(Html.fromHtml(waypoint.note.trim()), TextView.BufferType.SPANNABLE);
              }

              Button buttonEdit = (Button) findViewById(R.id.edit);
              buttonEdit.setOnClickListener(new editWaypointListener(waypoint.id));

              Button buttonDelete = (Button) findViewById(R.id.delete);
              if (waypoint.type != null && waypoint.type.equalsIgnoreCase("own") == true) {
                buttonDelete.setOnClickListener(new deleteWaypointListener(waypoint.id));
                buttonDelete.setVisibility(View.VISIBLE);
              }

              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }
            }
          } catch (Exception e) {
            if (waitDialog != null) {
              waitDialog.dismiss();
              waitDialog = null;
            }
            Log.e(cgSettings.tag, "cgeowaypoint.loadWaypointHandler: " + e.toString());
          }
        }