Beispiel #1
0
 /**
  * When the back button is pressed, update the MidiOptions. Return the updated options as the
  * 'result' of this Activity.
  */
 @Override
 public void onBackPressed() {
   Intent intent = new Intent();
   updateOptions();
   intent.putExtra(SettingsActivity.settingsID, options);
   setResult(Activity.RESULT_OK, intent);
   super.onBackPressed();
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == FILECHOOSER_RESULTCODE) { // found this from StackOverflow
     if (null == mUploadMessage) return;
     Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
     mUploadMessage.onReceiveValue(result);
     mUploadMessage = null;
   } else {
     // -----------I wrote this code below this line----------------------------------
     jpegData = intent.getExtras().getByteArray("image");
     Bitmap img = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
     Drawable d = new BitmapDrawable(img);
     profilePicture.setBackground(d);
   }
 }
Beispiel #3
0
 public void doRestart() {
   try {
     String action = "org.mozilla.gecko.restart";
     Intent intent = new Intent(action);
     intent.setClassName(getPackageName(), getPackageName() + ".Restarter");
     addEnvToIntent(intent);
     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
     Log.i(LOG_FILE_NAME, intent.toString());
     GeckoAppShell.killAnyZombies();
     startActivity(intent);
   } catch (Exception e) {
     Log.i(LOG_FILE_NAME, "error doing restart", e);
   }
   finish();
   // Give the restart process time to start before we die
   GeckoAppShell.waitForAnotherGeckoProc();
 }
Beispiel #4
0
        @Override
        public void onFinish() {
          Intent intent;

          if (mPref.getCheckedTutorial() == true) {
            // 튜토리얼을 했을 경우
            intent = new Intent(AC_Loading.this, AC_Main.class);
          } else {
            // 튜토리얼을 안했을 경우
            intent = new Intent(AC_Loading.this, AC_Help_tutorial.class);
          }
          intent.putExtra("tutorial", true);
          intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
          startActivity(intent);
          overridePendingTransition(R.anim.fadein, R.anim.fadeout);
          cTimer.cancel();
          finish();
        }
Beispiel #5
0
  public String showFilePicker(String aMimeType) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(aMimeType);
    GeckoApp.this.startActivityForResult(
        Intent.createChooser(intent, getString(R.string.choose_file)), FILE_PICKER_REQUEST);
    String filePickerResult = "";

    try {
      while (null == (filePickerResult = mFilePickerResult.poll(1, TimeUnit.MILLISECONDS))) {
        Log.i("GeckoApp", "processing events from showFilePicker ");
        GeckoAppShell.processNextNativeEvent();
      }
    } catch (InterruptedException e) {
      Log.i(LOG_FILE_NAME, "showing file picker ", e);
    }

    return filePickerResult;
  }
Beispiel #6
0
  @Override
  protected void onNewIntent(Intent intent) {
    if (checkLaunchState(LaunchState.GeckoExiting)) {
      // We're exiting and shouldn't try to do anything else just incase
      // we're hung for some reason we'll force the process to exit
      System.exit(0);
      return;
    }
    final String action = intent.getAction();
    if (ACTION_DEBUG.equals(action)
        && checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) {

      mMainHandler.postDelayed(
          new Runnable() {
            public void run() {
              Log.i(LOG_FILE_NAME, "Launching from debug intent after 5s wait");
              setLaunchState(LaunchState.Launching);
              launch(null);
            }
          },
          1000 * 5 /* 5 seconds */);
      Log.i(LOG_FILE_NAME, "Intent : ACTION_DEBUG - waiting 5s before launching");
      return;
    }
    if (checkLaunchState(LaunchState.WaitForDebugger) || launch(intent)) return;

    if (Intent.ACTION_MAIN.equals(action)) {
      Log.i(LOG_FILE_NAME, "Intent : ACTION_MAIN");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
    } else if (Intent.ACTION_VIEW.equals(action)) {
      String uri = intent.getDataString();
      GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
      Log.i(LOG_FILE_NAME, "onNewIntent: " + uri);
    } else if (ACTION_WEBAPP.equals(action)) {
      String uri = intent.getStringExtra("args");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
      Log.i(LOG_FILE_NAME, "Intent : WEBAPP - " + uri);
    } else if (ACTION_BOOKMARK.equals(action)) {
      String args = intent.getStringExtra("args");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(args));
      Log.i(LOG_FILE_NAME, "Intent : BOOKMARK - " + args);
    }
  }
