@Override
  public void onBackPressed() {
    Log.i(this, "onBackPressed");

    // BACK is also used to exit out of any "special modes" of the
    // in-call UI:

    if (!mConferenceManagerFragment.isVisible() && !mCallCardFragment.isVisible()) {
      return;
    }

    if (mDialpadFragment != null && mDialpadFragment.isVisible()) {
      mCallButtonFragment.displayDialpad(false /* show */, true /* animate */);
      return;
    } else if (mConferenceManagerFragment.isVisible()) {
      showConferenceCallManager(false);
      return;
    }

    // Always disable the Back key while an incoming call is ringing
    final Call call = CallList.getInstance().getIncomingCall();
    if (call != null) {
      Log.d(this, "Consume Back press for an incoming call");
      return;
    }

    // Nothing special to do.  Fall back to the default behavior.
    super.onBackPressed();
  }
Example #2
0
  private void addSaveRequest(SaveRequest r) {
    synchronized (this) {
      // some time onDestroy() execute before add save request which is
      // through
      // post runnable
      synchronized (mSaveServiceObject) {
        if (mSaverService == null) {
          Log.e(TAG, "[addSaveRequest]mSaverService is null,return.");
          return;
        }

        while (mSaverService.getWaitingCount() >= QUEUE_LIMIT) {
          try {
            Log.i(TAG, "[addSaveRequest],waiting count > QUEUE_LIMIT 100,wait...");
            wait();
          } catch (InterruptedException ex) {
            // ignore.
            Log.e(TAG, "[addSaveRequest]exception:", ex);
          }
        }
        Log.i(TAG, "[addSaveRequest]mSaverService.addSaveRequest...");
        mSaverService.addSaveRequest(r);
      }
    }
  }
Example #3
0
 private void init() {
   Log.init("BlackList");
   Log.i("Application start init...");
   Context context = getApplicationContext();
   BlackListCache.init(context);
   Log.i("Application init completed.");
 }
 private void updateUiTtyMode(int ttyMode) {
   Log.i(this, "updateUiTtyMode %d -> %d", mUiTtyMode, ttyMode);
   if (mUiTtyMode != ttyMode) {
     mUiTtyMode = ttyMode;
     mPhone.setUiTTYMode(telecomModeToPhoneMode(ttyMode), null);
   } else {
     Log.i(this, "ui tty mode didnt change");
   }
 }
Example #5
0
    public void saveImageToDatabase(RequestOperator r) {
      Log.i(TAG, "[saveImageToDatabase]...");
      // Insert into MediaStore.
      ContentValues values = new ContentValues(14);
      values.put(ImageColumns.TITLE, r.mTitle);
      values.put(ImageColumns.DISPLAY_NAME, r.mFileName);
      values.put(ImageColumns.DATE_TAKEN, r.mDateTaken);
      values.put(ImageColumns.MIME_TYPE, r.mMimeType);
      values.put(ImageColumns.DATA, r.mFilePath);
      values.put(ImageColumns.SIZE, r.mDataSize);
      if (r.mLocation != null) {
        values.put(ImageColumns.LATITUDE, r.mLocation.getLatitude());
        values.put(ImageColumns.LONGITUDE, r.mLocation.getLongitude());
      }
      values.put(ImageColumns.ORIENTATION, r.mOrientation);
      // M: ConShots
      values.put(Images.Media.GROUP_ID, r.mGroupId);
      values.put(Images.Media.GROUP_INDEX, r.mGroupIndex);
      values.put(Images.Media.FOCUS_VALUE_HIGH, r.mFocusValueHigh);
      values.put(Images.Media.FOCUS_VALUE_LOW, r.mFocusValueLow);
      // Add for Refocus image database
      values.put(Images.Media.CAMERA_REFOCUS, r.mTag);
      values.put(ImageColumns.WIDTH, r.mWidth);
      values.put(ImageColumns.HEIGHT, r.mHeight);
      try {
        r.mUri = mContentResolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
        if (r.mUri != null) {
          mContext.addSecureAlbumItemIfNeeded(false, r.mUri);
          if (mContext.isNonePickIntent()) {
            // picture taken and saved by camera which is launched
            // by 3rd apps will
            // be inserted into DB. But do not broadcast
            // "New_Picture" intent,
            // otherwise, it will not pass camera CTS test.
            Util.broadcastNewPicture(mContext, r.mUri);
          }
          Log.i(TAG, "[saveImageToDatabase]mUri = " + r.mUri);
        }

      } catch (IllegalArgumentException e) { // Here we keep google
        // default, don't
        // follow check style
        // This can happen when the external volume is already mounted,
        // but
        // MediaScanner has not notify MediaProvider to add that volume.
        // The picture is still safe and MediaScanner will find it and
        // insert it into MediaProvider. The only problem is that the
        // user
        // cannot click the thumbnail to review the picture.
        Log.e(TAG, "[saveImageToDatabase]Failed to write MediaStore,IllegalArgumentException:", e);
      } catch (UnsupportedOperationException e) {
        Log.e(
            TAG,
            "[saveImageToDatabase]Failed to write MediaStore," + "UnsupportedOperationException:",
            e);
      }
    }
