@Override
  protected void onStart() {
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);

    this.level = prefs.getInt("level", 0);
    String mapJson = prefs.getString("map", null);

    if (mapJson == null) {
      waitForNext = true;
    } else {
      this.game.initGame(mapJson);
      String howdyPosition = prefs.getString("howdy", null);

      if (howdyPosition != null) {
        this.game.setHowdyPosition(howdyPosition);
      }

      Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();
    }

    String allDoneLevelsString = prefs.getString("doneLevels", null);

    if (allDoneLevelsString != null) {
      allDoneLevels = new ArrayList<String>(Arrays.asList(allDoneLevelsString.split(",")));
    }

    super.onStart();
  }
Example #2
0
  private void UploadToDropBox() {
    Utilities.LogDebug("GpsMainActivity.UploadToDropBox");

    final DropBoxHelper dropBoxHelper = new DropBoxHelper(getApplicationContext(), this);

    if (!dropBoxHelper.IsLinked()) {
      startActivity(new Intent("com.mendhak.gpslogger.DROPBOX_SETUP"));
      return;
    }

    final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");

    if (gpxFolder.exists()) {

      String[] enumeratedFiles = gpxFolder.list();
      List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
      Collections.reverse(fileList);
      final String[] files = fileList.toArray(new String[fileList.size()]);

      final Dialog dialog = new Dialog(this);
      dialog.setTitle(R.string.dropbox_upload);
      dialog.setContentView(R.layout.filelist);
      ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

      thelist.setAdapter(
          new ArrayAdapter<String>(
              getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

      thelist.setOnItemClickListener(
          new OnItemClickListener() {

            public void onItemClick(AdapterView<?> av, View v, int index, long arg) {

              dialog.dismiss();
              String chosenFileName = files[index];
              Utilities.ShowProgress(
                  GpsMainActivity.this,
                  getString(R.string.dropbox_uploading),
                  getString(R.string.please_wait));
              dropBoxHelper.UploadFile(chosenFileName);
            }
          });
      dialog.show();
    } else {
      Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
    }
  }
Example #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    c = this;
    preferences = PreferenceManager.getDefaultSharedPreferences(c);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.gpu_sgx540);

    gpuCurrent = readFile(Constants.GPU_SGX540);
    seekGpu = (SeekBar) findViewById(R.id.seek_gpu);

    gpu = Arrays.asList(153, 307, 384);
    seekBar(gpu.size() - 1, gpu.indexOf(gpuCurrent));

    /*else{
    seekGpu.setEnabled(false);
    seekIva.setEnabled(false);
    TextView ns = (TextView)findViewById(R.id.not_supported);
    ns.setVisibility(View.VISIBLE);
    }*/
    preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    curGpuTxt = (TextView) findViewById(R.id.current_gpu);
    maxGpuTxt = (TextView) findViewById(R.id.max_gpu);
    minGpuTxt = (TextView) findViewById(R.id.min_gpu);

    mhz = getResources().getString(R.string.mhz);
    current = getResources().getString(R.string.current);
    max = getResources().getString(R.string._max);
    min = getResources().getString(R.string._min);
    curGpuTxt.setText(current + ": " + (gpuCurrent) + mhz);
    maxGpuTxt.setText(max + ": " + gpu.get(2) + mhz);
    minGpuTxt.setText(min + ": " + gpu.get(0) + mhz);

    Button cancel = (Button) findViewById(R.id.cancel);
    cancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            finish();
          }
        });
  }
  public void setMeatToppingsView() {

    ListView list = (ListView) findViewById(R.id.meatToppingsView);
    String[] meat = {"Pepperoni", "Chicken", "Ground Beef", "Anchovies", "Bacon Bits"};
    List<String> meatList = Arrays.asList(meat);
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, meatList);
    list.setAdapter(adapter);
    list.setClickable(true);
    list.setChoiceMode(list.CHOICE_MODE_MULTIPLE);
    list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckedTextView item = (CheckedTextView) view;
            if (item.isChecked()) {
              numMeatToppings++;
            } else {
              numMeatToppings--;
            }
          }
        });
  }
Example #5
0
  /** Uploads a GPS Trace to OpenStreetMap.org. */
  private void UploadToOpenStreetMap() {
    Utilities.LogDebug("GpsMainactivity.UploadToOpenStreetMap");

    if (!OSMHelper.IsOsmAuthorized(getApplicationContext())) {
      startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext()));
      return;
    }

    final String goToOsmSettings = getString(R.string.menu_settings);

    final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");

    if (gpxFolder.exists()) {
      FilenameFilter select =
          new FilenameFilter() {

            public boolean accept(File dir, String filename) {
              return filename.toLowerCase().contains(".gpx");
            }
          };

      String[] enumeratedFiles = gpxFolder.list(select);
      List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
      Collections.reverse(fileList);
      fileList.add(0, goToOsmSettings);
      final String[] files = fileList.toArray(new String[fileList.size()]);

      final Dialog dialog = new Dialog(this);
      dialog.setTitle(R.string.osm_pick_file);
      dialog.setContentView(R.layout.filelist);
      ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

      thelist.setAdapter(
          new ArrayAdapter<String>(
              getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

      thelist.setOnItemClickListener(
          new OnItemClickListener() {

            public void onItemClick(AdapterView<?> av, View v, int index, long arg) {

              dialog.dismiss();
              String chosenFileName = files[index];

              if (chosenFileName.equalsIgnoreCase(goToOsmSettings)) {
                startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext()));
              } else {
                OSMHelper osm = new OSMHelper(GpsMainActivity.this, GpsMainActivity.this);
                Utilities.ShowProgress(
                    GpsMainActivity.this,
                    getString(R.string.osm_uploading),
                    getString(R.string.please_wait));
                osm.UploadGpsTrace(chosenFileName);
              }
            }
          });
      dialog.show();
    } else {
      Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
    }
  }
