Exemplo n.º 1
0
 // Load the .so
 static {
   System.loadLibrary("SDL");
   // System.loadLibrary("SDL_image");
   // System.loadLibrary("SDL_mixer");
   // System.loadLibrary("SDL_ttf");
   System.loadLibrary("main");
 }
Exemplo n.º 2
0
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   long start = System.currentTimeMillis();
   if (changed) {
     buildLayout();
   }
   // Logger.d(TAG, "onLayout in " + (System.currentTimeMillis() - start) + " ms");
 }
Exemplo n.º 3
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   long start = System.currentTimeMillis();
   if (IS_LARGE) {
     setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), getPx(80));
   } else {
     setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), getPx(68));
   }
   // Logger.d(TAG, "onMeasure in " + (System.currentTimeMillis() - start) + " ms");
 }
Exemplo n.º 4
0
  private void checkAndLaunchUpdate() {
    Log.i(LOG_FILE_NAME, "Checking for an update");

    int statusCode = 8; // UNEXPECTED_ERROR
    File baseUpdateDir = null;
    if (Build.VERSION.SDK_INT >= 8)
      baseUpdateDir = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
    else baseUpdateDir = new File(Environment.getExternalStorageDirectory().getPath(), "download");

    File updateDir = new File(new File(baseUpdateDir, "updates"), "0");

    File updateFile = new File(updateDir, "update.apk");
    File statusFile = new File(updateDir, "update.status");

    if (!statusFile.exists() || !readUpdateStatus(statusFile).equals("pending")) return;

    if (!updateFile.exists()) return;

    Log.i(LOG_FILE_NAME, "Update is available!");

    // Launch APK
    File updateFileToRun = new File(updateDir, getPackageName() + "-update.apk");
    try {
      if (updateFile.renameTo(updateFileToRun)) {
        String amCmd =
            "/system/bin/am start -a android.intent.action.VIEW "
                + "-n com.android.packageinstaller/.PackageInstallerActivity -d file://"
                + updateFileToRun.getPath();
        Log.i(LOG_FILE_NAME, amCmd);
        Runtime.getRuntime().exec(amCmd);
        statusCode = 0; // OK
      } else {
        Log.i(LOG_FILE_NAME, "Cannot rename the update file!");
        statusCode = 7; // WRITE_ERROR
      }
    } catch (Exception e) {
      Log.i(LOG_FILE_NAME, "error launching installer to update", e);
    }

    // Update the status file
    String status = statusCode == 0 ? "succeeded\n" : "failed: " + statusCode + "\n";

    OutputStream outStream;
    try {
      byte[] buf = status.getBytes("UTF-8");
      outStream = new FileOutputStream(statusFile);
      outStream.write(buf, 0, buf.length);
      outStream.close();
    } catch (Exception e) {
      Log.i(LOG_FILE_NAME, "error writing status file", e);
    }

    if (statusCode == 0) System.exit(0);
  }
Exemplo n.º 5
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++;
   }
 }
Exemplo n.º 6
0
 public Contribution(
     Uri localUri,
     String remoteUri,
     String filename,
     String description,
     long dataLength,
     Date dateCreated,
     Date dateUploaded,
     String creator,
     String editSummary) {
   super(
       localUri, remoteUri, filename, description, dataLength, dateCreated, dateUploaded, creator);
   this.editSummary = editSummary;
   timestamp = new Date(System.currentTimeMillis());
 }
Exemplo n.º 7
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);
    }
  }
Exemplo n.º 8
0
 public Contribution() {
   timestamp = new Date(System.currentTimeMillis());
 }
Exemplo n.º 9
0
  public void forceQuit() {

    System.exit(0);
  }