Example #6
0
 public void initAddPageData() {
   Log.i("Init add page data...");
   Context context = getApplicationContext();
   Conversation.init(context);
   RecipientIdCache.init(context);
   Contact.init(context);
   CallLog.init(context);
   Log.i("Init add page data completed.");
   mInitedAddPage = true;
 }
Example #7
0
 public static Boolean addLoadPath(String scriptsDir) {
   if (new File(scriptsDir).exists()) {
     Log.i("Added directory to load path: " + scriptsDir);
     Script.addDir(scriptsDir);
     runScriptlet("$:.unshift '" + scriptsDir + "' ; $:.uniq!");
     Log.d("Changing JRuby current directory to " + scriptsDir);
     callScriptingContainerMethod(Void.class, "setCurrentDirectory", scriptsDir);
     return true;
   } else {
     Log.i("Extra scripts dir not present: " + scriptsDir);
     return false;
   }
 }
  @Override
  public void onRequestPermissionsResult(
      int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    if (requestCode == PBPreferenceFragment.PERMISSION_READ_EXTERNAL_STORAGE) {
      if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        Log.i("PBPreferenceFragment", "READ_EXTERNAL_STORAGE permission granted.");
        preferenceFragment.testMediaSender(); // continue to next step
      } else {
        Log.i("PBPreferenceFragment", "READ_EXTERNAL_STORAGE was NOT granted.");
        Toast.makeText(this, R.string.toast_permission_not_granted, Toast.LENGTH_LONG).show();
      }
    }
  }
  @Override
  protected void onResume() {
    Log.i(this, "onResume()...");
    super.onResume();

    mIsForegroundActivity = true;

    InCallPresenter.getInstance().setThemeColors();
    InCallPresenter.getInstance().onUiShowing(true);

    if (mShowDialpadRequested) {
      mCallButtonFragment.displayDialpad(true /* show */, mAnimateDialpadOnShow /* animate */);
      mShowDialpadRequested = false;
      mAnimateDialpadOnShow = false;

      if (mDialpadFragment != null) {
        mDialpadFragment.setDtmfText(mDtmfText);
        mDtmfText = null;
      }
    }

    if (mShowPostCharWaitDialogOnResume) {
      showPostCharWaitDialog(mShowPostCharWaitDialogCallId, mShowPostCharWaitDialogChars);
    }
  }
  /**
   * Called when there is a change to the call list. Sets the In-Call state for the entire in-call
   * app based on the information it gets from CallList. Dispatches the in-call state to all
   * listeners. Can trigger the creation or destruction of the UI based on the states that is
   * calculates.
   */
  @Override
  public void onCallListChange(CallList callList) {
    if (callList == null) {
      return;
    }
    InCallState newState = getPotentialStateFromCallList(callList);
    newState = startOrFinishUi(newState);

    // Renable notification shade and soft navigation buttons, if we are no longer in the
    // incoming call screen
    if (!newState.isIncoming()) {
      if (mAccelerometerListener != null) {
        mAccelerometerListener.enableSensor(false);
      }
      CallCommandClient.getInstance().setSystemBarNavigationEnabled(true);
    }

    // Set the new state before announcing it to the world
    Log.i(this, "Phone switching state: " + mInCallState + " -> " + newState);
    mInCallState = newState;

    // notify listeners of new state
    for (InCallStateListener listener : mListeners) {
      Log.d(this, "Notify " + listener + " of state " + mInCallState.toString());
      listener.onStateChange(mInCallState, callList);
    }

    if (isActivityStarted()) {
      final boolean hasCall =
          callList.getActiveOrBackgroundCall() != null || callList.getOutgoingCall() != null;
      mInCallActivity.dismissKeyguard(hasCall);
    }
  }
