├── CatchNotesIntegration
├── .classpath
├── .gitignore
├── .project
├── AndroidManifest.xml
├── build.xml
├── default.properties
├── local.properties
├── local.properties.sample
├── proguard.cfg
├── project.properties
├── res
│ ├── drawable
│ │ ├── icon.png
│ │ └── market_icon.png
│ ├── layout
│ │ └── main.xml
│ └── values
│ │ ├── CatchIntent.xml
│ │ └── strings.xml
└── src
│ └── com
│ └── catchnotes
│ ├── integration
│ └── IntentIntegrator.java
│ ├── intent
│ └── CatchIntent.java
│ └── samples
│ └── integration
│ └── IntentTestActivity.java
├── LICENSE.txt
└── README.markdown
/CatchNotesIntegration/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/.gitignore:
--------------------------------------------------------------------------------
1 | /bin
2 | /libs
3 | /assets
4 | /gen
5 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Intents
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.ResourceManagerBuilder
15 |
16 |
17 |
18 |
19 | com.android.ide.eclipse.adt.PreCompilerBuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.jdt.core.javanature
31 | com.android.ide.eclipse.adt.AndroidNature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
51 |
63 |
64 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/default.properties:
--------------------------------------------------------------------------------
1 | # Project target.
2 | target=android-3
3 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked in Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/Applications/android-sdk-mac_x86
11 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/local.properties.sample:
--------------------------------------------------------------------------------
1 | # Location of the Android SDK.
2 | #
3 | # Replace this with the path specific to your build machine.
4 | #
5 | # This is only necessary if you want to use ant to build the APK
6 | # from the command line.
7 |
8 | sdk.dir=/Developer/Android/android-sdk-mac_86
9 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-4
12 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catch/android-intent/b365b0f5cb7890e71fe151036fc79bd47445b0dd/CatchNotesIntegration/res/drawable/icon.png
--------------------------------------------------------------------------------
/CatchNotesIntegration/res/drawable/market_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catch/android-intent/b365b0f5cb7890e71fe151036fc79bd47445b0dd/CatchNotesIntegration/res/drawable/market_icon.png
--------------------------------------------------------------------------------
/CatchNotesIntegration/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
20 |
21 |
28 |
29 |
36 |
37 |
44 |
45 |
52 |
53 |
60 |
61 |
68 |
69 |
76 |
77 |
84 |
85 |
92 |
93 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/res/values/CatchIntent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cancel
4 | Upgrade
5 | OK
6 | Error!
7 | Install
8 | Install Catch Notes?
9 | This feature requires Catch Notes, the easiest way to take notes on the go!\n\n\"Top 10 Apps All Android Users Should Try\" - TechCrunch\n\nWould you like to install Catch Notes?
10 | Failed to launch the Catch Notes intent.
11 | Upgrade Catch Notes?
12 | This feature requires a newer version of Catch Notes, the easiest way to take notes on the go!\n\n\"Top 10 Apps All Android Users Should Try\" - TechCrunch\n\nWould you like to upgrade Catch Notes?
13 | An error occurred while attempting to display the Android Market.
14 |
15 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Click any button to test Catch Intents:
4 | Catch Intent Test Utility
5 | Create a Simple Note
6 | Create a Note with Image
7 | Add a Quick Note
8 | Create a Location Tagged Note
9 | View Notes
10 | View Tagged Notes
11 | View Stream
12 | Cursor Positioning Example
13 | Record a Voice Note
14 | Add a Reminder Note
15 | Quick note added.
16 |
17 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/src/com/catchnotes/integration/IntentIntegrator.java:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011 Catch.com, Inc.
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | //
16 |
17 | package com.catchnotes.integration;
18 |
19 | import java.util.ArrayList;
20 |
21 | import android.app.AlertDialog;
22 | import android.content.ActivityNotFoundException;
23 | import android.content.Context;
24 | import android.content.DialogInterface;
25 | import android.content.Intent;
26 | import android.content.pm.PackageInfo;
27 | import android.content.pm.PackageManager;
28 | import android.content.pm.PackageManager.NameNotFoundException;
29 | import android.location.Location;
30 | import android.net.Uri;
31 | import android.widget.Toast;
32 |
33 | import com.catchnotes.intent.CatchIntent;
34 | import com.catchnotes.samples.integration.R;
35 |
36 | public class IntentIntegrator {
37 | // Note: "3banana" was the original name of Catch Notes. Though it has been
38 | // rebranded, the package name must persist.
39 | private static final String NOTES_PACKAGE_NAME = "com.threebanana.notes";
40 | private static final String NOTES_MARKET_URI = "http://market.android.com/search?q=pname:" + NOTES_PACKAGE_NAME;
41 |
42 | private static final int NOTES_MIN_VERSION_CODE = 54;
43 |
44 | private final Context _context;
45 |
46 | public IntentIntegrator(Context context) {
47 | _context = context;
48 | }
49 |
50 | public void createNote(String message) {
51 | createNote(message, null, 0, -1, false, null, null, false);
52 | }
53 |
54 | public void createNote(String message, int cursorPosition) {
55 | createNote(message, null, 0, cursorPosition, false, null, null, false);
56 | }
57 |
58 | public void createNote(String message, boolean autoSave) {
59 | createNote(message, null, 0, -1, autoSave, null, null, false);
60 | }
61 |
62 | public void createNote(String message, Uri mediaUri, String mimeType, boolean isVoiceNote) {
63 | createNote(message, null, 0, -1, false, mediaUri, mimeType, isVoiceNote);
64 | }
65 |
66 | public void createNote(String message, Location location) {
67 | createNote(message, location, 0, -1, false, null, null, false);
68 | }
69 |
70 | public void createNote(String message, long reminder) {
71 | createNote(message, null, reminder, -1, false, null, null, false);
72 | }
73 |
74 | public void createNote(String message, Location location, long reminder, int cursorPosition, boolean autoSave, Uri mediaUri, String mimeType, boolean isVoiceNote) {
75 | // Verify that correct version of notes is installed
76 | if (!isNotesInstalled()) {
77 | return;
78 | }
79 |
80 | // Create the Intent
81 | Intent intent = new Intent();
82 |
83 | // This action signifies you want to add a new note to the user's notebook
84 | intent.setAction(CatchIntent.ACTION_ADD);
85 |
86 | // Mandatory. This will be the content of the note. The object should be
87 | // a String.
88 | intent.putExtra(Intent.EXTRA_TEXT, message);
89 |
90 | // Mandatory; EXTRA_SOURCE identifies your app as the source
91 | // for this note. Don't use the example below; please arrange with the
92 | // Catch development team for the string you will use to identify your
93 | // app. The object should be a String.
94 | intent.putExtra(CatchIntent.EXTRA_SOURCE, "Catch Intent Test Utility"); // TODO: *** change this to your own source string! ***
95 |
96 | // Mandatory; EXTRA_SOURCE_URL identifies a URL which will be presented
97 | // in conjunction with your EXTRA_SOURCE field. This should link to your
98 | // site, app, or other relevant web asset. The object should be a String.
99 | intent.putExtra(CatchIntent.EXTRA_SOURCE_URL, "https://catch.com/"); // TODO: *** change this to your own source URL! ***
100 |
101 | // Optional; if EXTRA_TITLE is supplied it will appear in the
102 | // titlebar of the note editor activity in Catch Notes. The object should be
103 | // a String. It will appear as:
104 | //
105 | // New note:
106 | //
107 | intent.putExtra(Intent.EXTRA_TITLE, "testing Catch Intents"); // TODO: *** change this to your own title (or leave the extra out) ***
108 |
109 | // Optional: include a media attachment. The attachment Uri should be
110 | // accessible to external packages (i.e., don't point to content private
111 | // to your application).
112 | if (mediaUri != null) {
113 | intent.putExtra(Intent.EXTRA_STREAM, mediaUri);
114 |
115 | // If you don't supply a MIME type, Catch Notes will attempt to
116 | // figure it out based on ContentProvider hints or the filename extension.
117 | //
118 | // Note that the Catch sync servers do strict MIME type checking; if you
119 | // misrepresent the MIME type of a media attachment, your users will not be
120 | // able to sync them.
121 | if (mimeType != null) {
122 | intent.setType(mimeType);
123 | }
124 |
125 | // Note that Catch Notes will enforce restrictions of what MIME types
126 | // can be considered voice recordings: "audio/*", "video/*", "application/ogg".
127 | // Also note that not all media files that match these descriptors will
128 | // play in the player controllers of Catch Notes (Android, iOS, or web).
129 | // Only certain common codecs and container formats are supported.
130 | // For Android, we suggest "video/3gpp" with AMR narrowband audio or
131 | // "video/mp4" with AAC audio for best compatibility.
132 | //
133 | // Audio attachments that do not have this voice note flag set will
134 | // be treated like regular file attachments to the note.
135 | if (isVoiceNote) {
136 | intent.putExtra(CatchIntent.EXTRA_VOICE, true);
137 | }
138 | }
139 |
140 | // Optional: include a location. The object should be a Location.
141 | if (location != null) {
142 | intent.putExtra(CatchIntent.EXTRA_LOCATION, location);
143 | }
144 |
145 | // Optional: include a reminder. This value is standard system
146 | // millisecond time (milliseconds since January 1, 1970 00:00:00 UTC)
147 | if (reminder > System.currentTimeMillis()) {
148 | intent.putExtra(CatchIntent.EXTRA_REMINDER, reminder);
149 | }
150 |
151 | // Optional: specify a cursor position for the editor. The type should
152 | // be an int.
153 | if (cursorPosition >= 0) {
154 | intent.putExtra(CatchIntent.EXTRA_CURSOR_POSITION, cursorPosition);
155 | }
156 |
157 | // Optional: specify autosave. Intents with autosave set will send the
158 | // note and its contents, save it immediately, and return to your
159 | // activity. You may want to provide feedback to your users that the
160 | // action completed. The type should be a boolean.
161 | if (autoSave) {
162 | intent.putExtra(CatchIntent.EXTRA_AUTOSAVE, true);
163 | }
164 |
165 | // Start the Intent
166 | startNotesIntent(intent);
167 | }
168 |
169 | public void viewNotes(String stream, String text, ArrayList tags) {
170 | // Verify that correct version of notes is installed
171 | if (!isNotesInstalled()) {
172 | return;
173 | }
174 |
175 | // Create the Intent
176 | Intent intent = new Intent();
177 | intent.setAction(CatchIntent.ACTION_VIEW);
178 |
179 | if (stream != null) {
180 | intent.putExtra(CatchIntent.EXTRA_VIEW_FILTER_STREAM, stream);
181 | }
182 |
183 | if (text != null) {
184 | intent.putExtra(CatchIntent.EXTRA_VIEW_FILTER, text);
185 | }
186 |
187 | if (tags != null) {
188 | intent.putExtra(CatchIntent.EXTRA_VIEW_FILTER_TAGS, tags);
189 | }
190 |
191 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
192 |
193 | // Start the Intent
194 | startNotesIntent(intent);
195 | }
196 |
197 | // Ask Catch Notes to interactively record a voice note and save it to
198 | // the user's notebook. Text may be included with the Intent and the text
199 | // will be included in the text portion of the voice note entry. This
200 | // is an *interactive* Intent -- to add a pre-recorded voice note to Catch,
201 | // one would use CatchIntent.ACTION_ADD, include a URI to the voice recording
202 | // in Intent.EXTRA_STREAM, and include a boolean true extra as CatchIntent.EXTRA_VOICE.
203 | public void recordVoice(String message) {
204 | // Verify that correct version of notes is installed
205 | if (!isNotesInstalled()) {
206 | return;
207 | }
208 |
209 | // Create the Intent
210 | Intent intent = new Intent();
211 | intent.setAction(CatchIntent.ACTION_ADD_VOICE);
212 |
213 | // Optional: text to include with the voice note.
214 | if (message != null) {
215 | intent.putExtra(Intent.EXTRA_TEXT, message);
216 | }
217 |
218 | // Start the Intent
219 | startNotesIntent(intent);
220 | }
221 |
222 | // Ask Catch Notes to interactively allow the user to set a reminder date/time
223 | // and save it to the user's notebook. Text may be included with the Intent
224 | // and the text will be included in the text portion of the entry. This
225 | // is an *interactive* Intent -- to add a note to Catch with a predetermined
226 | // reminder timestamp, one would use CatchIntent.ACTION_ADD, and include as
227 | // a long extra the reminder value as CatchIntent.EXTRA_REMINDER.
228 | public void addReminder(String message) {
229 | // Verify that correct version of notes is installed
230 | if (!isNotesInstalled()) {
231 | return;
232 | }
233 |
234 | // Create the Intent
235 | Intent intent = new Intent();
236 | intent.setAction(CatchIntent.ACTION_ADD_REMINDER);
237 |
238 | // Optional: text to include with the reminder note.
239 | if (message != null) {
240 | intent.putExtra(Intent.EXTRA_TEXT, message);
241 | }
242 |
243 | // Start the Intent
244 | startNotesIntent(intent);
245 | }
246 |
247 | private boolean isNotesInstalled() {
248 | // Verify that correct version of notes is installed
249 | try {
250 | PackageInfo packageInfo = _context.getPackageManager().getPackageInfo(NOTES_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
251 |
252 | if (packageInfo.versionCode < NOTES_MIN_VERSION_CODE) {
253 | displayUpgradeDialog(packageInfo.applicationInfo.name);
254 | return false;
255 | }
256 | } catch (NameNotFoundException e) {
257 | displayInstallDialog();
258 | return false;
259 | }
260 |
261 | return true;
262 | }
263 |
264 | private void displayInstallDialog() {
265 | AlertDialog.Builder builder = new AlertDialog.Builder(_context);
266 |
267 | builder.setTitle(R.string.install_notes_title);
268 | builder.setMessage(R.string.install_notes_message);
269 | builder.setIcon(R.drawable.market_icon);
270 |
271 | builder.setNegativeButton(R.string.cancel_button, null);
272 |
273 | builder.setPositiveButton(R.string.install_button, new DialogInterface.OnClickListener() {
274 | public void onClick(DialogInterface dialog, int which) {
275 | displayNotesMarketPage();
276 | }
277 | });
278 |
279 | builder.show();
280 | }
281 |
282 | private void displayUpgradeDialog(String appName) {
283 | AlertDialog.Builder builder = new AlertDialog.Builder(_context);
284 |
285 | builder.setTitle(R.string.upgrade_notes_title);
286 | builder.setMessage(R.string.upgrade_notes_message);
287 | builder.setIcon(R.drawable.market_icon);
288 |
289 | builder.setNegativeButton(R.string.cancel_button, null);
290 |
291 | builder.setPositiveButton(R.string.upgrade_button, new DialogInterface.OnClickListener() {
292 | public void onClick(DialogInterface dialog, int which) {
293 | displayNotesMarketPage();
294 | }
295 | });
296 |
297 | builder.show();
298 | }
299 |
300 | private void displayNotesMarketPage() {
301 | try {
302 | Uri uri = Uri.parse(NOTES_MARKET_URI);
303 | Intent intent = new Intent(Intent.ACTION_VIEW, uri);
304 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
305 | _context.startActivity(intent);
306 | } catch (ActivityNotFoundException e) {
307 | e.printStackTrace();
308 | displayError(R.string.market_error_message);
309 | }
310 | }
311 |
312 | private void displayError(int messageId) {
313 | new AlertDialog.Builder(_context)
314 | .setIcon(android.R.drawable.ic_dialog_alert)
315 | .setTitle(R.string.error_dialog_title)
316 | .setMessage(messageId)
317 | .setPositiveButton(_context.getString(R.string.ok_button), null)
318 | .show();
319 | }
320 |
321 | private void startNotesIntent(Intent intent) {
322 | // Start the Intent
323 | try {
324 | _context.startActivity(intent);
325 |
326 | if (intent.hasExtra(CatchIntent.EXTRA_AUTOSAVE)) {
327 | // Pop up a mesage to let your users know when a quick note has
328 | // been added.
329 | Toast.makeText(_context,
330 | R.string.toast_quick_note,
331 | Toast.LENGTH_SHORT).show();
332 | }
333 | } catch (ActivityNotFoundException e) {
334 | e.printStackTrace();
335 | displayError(R.string.notes_intent_error);
336 | }
337 | }
338 | }
339 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/src/com/catchnotes/intent/CatchIntent.java:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011 Catch.com, Inc.
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | //
16 |
17 | package com.catchnotes.intent;
18 |
19 | public final class CatchIntent {
20 | // Intent actions
21 | public static final String ACTION_ADD = "com.catchnotes.intent.action.ADD";
22 | public static final String ACTION_VIEW = "com.catchnotes.intent.action.VIEW";
23 | public static final String ACTION_ADD_VOICE = "com.catchnotes.intent.action.ADD_VOICE";
24 | public static final String ACTION_ADD_REMINDER = "com.catchnotes.intent.action.ADD_REMINDER";
25 |
26 | // Intent extras for ACTION_ADD
27 | public static final String EXTRA_SOURCE = "com.catchnotes.intent.extra.SOURCE";
28 | public static final String EXTRA_SOURCE_URL = "com.catchnotes.intent.extra.SOURCE_URL";
29 | public static final String EXTRA_LOCATION = "com.catchnotes.intent.extra.LOCATION";
30 | public static final String EXTRA_CURSOR_POSITION = "com.catchnotes.intent.extra.CURSOR_POSITION";
31 | public static final String EXTRA_AUTOSAVE = "com.catchnotes.intent.extra.AUTOSAVE";
32 | public static final String EXTRA_VOICE = "com.catchnotes.intent.extra.VOICE";
33 | public static final String EXTRA_REMINDER = "com.catchnotes.intent.extra.REMINDER";
34 | public static final String EXTRA_STARRED = "com.catchnotes.intent.extra.STARRED";
35 |
36 | // Intent extras for ACTION_VIEW
37 | public static final String EXTRA_VIEW_FILTER = "com.catchnotes.intent.extra.VIEW_FILTER";
38 | public static final String EXTRA_VIEW_FILTER_TAGS = "com.catchnotes.intent.extra.VIEW_FILTER_TAGS";
39 | public static final String EXTRA_VIEW_FILTER_STREAM = "com.catchnotes.intent.extra.VIEW_FILTER_STREAM";
40 | public static final String EXTRA_VIEW_FILTER_STARRED = "com.catchnotes.intent.extra.VIEW_FILTER_STARRED";
41 | }
42 |
--------------------------------------------------------------------------------
/CatchNotesIntegration/src/com/catchnotes/samples/integration/IntentTestActivity.java:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011 Catch.com, Inc.
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | //
16 |
17 | package com.catchnotes.samples.integration;
18 |
19 | import java.util.ArrayList;
20 |
21 | import android.app.Activity;
22 | import android.content.Intent;
23 | import android.location.Location;
24 | import android.location.LocationManager;
25 | import android.os.Bundle;
26 | import android.view.View;
27 | import android.view.View.OnClickListener;
28 | import android.widget.Button;
29 |
30 | import com.catchnotes.integration.IntentIntegrator;
31 |
32 | public class IntentTestActivity extends Activity {
33 | private IntentIntegrator _notesIntent;
34 | private final int IMAGE_PICKED = 0;
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.main);
40 |
41 | _notesIntent = new IntentIntegrator(this);
42 |
43 | ((Button)findViewById(R.id.create_simple_note_button)).setOnClickListener(new OnClickListener() {
44 | public void onClick(View v) {
45 | _notesIntent.createNote("My Simple Note\n\n#sample");
46 | }
47 | });
48 |
49 | ((Button)findViewById(R.id.create_image_note_button)).setOnClickListener(new OnClickListener() {
50 | public void onClick(View v) {
51 | Intent galleryIntent = new Intent(Intent.ACTION_PICK);
52 | galleryIntent.setType("image/*");
53 | startActivityForResult(Intent.createChooser(galleryIntent,
54 | "Choose from:"), IMAGE_PICKED);
55 | }
56 | });
57 |
58 | ((Button)findViewById(R.id.create_quick_note_button)).setOnClickListener(new OnClickListener() {
59 | public void onClick(View v) {
60 | _notesIntent.createNote("My Quick Note\n\n#sample", true);
61 | }
62 | });
63 |
64 | ((Button)findViewById(R.id.create_location_note_button)).setOnClickListener(new OnClickListener() {
65 | public void onClick(View v) {
66 | // Create a sample location
67 | Location location = new Location(LocationManager.NETWORK_PROVIDER);
68 | location.setLatitude(30.267153);
69 | location.setLongitude(-97.743061);
70 |
71 | _notesIntent.createNote("My Location Tagged Note\n\n#sample", location);
72 | }
73 | });
74 |
75 | ((Button)findViewById(R.id.view_notes_button)).setOnClickListener(new OnClickListener() {
76 | public void onClick(View v) {
77 | _notesIntent.viewNotes(null, "sample", null);
78 | }
79 | });
80 |
81 | ((Button)findViewById(R.id.view_tagged_notes_button)).setOnClickListener(new OnClickListener() {
82 | public void onClick(View v) {
83 | ArrayList tags = new ArrayList(1);
84 | tags.add("sample");
85 | _notesIntent.viewNotes(null, null, tags);
86 | }
87 | });
88 |
89 | ((Button)findViewById(R.id.view_stream_button)).setOnClickListener(new OnClickListener() {
90 | public void onClick(View v) {
91 | _notesIntent.viewNotes("Sample", null, null);
92 | }
93 | });
94 |
95 | ((Button)findViewById(R.id.cursor_positioning_button)).setOnClickListener(new OnClickListener() {
96 | public void onClick(View v) {
97 | _notesIntent.createNote("Cursor Positioning\n\nExample", 19);
98 | }
99 | });
100 |
101 | ((Button)findViewById(R.id.voice_recording_button)).setOnClickListener(new OnClickListener() {
102 | public void onClick(View v) {
103 | _notesIntent.recordVoice("My Voice Note\n\n#sample");
104 | }
105 | });
106 |
107 | ((Button)findViewById(R.id.reminder_button)).setOnClickListener(new OnClickListener() {
108 | public void onClick(View v) {
109 | _notesIntent.addReminder("My Reminder Note\n\n#sample");
110 | }
111 | });
112 | }
113 |
114 | @Override
115 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
116 | if (resultCode == RESULT_OK) {
117 | switch (requestCode) {
118 | case IMAGE_PICKED:
119 | _notesIntent.createNote("My Image Note\n\n#sample", data.getData(), null, false);
120 | break;
121 | }
122 | }
123 |
124 | super.onActivityResult(requestCode, resultCode, data);
125 | }
126 | }
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | # Catch Notes Android Intent
2 | Using CatchIntent makes it easy to create notes from your application.
3 |
4 | CatchNotesIntegration is a sample Eclipse project which demonstrates how to use the Intent. Be sure to check out the [documentation](https://github.com/catch/android-intent/wiki) on the wiki.
5 |
--------------------------------------------------------------------------------