Android Samples
Révision | 889e26f4180b43aaebfb53071498f98501f4e04b (tree) |
---|---|
l'heure | 2013-07-09 18:03:42 |
Auteur | Masahiko, SAWAI <say@user...> |
Commiter | Masahiko, SAWAI |
Added markdown-viewer sample project
@@ -0,0 +1,26 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + package="com.example.hello.android.markdown_viewer" | |
4 | + android:versionCode="1" | |
5 | + android:versionName="1.0" | |
6 | +> | |
7 | + <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="11" /> | |
8 | + | |
9 | + <application android:label="@string/app_name"> | |
10 | + <activity android:name=".MainActivity" > | |
11 | + <intent-filter> | |
12 | + <action android:name="android.intent.action.MAIN" /> | |
13 | + <category android:name="android.intent.category.LAUNCHER" /> | |
14 | + </intent-filter> | |
15 | + </activity> | |
16 | + | |
17 | + <activity | |
18 | + android:name=".MarkdownViewerActivity" | |
19 | + android:label="@string/preview" | |
20 | + /> | |
21 | + </application> | |
22 | + | |
23 | + <!-- | |
24 | + <uses-permission android:name="android.permission.INTERNET" /> | |
25 | + --> | |
26 | +</manifest> |
@@ -0,0 +1,47 @@ | ||
1 | +RELEASE_PROFILE=android-hello | |
2 | + | |
3 | +all : package | |
4 | + | |
5 | +#################### build | |
6 | + | |
7 | +compile : | |
8 | + mvn $@ | |
9 | + | |
10 | +gen : | |
11 | + mvn android:generate-sources | |
12 | + | |
13 | +package : | |
14 | + mvn $@ | |
15 | + | |
16 | +release : | |
17 | + mvn clean && mvn -P$(RELEASE_PROFILE) package | |
18 | + | |
19 | +install : | |
20 | + mvn $@ | |
21 | + | |
22 | +deploy : | |
23 | + mvn package android:deploy | |
24 | + | |
25 | +undeploy : | |
26 | + mvn android:undeploy | |
27 | + | |
28 | +rebuild : | |
29 | + mvn clean package | |
30 | + | |
31 | +redeploy : | |
32 | + mvn clean package android:deploy | |
33 | + | |
34 | + | |
35 | +#################### emulator | |
36 | +start : | |
37 | + mvn android:emulator-start | |
38 | + | |
39 | +stop : | |
40 | + mvn android:emulator-stop | |
41 | + | |
42 | +#################### project | |
43 | +dist : | |
44 | + mvn assembly:assembly | |
45 | + | |
46 | +clean : | |
47 | + mvn $@ |
@@ -0,0 +1,26 @@ | ||
1 | +! markdownj-viewer | |
2 | + | |
3 | +Markdown ぱーざライブラリ MarkdownJ を使って | |
4 | +Markdown テキストをパースシテ表示するサンプル。 | |
5 | + | |
6 | +* MarkdownProcessor で Markdown のソースをパースしてHTMLに変換 | |
7 | +* WebView に設定して表示 | |
8 | + | |
9 | + | |
10 | +############################################################ | |
11 | +!! ビルドターゲット | |
12 | + | |
13 | +http://maven-android-plugin-m2site.googlecode.com/svn/plugin-info.html | |
14 | + | |
15 | +* mvn compile - アプリケーションのコンパイル | |
16 | +* mvn package - apk の作成 | |
17 | +* mvn clean - ビルドファイルの削除 | |
18 | +* mvn install - maven の local リポジトリにインストール | |
19 | + | |
20 | +* mvn android:deploy - エミュレータやデバイスにインストール | |
21 | +* mvn android:generate-sources | |
22 | + | |
23 | +* mvn install - アプリケーションのインストール | |
24 | +* mvn uninstall - アプリケーションのアンインストール | |
25 | + | |
26 | + |
@@ -0,0 +1,151 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" | |
4 | +> | |
5 | + <modelVersion>4.0.0</modelVersion> | |
6 | + <groupId>com.example.hello</groupId> | |
7 | + <artifactId>markdown-viewer</artifactId> | |
8 | + <packaging>apk</packaging> | |
9 | + <version>1.0.0</version> | |
10 | + <name>Android Markdown Viewer </name> | |
11 | + <url>http://www.example.com/</url> | |
12 | + | |
13 | + <parent> | |
14 | + <groupId>com.example.hello</groupId> | |
15 | + <artifactId>android-samples</artifactId> | |
16 | + <version>1.0.0</version> | |
17 | + </parent> | |
18 | + | |
19 | + <dependencies> | |
20 | + | |
21 | + <dependency> | |
22 | + <groupId>android</groupId> | |
23 | + <artifactId>android</artifactId> | |
24 | + <version>1.5_r4</version> | |
25 | + <!-- | |
26 | + <version>1.5_r3</version> | |
27 | + <version>1.5_r4</version> | |
28 | + <version>1.6_r2</version> | |
29 | + <version>2.1.2</version> | |
30 | + <version>2.1_r1</version> | |
31 | + <version>2.2.1</version> | |
32 | + <version>2.3.1</version> | |
33 | + <version>2.3.3</version> | |
34 | + <version>4.0.1.2</version> | |
35 | + --> | |
36 | + <scope>provided</scope> | |
37 | + </dependency> | |
38 | + | |
39 | + <dependency> | |
40 | + <groupId>junit</groupId> | |
41 | + <artifactId>junit</artifactId> | |
42 | + <scope>test</scope> | |
43 | + </dependency> | |
44 | + <dependency> | |
45 | + <groupId>org.markdownj</groupId> | |
46 | + <artifactId>markdownj</artifactId> | |
47 | + <version>0.3.0-1.0.2b4</version> | |
48 | + </dependency> | |
49 | + </dependencies> | |
50 | + | |
51 | + <build> | |
52 | + <sourceDirectory>src</sourceDirectory> | |
53 | + | |
54 | + <plugins> | |
55 | + <plugin> | |
56 | + <groupId>com.jayway.maven.plugins.android.generation2</groupId> | |
57 | + <artifactId>android-maven-plugin</artifactId> | |
58 | + <configuration> | |
59 | + <sdk> | |
60 | + <path>${env.ANDROID_HOME}</path> | |
61 | + <!-- <path>C:/Java/android-sdk</path> --> | |
62 | + <platform>8</platform> | |
63 | + </sdk> | |
64 | + <proguard> | |
65 | + <skip>true</skip> | |
66 | + <config>proguard.conf</config> | |
67 | + </proguard> | |
68 | + <extractDuplicates>true</extractDuplicates> | |
69 | + </configuration> | |
70 | + <extensions>true</extensions> | |
71 | + </plugin> | |
72 | + | |
73 | + <!-- mvn compile --> | |
74 | + <plugin> | |
75 | + <groupId>org.apache.maven.plugins</groupId> | |
76 | + <artifactId>maven-compiler-plugin</artifactId> | |
77 | + <configuration> | |
78 | + <source>1.5</source> | |
79 | + <target>1.5</target> | |
80 | + <encoding>UTF-8</encoding> | |
81 | + </configuration> | |
82 | + </plugin> | |
83 | + | |
84 | + <!-- mvn assembly:assembly --> | |
85 | + <plugin> | |
86 | + <groupId>org.apache.maven.plugins</groupId> | |
87 | + <artifactId>maven-assembly-plugin</artifactId> | |
88 | + <configuration> | |
89 | + <descriptorRefs> | |
90 | + <!-- | |
91 | + <descriptorRef>jar-with-dependencies</descriptorRef> | |
92 | + <descriptorRef>bin</descriptorRef> | |
93 | + <descriptorRef>src</descriptorRef> | |
94 | + --> | |
95 | + <descriptorRef>project</descriptorRef> | |
96 | + </descriptorRefs> | |
97 | + </configuration> | |
98 | + </plugin> | |
99 | + | |
100 | + <!-- mvn resources:resources --> | |
101 | + <plugin> | |
102 | + <groupId>org.apache.maven.plugins</groupId> | |
103 | + <artifactId>maven-resources-plugin</artifactId> | |
104 | + <configuration> | |
105 | + <encoding>UTF-8</encoding> | |
106 | + </configuration> | |
107 | + </plugin> | |
108 | + | |
109 | + <!-- mvn site --> | |
110 | + <plugin> | |
111 | + <groupId>org.apache.maven.plugins</groupId> | |
112 | + <artifactId>maven-site-plugin</artifactId> | |
113 | + <configuration> | |
114 | + <locales>en</locales> | |
115 | + <inputEncoding>UTF-8</inputEncoding> | |
116 | + <outputEncoding>UTF-8</outputEncoding> | |
117 | + | |
118 | + <reportPlugins> | |
119 | + <plugin> | |
120 | + <groupId>org.apache.maven.plugins</groupId> | |
121 | + <artifactId>maven-project-info-reports-plugin</artifactId> | |
122 | + </plugin> | |
123 | + | |
124 | + <!-- mvn javadoc:javadoc --> | |
125 | + <plugin> | |
126 | + <groupId>org.apache.maven.plugins</groupId> | |
127 | + <artifactId>maven-javadoc-plugin</artifactId> | |
128 | + <configuration> | |
129 | + <charset>utf-8</charset> | |
130 | + </configuration> | |
131 | + </plugin> | |
132 | + </reportPlugins> | |
133 | + </configuration> | |
134 | + </plugin> | |
135 | + | |
136 | + </plugins> | |
137 | + | |
138 | + <!-- mvn resources:resources --> | |
139 | + <resources> | |
140 | + <resource> | |
141 | + <directory>res</directory> | |
142 | + <filtering>false</filtering> | |
143 | + <includes> | |
144 | + <include>**/*.properties</include> | |
145 | + </includes> | |
146 | + </resource> | |
147 | + </resources> | |
148 | + </build> | |
149 | + | |
150 | + | |
151 | +</project> |
@@ -0,0 +1,31 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + android:orientation="vertical" | |
5 | + android:layout_width="fill_parent" | |
6 | + android:layout_height="fill_parent" | |
7 | + android:padding="4dip" | |
8 | +> | |
9 | + <ScrollView | |
10 | + android:layout_width="fill_parent" | |
11 | + android:layout_height="wrap_content" | |
12 | + android:layout_weight="1" | |
13 | + android:layout_margin="4dip" | |
14 | + android:fillViewport="true" | |
15 | + > | |
16 | + <EditText | |
17 | + android:id="@+id/markdown_source_edittext" | |
18 | + android:layout_width="fill_parent" | |
19 | + android:layout_height="fill_parent" | |
20 | + android:gravity="left|top" | |
21 | + /> | |
22 | + </ScrollView> | |
23 | + <Button | |
24 | + android:id="@+id/preview_button" | |
25 | + android:layout_width="fill_parent" | |
26 | + android:layout_height="wrap_content" | |
27 | + android:layout_weight="0" | |
28 | + android:layout_margin="4dip" | |
29 | + android:text="@string/preview" | |
30 | + /> | |
31 | +</LinearLayout> | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<WebView | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + android:id="@+id/viewer_webview" | |
5 | + android:layout_width="fill_parent" | |
6 | + android:layout_height="fill_parent" | |
7 | + android:padding="4dip" | |
8 | +/> | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<!-- | |
3 | +* How to define string resource | |
4 | +--> | |
5 | +<resources> | |
6 | + <string name="app_name">Markdown Viewer</string> | |
7 | + <string name="preview">Preview</string> | |
8 | +</resources> |
@@ -0,0 +1,34 @@ | ||
1 | +package com.example.hello.android.markdown_viewer; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.content.Intent; | |
5 | +import android.os.Bundle; | |
6 | +import android.view.View; | |
7 | +import android.widget.Button; | |
8 | +import android.widget.EditText; | |
9 | + | |
10 | +public class MainActivity extends Activity | |
11 | + implements View.OnClickListener | |
12 | +{ | |
13 | + | |
14 | + @Override | |
15 | + public void onCreate(Bundle savedInstanceState) | |
16 | + { | |
17 | + super.onCreate(savedInstanceState); | |
18 | + setContentView(R.layout.main_activity); | |
19 | + | |
20 | + Button previewButton = (Button) findViewById(R.id.preview_button); | |
21 | + previewButton.setOnClickListener(this); | |
22 | + | |
23 | + } | |
24 | + | |
25 | + public void onClick(View view) | |
26 | + { | |
27 | + EditText markdownSourceEditText = (EditText) findViewById(R.id.markdown_source_edittext); | |
28 | + String markdownSourceText = markdownSourceEditText.getText().toString(); | |
29 | + | |
30 | + Intent intent = new Intent(this, MarkdownViewerActivity.class); | |
31 | + intent.putExtra(Intent.EXTRA_TEXT, markdownSourceText); | |
32 | + startActivity(intent); | |
33 | + } | |
34 | +} |
@@ -0,0 +1,38 @@ | ||
1 | +package com.example.hello.android.markdown_viewer; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.content.Intent; | |
5 | +import android.os.Bundle; | |
6 | +import android.text.Html; | |
7 | +import android.text.Spanned; | |
8 | +import android.util.Log; | |
9 | +import android.webkit.WebView; | |
10 | +import android.widget.TextView; | |
11 | +import com.petebevin.markdown.MarkdownProcessor; | |
12 | + | |
13 | +public class MarkdownViewerActivity extends Activity | |
14 | +{ | |
15 | + private static final String LOG_TAG = "XXX"; | |
16 | + | |
17 | + @Override | |
18 | + public void onCreate(Bundle savedInstanceState) | |
19 | + { | |
20 | + super.onCreate(savedInstanceState); | |
21 | + setContentView(R.layout.markdown_viewer_activity); | |
22 | + | |
23 | + Intent intent = getIntent(); | |
24 | + String markdownText = intent.getStringExtra(Intent.EXTRA_TEXT); | |
25 | + setMarkdownText(markdownText); | |
26 | + } | |
27 | + | |
28 | + private void setMarkdownText(String markdownText) | |
29 | + { | |
30 | + MarkdownProcessor processor = new MarkdownProcessor(); | |
31 | + String htmlSourceText = processor.markdown(markdownText); | |
32 | + Log.d(LOG_TAG, "htmlSourceText => " + htmlSourceText); | |
33 | + | |
34 | + WebView viewerWebView = (WebView) findViewById(R.id.viewer_webview); | |
35 | + viewerWebView.loadData(htmlSourceText, "text/html; charset=utf-8", "utf-8"); | |
36 | + | |
37 | + } | |
38 | +} |
@@ -57,6 +57,7 @@ | ||
57 | 57 | <module>layout-framelayout-hello</module> |
58 | 58 | <module>layout-tablelayout-hello</module> |
59 | 59 | <module>layout-tablelayout-stripe-style</module> |
60 | + <module>markdown-viewer</module> | |
60 | 61 | <module>option-menu-hello</module> |
61 | 62 | <module>preference-activity-hello</module> |
62 | 63 | <module>preference-auto-summary</module> |