package net.everythingandroid.smspopup;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.preference.PreferenceManager;
import android.provider.Contacts;
import android.provider.Settings;
import android.provider.Contacts.PeopleColumns;
import android.provider.Contacts.PhotosColumns;
import android.telephony.PhoneNumberUtils;
import android.telephony.gsm.SmsMessage;
import android.text.TextUtils;
public class SMSPopupUtils {
//Content URIs for SMS app, these may change in future SDK
public static final Uri MMS_SMS_CONTENT_URI = Uri.parse("content://mms-sms/");
public static final Uri THREAD_ID_CONTENT_URI =
Uri.withAppendedPath(MMS_SMS_CONTENT_URI, "threadID");
public static final Uri CONVERSATION_CONTENT_URI =
Uri.withAppendedPath(MMS_SMS_CONTENT_URI, "conversations");
public static final Uri SMS_INBOX_CONTENT_URI = Uri.parse("content://sms/inbox");
public static final Uri MMS_CONTENT_URI = Uri.parse("content://mms");
public static final Uri MMS_INBOX_CONTENT_URI = Uri.withAppendedPath(MMS_CONTENT_URI, "inbox");
public static final String SMS_ID = "_id";
public static final String SMS_TO_URI = "smsto:/";
public static final String SMS_MIME_TYPE = "vnd.android-dir/mms-sms";
public static final String SMS_ADDRESS_EXTRA = "address";
public static final int READ_THREAD = 1;
public static final int MESSAGE_TYPE_SMS = 1;
public static final int MESSAGE_TYPE_MMS = 2;
private static final String TIME_FORMAT_12_HOUR = "h:mm a";
private static final String TIME_FORMAT_24_HOUR = "H:mm";
public static String getPersonName(Context context, String id, String address) {
if (id == null) {
if (address != null) {
Log.v("Contact not found, formatting number");
return PhoneNumberUtils.formatNumber(address);
} else {
return null;
}
}
Cursor cursor = context.getContentResolver().query(
Uri.withAppendedPath(Contacts.People.CONTENT_URI, id),
new String[] { PeopleColumns.DISPLAY_NAME }, null, null, null);
if (cursor != null) {
try {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
String name = cursor.getString(0);
Log.v("Contact Display Name: " + name);
return name;
}
} finally {
cursor.close();
}
}
if (address != null) {
Log.v("Contact not found, formatting number");
return PhoneNumberUtils.formatNumber(address);
}
return null;
}
public static String getPersonIdFromPhoneNumber(Context context,
String address) {
if (address == null)
return null;
Cursor cursor = context.getContentResolver().query(
Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, address),
new String[] { Contacts.Phones.PERSON_ID }, null, null, null);
if (cursor != null) {
try {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
Long id = Long.valueOf(cursor.getLong(0));
Log.v("Found person: " + id);
return (String.valueOf(id));
}
} finally {
cursor.close();
}
}
return null;
}
public static byte[] getPersonPhoto(Context context, String id) {
if (id == null)
return null;
byte photo[] = null;
Cursor cursor = context.getContentResolver().query(
Uri.withAppendedPath(Contacts.Photos.CONTENT_URI, id),
new String[] { PhotosColumns.DATA }, null, null, null);
if (cursor != null) {
try {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
photo = cursor.getBlob(0);
if (photo != null) {
return photo;
// Log.v("Found photo for person: " + id);
// bitmap = BitmapFactory.decodeStream(new
// ByteArrayInputStream(photo));
}
}
} finally {
cursor.close();
}
}
return photo;
}
public static long getThreadIdFromAddress(Context context, String address) {
if (address == null) return 0;
String THREAD_RECIPIENT_QUERY = "recipient";
Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
uriBuilder.appendQueryParameter(THREAD_RECIPIENT_QUERY, address);
long threadId = 0;
Cursor cursor = context.getContentResolver().query(
uriBuilder.build(),
new String[] { SMS_ID },
null, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
threadId = cursor.getLong(0);
}
} finally {
cursor.close();
}
}
return threadId;
}
public static void setThreadRead(Context context, long threadId) {
SharedPreferences myPrefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean markRead = myPrefs.getBoolean(
context.getString(R.string.pref_markread_key),
Boolean.valueOf(context.getString(R.string.pref_markread_default)));
if (!markRead) return;
if (threadId > 0) {
ContentValues values = new ContentValues(1);
values.put("read", READ_THREAD);
ContentResolver cr = context.getContentResolver();
int result = 0;
try {
result = cr.update(
ContentUris.withAppendedId(CONVERSATION_CONTENT_URI, threadId),
values, null, null);
} catch (Exception e) {
Log.v("error marking thread read");
}
Log.v("thread id " + threadId + " marked as read, result = " + result);
}
}
public static Intent getSmsIntent() {
Intent conversations = new Intent(Intent.ACTION_MAIN);
//conversations.addCategory(Intent.CATEGORY_DEFAULT);
conversations.setType(SMS_MIME_TYPE);
//TODO: use FLAG_ACTIVITY_RESET_TASK_IF_NEEDED??
int flags =
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_CLEAR_TOP;
conversations.setFlags(flags);
return conversations;
}
public static Intent getSmsToIntentFromThreadId(Context context, long threadId) {
Intent popup = new Intent(Intent.ACTION_VIEW);
//TODO: use FLAG_ACTIVITY_RESET_TASK_IF_NEEDED??
int flags =
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_CLEAR_TOP;
popup.setFlags(flags);
if (threadId > 0) {
Log.v("^^Found threadId (" + threadId + "), sending to Sms intent");
popup.setData(Uri.withAppendedPath(THREAD_ID_CONTENT_URI, String.valueOf(threadId)));
} else {
return getSmsIntent();
}
return popup;
}
public static void launchEmailToIntent(Context context, String subject, boolean includeDebug) {
Intent msg = new Intent(Intent.ACTION_SEND);
String[] recipients={"Adam K <adam@everythingandroid.net>"};
String body = "";
if (includeDebug) {
body = "\n\n----------\nSysinfo - " + Build.FINGERPRINT + "\n"
+ "Model: " + Build.MODEL + "\n\n";
String[] pref_keys = {
context.getString(R.string.pref_enabled_key),
context.getString(R.string.pref_timeout_key),
context.getString(R.string.pref_privacy_key),
context.getString(R.string.pref_markread_key),
context.getString(R.string.pref_onlyShowOnKeyguard_key),
context.getString(R.string.pref_blur_key),
context.getString(R.string.pref_notif_enabled_key),
context.getString(R.string.pref_notif_sound_key),
context.getString(R.string.pref_vibrate_key),
context.getString(R.string.pref_vibrate_pattern_key),
context.getString(R.string.pref_vibrate_pattern_custom_key),
context.getString(R.string.pref_flashled_key),
context.getString(R.string.pref_flashled_color_key),
context.getString(R.string.pref_notif_repeat_key),
context.getString(R.string.pref_notif_repeat_times_key
没有合适的资源?快使用搜索试试~ 我知道了~
SMSPOPUP源代码.
共213个文件
svn-base:59个
class:46个
format:22个
4星 · 超过85%的资源 需积分: 10 92 下载量 168 浏览量
2011-04-13
17:32:20
上传
评论 1
收藏 320KB RAR 举报
温馨提示
ANDROID上的SMSPOPUP源代码,短信增强软件源码,具有推送至桌面显示,快捷回复,关键字查询,黑名单等功能。
资源推荐
资源详情
资源评论
收起资源包目录
SMSPOPUP源代码. (213个子文件)
all-wcprops 2KB
all-wcprops 2KB
all-wcprops 1KB
all-wcprops 1KB
all-wcprops 505B
all-wcprops 422B
all-wcprops 368B
all-wcprops 331B
all-wcprops 204B
all-wcprops 196B
all-wcprops 196B
all-wcprops 196B
all-wcprops 196B
all-wcprops 192B
all-wcprops 98B
all-wcprops 98B
all-wcprops 80B
all-wcprops 80B
all-wcprops 79B
all-wcprops 76B
all-wcprops 76B
all-wcprops 76B
resources.ap_ 59KB
SMSPopup.apk 88KB
SMSPopupUtils.class 15KB
SMSPopupActivity.class 9KB
ManageNotification.class 8KB
SMSReceiverService.class 8KB
SmsMmsMessage.class 7KB
R$string.class 6KB
ReminderReceiverService.class 5KB
CustomVibrateListPreference.class 4KB
SMSPopupUtilsService.class 4KB
ReminderReceiver.class 4KB
ManageWakeLock.class 3KB
CustomVibrateListPreference$1.class 3KB
ClearAllReceiver.class 2KB
ManageKeyguard.class 2KB
SMSPopupConfigActivity.class 2KB
ReminderReceiverService$ServiceHandler.class 2KB
DialogCheckBoxPreference.class 2KB
SMSPopupUtilsService$ServiceHandler.class 2KB
SMSReceiverService$ServiceHandler.class 2KB
AppEnabledCheckBoxPreference.class 2KB
TestNotificationDialogPreference.class 2KB
SMSPopupActivity$4.class 2KB
SMSPopupActivity$5.class 2KB
SMSPopupActivity$1.class 2KB
EmailDialogPreference.class 2KB
R$id.class 2KB
SMSPopupActivity$2.class 2KB
SMSPopupActivity$4$1.class 1KB
SMSPopupActivity$5$1.class 1KB
SMSPopupActivity$3.class 1KB
SMSPopupActivity$3$1.class 1KB
SMSPopupActivity$2$1.class 1KB
ManageKeyguard$1.class 1KB
SMSReceiver.class 1KB
DialogCheckBoxPreference$1.class 1015B
R.class 851B
R$array.class 847B
SMSPopupUtils$MmsMessage.class 842B
Log.class 687B
R$drawable.class 555B
R$style.class 532B
R$layout.class 504B
R$color.class 466B
R$xml.class 428B
R$attr.class 376B
ManageKeyguard$LaunchOnKeyguardExit.class 310B
.classpath 238B
classes.dex 62KB
dir-prop-base 61B
entries 3KB
entries 3KB
entries 1KB
entries 1KB
entries 944B
entries 832B
entries 787B
entries 645B
entries 461B
entries 448B
entries 447B
entries 447B
entries 447B
entries 445B
entries 386B
entries 306B
entries 306B
entries 297B
entries 297B
entries 279B
entries 279B
entries 272B
format 2B
format 2B
format 2B
format 2B
format 2B
共 213 条
- 1
- 2
- 3
DeepVodka
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
- 基于stm32f103+空心杯电机+oled按键+运动算法
- 《CKA/CKAD应试指南/从docker到kubernetes 完全攻略》学习笔记 第1章docker基础(1.1-1.4)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页