Example #6
0
  /**
   * Allows user to send a GPX/KML file along with location, or location only using a provider.
   * 'Provider' means any application that can accept such an intent (Facebook, SMS, Twitter, Email,
   * K-9, Bluetooth)
   */
  private void Share() {
    Utilities.LogDebug("GpsMainActivity.Share");
    try {

      final String locationOnly = getString(R.string.sharing_location_only);
      final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");
      if (gpxFolder.exists()) {
        String[] enumeratedFiles = gpxFolder.list();
        List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
        Collections.reverse(fileList);
        fileList.add(0, locationOnly);
        final String[] files = fileList.toArray(new String[fileList.size()]);

        final Dialog dialog = new Dialog(this);
        dialog.setTitle(R.string.sharing_pick_file);
        dialog.setContentView(R.layout.filelist);
        ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

        thelist.setAdapter(
            new ArrayAdapter<String>(
                getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

        thelist.setOnItemClickListener(
            new OnItemClickListener() {

              public void onItemClick(AdapterView<?> av, View v, int index, long arg) {
                dialog.dismiss();
                String chosenFileName = files[index];

                final Intent intent = new Intent(Intent.ACTION_SEND);

                // intent.setType("text/plain");
                intent.setType("*/*");

                if (chosenFileName.equalsIgnoreCase(locationOnly)) {
                  intent.setType("text/plain");
                }

                intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.sharing_mylocation));
                if (Session.hasValidLocation()) {
                  String bodyText =
                      getString(
                          R.string.sharing_latlong_text,
                          String.valueOf(Session.getCurrentLatitude()),
                          String.valueOf(Session.getCurrentLongitude()));
                  intent.putExtra(Intent.EXTRA_TEXT, bodyText);
                  intent.putExtra("sms_body", bodyText);
                }

                if (chosenFileName.length() > 0 && !chosenFileName.equalsIgnoreCase(locationOnly)) {
                  intent.putExtra(
                      Intent.EXTRA_STREAM, Uri.fromFile(new File(gpxFolder, chosenFileName)));
                }

                startActivity(Intent.createChooser(intent, getString(R.string.sharing_via)));
              }
            });
        dialog.show();
      } else {
        Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
      }
    } catch (Exception ex) {
      Utilities.LogError("Share", ex);
    }
  }
  public void nextLevel() {
    boolean loaded = false;
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    this.level++;

    AssetManager am = getResources().getAssets();

    try {
      List<String> allTutoLevels =
          new LinkedList<String>(Arrays.asList(am.list("levels/tutorial")));

      // if(addMsg){
      //    allTutoLevels.addAll(Arrays.asList(am.list("msg")));
      // }

      Log.d(TAG, allTutoLevels.toString());

      for (String name : allTutoLevels) {
        if (name.startsWith(this.level + ".")) {
          BufferedReader br =
              new BufferedReader(new InputStreamReader(am.open("levels/tutorial/" + name)));
          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
          loaded = true;
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (!loaded) {
      Random r = new Random();

      List<String> allLevels = new ArrayList<>();

      try {
        allLevels = Arrays.asList(am.list("levels"));
      } catch (IOException e) {
      }

      if (r.nextBoolean() && !allLevels.isEmpty() && allLevels.size() != allDoneLevels.size()) {
        try {
          int nLevel;
          do {
            nLevel = r.nextInt(allLevels.size());
          } while (allDoneLevels.contains(allLevels.get(nLevel)));

          String name = allLevels.get(nLevel);
          BufferedReader br = new BufferedReader(new InputStreamReader(am.open("levels/" + name)));

          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          allDoneLevels.add(name);

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        } catch (IOException e) {
          this.game.initGame(
              level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        }
      } else {
        this.game.initGame(
            level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
      }
    }

    // am.close();

    boardView.setGame(this.game);
    boardView.invalidate();
    boardView.getHowdyShadeView().invalidate();

    Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();

    Log.i(
        TAG,
        "Max tiles : "
            + (boardView.getMeasuredWidth() / 60) * (boardView.getMeasuredHeight() / 60));
  }
 public FluentInitializer withHighlightedDate(Date date) {
   return withHighlightedDates(Arrays.asList(date));
 }
 /**
  * Set an initially-selected date. The calendar will scroll to that date if it's not already
  * visible.
  */
 public FluentInitializer withSelectedDate(Date selectedDates) {
   return withSelectedDates(Arrays.asList(selectedDates));
 }