package="org.openintents.safe" \r
android:versionCode="1" \r
android:versionName="0.7.0">
- <application android:icon="@drawable/icon_safe" android:allowClearUserData="true" android:debuggable="true" android:label="@string/app_name">
+ <application android:icon="@drawable/icon_safe" android:allowClearUserData="true" android:debuggable="true" android:label="@string/app_name">\r
+ \r
+ <meta-data android:name="org.openintents.metadata.COMMENTS"\r
+ android:value="@string/about_comments" />\r
+ <meta-data android:name="org.openintents.metadata.COPYRIGHT"\r
+ android:value="@string/about_copyright" />\r
+ <meta-data android:name="org.openintents.metadata.AUTHORS"\r
+ android:resource="@array/about_authors" />\r
+ <meta-data android:name="org.openintents.metadata.DOCUMENTERS"\r
+ android:resource="@array/about_documenters" />\r
+ <meta-data android:name="org.openintents.metadata.TRANSLATORS"\r
+ android:resource="@array/about_translators" />\r
+ <meta-data android:name="org.openintents.metadata.ARTISTS"\r
+ android:resource="@array/about_artists" />\r
+ <meta-data android:name="org.openintents.metadata.WEBSITE_LABEL"\r
+ android:value="@string/about_website_label" />\r
+ <meta-data android:name="org.openintents.metadata.WEBSITE_URL"\r
+ android:value="@string/about_website_url" />\r
+ <meta-data android:name="org.openintents.metadata.LICENSE"\r
+ android:resource="@raw/license_short" />\r
+ <meta-data android:name="org.openintents.metadata.EMAIL"\r
+ android:value="@string/about_email" />\r
+
<activity class=".FrontDoor" android:name="FrontDoor" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<activity class=".ChangePass" android:name="ChangePass" android:label="@string/app_name" />
<activity class=".Restore" android:name="Restore" android:label="@string/app_name" />
<activity class=".Preferences" android:name="Preferences" android:label="@string/app_name" />
- <activity class="LogOffActivity" android:name="LogOffActivity" android:label="@string/app_name" />
+ <activity class=".LogOffActivity" android:name="LogOffActivity" android:label="@string/app_name" />
<service class=".service.ServiceDispatchImpl" android:name=".service.ServiceDispatchImpl"
android:label="@string/app_name"
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2006-2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->\r
+\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:orientation="horizontal"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginBottom="10dip"\r
+ >\r
+ <EditText android:id="@+id/file_path"\r
+ android:layout_width="0dip" \r
+ android:layout_height="wrap_content" \r
+ android:layout_weight="1"/>\r
+ <ImageButton android:id="@+id/file_manager"\r
+ android:src="@drawable/ic_launcher_folder_small"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content" />\r
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<!-- \r
+ * Copyright (C) 2007-2008 OpenIntents.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ -->\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:orientation="vertical"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent"\r
+ >\r
+ <TextView \r
+ android:id="@+id/text1"\r
+ android:layout_width="fill_parent" \r
+ android:layout_height="34dip" \r
+ android:text="@string/eula_title"\r
+ android:gravity="center"\r
+ android:textStyle="bold"\r
+ android:textColor="#ffffffff"\r
+ android:layout_marginTop="10dip"\r
+ android:layout_marginBottom="10dip"\r
+ />\r
+ <ScrollView\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="0dip"\r
+ android:layout_weight="1"\r
+ android:layout_marginBottom="10dip"\r
+ android:layout_marginLeft="5dip"\r
+ >\r
+ <TextView \r
+ android:id="@+id/text"\r
+ android:layout_width="wrap_content" \r
+ android:layout_height="wrap_content" \r
+ android:autoLink="web"\r
+ android:bufferType="spannable"\r
+ android:textColor="#ffffffff"\r
+ android:layout_marginLeft="10dip"\r
+ android:layout_marginRight="10dip"\r
+ android:layout_marginTop="10dip"\r
+ android:layout_marginBottom="10dip"\r
+ />\r
+ </ScrollView>\r
+ <LinearLayout\r
+ android:id="@+id/container2"\r
+ android:orientation="horizontal"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="wrap_content"\r
+ >\r
+ <Button android:id="@+id/button1"\r
+ android:layout_width="0dip"\r
+ android:layout_height="wrap_content" \r
+ android:layout_gravity="bottom"\r
+ android:layout_weight="1"\r
+ android:text="@string/eula_accept" />\r
+ <LinearLayout\r
+ android:orientation="horizontal"\r
+ android:layout_width="0dip"\r
+ android:layout_height="wrap_content"\r
+ android:layout_weight="1"\r
+ />\r
+ <Button android:id="@+id/button2"\r
+ android:layout_width="0dip"\r
+ android:layout_height="wrap_content" \r
+ android:layout_gravity="bottom"\r
+ android:layout_weight="1"\r
+ android:text="@string/eula_refuse" />\r
+ </LinearLayout>\r
+ \r
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+Copyright (C) 2008-2009 Steven Osborn - http://steven.bitsetters.com and
+Randy McEoin (and others, see About box)
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- \r
+ * Copyright (C) 2007-2008 OpenIntents.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ -->\r
+<resources>\r
+\r
+ <!-- Strings for OI About -->\r
+ <string name="about_comments">OI Safe keeps all your private data encrypted.</string> \r
+ <string name="about_copyright">Copyright © 2008-2009 Steven Osborn and Randy McEoin</string> \r
+ <string name="about_website_label">OI Safe at OpenIntents</string> \r
+ <string name="about_website_url">http://www.openintents.org</string>\r
+ <string name="about_email">support@openintents.org</string>\r
+ \r
+ <string-array name="about_authors"><!-- Add your name here if you helped out -->\r
+ <item>Steven Osborn - http://steven.bitsetters.com</item>\r
+ <item>Randy McEoin</item>\r
+ <item>Isaac Potoczny-Jones - http://www.syntaxpolice.org</item>\r
+ <item>Peli</item>\r
+ </string-array>\r
+ \r
+ <string-array name="about_documenters"><!-- Add your name here if you helped out -->\r
+ <!-- <item></item> -->\r
+ </string-array>\r
+ \r
+ <string-array name="about_translators"><!-- Add your name here if you helped out, but only in the arrays.xml for the localization that you helped to translate into! -->\r
+ <!-- <item></item> -->\r
+ </string-array>\r
+ \r
+ <string-array name="about_artists"><!-- Add your name here if you helped out -->\r
+ <item>David Vignoni - http://www.icon-king.com/</item>\r
+ <item>Peli</item>\r
+ </string-array>
+</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- \r
+ * Copyright (C) 2007-2008 OpenIntents.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ -->\r
+<resources>\r
+ \r
+ <!-- EULA -->\r
+ <string name="eula_title">OI Safe EULA</string>\r
+ <string name="eula_accept">Accept</string>\r
+ <string name="eula_refuse">Cancel</string>\r
+ \r
+ <!-- Update -->\r
+ <string name="update_box_text">Please check manually for updates or install OI Update\r
+for automatic notifications.\r
+Current version: %s\r
+ </string>\r
+ <string name="update_check_now">Check now.</string>\r
+ <string name="update_get_updater">Get OI Updater.</string>\r
+ <string name="update_app_url">market://search?q=pname:org.openintents.safe</string>\r
+ <string name="update_checker_url">market://search?q=pname:org.openintents.updatechecker</string>\r
+ <string name="update_error">Download application not available.</string>\r
+ <string name="update">Check updates</string>\r
+ \r
+ <!-- About -->\r
+ <string name="about">About</string>\r
+ <string name="aboutapp_not_available">Version %s\n\nNo compatible extension available to display full info (contact, credits, license).</string>\r
+ <string name="aboutapp_get">Get OI About</string>\r
+ <string name="aboutapp_market_uri">market://search?q=pname:org.openintents.about</string>\r
+ \r
+ <!-- File Manager -->\r
+ <string name="filemanager_not_available">No compatible file manager is available.</string>\r
+ <string name="filemanager_get_oi_filemanager">Get OI File Manager</string>\r
+ <string name="filemanager_market_uri">market://search?q=pname:org.openintents.filemanager</string>
+</resources>
--- /dev/null
+/* \r
+ * Copyright (C) 2007-2008 OpenIntents.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openintents.distribution;\r
+\r
+import org.openintents.intents.AboutMiniIntents;\r
+import org.openintents.util.IntentUtils;\r
+import org.openintents.util.VersionUtils;\r
+\r
+import android.app.Activity;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+\r
+/**\r
+ * About dialog\r
+ *\r
+ * @version 2009-01-16\r
+ * @author Peli\r
+ *\r
+ */\r
+public class AboutDialog extends GetFromMarketDialog {\r
+ private static final String TAG = "About";\r
+ \r
+ public AboutDialog(Context context) {\r
+ super(context,\r
+ RD.string.aboutapp_not_available,\r
+ RD.string.aboutapp_get,\r
+ RD.string.aboutapp_market_uri);\r
+ \r
+ String version = VersionUtils.getVersionNumber(context);\r
+ String name = VersionUtils.getApplicationName(context);\r
+\r
+ setTitle(name);\r
+ setMessage(context.getString(RD.string.aboutapp_not_available, version));\r
+ }\r
+ \r
+ public static void showDialogOrStartActivity(Activity activity, int dialogId) {\r
+ Intent intent = new Intent(AboutMiniIntents.ACTION_SHOW_ABOUT_DIALOG);\r
+ intent.putExtra(AboutMiniIntents.EXTRA_PACKAGE_NAME, activity.getPackageName());\r
+ \r
+ if (IntentUtils.isIntentAvailable(activity, intent)) {\r
+ activity.startActivity(intent);\r
+ } else {\r
+ activity.showDialog(dialogId);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.openintents.distribution;\r
+\r
+\r
+import java.io.BufferedReader;\r
+import java.io.IOException;\r
+import java.io.InputStreamReader;\r
+\r
+import android.app.Activity;\r
+import android.content.ComponentName;\r
+import android.content.Intent;\r
+import android.content.SharedPreferences;\r
+import android.content.res.Resources;\r
+import android.os.Bundle;\r
+import android.preference.PreferenceManager;\r
+import android.text.TextUtils;\r
+import android.util.Log;\r
+import android.view.View;\r
+import android.widget.Button;\r
+import android.widget.TextView;\r
+\r
+/**\r
+ * Displays the Eula for the first time, reading it from a raw resource.\r
+ * \r
+ * @version 2009-01-17\r
+ * @author Peli\r
+ *\r
+ */\r
+public class EulaActivity extends Activity {\r
+\r
+ /** TAG for log messages. */\r
+ private static final String TAG = "EulaActivity";\r
+ \r
+ static final String PREFERENCES_EULA_ACCEPTED = "eula_accepted";\r
+ \r
+ /**\r
+ * Extra for main intent.\r
+ * Specifies activity that should be launched after Eula has been accepted.\r
+ */\r
+ private static final String EXTRA_LAUNCH_ACTIVITY_PACKAGE = "org.openintents.extra.launch_activity_package";\r
+ private static final String EXTRA_LAUNCH_ACTIVITY_CLASS = "org.openintents.extra.launch_activity_class";\r
+ \r
+ private Button mAgree;\r
+ private Button mDisagree;\r
+ \r
+ private String mLaunchPackage;\r
+ private String mLaunchClass;\r
+ \r
+ /** Called when the activity is first created. */\r
+ @Override\r
+ public void onCreate(Bundle icicle) {\r
+ super.onCreate(icicle);\r
+ \r
+ setContentView(RD.layout.eula);\r
+ \r
+ // Extras are provided by checkEula() below.\r
+ Intent i = getIntent();\r
+ Bundle b = i.getExtras();\r
+ mLaunchPackage = b.getString(EXTRA_LAUNCH_ACTIVITY_PACKAGE);\r
+ mLaunchClass = b.getString(EXTRA_LAUNCH_ACTIVITY_CLASS);\r
+ \r
+ //mIntroContinue = (Button) findViewById(R.id.intro_continue);\r
+ mAgree = (Button) findViewById(RD.id.button1);\r
+ mAgree.setOnClickListener(new View.OnClickListener() {\r
+ public void onClick(View view) {\r
+ acceptEula();\r
+ }\r
+ });\r
+ \r
+ mDisagree = (Button) findViewById(RD.id.button2);\r
+ mDisagree.setOnClickListener(new View.OnClickListener() {\r
+ public void onClick(View view) {\r
+ refuseEula();\r
+ }\r
+ });\r
+ \r
+ TextView text = (TextView) findViewById(RD.id.text);\r
+ text.setText(readLicenseFromRawResource(RD.raw.license_short));\r
+ \r
+ }\r
+ \r
+ /**\r
+ * Accept EULA and proceed with main application.\r
+ */\r
+ public void acceptEula() {\r
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);\r
+ SharedPreferences.Editor e = sp.edit();\r
+ e.putBoolean(PREFERENCES_EULA_ACCEPTED, true);\r
+ e.commit();\r
+ \r
+ // Call the activity that originally called checkEula()\r
+ Intent i = new Intent();\r
+ i.setClassName(mLaunchPackage, mLaunchClass);\r
+ startActivity(i);\r
+ finish();\r
+ }\r
+ \r
+ /**\r
+ * Refuse EULA.\r
+ */\r
+ public void refuseEula() {\r
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);\r
+ SharedPreferences.Editor e = sp.edit();\r
+ e.putBoolean(PREFERENCES_EULA_ACCEPTED, false);\r
+ e.commit();\r
+ \r
+ finish();\r
+ }\r
+\r
+ /**\r
+ * Test whether EULA has been accepted. Otherwise display EULA.\r
+ * \r
+ * @return True if Eula has been accepted.\r
+ */\r
+ public static boolean checkEula(Activity activity) {\r
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity);\r
+ boolean accepted = sp.getBoolean(PREFERENCES_EULA_ACCEPTED, false);\r
+ \r
+ if (accepted) {\r
+ Log.i(TAG, "Eula has been accepted.");\r
+ return true;\r
+ } else {\r
+ Log.i(TAG, "Eula has not been accepted yet.");\r
+ \r
+ // Launch Eula activity\r
+ Intent i = new Intent(activity, EulaActivity.class);\r
+ ComponentName ci = activity.getComponentName();\r
+ \r
+ // Specify in intent extras which activity should be called\r
+ // after Eula has been accepted.\r
+ Log.d(TAG, "Local package name: " + ci.getPackageName());\r
+ Log.d(TAG, "Local class name: " + ci.getClassName());\r
+ i.putExtra(EXTRA_LAUNCH_ACTIVITY_PACKAGE, ci.getPackageName());\r
+ i.putExtra(EXTRA_LAUNCH_ACTIVITY_CLASS, ci.getClassName());\r
+ activity.startActivity(i);\r
+ activity.finish();\r
+ return false;\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Read license from raw resource.\r
+ * @param resourceid ID of the raw resource.\r
+ * @return\r
+ */\r
+ private String readLicenseFromRawResource(int resourceid) {\r
+\r
+ // Retrieve license from resource:\r
+ String license = "";\r
+ Resources resources = getResources();\r
+ \r
+ //Read in the license file as a big String\r
+ BufferedReader in\r
+ = new BufferedReader(new InputStreamReader(\r
+ resources.openRawResource(resourceid)));\r
+ String line;\r
+ StringBuilder sb = new StringBuilder();\r
+ try {\r
+ while ((line = in.readLine()) != null) { // Read line per line.\r
+ if (TextUtils.isEmpty(line)) {\r
+ // Empty line: Leave line break\r
+ sb.append("\n\n");\r
+ } else {\r
+ sb.append(line);\r
+ sb.append(" ");\r
+ }\r
+ }\r
+ license = sb.toString();\r
+ } catch (IOException e) {\r
+ //Should not happen.\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ \r
+ return license;\r
+ }\r
+}\r
--- /dev/null
+package org.openintents.distribution;\r
+\r
+import android.app.AlertDialog;\r
+import android.content.ActivityNotFoundException;\r
+import android.content.Context;\r
+import android.content.DialogInterface;\r
+import android.content.Intent;\r
+import android.content.DialogInterface.OnClickListener;\r
+import android.net.Uri;\r
+import android.util.Log;\r
+import android.widget.Toast;\r
+\r
+public class GetFromMarketDialog extends AlertDialog implements OnClickListener {\r
+ private static final String TAG = "StartSaveActivity";\r
+\r
+ Context mContext;\r
+ int mMarketUri;\r
+ \r
+ public GetFromMarketDialog(Context context, int message, int buttontext, int market_uri) {\r
+ super(context);\r
+ mContext = context;\r
+ mMarketUri = market_uri;\r
+\r
+ //setTitle(context.getText(R.string.menu_edit_tags));\r
+ setMessage(mContext.getText(message));\r
+ setButton(mContext.getText(buttontext), this);\r
+ \r
+ }\r
+\r
+ public void onClick(DialogInterface dialog, int which) {\r
+ if (which == BUTTON1) {\r
+ Uri uri = Uri.parse(mContext.getString(mMarketUri));\r
+ \r
+ Intent intent = new Intent(Intent.ACTION_VIEW);\r
+ intent.setData(uri);\r
+ GetFromMarketDialog.startSaveActivity(mContext, intent);\r
+ }\r
+ \r
+ }\r
+ \r
+ /**\r
+ * Start an activity but prompt a toast if activity is not found\r
+ * (instead of crashing).\r
+ * \r
+ * @param context\r
+ * @param intent\r
+ */\r
+ public static void startSaveActivity(Context context, Intent intent) {\r
+ try {\r
+ context.startActivity(intent);\r
+ } catch (ActivityNotFoundException e) {\r
+ Toast.makeText(context,\r
+ RD.string.update_error,\r
+ Toast.LENGTH_SHORT).show();\r
+ Log.e(TAG, "Error starting activity.", e);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package org.openintents.distribution;\r
+\r
+import org.openintents.safe.R;\r
+\r
+/**\r
+ * Resources for the distribution package.\r
+ * RD = Resources Distribution\r
+ * @author Peli\r
+ *\r
+ */\r
+public class RD {\r
+ public class layout {\r
+ public static final int eula = R.layout.eula;\r
+ }\r
+ \r
+ public class id {\r
+ \r
+ ///////////////////////////////////////\r
+ // Eula activity\r
+ public static final int button1 = R.id.button1;\r
+ public static final int button2 = R.id.button2;\r
+ public static final int text = R.id.text;\r
+ \r
+ }\r
+ \r
+ public class string {\r
+ \r
+ ///////////////////////////////////////\r
+ // Eula activity\r
+\r
+ ///////////////////////////////////////\r
+ // Update Menu\r
+ public static final int update_box_text = R.string.update_box_text;\r
+ public static final int update_check_now = R.string.update_check_now;\r
+ public static final int update_app_url = R.string.update_app_url;\r
+ public static final int update_get_updater = R.string.update_get_updater;\r
+ public static final int update_checker_url = R.string.update_checker_url;\r
+ public static final int update_error = R.string.update_error;\r
+\r
+ ///////////////////////////////////////\r
+ // GetFromMarketDialog\r
+ public static final int filemanager_not_available = R.string.filemanager_not_available;\r
+ public static final int filemanager_get_oi_filemanager = R.string.filemanager_get_oi_filemanager;\r
+ public static final int filemanager_market_uri = R.string.filemanager_market_uri;\r
+\r
+ ///////////////////////////////////////\r
+ // GetFromMarketDialog\r
+ public static final int aboutapp_not_available = R.string.aboutapp_not_available;\r
+ public static final int aboutapp_get = R.string.aboutapp_get;\r
+ public static final int aboutapp_market_uri = R.string.aboutapp_market_uri;\r
+ \r
+ }\r
+ \r
+ public class raw {\r
+ ///////////////////////////////////////\r
+ // Eula activity\r
+ public static final int license_short = R.raw.license_short;\r
+ \r
+ }\r
+}\r
--- /dev/null
+/* \r
+ * Copyright (C) 2008 OpenIntents.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openintents.distribution;\r
+\r
+// Version Nov 12, 2008\r
+\r
+import android.app.AlertDialog.Builder;\r
+import android.content.ActivityNotFoundException;\r
+import android.content.Context;\r
+import android.content.DialogInterface;\r
+import android.content.Intent;\r
+import android.content.DialogInterface.OnClickListener;\r
+import android.content.pm.PackageInfo;\r
+import android.content.pm.PackageManager.NameNotFoundException;\r
+import android.net.Uri;\r
+import android.util.Log;\r
+import android.view.Menu;\r
+import android.view.MenuItem;\r
+import android.widget.Toast;\r
+\r
+public class UpdateMenu {\r
+ \r
+ private static final String TAG = "UpdateMenu";\r
+ \r
+ public static final String UPDATE_CHECKER = "org.openintents.updatechecker";\r
+\r
+ /**\r
+ * Adds a menu item for update only if update checker is not installed.\r
+ * \r
+ * @param context\r
+ * @param menu\r
+ * @param groupId\r
+ * @param itemId\r
+ * @param order\r
+ * @param titleRes\r
+ * @return\r
+ */\r
+ public static MenuItem addUpdateMenu(Context context, Menu menu, int groupId,\r
+ int itemId, int order, int titleRes) {\r
+ PackageInfo pi = null;\r
+ try {\r
+ pi = context.getPackageManager().getPackageInfo(\r
+ UPDATE_CHECKER, 0);\r
+ } catch (NameNotFoundException e) {\r
+ // ignore\r
+ }\r
+ if (pi == null) {\r
+ return menu.add(groupId, itemId, order, titleRes).setIcon(\r
+ android.R.drawable.ic_menu_info_details).setShortcut('9',\r
+ 'u');\r
+ } else {\r
+ return null;\r
+ }\r
+ }\r
+ \r
+\r
+ /**\r
+ * Shows dialog box with option to upgrade.\r
+ * \r
+ * @param context\r
+ */\r
+ public static void showUpdateBox(final Context context) {\r
+ String version = null;\r
+ try {\r
+ version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;\r
+ } catch (NameNotFoundException e) {\r
+ e.printStackTrace();\r
+ }\r
+ final Intent intent = new Intent(Intent.ACTION_VIEW);\r
+ new Builder(context).setMessage(context.getString(RD.string.update_box_text, version))\r
+ .setPositiveButton(RD.string.update_check_now, new OnClickListener(){\r
+\r
+ public void onClick(DialogInterface arg0, int arg1) {\r
+ intent.setData(Uri.parse(context.getString(RD.string.update_app_url)));\r
+ startSaveActivity(context, intent);\r
+ }\r
+ \r
+ }).setNegativeButton(RD.string.update_get_updater, new OnClickListener(){\r
+\r
+ public void onClick(DialogInterface dialog, int which) {\r
+ intent.setData(Uri.parse(context.getString(RD.string.update_checker_url)));\r
+ startSaveActivity(context, intent);\r
+ }\r
+ \r
+ }).show(); \r
+ }\r
+ \r
+ /**\r
+ * Start an activity but prompt a toast if activity is not found\r
+ * (instead of crashing).\r
+ * \r
+ * @param context\r
+ * @param intent\r
+ */\r
+ private static void startSaveActivity(Context context, Intent intent) {\r
+ try {\r
+ context.startActivity(intent);\r
+ } catch (ActivityNotFoundException e) {\r
+ Toast.makeText(context,\r
+ RD.string.update_error,\r
+ Toast.LENGTH_SHORT).show();\r
+ Log.e(TAG, "Error starting activity.", e);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*
+ * Copyright (C) 2008-2009 OpenIntents.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openintents.intents;
+
+/**
+ * Intents definition belonging to OI About.
+ *
+ * @version 2009-Jan-08
+ *
+ * @author pjv
+ * @author Peli
+ *
+ */
+public final class AboutMiniIntents {
+
+ /**
+ * Empty, preventing instantiation.
+ */
+ private AboutMiniIntents() {
+ //Empty, preventing instantiation.
+ }
+
+ /**
+ * Activity Action: Show an about dialog to display
+ * information about the application.
+ *
+ * The application information is retrieved from the
+ * application's manifest. In order to send the package
+ * you have to launch this activity through
+ * startActivityForResult().
+ *
+ * Alternatively, you can specify the package name
+ * manually through the extra EXTRA_PACKAGE.
+ *
+ * All data can be replaced using optional intent extras.
+ *
+ * <p>
+ * Constant Value: "org.openintents.action.SHOW_ABOUT_DIALOG"
+ * </p>
+ */
+ public static final String ACTION_SHOW_ABOUT_DIALOG =
+ "org.openintents.action.SHOW_ABOUT_DIALOG";
+
+ /**
+ * Optional intent extra: Specify your application package name.
+ *
+ * If you start the About dialog through startActivityForResult()
+ * then the application package is sent automatically and does
+ * not need to be supplied here.
+ *
+ * <p>
+ * Constant Value: "org.openintents.extra.PACKAGE_NAME"
+ * </p>
+ */
+ public static final String EXTRA_PACKAGE_NAME =
+ "org.openintents.extra.PACKAGE_NAME";
+
+}
--- /dev/null
+/* \r
+ * Copyright (C) 2008 OpenIntents.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openintents.intents;\r
+\r
+// Version Dec 9, 2008\r
+\r
+\r
+/**\r
+ * Provides OpenIntents actions, extras, and categories used by providers. \r
+ * <p>These specifiers extend the standard Android specifiers.</p>\r
+ */\r
+public final class FileManagerIntents {\r
+\r
+ /**\r
+ * Activity Action: Pick a file through the file manager, or let user\r
+ * specify a custom file name.\r
+ * Data is the current file name or file name suggestion.\r
+ * Returns a new file name as file URI in data.\r
+ * \r
+ * <p>Constant Value: "org.openintents.action.PICK_FILE"</p>\r
+ */\r
+ public static final String ACTION_PICK_FILE = "org.openintents.action.PICK_FILE";\r
+\r
+ /**\r
+ * Activity Action: Pick a directory through the file manager, or let user\r
+ * specify a custom file name.\r
+ * Data is the current directory name or directory name suggestion.\r
+ * Returns a new directory name as file URI in data.\r
+ * \r
+ * <p>Constant Value: "org.openintents.action.PICK_DIRECTORY"</p>\r
+ */\r
+ public static final String ACTION_PICK_DIRECTORY = "org.openintents.action.PICK_DIRECTORY";\r
+ \r
+ /**\r
+ * The title to display.\r
+ * \r
+ * <p>This is shown in the title bar of the file manager.</p>\r
+ * \r
+ * <p>Constant Value: "org.openintents.extra.TITLE"</p>\r
+ */\r
+ public static final String EXTRA_TITLE = "org.openintents.extra.TITLE";\r
+\r
+ /**\r
+ * The text on the button to display.\r
+ * \r
+ * <p>Depending on the use, it makes sense to set this to "Open" or "Save".</p>\r
+ * \r
+ * <p>Constant Value: "org.openintents.extra.BUTTON_TEXT"</p>\r
+ */\r
+ public static final String EXTRA_BUTTON_TEXT = "org.openintents.extra.BUTTON_TEXT";\r
+\r
+}\r
import java.util.List;
import java.util.Set;
+import org.openintents.distribution.AboutDialog;
import org.openintents.intents.CryptoIntents;
import org.openintents.safe.service.ServiceDispatchImpl;
public static final int BACKUP_INDEX = Menu.FIRST + 9;
public static final int RESTORE_INDEX = Menu.FIRST + 10;
public static final int PREFERENCES_INDEX = Menu.FIRST + 11;
+ public static final int ABOUT_INDEX = Menu.FIRST + 12;
public static final int REQUEST_ONCREATE = 0;
public static final int REQUEST_EDIT_CATEGORY = 1;
private static final int IMPORT_PROGRESS_KEY = 0;
private static final int BACKUP_PROGRESS_KEY = IMPORT_PROGRESS_KEY + 1;
+ private static final int ABOUT_KEY = IMPORT_PROGRESS_KEY + 2;
public static final int MAX_CATEGORIES = 256;
dialog.setCancelable(false);
return dialog;
}
+ case ABOUT_KEY:
+ return new AboutDialog(this);
}
return null;
}
menu.add(0, RESTORE_INDEX, 0, R.string.restore);
menu.add(0, PREFERENCES_INDEX, 0, R.string.preferences);
+ menu.add(0, ABOUT_INDEX, 0, R.string.about).setIcon(
+ android.R.drawable.ic_menu_info_details);
return super.onCreateOptionsMenu(menu);
}
Intent preferences = new Intent(this, Preferences.class);
startActivity(preferences);
break;
+ case ABOUT_INDEX:
+ AboutDialog.showDialogOrStartActivity(this, ABOUT_KEY);
+ break;
default:
Log.e(TAG,"Unknown itemId");
break;
\r
private static final boolean debug = !false;\r
private static String TAG = "FrontDoor";\r
+ \r
+ private static final int REQUEST_CODE_ASK_PASSWORD = 1;\r
+ private static final int REQUEST_CODE_GRANT_EXTERNAL_ACCESS = 2;\r
+ \r
\r
private DBHelper dbHelper;\r
private String masterKey;\r
\r
//currently only handles result from askPassword function.\r
protected void onActivityResult (int requestCode, int resultCode, Intent data) {\r
- switch (resultCode) {\r
- case RESULT_OK:\r
- masterKey = data.getStringExtra("masterKey");\r
- String timeout = mPreferences.getString("lock_timeout", "5"); \r
- int timeoutMinutes=5; // default to 5\r
- try {\r
- timeoutMinutes = Integer.valueOf(timeout);\r
- } catch (NumberFormatException e) {\r
- Log.d(TAG,"why is lock_timeout busted?");\r
- }\r
- try {\r
- service.setTimeoutMinutes(timeoutMinutes);\r
- service.setPassword(masterKey); // should already be connected.\r
- } catch (RemoteException e1) {\r
- // TODO Auto-generated catch block\r
- e1.printStackTrace();\r
+ if (resultCode == RESULT_OK) {\r
+ switch (requestCode) {\r
+ case REQUEST_CODE_ASK_PASSWORD:\r
+ masterKey = data.getStringExtra("masterKey");\r
+ String timeout = mPreferences.getString("lock_timeout", "5"); \r
+ int timeoutMinutes=5; // default to 5\r
+ try {\r
+ timeoutMinutes = Integer.valueOf(timeout);\r
+ } catch (NumberFormatException e) {\r
+ Log.d(TAG,"why is lock_timeout busted?");\r
+ }\r
+ try {\r
+ service.setTimeoutMinutes(timeoutMinutes);\r
+ service.setPassword(masterKey); // should already be connected.\r
+ } catch (RemoteException e1) {\r
+ // TODO Auto-generated catch block\r
+ e1.printStackTrace();\r
+ }\r
+ actionDispatch();\r
+ break;\r
+ case REQUEST_CODE_GRANT_EXTERNAL_ACCESS:\r
+ \r
+ break;\r
}\r
- actionDispatch();\r
- break;\r
- case RESULT_CANCELED:\r
+ \r
+ } else { // resultCode == RESULT_CANCELED\r
setResult(RESULT_CANCELED);\r
finish();\r
- break;\r
}\r
}\r
\r
askPass.putExtra (CryptoIntents.EXTRA_TEXT, inputBody);\r
askPass.putExtra (AskPassword.EXTRA_IS_LOCAL, askPassIsLocal);\r
//TODO: Is there a way to make sure all the extras are set? \r
- startActivityForResult (askPass, 0);\r
+ startActivityForResult (askPass, REQUEST_CODE_ASK_PASSWORD);\r
} else {\r
if (debug) Log.d(TAG, "ask for password");\r
// Don't prompt but cancel\r
--- /dev/null
+package org.openintents.safe.dialog;\r
+\r
+import org.openintents.distribution.GetFromMarketDialog;\r
+import org.openintents.distribution.RD;\r
+import org.openintents.intents.FileManagerIntents;\r
+import org.openintents.safe.R;\r
+import org.openintents.util.IntentUtils;\r
+\r
+import android.app.Activity;\r
+import android.app.Dialog;\r
+import android.content.DialogInterface;\r
+import android.content.Intent;\r
+import android.content.DialogInterface.OnDismissListener;\r
+import android.os.Bundle;\r
+import android.util.Log;\r
+import android.widget.EditText;\r
+\r
+public class DialogHostingActivity extends Activity {\r
+\r
+ private static final String TAG = "FilenameActivity";\r
+\r
+ public static final int DIALOG_ID_SAVE = 1;\r
+ public static final int DIALOG_ID_OPEN = 2;\r
+ public static final int DIALOG_ID_NO_FILE_MANAGER_AVAILABLE = 3;\r
+ \r
+ public static final String EXTRA_DIALOG_ID = "org.openintents.notepad.extra.dialog_id";\r
+ \r
+ EditText mEditText;\r
+ \r
+ @Override\r
+ protected void onCreate(Bundle savedInstanceState) {\r
+ super.onCreate(savedInstanceState);\r
+ \r
+ Intent i = getIntent();\r
+ if (i != null) {\r
+ int dialogId = i.getIntExtra(EXTRA_DIALOG_ID, 0);\r
+ switch (dialogId) {\r
+ case DIALOG_ID_SAVE:\r
+ Log.i(TAG, "Show Save dialog");\r
+ saveFile();\r
+ break;\r
+ case DIALOG_ID_OPEN:\r
+ Log.i(TAG, "Show Save dialog");\r
+ openFile();\r
+ break;\r
+ case DIALOG_ID_NO_FILE_MANAGER_AVAILABLE:\r
+ Log.i(TAG, "Show no file manager dialog");\r
+ showDialog(DIALOG_ID_NO_FILE_MANAGER_AVAILABLE);\r
+ break;\r
+ }\r
+ }\r
+ \r
+ \r
+ }\r
+\r
+\r
+ /**\r
+ * \r
+ */\r
+ private void saveFile() {\r
+ \r
+ // Check whether intent exists\r
+ Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE);\r
+ intent.setData(getIntent().getData());\r
+ if (IntentUtils.isIntentAvailable(this, intent)) {\r
+ /*\r
+ intent.putExtra(NotePadIntents.EXTRA_URI, getIntent().getStringExtra(NotePadIntents.EXTRA_URI));\r
+ intent.putExtra(FileManagerIntents.EXTRA_TITLE, getText(R.string.menu_save_to_sdcard));\r
+ intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getText(R.string.save));\r
+ */\r
+ intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);\r
+ startActivity(intent);\r
+ finish();\r
+ } else {\r
+ showDialog(DIALOG_ID_SAVE);\r
+ }\r
+ }\r
+ \r
+\r
+ private void openFile() {\r
+ \r
+ // Check whether intent exists\r
+ Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE);\r
+ intent.setData(getIntent().getData());\r
+ if (IntentUtils.isIntentAvailable(this, intent)) {\r
+ /*\r
+ intent.putExtra(NotePadIntents.EXTRA_URI, getIntent().getStringExtra(NotePadIntents.EXTRA_URI));\r
+ intent.putExtra(FileManagerIntents.EXTRA_TITLE, getText(R.string.menu_open_from_sdcard));\r
+ intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getText(R.string.open));\r
+ intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);\r
+ */\r
+ startActivity(intent);\r
+ finish();\r
+ } else {\r
+ showDialog(DIALOG_ID_OPEN);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ protected Dialog onCreateDialog(int id) {\r
+\r
+ switch (id) {\r
+ case DIALOG_ID_SAVE:\r
+ return new FilenameDialog(this);\r
+ case DIALOG_ID_OPEN:\r
+ return new FilenameDialog(this);\r
+ case DIALOG_ID_NO_FILE_MANAGER_AVAILABLE:\r
+ Log.i(TAG, "fmd - create");\r
+ return new GetFromMarketDialog(this, \r
+ RD.string.filemanager_not_available,\r
+ RD.string.filemanager_get_oi_filemanager,\r
+ RD.string.filemanager_market_uri);\r
+\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ protected void onPrepareDialog(int id, Dialog dialog) {\r
+ FilenameDialog fd;\r
+ \r
+ dialog.setOnDismissListener(mDismissListener);\r
+ \r
+ switch (id) {\r
+ case DIALOG_ID_SAVE:\r
+ fd = (FilenameDialog) dialog;\r
+ //fd.setTitle(R.string.menu_save_to_sdcard);\r
+ \r
+ break;\r
+ case DIALOG_ID_OPEN:\r
+ fd = (FilenameDialog) dialog;\r
+ //fd.setTitle(R.string.menu_open_from_sdcard);\r
+ break;\r
+ \r
+ case DIALOG_ID_NO_FILE_MANAGER_AVAILABLE:\r
+ Log.i(TAG, "fmd - prepare");\r
+ /*\r
+ GetFileManagerFromMarketDialog gd = (GetFileManagerFromMarketDialog) dialog;\r
+ gd.setMessageResource(R.string.filemanager_not_available);\r
+ gd.setInfoResources(R.string.filemanager_get_oi_filemanager, \r
+ R.string.filemanager_market_uri, \r
+ R.drawable.ic_launcher_folder_small, \r
+ R.string.update_error);\r
+ */\r
+ break;\r
+ }\r
+ }\r
+ \r
+ OnDismissListener mDismissListener = new OnDismissListener() {\r
+ \r
+ public void onDismiss(DialogInterface dialoginterface) {\r
+ DialogHostingActivity.this.finish();\r
+ }\r
+ \r
+ };\r
+ \r
+}\r
--- /dev/null
+package org.openintents.safe.dialog;\r
+\r
+import org.openintents.safe.R;\r
+\r
+import android.app.AlertDialog;\r
+import android.content.Context;\r
+import android.content.DialogInterface;\r
+import android.content.Intent;\r
+import android.content.DialogInterface.OnClickListener;\r
+import android.os.Bundle;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.widget.EditText;\r
+import android.widget.ImageButton;\r
+\r
+public class FilenameDialog extends AlertDialog implements OnClickListener {\r
+ private static final String TAG = "FilenameDialog";\r
+\r
+ private static final String BUNDLE_TAGS = "tags";\r
+ \r
+ protected static final int DIALOG_ID_NO_FILE_MANAGER_AVAILABLE = 2;\r
+ \r
+ Context mContext;\r
+ \r
+ EditText mEditText;\r
+ \r
+ public FilenameDialog(Context context) {\r
+ super(context);\r
+ mContext = context;\r
+ \r
+ //setTitle(context.getText(R.string.menu_edit_tags));\r
+ setButton(context.getText(android.R.string.ok), this);\r
+ setButton2(context.getText(android.R.string.cancel), (OnClickListener) null);\r
+ setIcon(R.drawable.ic_launcher_folder_small);\r
+ \r
+ LayoutInflater inflater = \r
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
+ View view = inflater.inflate(R.layout.dialog_filename, null);\r
+ setView(view);\r
+\r
+ mEditText = (EditText) view.findViewById(R.id.file_path);\r
+ \r
+ //SharedPreferences pm = PreferenceManager.getDefaultSharedPreferences(this);\r
+ //mEditText.setText(pm.getString(PREFERENCE_FILENAME, DEFAULT_FILENAME));\r
+\r
+ ImageButton buttonFileManager = (ImageButton) view.findViewById(R.id.file_manager);\r
+ \r
+ buttonFileManager.setOnClickListener(new View.OnClickListener() {\r
+ \r
+ public void onClick(View arg0) {\r
+ openFileManager();\r
+ }\r
+ });\r
+\r
+ }\r
+ \r
+ \r
+ public void onClick(DialogInterface dialog, int which) {\r
+ if (which == BUTTON1) {\r
+ openOrSave();\r
+ }\r
+ \r
+ }\r
+ \r
+ void openOrSave() {\r
+ }\r
+\r
+ private void openFileManager() {\r
+ showNoFileManagerAvailableDialog();\r
+ \r
+ /*\r
+ String fileName = mEditText.getText().toString();\r
+ \r
+ Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE);\r
+ intent.setData(Uri.parse("file://" + fileName));\r
+ */\r
+ \r
+ //intent.putExtra(FileManagerIntents.EXTRA_TITLE, getString(RES_STRING_FILEMANAGER_TITLE));\r
+ //intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getString(RES_STRING_FILEMANAGER_BUTTON_TEXT));\r
+ \r
+ /*\r
+ try {\r
+ startActivityForResult(intent, REQUEST_CODE_PICK_FILE);\r
+ } catch (ActivityNotFoundException e) {\r
+ mContext.showDialog(DIALOG_ID_NO_FILE_MANAGER_AVAILABLE);\r
+ }\r
+ */\r
+ }\r
+\r
+ void showNoFileManagerAvailableDialog() {\r
+\r
+ Intent i = new Intent(mContext, DialogHostingActivity.class);\r
+ i.putExtra(DialogHostingActivity.EXTRA_DIALOG_ID, DialogHostingActivity.DIALOG_ID_NO_FILE_MANAGER_AVAILABLE);\r
+ mContext.startActivity(i);\r
+ }\r
+ \r
+ @Override\r
+ public Bundle onSaveInstanceState() {\r
+ Bundle state = super.onSaveInstanceState();\r
+ state.putString(BUNDLE_TAGS, "");\r
+ return state;\r
+ }\r
+ \r
+ @Override\r
+ public void onRestoreInstanceState(Bundle savedInstanceState) {\r
+ super.onRestoreInstanceState(savedInstanceState);\r
+ String tags = savedInstanceState.getString(BUNDLE_TAGS);\r
+ }\r
+}\r
--- /dev/null
+\r
+\r
+/**\r
+ * Original method retrieved from:\r
+ * http://android-developers.blogspot.com/2009/01/can-i-use-this-intent.html\r
+ */\r
+package org.openintents.util;\r
+\r
+import java.util.List;\r
+\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.pm.PackageManager;\r
+import android.content.pm.ResolveInfo;\r
+\r
+/**\r
+ * \r
+ * @author romainguy\r
+ * @author Peli\r
+ *\r
+ */\r
+public class IntentUtils {\r
+ \r
+ /**\r
+ * Indicates whether the specified action can be used as an intent. This\r
+ * method queries the package manager for installed packages that can\r
+ * respond to the specified intent. If no suitable package is\r
+ * found, this method returns false.\r
+ *\r
+ * @param context The application's environment.\r
+ * @param intent The Intent to check for availability.\r
+ *\r
+ * @return True if an Intent with the specified action can be sent and\r
+ * responded to, false otherwise.\r
+ */\r
+ public static boolean isIntentAvailable(final Context context, final Intent intent) {\r
+ final PackageManager packageManager = context.getPackageManager();\r
+ List<ResolveInfo> list =\r
+ packageManager.queryIntentActivities(intent,\r
+ PackageManager.MATCH_DEFAULT_ONLY);\r
+ return list.size() > 0;\r
+ }\r
+}\r