Exemplo n.º 10
0
  @Override
  protected boolean drawBubble(Canvas canvas) {
    if (messageLayout == null) {
      requestLayout();
      return false;
    }

    boolean isAnimated = false;

    if (messageLayout.isForwarded) {
      canvas.drawText("Forwarded message", 0, getPx(16), messageLayout.forwardingPaint);
      canvas.drawText("From", 0, getPx(35), messageLayout.forwardingPaint);
      canvas.drawText(
          messageLayout.forwarderNameMeasured,
          messageLayout.forwardOffset,
          getPx(35),
          messageLayout.senderPaint);
      canvas.save();
      canvas.translate(0, getPx(19) * 2);
      messageLayout.layout.draw(canvas);
      canvas.restore();
    } else {
      if (!messageLayout.isOut & messageLayout.isGroup) {
        canvas.drawText(messageLayout.senderNameMeasured, 0, getPx(16), messageLayout.senderPaint);
        canvas.save();
        canvas.translate(0, getPx(19));
        messageLayout.layout.draw(canvas);
        canvas.restore();
      } else {
        messageLayout.layout.draw(canvas);
      }
    }

    if (messageLayout.showState) {
      if (state == MessageState.PENDING) {
        canvas.save();
        canvas.translate(
            messageLayout.layoutRealWidth - getPx(12),
            messageLayout.layoutHeight - getPx(12) - getPx(3));
        canvas.drawCircle(getPx(6), getPx(6), getPx(6), clockIconPaint);
        double time = (System.currentTimeMillis() / 15.0) % (12 * 60);
        double angle = (time / (6 * 60)) * Math.PI;

        int x = (int) (Math.sin(-angle) * getPx(4));
        int y = (int) (Math.cos(-angle) * getPx(4));
        canvas.drawLine(getPx(6), getPx(6), getPx(6) + x, getPx(6) + y, clockIconPaint);

        x = (int) (Math.sin(-angle * 12) * getPx(5));
        y = (int) (Math.cos(-angle * 12) * getPx(5));
        canvas.drawLine(getPx(6), getPx(6), getPx(6) + x, getPx(6) + y, clockIconPaint);

        canvas.restore();

        clockOutPaint.setColor(COLOR_NORMAL);

        isAnimated = true;
      } else if (state == MessageState.READED
          && prevState == MessageState.SENT
          && (SystemClock.uptimeMillis() - stateChangeTime < STATE_ANIMATION_TIME)) {
        long animationTime = SystemClock.uptimeMillis() - stateChangeTime;
        float progress = easeStateFade(animationTime / (float) STATE_ANIMATION_TIME);
        int offset = (int) (getPx(5) * progress);
        int alphaNew = (int) (progress * 255);

        bounds(
            stateSent,
            messageLayout.layoutRealWidth - stateSent.getIntrinsicWidth() - offset,
            messageLayout.layoutHeight - stateSent.getIntrinsicHeight() - getPx(3));
        stateSent.setAlpha(255);
        stateSent.draw(canvas);

        bounds(
            stateHalfCheck,
            messageLayout.layoutRealWidth - stateHalfCheck.getIntrinsicWidth() + getPx(5) - offset,
            messageLayout.layoutHeight - stateHalfCheck.getIntrinsicHeight() - getPx(3));
        stateHalfCheck.setAlpha(alphaNew);
        stateHalfCheck.draw(canvas);

        clockOutPaint.setColor(COLOR_NORMAL);

        isAnimated = true;
      } else {
        Drawable stateDrawable = getStateDrawable(state);

        bounds(
            stateDrawable,
            messageLayout.layoutRealWidth - stateDrawable.getIntrinsicWidth(),
            messageLayout.layoutHeight - stateDrawable.getIntrinsicHeight() - getPx(3));
        stateDrawable.setAlpha(255);
        stateDrawable.draw(canvas);

        if (state == MessageState.READED) {
          bounds(
              stateSent,
              messageLayout.layoutRealWidth - stateSent.getIntrinsicWidth() - getPx(5),
              messageLayout.layoutHeight - stateDrawable.getIntrinsicHeight() - getPx(3));
          stateSent.setAlpha(255);
          stateSent.draw(canvas);
        }

        if (state == MessageState.FAILURE) {
          clockOutPaint.setColor(COLOR_ERROR);
        } else {
          clockOutPaint.setColor(COLOR_NORMAL);
        }
      }
    } else {
      clockOutPaint.setColor(COLOR_IN);
    }
    canvas.drawText(
        wireframe.date,
        messageLayout.layoutRealWidth - messageLayout.timeWidth + getPx(6),
        messageLayout.layoutHeight - getPx(4),
        clockOutPaint);
    return isAnimated;
  }