@Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case MSG_SET_TTY_MODE_RESPONSE:
       {
         Log.v(TtyManager.this, "got setTtyMode response");
         AsyncResult ar = (AsyncResult) msg.obj;
         if (ar.exception != null) {
           Log.d(TtyManager.this, "setTTYMode exception: %s", ar.exception);
         }
         mPhone.queryTTYMode(obtainMessage(MSG_GET_TTY_MODE_RESPONSE));
         break;
       }
     case MSG_GET_TTY_MODE_RESPONSE:
       {
         Log.v(TtyManager.this, "got queryTTYMode response");
         AsyncResult ar = (AsyncResult) msg.obj;
         if (ar.exception != null) {
           Log.d(TtyManager.this, "queryTTYMode exception: %s", ar.exception);
         } else {
           int ttyMode = phoneModeToTelecomMode(((int[]) ar.result)[0]);
           if (ttyMode != mTtyMode) {
             Log.d(
                 TtyManager.this,
                 "setting TTY mode failed, attempted %d, got: %d",
                 mTtyMode,
                 ttyMode);
           } else {
             Log.d(TtyManager.this, "setting TTY mode to %d succeeded", ttyMode);
           }
         }
         break;
       }
   }
 }
Example #2
0
  public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    // If your preview can change or rotate, take care of those events here.
    // Make sure to stop the preview before resizing or reformatting it.

    if (mHolder.getSurface() == null) {
      // preview surface does not exist
      return;
    }

    // stop preview before making changes
    try {
      mCamera.stopPreview();

      Log.v(TAG, "stopPreview");

      googleGlassXE10WorkAround(mCamera);

    } catch (Exception e) {
      // ignore: tried to stop a non-existent preview
      Log.d(TAG, "Tried to stop a non-existent preview: " + e.getMessage());
    }

    // start preview with new settings
    try {
      mCamera.setPreviewDisplay(mHolder);
      mCamera.startPreview();
      Log.v(TAG, "startPreview");

    } catch (Exception e) {
      Log.d(TAG, "Error starting camera preview: " + e.getMessage());
    }
  }