Beispiel #7
0
 public void addEnvToIntent(Intent intent) {
   Map<String, String> envMap = System.getenv();
   Set<Map.Entry<String, String>> envSet = envMap.entrySet();
   Iterator<Map.Entry<String, String>> envIter = envSet.iterator();
   int c = 0;
   while (envIter.hasNext()) {
     Map.Entry<String, String> entry = envIter.next();
     intent.putExtra("env" + c, entry.getKey() + "=" + entry.getValue());
     c++;
   }
 }
Beispiel #8
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    String filePickerResult = "";
    if (data != null && resultCode == RESULT_OK) {
      try {
        ContentResolver cr = getContentResolver();
        Uri uri = data.getData();
        Cursor cursor =
            GeckoApp.mAppContext
                .getContentResolver()
                .query(uri, new String[] {OpenableColumns.DISPLAY_NAME}, null, null, null);
        String name = null;
        if (cursor != null) {
          try {
            if (cursor.moveToNext()) {
              name = cursor.getString(0);
            }
          } finally {
            cursor.close();
          }
        }
        String fileName = "tmp_";
        String fileExt = null;
        int period;
        if (name == null || (period = name.lastIndexOf('.')) == -1) {
          String mimeType = cr.getType(uri);
          fileExt = "." + GeckoAppShell.getExtensionFromMimeType(mimeType);
        } else {
          fileExt = name.substring(period);
          fileName = name.substring(0, period);
        }
        File file = File.createTempFile(fileName, fileExt, sGREDir);

        FileOutputStream fos = new FileOutputStream(file);
        InputStream is = cr.openInputStream(uri);
        byte[] buf = new byte[4096];
        int len = is.read(buf);
        while (len != -1) {
          fos.write(buf, 0, len);
          len = is.read(buf);
        }
        fos.close();
        filePickerResult = file.getAbsolutePath();
      } catch (Exception e) {
        Log.e(LOG_FILE_NAME, "showing file picker", e);
      }
    }
    try {
      mFilePickerResult.put(filePickerResult);
    } catch (InterruptedException e) {
      Log.i(LOG_FILE_NAME, "error returning file picker result", e);
    }
  }