Example #11
0
 @Override
 protected Boolean doInBackground(String... args) {
   this.request = this.createRequest();
   try {
     this.performRequest(this.getUrl());
   } catch (IOException e) {
     e.printStackTrace();
     this.error_message = "Failed to connect to the server";
     return false;
   }
   String data;
   try {
     data = this.request.body();
     Log.i(data);
   } catch (Exception e1) {
     e1.printStackTrace();
     return false;
   }
   try {
     doc = this.request.getXML();
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
Example #12
0
  public void handleMoving(String[] fields) {
    String volunteerString = fields[1];
    String startString = fields[2];
    String destinationString = fields[3];
    int transitTime = Integer.parseInt(fields[4]);

    Log.i(
        "MOVING: volunteer=%s start=%s destination=%s transitTime=%d",
        volunteerString, startString, destinationString, transitTime);

    Volunteer volunteer = model.getVolunteerByName(volunteerString);
    if (volunteer == null) {
      Log.w("Haven't seen moving volunteer %s yet", volunteerString);
      return;
    }

    Location start = model.getLocationByName(startString);
    if (start == null) {
      Log.w("Haven't see start location %s yet", startString);
      return;
    }

    Location destination = model.getLocationByName(destinationString);
    if (destination == null) {
      Log.w("Haven't seen destination location %s yet", destinationString);
      return;
    }

    if (!start.getName().equals(startString))
      Log.w(
          "MOVING violation: %s not at %s but rather at %s",
          volunteerString, startString, start.getName());

    volunteer.startMoving(destination, transitTime);
  }
Example #13
0
  public void handleRequest(String[] fields) {
    String requesterName = fields[1];
    String startString = fields[2];
    String destinationString = fields[3];
    int value = Integer.parseInt(fields[4]);

    Log.i(
        "REQUEST: requester=%s start=%s, destination=%s value=%d",
        requesterName, startString, destinationString, value);

    // Remove any old request with the same name...
    Request request = model.getRequestByName(requesterName);
    if (request != null) model.removeRequest(request);

    Location start = model.getLocationByName(startString);
    Location destination = model.getLocationByName(destinationString);

    if (start == null) {
      Log.w("Haven't see the request start location %s yet", startString);
      return;
    }

    if (destination == null) {
      Log.w("Haven't see the request destination location %s yet", destinationString);
      return;
    }

    new Request(model, requesterName, start, destination, value);
  }
Example #14
0
    @Override
    public synchronized void saveRequest() {
      if (mData == null) {
        Log.w(TAG, "[saveRequest]mData is null,return!");
        return;
      }
      int orientation = Exif.getOrientation(mData);
      // M: ConShots
      mGroupId = Exif.getGroupId(mData);
      mGroupIndex = Exif.getGroupIndex(mData);
      mFocusValueHigh = Exif.getFocusValueHigh(mData);
      mFocusValueLow = Exif.getFocusValueLow(mData);
      mOrientation = orientation;
      mDataSize = mData.length;

      if (null != mFileName) {
        mTitle = mFileName.substring(0, mFileName.indexOf('.'));
      } else {
        mTitle = createName(mFileType, mDateTaken, mGroupIndex);
        mFileName = Storage.generateFileName(mTitle, mTempPictureType);
        Log.i(TAG, "[saveRequest]PhotoOperator,mFileName = " + mFileName);
      }
      mFilePath = Storage.generateFilepath(mFileName);
      mTempFilePath = mFilePath + TEMP_SUFFIX;
      saveImageToSDCard(mTempFilePath, mFilePath, mData);
      // camera decouple
      mMimeType = Storage.generateMimetype(mTitle, mTempPictureType);
      checkDataProperty();
      saveImageToDatabase(this);
    }
Example #15
0
 // Return null when we cannot instantiate a BlobCache, e.g.:
 // there is no SD card found.
 // This can only be called from data thread.
 public static BlobCache getCache(
     Context context, String filename, int maxEntries, int maxBytes, int version) {
   synchronized (sCacheMap) {
     if (!sOldCheckDone) {
       removeOldFilesIfNecessary(context);
       sOldCheckDone = true;
     }
     BlobCache cache = sCacheMap.get(filename);
     if (cache == null) {
       /// M: [BEHAVIOR.MODIFY] @{
       /*File cacheDir = context.getExternalCacheDir();*/
       File cacheDir = FeatureHelper.getExternalCacheDir(context);
       if (cacheDir == null) {
         Log.e(TAG, "<getCache> failed to get cache dir");
         return null;
       }
       /// @}
       String path = cacheDir.getAbsolutePath() + "/" + filename;
       try {
         /// M: [DEBUG.ADD] @{
         Log.i(TAG, "<getCache> new BlobCache, path = " + path);
         /// @}
         cache = new BlobCache(path, maxEntries, maxBytes, false, version);
         sCacheMap.put(filename, cache);
       } catch (IOException e) {
         Log.e(TAG, "Cannot instantiate cache!", e);
       }
     }
     return cache;
   }
 }
  /** Utility function to bring up a generic "error" dialog. */
  private void showErrorDialog(CharSequence msg) {
    Log.i(this, "Show Dialog: " + msg);

    dismissPendingDialogs();

    mDialog =
        new AlertDialog.Builder(this)
            .setMessage(msg)
            .setPositiveButton(
                android.R.string.ok,
                new OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    onDialogDismissed();
                  }
                })
            .setOnCancelListener(
                new OnCancelListener() {
                  @Override
                  public void onCancel(DialogInterface dialog) {
                    onDialogDismissed();
                  }
                })
            .create();

    mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    mDialog.show();
  }
 /**
  * A dialog could have prevented in-call screen from being previously finished. This function
  * checks to see if there should be any UI left and if not attempts to tear down the UI.
  */
 public void onDismissDialog() {
   Log.i(this, "Dialog dismissed");
   if (mInCallState == InCallState.NO_CALLS) {
     attemptFinishActivity();
     attemptCleanup();
   }
 }