Example #3
0
 /**
  * M: copy one file from source to target
  *
  * @author mtk54296
  * @param from source
  * @param to target
  * @return @{
  */
 private static int copyFile(String from, String to) {
   Log.v("source: " + from + "  target: " + to);
   int result = 0;
   if (TextUtils.isEmpty(from) || TextUtils.isEmpty(to)) {
     result = -1;
   }
   Log.v("media mounted: " + Environment.getExternalStorageState());
   if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
     java.io.InputStream fis = null;
     java.io.OutputStream fos = null;
     try {
       fis = new java.io.FileInputStream(from);
       fos = new java.io.FileOutputStream(to);
       byte bt[] = new byte[1024];
       int c;
       while ((c = fis.read(bt)) > 0) {
         fos.write(bt, 0, c);
       }
       fos.flush();
       fos.close();
       fis.close();
     } catch (IOException e) {
       e.printStackTrace();
       Log.v("copy ringtone file error: " + e.toString());
       result = -1;
     }
   }
   return result;
 }
  public ManagePreferences(Context _context, String _contactId) {
    contactId = _contactId;
    context = _context;
    useDatabase = false;

    if (Log.DEBUG) Log.v("contactId = " + contactId);
    long contactIdLong;
    try {
      contactIdLong = Long.parseLong(contactId);
    } catch (NumberFormatException e) {
      contactIdLong = 0;
    }

    if (contactIdLong > 0) {
      mDbAdapter = new SmsPopupDbAdapter(context);
      try {
        mDbAdapter.open(true); // Open database read-only
        contactCursor = mDbAdapter.fetchContactSettings(contactIdLong);
        if (contactCursor != null) {
          if (Log.DEBUG) Log.v("Contact found - using database");
          useDatabase = true;
        }
        mDbAdapter.close();
      } catch (SQLException e) {
        if (Log.DEBUG) Log.v("Error opening or creating database");
        useDatabase = false;
      }
    } else {
      if (Log.DEBUG) Log.v("Contact NOT found - using prefs");
    }

    mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  }
  /** Handle receiving a MMS message */
  private void handleMmsReceived(Intent intent) {
    if (Log.DEBUG) Log.v("MMS received!");
    SmsMmsMessage mmsMessage = null;
    int count = 0;

    // Ok this is super hacky, but fixes the case where this code
    // runs before the system MMS transaction service (that stores
    // the MMS details in the database). This should really be
    // a content listener that waits for a while then gives up...
    while (mmsMessage == null && count < MESSAGE_RETRY) {

      mmsMessage = SmsPopupUtils.getMmsDetails(context);

      if (mmsMessage != null) {
        if (Log.DEBUG) Log.v("MMS found in content provider");
        notifyMessageReceived(mmsMessage);
      } else {
        if (Log.DEBUG) Log.v("MMS not found, sleeping (count is " + count + ")");
        count++;
        try {
          Thread.sleep(MESSAGE_RETRY_PAUSE);
        } catch (InterruptedException e) {
          // e.printStackTrace();
        }
      }
    }
  }
 public static void setReminder(
     Context context,
     long id,
     String title,
     long dueDate,
     long listId,
     long reminderDate,
     long reminderInterval) {
   String actionName = context.getResources().getString(R.string.intent_action_alarm);
   Intent alarmIntent = new Intent(actionName);
   alarmIntent.putExtra(NotificationUtils.ID, id);
   alarmIntent.putExtra(NotificationUtils.TITLE, title);
   alarmIntent.putExtra(NotificationUtils.DUE_DATE, dueDate);
   alarmIntent.putExtra(NotificationUtils.LIST_ID, listId);
   PendingIntent alarmPendingIntent =
       PendingIntent.getBroadcast(context, getNotificationId(id), alarmIntent, 0);
   AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
   if (reminderInterval > 0) {
     alarmManager.setRepeating(
         AlarmManager.RTC_WAKEUP, reminderDate, reminderInterval, alarmPendingIntent);
     if (Log.LOGV) Log.v("TaskDetailDialog set recurring reminder at " + dueDate);
   } else {
     alarmManager.set(AlarmManager.RTC_WAKEUP, reminderDate, alarmPendingIntent);
     if (Log.LOGV) Log.v("TaskDetailDialog set reminder at " + dueDate);
   }
 }
 /*
  * Handle the results from the recognition activity.
  */
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (Log.DEBUG) Log.v("onActivityResult");
   if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
     ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
     if (Log.DEBUG) Log.v("Voice recog text: " + matches.get(0));
     quickReply(matches.get(0));
   }
 }
Example #8
0
  /**
   * function to set up alarm flag
   *
   * @return
   */
  private static void alarm_path_setup(String alarmPath, FileWriter command) {
    try {
      command.write(alarmPath);
      command.write("\n");
    } catch (Exception e) {
      Log.v(ALARM_FLAG_FILE + "write error");
    } finally {

      Log.v(ALARM_FLAG_FILE + " write done");
    }
  }
Example #9
0
 /**
  * function to cancel alarm flag
  *
  * @return
  */
 private static void alarm_flag_cancel() {
   if (ALARM_FLAG_FILE.exists()) {
     Log.v(ALARM_FLAG_FILE + " exist");
     try {
       ALARM_FLAG_FILE.delete();
       Log.v(ALARM_FLAG_FILE + " delete success");
     } catch (Exception e) {
       Log.v(ALARM_FLAG_FILE + " delete failed");
     }
   } else {
     Log.v(ALARM_FLAG_FILE + " already delete");
   }
 }
