

・「カレンダーに登録」機能を追加しました。
メール一覧のロングクリックで、メールの件名をタイトルに本文を内容に設定して、カレンダーアプリを起動します。
・設定画面を実装しました。
起動時に表示するラベルを「受信トレイ」「送信済みメール」「前回終了時のラベル」「起動時に選択」から設定できます。
更新情報・アプリのダウンロードは、こちらです。
Intent intent = new Intent(Intent.ACTION_EDIT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra("title", "!タイトル!"); // タイトル intent.putExtra("description", "!内容!"); // 内容 intent.putExtra("eventLocation", "!場所!"); //場所 Calendar cal = Calendar.getInstance(); cal.set(2011, 4, 29, 20, 0); intent.putExtra("beginTime", cal.getTimeInMillis()); // 開始日時 cal.set(2011, 4, 29, 23, 0); intent.putExtra("endTime", cal.getTimeInMillis()); // 終了日時 intent.putExtra("allDay", true); // 終日 startActivity(intent);
Intent intentPref = new Intent(this,SettingActivity.class); // インテントへのインスタンス生成 try { startActivity(intentPref); // 設定画面(インテント)の起動 } catch (ActivityNotFoundException e) { Log.d(LOGTAG, "intentPrefErr=" + e.getMessage()); }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/title_left_image" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/title_left_text" android:layout_width="wrap_content" android:layout_height="fill_parent" android:ellipsize="none" android:singleLine="true" style="?android:attr/windowTitleStyle" android:gravity="center_vertical" /> <TextView android:id="@+id/title_right_text" android:layout_width="fill_parent" android:layout_height="fill_parent" android:ellipsize="end" android:singleLine="true" android:textColor="#ffffff" android:textStyle="italic" android:gravity="center_vertical" /> </LinearLayout> </RelativeLayout>
public class GmailResenderActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // タイトルバーをカスタム宣言 setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); // カスタムタイトル登録タイトルバーを更新したいところで、
// タイトルバー表示 ImageView iv = (ImageView) findViewById(R.id.title_left_image); // 左側イメージアイコン iv.setImageResource(R.drawable.icon); TextView tv; tv = (TextView) findViewById(R.id.title_left_text); // 左側タイトル tv.setText(selectedLabel); // ラベル名表示 tv = (TextView) findViewById(R.id.title_right_text); // 右側タイトル SpannableStringBuilder spannable = new SpannableStringBuilder(); spannable.append(account); // 右揃えの SPAN インスタンスを生成。 AlignmentSpan.Standard right_span = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE); // SPAN を SpannableStringBuilder に組み込む。 spannable.setSpan(right_span, 0, spannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(spannable);で出来上がり。
// コンテキストメニュー表示 @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) menuInfo; ListView listView = (ListView) view; Map map = (Map) listView.getItemAtPosition(adapterInfo.position); Log.d(LOGTAG, "DBG:onCreateContextMenu position=" + adapterInfo.position); menu.setHeaderTitle(map.get("name").toString() + map.get("subject").toString()); menu.add(getString(R.string.ContextMenuResend)); menu.add(getString(R.string.ContextMenuCopySubject)); menu.add(getString(R.string.ContextMenuCopyBody)); } // コンテキストメニュー処理部 @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) item.getMenuInfo(); Log.d(LOGTAG, "DBG:onContextItemSelected adapterInfo.position=" + adapterInfo.position); String strKindOfMenu = (String)item.getTitle(); Log.d(LOGTAG, "DBG:onContextItemSelected getTitle=" + strKindOfMenu); if(strKindOfMenu.equals(getString(R.string.ContextMenuResend))){ // 再送信/返信の時 setResendMessage(adapterInfo.position); }else{ // クリップボードにコピーの時 copySubjectBody(strKindOfMenu, adapterInfo.position); } return super.onContextItemSelected(item); } // 件名・本文をクリップボードへコピー protected void copySubjectBody(String strKindOfCopy, int position) { Map<String, Object> map = (Map<String, Object>) listview.getItemAtPosition(position); long messageId = (Long) map.get("messageId"); MessageCursor mc = gmail.getMessageCursorForMessageId(account, messageId); if(mc.next()){ ClipboardManager cm = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); // クリップボードマネージャ if(strKindOfCopy.equals(getString(R.string.ContextMenuCopySubject))){ // 件名をコピー cm.setText(mc.getSubject()); // クリップボードへ件名をコピー }else if(strKindOfCopy.equals(getString(R.string.ContextMenuCopyBody))){ // 本文をコピー cm.setText(Html.fromHtml(mc.getBody())); // クリップボードへ本文をコピー } Toast.makeText(this, strKindOfCopy + getString(R.string.msgFinish), Toast.LENGTH_SHORT).show(); // トーストで完了を表示 } }