Example #18
0
  protected void unpackComponents() throws IOException, FileNotFoundException {
    File applicationPackage = new File(getApplication().getPackageResourcePath());
    File componentsDir = new File(sGREDir, "components");
    if (componentsDir.lastModified() == applicationPackage.lastModified()) return;

    componentsDir.mkdir();
    componentsDir.setLastModified(applicationPackage.lastModified());

    GeckoAppShell.killAnyZombies();

    ZipFile zip = new ZipFile(applicationPackage);

    byte[] buf = new byte[32768];
    try {
      if (unpackFile(zip, buf, null, "removed-files")) removeFiles();
    } catch (Exception ex) {
      // This file may not be there, so just log any errors and move on
      Log.w(LOG_FILE_NAME, "error removing files", ex);
    }

    // copy any .xpi file into an extensions/ directory
    Enumeration<? extends ZipEntry> zipEntries = zip.entries();
    while (zipEntries.hasMoreElements()) {
      ZipEntry entry = zipEntries.nextElement();
      if (entry.getName().startsWith("extensions/") && entry.getName().endsWith(".xpi")) {
        Log.i("GeckoAppJava", "installing extension : " + entry.getName());
        unpackFile(zip, buf, entry, entry.getName());
      }
    }
  }
  protected Object handleAutoRotateSaveState() {
    Log.i("" + this.getClass(), "asked to prep object to save state prior to autorotate");

    ArrayList<EntityManager> l = new ArrayList<EntityManager>();
    l.add(em);
    return l;
  }
  /*
   * (non-Javadoc)
   *
   * @see android.content.ContentProvider#insert(android.net.Uri,
   * android.content.ContentValues)
   */
  @Override
  public Uri insert(Uri uri, ContentValues values) {

    ContentValues newValues = null;
    ContentValues outValues;
    Uri newUri = null;
    long rowId = 0;
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    if (db == null) {
      Log.v(TAG + " Fatal db object == null eeeek!");
      return null;
    }

    if (values != null) {
      outValues = new ContentValues(values);
    } else {
      outValues = new ContentValues();
    }

    switch (sUriMatcher.match(uri)) {
      case PROFILES:
        {
          newValues = preInsertProfiles(outValues);

          rowId = db.insert(PROFILES_TBL, null, newValues);
          if (rowId < 0) throw new SQLException("failed to insert profiles row " + uri);
          // update the insert row id
          // this is used for profile_id to link tables
          newUri = ContentUris.withAppendedId(Profile.Columns.CONTENT_URI, rowId);
          getContext().getContentResolver().notifyChange(newUri, null);
        }
        break;
      case CONTACTS:
        {
          rowId = db.insert(CONTACTS_TBL, null, outValues);
          if (rowId < 0) throw new SQLException("failed to insert contacts row " + uri);
          newUri = ContentUris.withAppendedId(Contacts.Columns.CONTENT_URI, rowId);
          getContext().getContentResolver().notifyChange(newUri, null);
          break; // <- that damn missing break took 10 minutes to find lol
        }

      case NOTIFICATION:
        {
          rowId = db.insert(NOTIFICATION_TBL, null, outValues);
          if (rowId < 0) throw new SQLException("failed to insert notification row " + uri);
          newUri = ContentUris.withAppendedId(Notify.Columns.CONTENT_URI, rowId);
          getContext().getContentResolver().notifyChange(newUri, null);
        }

        break;
      default:
        throw new IllegalArgumentException("Cannot insert null: " + uri);
    }

    if (Log.LOGV) Log.i(TAG + " new _id " + rowId + " new uri " + newUri);

    db.close();
    return newUri;
  }