Example #10
0
  private boolean execute(DataManager manager, JobContext jc, int cmd, Path path) {
    boolean result = true;
    Log.v(TAG, "Execute cmd: " + cmd + " for " + path);
    long startTime = System.currentTimeMillis();

    switch (cmd) {
      case R.id.action_delete:
        manager.delete(path);
        break;
      case R.id.action_rotate_cw:
        manager.rotate(path, 90);
        break;
      case R.id.action_rotate_ccw:
        manager.rotate(path, -90);
        break;
      case R.id.action_toggle_full_caching:
        {
          MediaObject obj = manager.getMediaObject(path);
          int cacheFlag = obj.getCacheFlag();
          if (cacheFlag == MediaObject.CACHE_FLAG_FULL) {
            cacheFlag = MediaObject.CACHE_FLAG_SCREENNAIL;
          } else {
            cacheFlag = MediaObject.CACHE_FLAG_FULL;
          }
          obj.cache(cacheFlag);
          break;
        }
      case R.id.action_show_on_map:
        {
          MediaItem item = (MediaItem) manager.getMediaObject(path);
          double latlng[] = new double[2];
          item.getLatLong(latlng);
          if (GalleryUtils.isValidLocation(latlng[0], latlng[1])) {
            GalleryUtils.showOnMap((Context) mActivity, latlng[0], latlng[1]);
          }
          break;
        }
      case R.id.action_import:
        {
          MediaObject obj = manager.getMediaObject(path);
          result = obj.Import();
          break;
        }
      default:
        throw new AssertionError();
    }
    Log.v(
        TAG,
        "It takes " + (System.currentTimeMillis() - startTime) + " ms to execute cmd for " + path);
    return result;
  }
Example #11
0
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    // No intent, tell the system not to restart us.
    if (intent == null) {
      stopSelf();
      return START_NOT_STICKY;
    }

    final Alarm alarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);

    if (alarm == null) {
      Log.v("AlarmKlaxon failed to parse the alarm from the intent");
      stopSelf();
      return START_NOT_STICKY;
    }

    if (mCurrentAlarm != null) {
      sendKillBroadcast(mCurrentAlarm);
    }

    play(alarm);
    mCurrentAlarm = alarm;
    // Record the initial call state here so that the new alarm has the
    // newest state.
    mInitialCallState = mTelephonyManager.getCallState();

    return START_STICKY;
  }
Example #12
0
  public void readLangFile(String language) {
    String filename = getLangFolder() + File.separator + language + ".yml";

    try {
      Configuration config = new Configuration(new File(filename));

      config.load();

      List<String> keys = config.getKeys();

      if (!langDb.containsKey(language)) {
        langDb.put(language, new HashMap<String, String>());
      }

      Map<String, String> langMap = langDb.get(language);

      for (Iterator<String> it = keys.iterator(); it.hasNext(); ) {
        String key = it.next();

        Log.v("Adding " + language + "." + key + ";");
        langMap.put(key, config.getString(key));
      }

      Log.d("Done parsing localization file '" + filename + "' for language '" + language + "'");
    } catch (Exception ex) {
      Log.e("Could not load localizaion file '" + filename + "'");
    }
  }
Example #13
0
 public static Alarm calculateNextAlert(final Context context) {
   Alarm alarm = null;
   long minTime = Long.MAX_VALUE;
   long now = System.currentTimeMillis();
   Cursor cursor = getFilteredAlarmsCursor(context.getContentResolver());
   if (cursor != null) {
     if (cursor.moveToFirst()) {
       do {
         Alarm a = new Alarm(context, cursor);
         // A time of 0 indicates this is a repeating alarm, so
         // calculate the time to get the next alert.
         if (a.time == 0) {
           a.time = calculateAlarm(a);
         } else if (a.time < now) {
           Log.v("Disabling expired alarm set for " + Log.formatTime(a.time));
           // Expired alarm, disable it and move along.
           enableAlarmInternal(context, a, false);
           continue;
         }
         if (a.time < minTime) {
           minTime = a.time;
           alarm = a;
         }
       } while (cursor.moveToNext());
     }
     cursor.close();
   }
   return alarm;
 }
 // change screen lock time out
 public static void setScreenTimeOut(int value) {
   if (Log.LOGV) {
     Log.v(t + ".setScreenTimeOut(): value = " + value);
   }
   Settings.System.putInt(
       OBS.getInstance().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, value);
 }
 // change screen brightness
 public static void switchBrightness(int value) {
   if (Log.LOGV) {
     Log.v(t + ".switchBrightness(): value = " + value);
   }
   Settings.System.putInt(
       OBS.getInstance().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, value);
 }
