Ejemplo n.º 1
0
 @Override
 public void setup(OsmandApplication app) {
   super.setup(app);
   originalSettings = createSettings(app.getSettings().getSettingsAPI());
   selectedTourPref = originalSettings.registerStringPreference(SELECTED_TOUR, null).makeGlobal();
   accessCodePref = originalSettings.registerStringPreference(ACCESS_CODE, "").makeGlobal();
   toursFolder = new File(originalSettings.getExternalStorageDirectory(), "osmand/tours");
 }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    getMyApplication().applyTheme(this);
    super.onCreate(savedInstanceState);
    if (Version.isSherpafy(getMyApplication())) {
      final Intent mapIntent = new Intent(this, TourViewActivity.class);
      getMyApplication().setAppCustomization(new SherpafyCustomization());
      startActivity(mapIntent);
      finish();
      return;
    }

    if (getIntent() != null) {
      Intent intent = getIntent();
      if (intent.getExtras() != null && intent.getExtras().containsKey(APP_EXIT_KEY)) {
        getMyApplication().closeApplication(this);
        return;
      }
    }

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.menu);

    final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();

    onCreateMainMenu(getWindow(), this);

    Window window = getWindow();
    final Activity activity = this;
    View showMap = window.findViewById(R.id.MapButton);
    showMap.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final Intent mapIndent = new Intent(activity, appCustomization.getMapActivity());
            activity.startActivityForResult(mapIndent, 0);
          }
        });
    View settingsButton = window.findViewById(R.id.SettingsButton);
    settingsButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final Intent settings = new Intent(activity, appCustomization.getSettingsActivity());
            activity.startActivity(settings);
          }
        });

    View favouritesButton = window.findViewById(R.id.FavoritesButton);
    favouritesButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
            favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            activity.startActivity(favorites);
          }
        });

    final View closeButton = window.findViewById(R.id.CloseButton);
    closeButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            getMyApplication().closeApplication(activity);
          }
        });
    View searchButton = window.findViewById(R.id.SearchButton);
    searchButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final Intent search = new Intent(activity, appCustomization.getSearchActivity());
            search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            activity.startActivity(search);
          }
        });
    appCustomization.customizeMainMenu(window, this);
    OsmandApplication app = getMyApplication();
    // restore follow route mode
    if (app.getSettings().FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated()) {
      final Intent mapIndent = new Intent(this, appCustomization.getMapActivity());
      startActivityForResult(mapIndent, 0);
      return;
    }
    startProgressDialog = new ProgressDialog(this);
    getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
    boolean dialogShown = false;
    boolean firstTime = false;
    SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
    boolean appVersionChanged = false;
    if (!pref.contains(FIRST_TIME_APP_RUN)) {
      firstTime = true;
      pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
      pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
    } else if (!Version.getFullVersion(app).equals(pref.getString(VERSION_INSTALLED, ""))) {
      pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
      appVersionChanged = true;
    }
    if (appCustomization.showFirstTimeRunAndTips(firstTime, appVersionChanged)) {
      if (firstTime) {
        applicationInstalledFirstTime();
        dialogShown = true;
      } else {
        int i = pref.getInt(TIPS_SHOW, 0);
        if (i < 7) {
          pref.edit().putInt(TIPS_SHOW, ++i).commit();
        }
        if (i == 1 || i == 5 || appVersionChanged) {
          if (TIPS_AND_TRICKS) {
            TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
            Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
            dlg.show();
            dialogShown = true;
          } else {
            if (appVersionChanged) {
              final Intent helpIntent = new Intent(activity, HelpActivity.class);
              helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(getMyApplication()));
              helpIntent.putExtra(HelpActivity.URL, "changes-1.8.html");
              activity.startActivity(helpIntent);
              dialogShown = true;
            }
          }
        }
      }
    }
    if (!dialogShown && appCustomization.checkBasemapDownloadedOnStart()) {
      if (startProgressDialog.isShowing()) {
        startProgressDialog.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              @Override
              public void onDismiss(DialogInterface dialog) {
                checkVectorIndexesDownloaded();
              }
            });
      } else {
        checkVectorIndexesDownloaded();
      }
    }
    if (appCustomization.checkExceptionsOnStart() && !dialogShown) {
      checkPreviousRunsForExceptions(firstTime);
    }
  }
Ejemplo n.º 3
0
 @Override
 public void getDownloadTypes(List<DownloadActivityType> items) {
   super.getDownloadTypes(items);
   items.add(0, TourDownloadType.TOUR);
 }