Example #21
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();
 }
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ArrayList<EntityManager> cachedData =
        (ArrayList<EntityManager>) getLastNonConfigurationInstance();
    if (cachedData != null) {
      Log.i(
          getClass().getSimpleName(),
          "onCreate: ... found a LastNonConfigurationInstance, attempting to load it...");
      em = (EntityManager) cachedData.get(0);

      /** We loaded a cached copy of the ES, so have to manually do this auto-setup */
      MetaEntity.defaultEntityManager = em;
    }

    Log.i("" + this.getClass(), "activity onCreate");
  }
Example #23
0
 // copy JpegRotation,location ,record type and datetaken
 public SaveRequest copyPhotoRequest(SaveRequest originRequest) {
   Log.i(TAG, "[copyPhotoRequest]...");
   SaveRequest request = null;
   if (originRequest instanceof PhotoOperator) {
     request = ((PhotoOperator) originRequest).copyRequest();
   }
   return request;
 }
Example #24
0
 public void waitDone() {
   Log.i(TAG, "[waitDone]...");
   if (mSaverService == null) {
     Log.e(TAG, "[waitDone]mSaverService is null,return.");
     return;
   }
   synchronized (FileSaver.this) {
     while (mSaverService != null && !mSaverService.isNoneSaveTask()) {
       try {
         wait();
       } catch (InterruptedException ex) {
         Log.e(TAG, "[waitDone]exception :", ex);
       }
     }
   }
   Log.i(TAG, "[waitDone]");
 }
  private void handleSetTimer(Intent intent) {
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    // If no length is supplied , show the timer setup view
    if (!intent.hasExtra(EXTRA_LENGTH)) {
      startActivity(
          new Intent(this, DeskClock.class)
              .putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.TIMER_TAB_INDEX)
              .putExtra(TimerFragment.GOTO_SETUP_VIEW, true));
      return;
    }

    final long length = 1000l * intent.getIntExtra(EXTRA_LENGTH, 0);
    if (length < TIMER_MIN_LENGTH || length > TIMER_MAX_LENGTH) {
      Log.i("Invalid timer length requested: " + length);
      return;
    }
    String label = getMessageFromIntent(intent);

    TimerObj timer = null;
    // Find an existing matching time
    final ArrayList<TimerObj> timers = new ArrayList<TimerObj>();
    TimerObj.getTimersFromSharedPrefs(prefs, timers);
    for (TimerObj t : timers) {
      if (t.mSetupLength == length
          && (TextUtils.equals(label, t.mLabel))
          && t.mState == TimerObj.STATE_RESTART) {
        timer = t;
        break;
      }
    }

    boolean skipUi = intent.getBooleanExtra(EXTRA_SKIP_UI, false);
    if (timer == null) {
      // Use a new timer
      timer = new TimerObj(length, label);
      // Timers set without presenting UI to the user will be deleted after use
      timer.mDeleteAfterUse = skipUi;
    }

    timer.mState = TimerObj.STATE_RUNNING;
    timer.mStartTime = Utils.getTimeNow();
    timer.writeToSharedPref(prefs);

    // Tell TimerReceiver that the timer was started
    sendBroadcast(
        new Intent()
            .setAction(Timers.START_TIMER)
            .putExtra(Timers.TIMER_INTENT_EXTRA, timer.mTimerId));

    if (skipUi) {
      Utils.showInUseNotifications(this);
    } else {
      startActivity(
          new Intent(this, DeskClock.class)
              .putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.TIMER_TAB_INDEX));
    }
  }
