<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">
+ <activity class=".FrontDoor" android:name="FrontDoor" android:label="@string/app_name"\r
+ android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />\r
<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" />\r
+ <activity android:name=".dialog.DialogHostingActivity" android:label="@string/app_name"\r
+ android:theme="@android:style/Theme.Translucent.NoTitleBar" />
\r
<activity android:name="org.openintents.distribution.EulaActivity" android:label="@string/eula_title" />\r
--- /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="vertical"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="wrap_content"\r
+ android:layout_marginBottom="10dip"\r
+ >\r
+ <CheckBox xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:id="@+id/checkbox"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="@string/dialog_summary_external_access"\r
+ />\r
+ \r
+ <TextView android:id="@+id/text"\r
+ android:layout_width="fill_parent" \r
+ android:layout_height="wrap_content" \r
+ android:text="@string/dialog_comment_external_access"\r
+ android:layout_margin="10dip" />\r
+</LinearLayout>
\ No newline at end of file
<string name="preferences">Preferences</string>\r
<string name="pref_title_external_access">Allow external access</string>\r
<string name="pref_summary_external_access">Allow other applications to access safe.</string>\r
+ <string name="dialog_title_external_access">External application tries to access OI Safe</string>\r
+ <string name="dialog_summary_external_access">Allow other applications to access OI Safe.</string>\r
+ <string name="dialog_comment_external_access">This can also be set in Menu / Preferences.</string>\r
<string name="pref_title_lock_timeout">Lock timeout</string>\r
<string name="pref_summary_lock_timeout">Minutes before timeout occurs and safe is locked.</string>\r
<string name="pref_dialog_title_lock_timeout">Lock timeout</string>\r
import java.util.ArrayList;\r
\r
import org.openintents.intents.CryptoIntents;\r
+import org.openintents.safe.dialog.DialogHostingActivity;\r
import org.openintents.safe.service.ServiceDispatch;\r
import org.openintents.safe.service.ServiceDispatchImpl;\r
\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
+ private static final int REQUEST_CODE_ALLOW_EXTERNAL_ACCESS = 2;\r
\r
\r
private DBHelper dbHelper;\r
// TODO Auto-generated catch block\r
e1.printStackTrace();\r
}\r
- actionDispatch();\r
+\r
+ boolean externalAccess = mPreferences.getBoolean(Preferences.PREFERENCE_ALLOW_EXTERNAL_ACCESS, false);\r
+ boolean isLocal = isIntentLocal();\r
+ \r
+ if (isLocal || externalAccess) {\r
+ actionDispatch();\r
+ } else {\r
+ // ask first\r
+ showDialogAllowExternalAccess();\r
+ }\r
break;\r
- case REQUEST_CODE_GRANT_EXTERNAL_ACCESS:\r
- \r
+ case REQUEST_CODE_ALLOW_EXTERNAL_ACCESS:\r
+\r
+ actionDispatch();\r
break;\r
}\r
\r
finish();\r
}\r
}\r
+\r
+ /**\r
+ * \r
+ */\r
+ private void showDialogAllowExternalAccess() {\r
+ Intent i = new Intent(this, DialogHostingActivity.class);\r
+ i.putExtra(DialogHostingActivity.EXTRA_DIALOG_ID, DialogHostingActivity.DIALOG_ID_ALLOW_EXTERNAL_ACCESS);\r
+ this.startActivityForResult(i, REQUEST_CODE_ALLOW_EXTERNAL_ACCESS);\r
+ }\r
\r
protected void actionDispatch () { \r
final Intent thisIntent = getIntent();\r
ch.setPassword(masterKey);\r
}\r
\r
- boolean externalAccess = mPreferences.getBoolean("external_access", false);\r
+ boolean externalAccess = mPreferences.getBoolean(Preferences.PREFERENCE_ALLOW_EXTERNAL_ACCESS, false);\r
\r
if (action == null || action.equals(Intent.ACTION_MAIN)){\r
//TODO: When launched from debugger, action is null. Other such cases?\r
//--------------------------- service stuff ------------\r
private void initService() {\r
\r
- String action = getIntent().getAction();\r
- boolean isLocal = action == null || action.equals(Intent.ACTION_MAIN);\r
+ boolean isLocal = isIntentLocal();\r
conn = new ServiceDispatchConnection(isLocal);\r
Intent i = new Intent();\r
i.setClass(this, ServiceDispatchImpl.class);\r
bindService( i, conn, Context.BIND_AUTO_CREATE);\r
}\r
\r
+ /**\r
+ * @return\r
+ */\r
+ private boolean isIntentLocal() {\r
+ String action = getIntent().getAction();\r
+ boolean isLocal = action == null || action.equals(Intent.ACTION_MAIN);\r
+ return isLocal;\r
+ }\r
+\r
private void releaseService() {\r
if (conn != null ) {\r
unbindService( conn );\r
} else {\r
if (debug) Log.d(TAG, "service already started");\r
//service already started, so don't need to ask pw.\r
- masterKey = service.getPassword();\r
- actionDispatch();\r
+\r
+ boolean externalAccess = mPreferences.getBoolean(Preferences.PREFERENCE_ALLOW_EXTERNAL_ACCESS, false);\r
+ \r
+ if (askPassIsLocal || externalAccess) {\r
+ masterKey = service.getPassword();\r
+ actionDispatch();\r
+ } else {\r
+ showDialogAllowExternalAccess();\r
+ }\r
}\r
} catch (RemoteException e) {\r
Log.d(TAG, e.toString());\r
public class Preferences extends PreferenceActivity {
+ public static final String PREFERENCE_ALLOW_EXTERNAL_ACCESS = "external_access";
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
--- /dev/null
+package org.openintents.safe.dialog;\r
+\r
+import org.openintents.safe.Preferences;\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.SharedPreferences;\r
+import android.content.DialogInterface.OnClickListener;\r
+import android.os.Bundle;\r
+import android.preference.PreferenceManager;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.widget.CheckBox;\r
+\r
+public class AllowExternalAccessDialog 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
+ CheckBox mCheckBox;\r
+ \r
+ public AllowExternalAccessDialog(Context context) {\r
+ super(context);\r
+ mContext = context;\r
+ \r
+ setTitle(context.getText(R.string.dialog_title_external_access));\r
+ setButton(context.getText(android.R.string.ok), this);\r
+ setButton2(context.getText(android.R.string.cancel), (OnClickListener) null);\r
+ setIcon(android.R.drawable.ic_dialog_alert);\r
+ \r
+ LayoutInflater inflater = \r
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
+ View view = inflater.inflate(R.layout.dialog_allow_access, null);\r
+ setView(view);\r
+\r
+ \r
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);\r
+ boolean externalAccess = sp.getBoolean(Preferences.PREFERENCE_ALLOW_EXTERNAL_ACCESS, false);\r
+ \r
+ mCheckBox = (CheckBox) view.findViewById(R.id.checkbox);\r
+ // mCheckBox.setText(R.string.pref_summary_external_access);\r
+ mCheckBox.setChecked(externalAccess);\r
+\r
+ }\r
+ \r
+ \r
+ public void onClick(DialogInterface dialog, int which) {\r
+ if (which == BUTTON1) {\r
+ // User pressed OK\r
+ boolean externalAccess = mCheckBox.isChecked();\r
+\r
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);\r
+ SharedPreferences.Editor editor = sp.edit();\r
+ editor.putBoolean(Preferences.PREFERENCE_ALLOW_EXTERNAL_ACCESS, externalAccess);\r
+ editor.commit();\r
+ \r
+ }\r
+ \r
+ }\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
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
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
+ public static final int DIALOG_ID_ALLOW_EXTERNAL_ACCESS = 4;\r
\r
public static final String EXTRA_DIALOG_ID = "org.openintents.notepad.extra.dialog_id";\r
\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
+ case DIALOG_ID_ALLOW_EXTERNAL_ACCESS:\r
+ Log.i(TAG, "Show allow access dialog");\r
+ showDialog(DIALOG_ID_ALLOW_EXTERNAL_ACCESS);\r
break;\r
}\r
}\r
RD.string.filemanager_not_available,\r
RD.string.filemanager_get_oi_filemanager,\r
RD.string.filemanager_market_uri);\r
-\r
+ case DIALOG_ID_ALLOW_EXTERNAL_ACCESS:\r
+ return new AllowExternalAccessDialog(this);\r
}\r
return null;\r
}\r