Beispiel #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    final String ID = intent.getStringExtra("ID");
    final String name = intent.getStringExtra("Name");
    final ActionBar actionBar = getSupportActionBar();

    setContentView(R.layout.individual_colour_change_layout);

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    ColH = settings.getInt("houCol" + ID, getResources().getColor(R.color.clokH));
    ColM = settings.getInt("minCol" + ID, getResources().getColor(R.color.clokM));
    ColS = settings.getInt("secCol" + ID, getResources().getColor(R.color.clokS));
    String currentTitle = name + ": " + getString(R.string.chsColour);
    if (actionBar != null) {
      actionBar.setTitle(currentTitle);
      actionBar.setDisplayUseLogoEnabled(false);
    }

    draw();

    Button reset = (Button) findViewById(R.id.reset);
    reset.setOnClickListener(
        v -> {
          Editor editor = settings.edit();
          ColH = IndividualColourChange.this.getResources().getColor(R.color.clokH);
          ColM = IndividualColourChange.this.getResources().getColor(R.color.clokM);
          ColS = IndividualColourChange.this.getResources().getColor(R.color.clokS);
          editor.putInt("houCol" + ID, ColH);
          editor.putInt("minCol" + ID, ColM);
          editor.putInt("secCol" + ID, ColS);
          editor.apply();
          IndividualColourChange.this.draw();
        });

    ImageView colPickH = (ImageView) findViewById(R.id.colorHou);
    colPickH.setClickable(true);
    colPickH.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColH = color;
                    Editor editor = settings.edit();
                    editor.putInt("houCol" + ID, ColH);
                    editor.apply();
                    draw();
                  },
                  ColH);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.hHandCol));
          dlg.show();
        });

    ImageView colPickM = (ImageView) findViewById(R.id.colorMin);
    colPickM.setClickable(true);
    colPickM.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColM = color;
                    Editor editor = settings.edit();
                    editor.putInt("minCol" + ID, ColM);
                    editor.apply();
                    draw();
                  },
                  ColM);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.mHandCol));
          dlg.show();
        });

    ImageView colPickS = (ImageView) findViewById(R.id.colorSec);
    colPickS.setClickable(true);
    colPickS.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColS = color;
                    Editor editor = settings.edit();
                    editor.putInt("minCol" + ID, ColS);
                    editor.apply();
                    draw();
                  },
                  ColS);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.sHandCol));
          dlg.show();
        });
  }
  public void onCreate() {
    int flags, screenLightVal = 1;
    Sensor mSensor;
    List<Sensor> sensors;

    if (scanData == null) return; // no ScanData, not possible to run correctly...

    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    try {
      screenLightVal = Integer.parseInt(SP.getString("screenLight", "2"));
    } catch (NumberFormatException nfe) {
    }
    if (screenLightVal == 1) flags = PowerManager.PARTIAL_WAKE_LOCK;
    else if (screenLightVal == 3) flags = PowerManager.FULL_WAKE_LOCK;
    else flags = PowerManager.SCREEN_DIM_WAKE_LOCK;
    wl = pm.newWakeLock(flags, "OpenWLANMap");
    wl.acquire();
    while (myWLocate == null) {
      try {
        myWLocate = new MyWLocate(this);
        break;
      } catch (IllegalArgumentException iae) {
        myWLocate = null;
      }
      try {
        Thread.sleep(100);
      } catch (InterruptedException ie) {
      }
    }

    try {
      scanData.setUploadThres(Integer.parseInt(SP.getString("autoUpload", "0")));
    } catch (NumberFormatException nfe) {
    }
    try {
      scanData.setNoGPSExitInterval(
          Integer.parseInt(SP.getString("noGPSExitInterval", "0")) * 60 * 1000);
    } catch (NumberFormatException nfe) {
    }

    Intent intent = new Intent(this, OWMapAtAndroid.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);

    notification =
        new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.icon)
            .setContentTitle(getResources().getText(R.string.app_name))
            .setContentText("")
            .setContentIntent(pendIntent)
            .build();

    notification.flags |= Notification.FLAG_NO_CLEAR;
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    startForeground(1703, notification);

    getScanData().setService(this);
    getScanData().setmView(new HUDView(this));
    getScanData().getmView().setValue(getScanData().incStoredValues());
    WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.LEFT | Gravity.BOTTOM;
    params.setTitle("Load Average");
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(getScanData().getmView(), params);

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
        SensorManager.SENSOR_DELAY_GAME);
    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
        SensorManager.SENSOR_DELAY_GAME);
    sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
    mSensor = sensors.get(0);
    getScanData().getTelemetryData().setAccelMax(mSensor.getMaximumRange());
    telemetryDir = Environment.getExternalStorageDirectory().getPath() + "/telemetry/";
    File dir = new File(telemetryDir);
    dir.mkdir();

    connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
  }
