import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_summary);
overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
summaryTextView = (TextView) findViewById(R.id.summary_text_view);
summaryTextViewDefaultColor = summaryTextView.getTextColors();
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
contactsLinearLayout = (LinearLayout) findViewById(R.id.contacts_linear_layout);
shutdownButton = (FloatingActionButton) findViewById(R.id.shutdown_button);
shutdownButton.setOnClickListener(this);
int flags = WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
getWindow().addFlags(flags);
// TODO: Sostituisci con BitmapDescriptorFactory.fromResource(R.drawable.ic_message) quando https://code.google.com/p/gmaps-api-issues/issues/detail?id=9011 sarà corretto
Drawable vectorDrawable = ContextCompat.getDrawable(this, R.drawable.ic_message);
int w = vectorDrawable.getIntrinsicWidth();
int h = vectorDrawable.getIntrinsicHeight();
vectorDrawable.setBounds(0, 0, w, h);
Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bm);
vectorDrawable.draw(canvas);
mapMarkerBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bm);
// :ODOT
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment);
mapFragment.getMapAsync(this);
smsUpdateReceiver = new SmsUpdateReceiver();
registerReceiver(smsUpdateReceiver, new IntentFilter("android.provider.Telephony.SMS_RECEIVED"));
sentSmsStatusReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int contactIndex = intent.getIntExtra(CONTACT_INDEX_EXTRA, -1);
if (contactIndex < 0 || contactIndex >= favoriteContacts.size())
return;
boolean smsDelivered = intent.getAction().equals(SMS_STATUS_DELIVERED_ACTION);
RoundedContactBadge contactBadge = (RoundedContactBadge) contactsLinearLayout.getChildAt(contactIndex);
if (smsDelivered)
contactBadge.setContactStatus(RoundedContactBadge.ContactStatus.DELIVERED);
else {
boolean smsSent = getResultCode() == Activity.RESULT_OK;
contactBadge.setContactStatus(smsSent ? RoundedContactBadge.ContactStatus.SENT : RoundedContactBadge.ContactStatus.ERROR);
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SMS_STATUS_SENT_ACTION);
filter.addAction(SMS_STATUS_DELIVERED_ACTION);
registerReceiver(sentSmsStatusReceiver, filter);
loadContactsIfNeeded();
if (savedInstanceState == null)
alertAllContacts();
}