Example #26
0
 @Override
 public void addRequest() {
   if (mData == null) {
     Log.w(TAG, "[addRequest]PhotoOperator,data is null,return!");
     return;
   }
   Log.i(TAG, "[addRequest]PhotoOperator...");
   addSaveRequest(this);
 }
  /**
   * Dismisses the in-call screen.
   *
   * <p>We never *really* finish() the InCallActivity, since we don't want to get destroyed and then
   * have to be re-created from scratch for the next call. Instead, we just move ourselves to the
   * back of the activity stack.
   *
   * <p>This also means that we'll no longer be reachable via the BACK button (since
   * moveTaskToBack() puts us behind the Home app, but the home app doesn't allow the BACK key to
   * move you any farther down in the history stack.)
   *
   * <p>(Since the Phone app itself is never killed, this basically means that we'll keep a single
   * InCallActivity instance around for the entire uptime of the device. This noticeably improves
   * the UI responsiveness for incoming calls.)
   */
  @Override
  public void finish() {
    Log.i(this, "finish().  Dialog showing: " + (mDialog != null));

    // skip finish if we are still showing a dialog.
    if (!hasPendingErrorDialog() && !mAnswerFragment.hasPendingDialogs()) {
      super.finish();
    }
  }
  @Override
  protected void onStart() {
    super.onStart();

    em = new EntityManager();
    MetaEntity.defaultEntityManager = em;
    Game game = new Game(em);

    /** create the surface + thread */
    SurfaceViewThePit surfaceView = new SurfaceViewThePit(this, game);
    RenderSystemSimpleDrawable renderSystem = new RenderSystemSimpleDrawable(em, surfaceView, game);
    MainRunThread runGameThread = new MainRunThread(this, em, surfaceView, renderSystem);
    runGameThread.loadAllCoreSubSystems();

    // runGameThread.setGameResult( gameToStart );
    SubsystemTouchHandler systemTh = new SubsystemTouchHandler(em);
    runGameThread.orderedSubSystems.addLast(systemTh); // MUST be before the Collision Subsystem
    TouchListenerPlayerMovement thv = new TouchListenerPlayerMovement(systemTh);

    SubsystemGhosts systemGhosts = new SubsystemGhosts(em, game);
    runGameThread.orderedSubSystems.addLast(systemGhosts);

    SubsystemMovementAndCollision systemCollision =
        new SubsystemMovementAndCollision(em, renderSystem);
    runGameThread.orderedSubSystems.addLast(systemCollision);

    SubsystemLighting systemLighting = new SubsystemLighting(em, game);
    runGameThread.orderedSubSystems.addLast(systemLighting);

    SubsystemTriggers systemTriggers = new SubsystemTriggers(this, em, game);
    runGameThread.orderedSubSystems.addLast(systemTriggers);

    surfaceView.setOnTouchListener(thv);
    surfaceView.thread = runGameThread;
    Log.i(getClass().getSimpleName(), "initialized thread and surface");

    /**
     * Finally ... tell the game that the ES is now valid, it's ship reference is OK, and it can do
     * game-setup
     */
    game.preSetupGame();
    renderSystem.shiftCanvasToKeepPositionOnScreen(
        new CPosition(
            game.initialPlayerLocation.x,
            game.initialPlayerLocation.y,
            game.mazeCellWidth,
            game.mazeCellHeight));

    // turn off the window's title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(surfaceView);
  }
Example #29
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;
  }
Example #30
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);
    }
  }