Exemplo n.º 1
0
  /**
   * Default Constructor.
   *
   * @param c {@link ConversationListActivity}
   */
  public ConversationAdapter(final Activity c) {
    super(c, R.layout.conversationlist_item, null, true);
    activity = c;

    SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(activity);
    useGridLayout = PreferencesActivity.getGridlayoutEnabled(activity);
    if (useGridLayout) {
      super.setViewResource(R.layout.conversation_square);
    }
    final ContentResolver cr = c.getContentResolver();
    queryHandler = new BackgroundQueryHandler(cr);
    SpamDB spam = new SpamDB(c);
    spam.open();
    blacklist = spam.getAllEntries();
    spam.close();

    defaultContactAvatar = c.getResources().getDrawable(R.drawable.ic_contact_picture);

    convertNCR = PreferencesActivity.decodeDecimalNCR(c);
    showEmoticons = PreferencesActivity.showEmoticons(c);
    textSize = PreferencesActivity.getTextsize(c);
    textColor = PreferencesActivity.getTextcolor(c);

    Cursor cursor = null;
    try {
      cursor = cr.query(Conversation.URI_SIMPLE, Conversation.PROJECTION_SIMPLE, null, null, null);
    } catch (SQLiteException e) {
      Log.e(TAG, "error getting conversations", e);
    }
    /* {@link Cursor} to the original Content to listen for changes. */
    Cursor origCursor = cursor;

    if (origCursor != null) {
      origCursor.registerContentObserver(
          new ContentObserver(new Handler()) {
            @Override
            public void onChange(final boolean selfChange) {
              super.onChange(selfChange);
              if (!selfChange) {
                Log.d(TAG, "call startMsgListQuery();");
                ConversationAdapter.this.startMsgListQuery();
                Log.d(TAG, "invalidate cache");
                Conversation.invalidate();
              }
            }
          });
    }
    // startMsgListQuery();
  }
 /**
  * Get a {@link Intent} for sending a new message.
  *
  * @param context {@link Context}
  * @param address address
  * @return {@link Intent}
  */
 static Intent getComposeIntent(
     final Context context, // .
     final String address) {
   final Intent i = new Intent(Intent.ACTION_SENDTO);
   i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   if (address == null) {
     i.setData(Uri.parse("sms:"));
   } else {
     i.setData(Uri.parse("smsto:" + PreferencesActivity.fixNumber(context, address)));
   }
   return i;
 }
Exemplo n.º 3
0
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.activity_info);

    if (!PreferencesActivity.getStringPreference(R.string.last_database_migration_key, null)
        .equals(""))
      ((TextView) findViewById(R.id.tv_local_database_version))
          .setText(
              PreferencesActivity.getStringPreference(R.string.last_database_migration_key, null));
    else
      ((TextView) findViewById(R.id.tv_local_database_version)).setText(R.string.info_no_database);

    if (!PreferencesActivity.getStringPreference(R.string.database_migration_duration_key, null)
        .equals(""))
      ((TextView) findViewById(R.id.tv_duration_last_update))
          .setText(
              PreferencesActivity.getStringPreference(
                      R.string.database_migration_duration_key, null)
                  + " "
                  + getText(R.string.time_entity));
    else ((TextView) findViewById(R.id.tv_duration_last_update)).setText(R.string.info_no_database);
  }
  /** {@inheritDoc} */
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    final Intent i = this.getIntent();
    Log.d(TAG, "got intent: " + i.getAction());
    Log.d(TAG, "got uri: " + i.getData());
    Log.d(TAG, "got extra: " + i.getExtras());

    this.setTheme(PreferencesActivity.getTheme(this));
    Utils.setLocale(this);
    this.setContentView(R.layout.conversationlist);

    ChangelogHelper.showChangelog(this, true);
    final List<ResolveInfo> ri =
        this.getPackageManager()
            .queryBroadcastReceivers(new Intent("de.ub0r.android.websms.connector.INFO"), 0);
    if (ri.size() == 0) {
      final Intent intent =
          Market.getInstallAppIntent(this, "de.ub0r.android.websms", Market.ALT_WEBSMS);
      ChangelogHelper.showNotes(this, true, "get WebSMS", null, intent);
    } else {
      ChangelogHelper.showNotes(this, true, null, null, null);
    }

    showRows(this);

    final ListView list = this.getListView();
    this.adapter = new ConversationAdapter(this);
    this.setListAdapter(this.adapter);
    list.setOnItemClickListener(this);
    list.setOnItemLongClickListener(this);
    this.longItemClickDialog = new String[WHICH_N];
    this.longItemClickDialog[WHICH_ANSWER] = this.getString(R.string.reply);
    this.longItemClickDialog[WHICH_CALL] = this.getString(R.string.call);
    this.longItemClickDialog[WHICH_VIEW_CONTACT] = this.getString(R.string.view_contact_);
    this.longItemClickDialog[WHICH_VIEW] = this.getString(R.string.view_thread_);
    this.longItemClickDialog[WHICH_DELETE] = this.getString(R.string.delete_thread_);
    this.longItemClickDialog[WHICH_MARK_SPAM] = this.getString(R.string.filter_spam_);
  }
 /** {@inheritDoc} */
 @Override
 public void onCreate(final Bundle savedInstanceState) {
   this.setTheme(PreferencesActivity.getTheme(this));
   super.onCreate(savedInstanceState);
   Log.d(TAG, "onCreate();");
   final Bundle extras = this.getIntent().getExtras();
   if (extras == null) {
     this.finish();
     return;
   }
   this.connector = new ConnectorSpec(this.getIntent());
   if (this.connector == null) {
     this.finish();
     return;
   }
   this.setContentView(R.layout.captcha);
   this.setTitle(this.connector.getName() + " - " + this.getString(R.string.captcha_));
   this.getSupportActionBar().setHomeButtonEnabled(true);
   WebSMSApp.fixActionBarBackground(
       this.getSupportActionBar(),
       this.getResources(),
       R.drawable.bg_striped,
       R.drawable.bg_striped_img);
   final Parcelable p = extras.getParcelable(Connector.EXTRA_CAPTCHA_DRAWABLE);
   if (p != null && p instanceof Bitmap) {
     ((ImageView) this.findViewById(R.id.captcha)).setImageBitmap((Bitmap) p);
   } else {
     this.finish();
     return;
   }
   final String t = extras.getString(Connector.EXTRA_CAPTCHA_MESSAGE);
   if (t != null) {
     ((TextView) this.findViewById(R.id.text)).setText(t);
   }
   this.findViewById(R.id.ok).setOnClickListener(this);
   this.findViewById(R.id.cancel).setOnClickListener(this);
 }