Beispiel #11
0
  @Override
  protected void onCreate(Bundle icicle) {

    Log.d("GODOT", "** GODOT ACTIVITY CREATED HERE ***\n");

    super.onCreate(icicle);
    _self = this;
    Window window = getWindow();
    window.addFlags(
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // check for apk expansion API
    if (true) {
      boolean md5mismatch = false;
      command_line = getCommandLine();
      boolean use_apk_expansion = false;
      String main_pack_md5 = null;
      String main_pack_key = null;

      List<String> new_args = new LinkedList<String>();

      for (int i = 0; i < command_line.length; i++) {

        boolean has_extra = i < command_line.length - 1;
        if (command_line[i].equals("-use_apk_expansion")) {
          use_apk_expansion = true;
        } else if (has_extra && command_line[i].equals("-apk_expansion_md5")) {
          main_pack_md5 = command_line[i + 1];
          i++;
        } else if (has_extra && command_line[i].equals("-apk_expansion_key")) {
          main_pack_key = command_line[i + 1];
          SharedPreferences prefs = getSharedPreferences("app_data_keys", MODE_PRIVATE);
          Editor editor = prefs.edit();
          editor.putString("store_public_key", main_pack_key);

          editor.commit();
          i++;
        } else if (command_line[i].trim().length() != 0) {
          new_args.add(command_line[i]);
        }
      }

      if (new_args.isEmpty()) {
        command_line = null;
      } else {

        command_line = new_args.toArray(new String[new_args.size()]);
      }
      if (use_apk_expansion && main_pack_md5 != null && main_pack_key != null) {
        // check that environment is ok!
        if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
          Log.d("GODOT", "**ERROR! No media mounted!");
          // show popup and die
        }

        // Build the full path to the app's expansion files
        try {
          expansion_pack_path =
              Environment.getExternalStorageDirectory().toString()
                  + "/Android/obb/"
                  + this.getPackageName();
          expansion_pack_path +=
              "/"
                  + "main."
                  + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode
                  + "."
                  + this.getPackageName()
                  + ".obb";
        } catch (Exception e) {
          e.printStackTrace();
        }

        File f = new File(expansion_pack_path);

        boolean pack_valid = true;
        Log.d("GODOT", "**PACK** - Path " + expansion_pack_path);

        if (!f.exists()) {

          pack_valid = false;
          Log.d("GODOT", "**PACK** - File does not exist");

        } else if (obbIsCorrupted(expansion_pack_path, main_pack_md5)) {
          Log.d("GODOT", "**PACK** - Expansion pack (obb) is corrupted");
          pack_valid = false;
          try {
            f.delete();
          } catch (Exception e) {
            Log.d("GODOT", "**PACK** - Error deleting corrupted expansion pack (obb)");
          }
        }

        if (!pack_valid) {
          Log.d("GODOT", "Pack Invalid, try re-downloading.");

          Intent notifierIntent = new Intent(this, this.getClass());
          notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

          PendingIntent pendingIntent =
              PendingIntent.getActivity(this, 0, notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT);

          int startResult;
          try {
            Log.d("GODOT", "INITIALIZING DOWNLOAD");
            startResult =
                DownloaderClientMarshaller.startDownloadServiceIfRequired(
                    getApplicationContext(), pendingIntent, GodotDownloaderService.class);
            Log.d("GODOT", "DOWNLOAD SERVICE FINISHED:" + startResult);

            if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
              Log.d("GODOT", "DOWNLOAD REQUIRED");
              // This is where you do set up to display the download
              // progress (next step)
              mDownloaderClientStub =
                  DownloaderClientMarshaller.CreateStub(this, GodotDownloaderService.class);

              setContentView(com.godot.game.R.layout.downloading_expansion);
              mPB = (ProgressBar) findViewById(com.godot.game.R.id.progressBar);
              mStatusText = (TextView) findViewById(com.godot.game.R.id.statusText);
              mProgressFraction = (TextView) findViewById(com.godot.game.R.id.progressAsFraction);
              mProgressPercent = (TextView) findViewById(com.godot.game.R.id.progressAsPercentage);
              mAverageSpeed = (TextView) findViewById(com.godot.game.R.id.progressAverageSpeed);
              mTimeRemaining = (TextView) findViewById(com.godot.game.R.id.progressTimeRemaining);
              mDashboard = findViewById(com.godot.game.R.id.downloaderDashboard);
              mCellMessage = findViewById(com.godot.game.R.id.approveCellular);
              mPauseButton = (Button) findViewById(com.godot.game.R.id.pauseButton);
              mWiFiSettingsButton = (Button) findViewById(com.godot.game.R.id.wifiSettingsButton);

              return;
            } else {
              Log.d("GODOT", "NO DOWNLOAD REQUIRED");
            }
          } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            Log.d("GODOT", "Error downloading expansion package:" + e.getMessage());
          }
        }
      }
    }

    initializeGodot();

    //	instanceSingleton( new GodotFacebook(this) );

  }