• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionee006ec46b68c2bd855cbf03593450ffde6bf679 (tree)
Zeit2013-01-30 17:56:31
AutorMasahiko, SAWAI <say@user...>
CommiterMasahiko, SAWAI

Log Message

Added intent name edit function

Ändern Zusammenfassung

Diff

--- a/intent-lab/AndroidManifest.xml
+++ b/intent-lab/AndroidManifest.xml
@@ -49,12 +49,14 @@
4949 </activity>
5050
5151 <!-- Activity List Viewer -->
52- <activity android:name=".ResolveInfoListActivity"
53- />
52+ <activity android:name=".ResolveInfoListActivity" />
5453 <!--
5554 android:theme="@android:style/Theme.Dialog"
5655 -->
5756
57+ <!-- Common Activity -->
58+ <activity android:name=".common.EditTextActivity" />
59+
5860 <!-- content provider -->
5961 <provider android:name=".intent.provider.IntentProvider"
6062 android:authorities="org.routine_work.intent_laboratory.intentsprovider"
--- a/intent-lab/README.txt
+++ b/intent-lab/README.txt
@@ -27,6 +27,7 @@ Intent の実験場ツールです. 以下のようなことができます。
2727 ** カテゴリ(リスト)
2828 ** エクストラ(マップ)
2929
30+
3031 ------------------------------------------------------------
3132 !! ビルドターゲット
3233
--- /dev/null
+++ b/intent-lab/res/layout/edit_text_activity.xml
@@ -0,0 +1,53 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<LinearLayout
3+ xmlns:android="http://schemas.android.com/apk/res/android"
4+ android:layout_width="fill_parent"
5+ android:layout_height="fill_parent"
6+ android:orientation="vertical"
7+>
8+ <!-- action bar -->
9+ <LinearLayout
10+ style="@style/actionbar"
11+ android:id="@+id/actionbar_container"
12+ >
13+ <ImageButton
14+ style="@style/actionbar_left_button"
15+ android:id="@+id/cancel_button"
16+ android:src="?attr/ic_clear"
17+ />
18+ <TextView
19+ style="@style/actionbar_title"
20+ android:id="@+id/title_textview"
21+ />
22+ <ImageButton
23+ style="@style/actionbar_right_button"
24+ android:id="@+id/ok_button"
25+ android:src="?attr/ic_ok"
26+ />
27+ </LinearLayout>
28+
29+
30+ <!-- body -->
31+ <FrameLayout
32+ style="@style/body"
33+ >
34+ <EditText
35+ android:id="@+id/singleLine_edittext"
36+ android:layout_width="fill_parent"
37+ android:layout_height="wrap_content"
38+ android:layout_marginTop="8dip"
39+ android:inputType="text"
40+ android:gravity="left"
41+ android:visibility="visible"
42+ />
43+ <EditText
44+ android:id="@+id/multiLine_edittext"
45+ android:layout_width="fill_parent"
46+ android:layout_height="fill_parent"
47+ android:inputType="textMultiLine"
48+ android:gravity="left|top"
49+ android:visibility="gone"
50+ />
51+ </FrameLayout>
52+
53+</LinearLayout>
\ No newline at end of file
--- a/intent-lab/res/layout/simple_list.xml
+++ b/intent-lab/res/layout/simple_list.xml
@@ -1,14 +1,15 @@
11 <?xml version="1.0" encoding="utf-8"?>
2-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3- android:id="@+id/list_frame"
2+<FrameLayout
3+ xmlns:android="http://schemas.android.com/apk/res/android"
44 android:layout_width="fill_parent"
55 android:layout_height="fill_parent"
6- android:padding="2dip"
76 >
87 <ListView
98 android:id="@android:id/list"
109 android:layout_width="fill_parent"
1110 android:layout_height="fill_parent"
11+ android:drawSelectorOnTop="false"
12+ android:fastScrollEnabled="true"
1213 />
1314 <TextView
1415 android:id="@android:id/empty"
--- /dev/null
+++ b/intent-lab/src/org/routine_work/intent_lab/common/EditTextActivity.java
@@ -0,0 +1,132 @@
1+/*
2+ * The MIT License
3+ *
4+ * Copyright 2012 Masahiko, SAWAI <masahiko.sawai@gmail.com>.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ * THE SOFTWARE.
23+ */
24+package org.routine_work.intent_lab.common;
25+
26+import android.app.Activity;
27+import android.content.Intent;
28+import android.os.Bundle;
29+import android.text.InputType;
30+import android.text.TextUtils;
31+import android.view.View;
32+import android.view.WindowManager;
33+import android.widget.EditText;
34+import android.widget.ImageButton;
35+import android.widget.TextView;
36+import org.routine_work.intent_lab.R;
37+import org.routine_work.utils.Log;
38+
39+/**
40+ *
41+ * @author Masahiko, SAWAI <masahiko.sawai@gmail.com>
42+ */
43+public class EditTextActivity extends Activity
44+ implements View.OnClickListener
45+{
46+
47+ public static final String EXTRA_INPUT_TYPE = EditTextActivity.class.getPackage().getName() + ".INPUT_TYPE";
48+ private static final String LOG_TAG = "simple-notepad";
49+ private EditText mainEditText;
50+
51+ @Override
52+ protected void onCreate(Bundle savedInstanceState)
53+ {
54+ Log.v(LOG_TAG, "Hello");
55+// setTheme(NotepadPreferenceUtils.getTheme(this));
56+ super.onCreate(savedInstanceState);
57+
58+ getWindow().setSoftInputMode(
59+ WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
60+ | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
61+ setContentView(R.layout.edit_text_activity);
62+
63+ EditText singleLineEditText = (EditText) findViewById(R.id.singleLine_edittext);
64+ EditText multiLineEditText = (EditText) findViewById(R.id.multiLine_edittext);
65+ ImageButton cancelImageButton = (ImageButton) findViewById(R.id.cancel_button);
66+ ImageButton okImageButton = (ImageButton) findViewById(R.id.ok_button);
67+
68+ cancelImageButton.setOnClickListener(this);
69+ okImageButton.setOnClickListener(this);
70+
71+ Intent intent = getIntent();
72+
73+ int defaultInputType = singleLineEditText.getInputType();
74+ int inputType = intent.getIntExtra(EXTRA_INPUT_TYPE, defaultInputType);
75+ Log.v(LOG_TAG, "EXTRA_INPUT_TYPE => " + inputType);
76+ if (((inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0)
77+ || ((inputType & InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE) != 0))
78+ {
79+ mainEditText = multiLineEditText;
80+ singleLineEditText.setVisibility(View.GONE);
81+ multiLineEditText.setVisibility(View.VISIBLE);
82+ }
83+ else
84+ {
85+ mainEditText = singleLineEditText;
86+ singleLineEditText.setVisibility(View.VISIBLE);
87+ multiLineEditText.setVisibility(View.GONE);
88+ }
89+
90+ if (inputType != mainEditText.getInputType())
91+ {
92+ mainEditText.setInputType(inputType);
93+ }
94+
95+ String title = intent.getStringExtra(Intent.EXTRA_TITLE);
96+ Log.v(LOG_TAG, "EXTRA_TITLE => " + title);
97+ if (!TextUtils.isEmpty(title))
98+ {
99+ TextView titleTextView = (TextView) findViewById(R.id.title_textview);
100+ titleTextView.setText(title);
101+ mainEditText.setHint(title);
102+ }
103+
104+ String text = intent.getStringExtra(Intent.EXTRA_TEXT);
105+ Log.v(LOG_TAG, "EXTRA_TEXT => " + text);
106+ if (!TextUtils.isEmpty(text))
107+ {
108+ mainEditText.setText(text);
109+ }
110+
111+ mainEditText.requestFocus();
112+
113+ Log.v(LOG_TAG, "Bye");
114+ }
115+
116+ public void onClick(View v)
117+ {
118+ switch (v.getId())
119+ {
120+ case R.id.ok_button:
121+ Intent okData = new Intent();
122+ okData.putExtra(Intent.EXTRA_TEXT, mainEditText.getText().toString());
123+ setResult(RESULT_OK, okData);
124+ finish();
125+ break;
126+ case R.id.cancel_button:
127+ setResult(RESULT_CANCELED);
128+ finish();
129+ break;
130+ }
131+ }
132+}
--- a/intent-lab/src/org/routine_work/intent_lab/intent/IntentDetailActivity.java
+++ b/intent-lab/src/org/routine_work/intent_lab/intent/IntentDetailActivity.java
@@ -19,6 +19,7 @@ import android.widget.TextView;
1919 import android.widget.Toast;
2020 import java.util.Set;
2121 import org.routine_work.intent_lab.R;
22+import org.routine_work.intent_lab.common.EditTextActivity;
2223 import org.routine_work.intent_lab.intent.provider.IntentStore;
2324 import org.routine_work.utils.Log;
2425
@@ -35,11 +36,20 @@ public class IntentDetailActivity extends ListActivity
3536 private static final int POSITION_CATEGORIES = 5;
3637 private static final int POSITION_FLAGS = 6;
3738 private static final int POSITION_EXTRAS = 7;
39+ private static final int REQUEST_CODE_EDIT_INTENT_NAME = 101;
40+ private static final int REQUEST_CODE_EDIT_INTENT_ACTION = 102;
41+ private static final int REQUEST_CODE_EDIT_INTENT_COMPONENT = 103;
42+ private static final int REQUEST_CODE_EDIT_INTENT_DATA_URI = 104;
43+ private static final int REQUEST_CODE_EDIT_INTENT_DATA_TYPE = 105;
44+ private static final int REQUEST_CODE_EDIT_INTENT_CATEGORIES = 106;
45+ private static final int REQUEST_CODE_EDIT_INTENT_FLAGS = 106;
46+ private static final int REQUEST_CODE_EDIT_INTENT_EXTRAS = 108;
3847 // data
3948 private Uri targetUri;
4049 private String targetName;
4150 private Intent targetIntent;
4251 private IntentDetailListAdapter intentDetailListAdapter;
52+ private boolean modified;
4353
4454 public void onClick(View view)
4555 {
@@ -52,6 +62,19 @@ public class IntentDetailActivity extends ListActivity
5262 }
5363 }
5464
65+ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
66+ {
67+ Log.d(LOG_TAG, "onItemClick() : Hello");
68+ Log.d(LOG_TAG, "position => " + position);
69+ switch (position)
70+ {
71+ case POSITION_NAME:
72+ startNameEditActivity();
73+ break;
74+ }
75+ Log.d(LOG_TAG, "onItemClick() : Bye");
76+ }
77+
5578 @Override
5679 protected void onCreate(Bundle savedInstanceState)
5780 {
@@ -89,6 +112,23 @@ public class IntentDetailActivity extends ListActivity
89112 Log.v(LOG_TAG, "Bye");
90113 }
91114
115+ @Override
116+ protected void onActivityResult(int requestCode, int resultCode, Intent data)
117+ {
118+ switch (requestCode)
119+ {
120+ case REQUEST_CODE_EDIT_INTENT_NAME:
121+ if (resultCode == RESULT_OK)
122+ {
123+ targetName = data.getStringExtra(Intent.EXTRA_TEXT);
124+ intentDetailListAdapter.notifyDataSetChanged();
125+ }
126+ break;
127+ default:
128+ super.onActivityResult(requestCode, resultCode, data);
129+ }
130+ }
131+
92132 private String loadName(ContentResolver cr)
93133 {
94134 String title = null;
@@ -117,9 +157,13 @@ public class IntentDetailActivity extends ListActivity
117157 return title;
118158 }
119159
120- public void onItemClick(AdapterView<?> parent, View view, int position, long id)
160+ private void startNameEditActivity()
121161 {
122- Log.d(LOG_TAG, "position => " + position);
162+ Intent intent = new Intent(this, EditTextActivity.class);
163+ String title = getString(R.string.name);
164+ intent.putExtra(Intent.EXTRA_TITLE, title);
165+ intent.putExtra(Intent.EXTRA_TEXT, targetName);
166+ startActivityForResult(intent, REQUEST_CODE_EDIT_INTENT_NAME);
123167 }
124168
125169 class IntentDetailListAdapter extends BaseAdapter