Example #16
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   Log.v(TAG, getClass().getSimpleName() + ".onSaveInstanceState (" + hashCode() + ")");
   super.onSaveInstanceState(outState);
   outState.putInt(PrefKey.opentab.name(), getCurrentTab());
   outState.putBundle("fragData", m_fragData);
 }
Example #17
0
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    if (Log.LOGV) Log.v("onAttachedToWindow " + this);

    if (mAttached) return;
    mAttached = true;

    if (mLive) {
      /* monitor time ticks, time changed, timezone */
      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_TIME_TICK);
      filter.addAction(Intent.ACTION_TIME_CHANGED);
      filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
      getContext().registerReceiver(mIntentReceiver, filter);
    }

    /* monitor 12/24-hour display preference */
    mFormatChangeObserver = new FormatChangeObserver();
    getContext()
        .getContentResolver()
        .registerContentObserver(Settings.System.CONTENT_URI, true, mFormatChangeObserver);

    updateTime();
  }
  private String[] internalGetSinglePass() {

    switch (type) {
      case TYPE_NO_GOOD:
        Log.v("");
      case TYPE_NO_CHANGE:
      case TYPE_TWO_PASS:
        return null;
    }

    ArrayList<String> cmd = new ArrayList<String>();
    cmd.add("ffmpeg");
    cmd.add("-i");
    cmd.add(conversionSetting.getOriginalVideoFile().getAbsolutePath());
    cmd.add("-vcodec");
    cmd.add("copy");
    if (type == TYPE_CONVERT_ONLY_AUDIO) {
      addAudioConversion(cmd);
    } else {
      cmd.add("-acodec");
      cmd.add("copy");
    }

    cmd.add("-movflags");
    cmd.add("+faststart");
    cmd.add(conversionSetting.getTempVideoFile().getAbsolutePath());

    return getArray(cmd);
  }
Example #19
0
  private static String getAlarmPath(Context context, Alarm alarm) {
    String alert = alarm.alert.toString();
    Uri alertUri = null;
    if (alert.contains("alarm_alert")) {
      String value = Settings.System.getString(context.getContentResolver(), "alarm_alert");
      alertUri = Uri.parse(value);
    } else {
      alertUri = alarm.alert;
    }
    String[] project = {"_data"};
    String path = "";
    Cursor cursor = context.getContentResolver().query(alertUri, project, null, null, null);
    try {
      if (cursor != null && cursor.moveToFirst()) {
        path = cursor.getString(0);
        Log.v("path" + path);
      }
    } catch (Exception ex) {

    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }
    return path;
  }
Example #20
0
  private void updateNotification(Context context, Alarm alarm, int timeout) {
    NotificationManager nm = getNotificationManager(context);

    // If the alarm is null, just cancel the notification.
    if (alarm == null) {
      if (Log.LOGV) {
        Log.v("Cannot update notification for killer callback");
      }
      return;
    }

    // Launch SetAlarm when clicked.
    Intent viewAlarm = new Intent(context, SetAlarm.class);
    viewAlarm.putExtra(Alarms.ALARM_ID, alarm.id);
    PendingIntent intent = PendingIntent.getActivity(context, alarm.id, viewAlarm, 0);

    // Update the notification to indicate that the alert has been
    // silenced.
    String label = alarm.getLabelOrDefault(context);
    Notification n = new Notification(R.drawable.stat_notify_alarm, label, alarm.time);
    n.setLatestEventInfo(
        context, label, context.getString(R.string.alarm_alert_alert_silenced, timeout), intent);
    n.flags |= Notification.FLAG_AUTO_CANCEL;
    // We have to cancel the original notification since it is in the
    // ongoing section and we want the "killed" notification to be a plain
    // notification.
    nm.cancel(alarm.id);
    nm.notify(alarm.id, n);
  }
Example #21
0
  private static ContentValues createContentValues(Context ctx, Alarm alarm) {
    ContentValues values = new ContentValues(8);
    // Set the alarm_time value if this alarm does not repeat. This will be
    // used later to disable expire alarms.
    long time = 0;
    if (!alarm.daysOfWeek.isRepeatSet()) {
      time = calculateAlarm(alarm);
    }

    // -1 means generate new id.
    if (alarm.id != -1) {
      values.put(Alarm.Columns._ID, alarm.id);
    }

    values.put(Alarm.Columns.ENABLED, alarm.enabled ? 1 : 0);
    values.put(Alarm.Columns.HOUR, alarm.hour);
    values.put(Alarm.Columns.MINUTES, alarm.minutes);
    values.put(Alarm.Columns.ALARM_TIME, time);
    values.put(Alarm.Columns.DAYS_OF_WEEK, alarm.daysOfWeek.getCoded());
    values.put(Alarm.Columns.VIBRATE, alarm.vibrate);
    values.put(Alarm.Columns.MESSAGE, alarm.label);

    // A null alert Uri indicates a silent alarm.
    values.put(
        Alarm.Columns.ALERT, alarm.alert == null ? ALARM_ALERT_SILENT : alarm.alert.toString());
    if (alarm.alert != null && alarm.alert.toString().contains("external")) {
      Log.v(" external uri = " + alarm.alert.toString());
      values.put(Alarm.Columns.PATH, getExternalRingtonePath(ctx, alarm.alert));
    }
    /// M: add for playing external ringtone for power-off alarm
    //        Alarms.backupRingtoneForPoweroffAlarm(ctx, null);
    return values;
  }
  @Override
  protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);

    if (Log.DEBUG) Log.v("onPrepareDialog()");
    // User interacted so remove all locks and cancel reminders
    ClearAllReceiver.removeCancel(getApplicationContext());
    ClearAllReceiver.clearAll(false);
    ReminderReceiver.cancelReminder(getApplicationContext());

    switch (id) {
      case DIALOG_QUICKREPLY:
        showSoftKeyboard(qrEditText);

        // Set width of dialog to fill_parent
        LayoutParams mLP = dialog.getWindow().getAttributes();

        // TODO: this should be limited in case the screen is large
        mLP.width = LayoutParams.FILL_PARENT;
        dialog.getWindow().setAttributes(mLP);
        break;

      case DIALOG_PRESET_MSG:
        break;
    }
  }
  /*
   * Customized activity finish. Ensures the notification is in sync and cancels
   * any scheduled reminders (as the user has interrupted the app.
   */
  private void myFinish() {
    if (Log.DEBUG) Log.v("myFinish()");

    if (inbox) {
      ManageNotification.clearAll(getApplicationContext());
    } else {

      // Start a service that will update the notification in the status bar
      Intent i = new Intent(getApplicationContext(), SmsPopupUtilsService.class);
      i.setAction(SmsPopupUtilsService.ACTION_UPDATE_NOTIFICATION);

      // Convert current message to bundle
      i.putExtras(message.toBundle());

      // We need to know if the user is replying - if so, the entire thread id should
      // be ignored when working out the message tally in the notification bar.
      // We can't rely on the system database as it may take a little while for the
      // reply intent to fire and load up the messaging up (after which the messages
      // will be marked read in the database).
      i.putExtra(SmsMmsMessage.EXTRAS_REPLYING, replying);

      // Start the service
      SmsPopupUtilsService.beginStartingService(SmsPopupActivity.this.getApplicationContext(), i);
    }

    // Cancel any reminder notifications
    ReminderReceiver.cancelReminder(getApplicationContext());

    // Finish up the activity
    finish();
  }
  @Override
  protected void onPause() {
    super.onPause();
    if (Log.DEBUG) Log.v("SMSPopupActivity: onPause()");

    // Hide the soft keyboard in case it was shown via quick reply
    hideSoftKeyboard();

    // Shutdown eyes-free TTS
    if (eyesFreeTts != null) {
      eyesFreeTts.shutdown();
    }

    // Shutdown Android TTS
    if (androidTextToSpeechAvailable) {
      if (androidTts != null) {
        androidTts.shutdown();
      }
    }

    // Dismiss loading dialog
    if (mProgressDialog != null) {
      mProgressDialog.dismiss();
    }

    if (wasVisible) {
      // Cancel the receiver that will clear our locks
      ClearAllReceiver.removeCancel(getApplicationContext());
      ClearAllReceiver.clearAll(!exitingKeyguardSecurely);
    }

    mDbAdapter.close();
  }
  /*
   * (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 #26
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(
        TAG,
        getClass().getSimpleName()
            + ".onCreate ("
            + hashCode()
            + "): "
            + (savedInstanceState != null));

    ApiCompatUtil compatUtil = ApiCompatUtil.getInstance();
    compatUtil.requestWindowFeatures(this);
    setContentView(R.layout.prime);
    compatUtil.setWindowFeatures(this);

    compatUtil.setupActionBar(this);

    int curTab = DEFAULT_TAB;

    if (savedInstanceState != null) {
      Bundle fragData = savedInstanceState.getBundle("fragData");
      if (fragData != null) {
        Log.d(TAG, "MainActivity.onCreate: got fragData!");
        for (String key : fragData.keySet()) {
          Log.d(TAG, "  fragData key: " + key);
          if (!m_fragData.containsKey(key)) m_fragData.putBundle(key, fragData.getBundle(key));
        }
      }

      curTab = savedInstanceState.getInt(PrefKey.opentab.name(), DEFAULT_TAB);
    }

    boolean upgraded = false;
    if (savedInstanceState != null) {
      //      setCurrentTab(savedInstanceState.getInt(PrefKey.opentab.name(), -1));
    } else {
      Resources resources = getResources();
      SharedPreferences p = StaticUtils.getApplicationPreferences(this);
      upgraded = StaticUtils.checkUpgrade(this);
      if (!readInstanceState(this)) setInitialState();
      if (PrefKey.sync_on_open.getBoolean(p, resources)) {
        WeaveAccountInfo loginInfo = StaticUtils.getLoginInfo(this);
        if (upgraded || loginInfo == null) {
          StaticUtils.requestSync(this, m_handler);
        }
      }
    }

    FragmentManager fm = getSupportFragmentManager();
    // You can find Fragments just like you would with a View by using FragmentManager.
    Fragment fragment = fm.findFragmentById(R.id.fragment_content);

    // If we are using activity_fragment_xml.xml then this the fragment will not be null, otherwise
    // it will be.
    if (fragment == null) {
      setMyFragment(new MiscListFragment(), false);
    }
  }
 /** Show the soft keyboard and store the view that triggered it */
 private void showSoftKeyboard(View triggerView) {
   if (Log.DEBUG) Log.v("showSoftKeyboard()");
   if (inputManager == null) {
     inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
   }
   inputView = triggerView;
   inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
 }
  @Override
  public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (Log.DEBUG) Log.v("SMSPopupActivity: onSaveInstanceState()");

    // Save values from most recent bundle (ie. most recent message)
    outState.putAll(bundle);
  }
 @Override
 protected void onResume() {
   super.onResume();
   if (Log.DEBUG) Log.v("SMSPopupActivity: onResume()");
   wasVisible = false;
   // Reset exitingKeyguardSecurely bool to false
   exitingKeyguardSecurely = false;
 }
 @Override
 protected void onPostExecute(Bitmap result) {
   if (Log.DEBUG) Log.v("Done loading contact photo");
   contactPhoto = result;
   if (result != null) {
     setContactPhoto(photoImageView, contactPhoto);
   }
 }