diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-04 22:04:27 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-04 22:04:27 +0200 |
commit | d8bd6e29461d30a8638831451b781b8efa7e4a3f (patch) | |
tree | ec41dd1c72d9602ec47cdeb7b67f592a8dbd34a7 | |
parent | c3b49a318f82238245f6c40b7a8abda01cb9433d (diff) | |
download | open-keychain-d8bd6e29461d30a8638831451b781b8efa7e4a3f.tar.gz open-keychain-d8bd6e29461d30a8638831451b781b8efa7e4a3f.tar.bz2 open-keychain-d8bd6e29461d30a8638831451b781b8efa7e4a3f.zip |
Settings fragment and activity for apps
11 files changed, 220 insertions, 113 deletions
diff --git a/OpenPGP-Keychain/AndroidManifest.xml b/OpenPGP-Keychain/AndroidManifest.xml index 69abb39d9..2509e1760 100644 --- a/OpenPGP-Keychain/AndroidManifest.xml +++ b/OpenPGP-Keychain/AndroidManifest.xml @@ -470,7 +470,12 @@ <activity android:name="org.sufficientlysecure.keychain.remote_api.RegisteredAppsListActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" + android:exported="false" android:label="@string/title_crypto_consumers" /> + <activity + android:name="org.sufficientlysecure.keychain.remote_api.AppSettingsActivity" + android:configChanges="orientation|screenSize|keyboardHidden|keyboard" + android:exported="false" /> <!-- Remote API --> diff --git a/OpenPGP-Keychain/res/layout/api_app_register_activity.xml b/OpenPGP-Keychain/res/layout/api_app_register_activity.xml new file mode 100644 index 000000000..b8b668681 --- /dev/null +++ b/OpenPGP-Keychain/res/layout/api_app_register_activity.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <fragment + android:id="@+id/api_app_settings_fragment" + android:name="org.sufficientlysecure.keychain.remote_api.AppSettingsFragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + tools:layout="@layout/api_app_settings_fragment" /> + + <LinearLayout + android:id="@+id/register_crypto_consumer_register_layout" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingBottom="3dip" > + + <TextView + android:id="@+id/register_crypto_consumer_question" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Package TODO requests permanent access to OpenPGP Keychain\'s API. Allow permanent access?" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <LinearLayout + android:id="@+id/register_crypto_consumer_register_layout" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingBottom="3dip" > + + <Button + android:id="@+id/register_crypto_consumer_disallow" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="Disallow access" /> + + <Button + android:id="@+id/register_crypto_consumer_allow" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="Allow access" /> + </LinearLayout> + </LinearLayout> + + +</LinearLayout>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/layout/api_app_settings_activity.xml b/OpenPGP-Keychain/res/layout/api_app_settings_activity.xml new file mode 100644 index 000000000..e25a110cc --- /dev/null +++ b/OpenPGP-Keychain/res/layout/api_app_settings_activity.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <fragment + android:id="@+id/api_app_settings_fragment" + android:name="org.sufficientlysecure.keychain.remote_api.AppSettingsFragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + tools:layout="@layout/api_app_settings_fragment" /> + + <LinearLayout + android:id="@+id/register_crypto_consumer_edit_layout" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingBottom="3dip" > + + <Button + android:id="@+id/register_crypto_consumer_disallow" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="Revoke access" /> + + <Button + android:id="@+id/register_crypto_consumer_allow" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="Save" /> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/layout/api_app_settings_fragment.xml b/OpenPGP-Keychain/res/layout/api_app_settings_fragment.xml new file mode 100644 index 000000000..3763d3198 --- /dev/null +++ b/OpenPGP-Keychain/res/layout/api_app_settings_fragment.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingBottom="3dip" > + + <TextView + android:id="@+id/register_crypto_consumer_select_key" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:text="Select key" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <Button + android:id="@+id/register_crypto_consumer_select_key_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="TD Select priv key" /> + </LinearLayout> + + <Button + android:id="@+id/api_app_settings_advanced_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="show advanced settings" /> + + <LinearLayout + android:id="@+id/api_app_settings_advanced" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <CheckBox + android:id="@+id/asciiArmour" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/label_asciiArmour" /> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/layout/api_app_settings_list_activity.xml b/OpenPGP-Keychain/res/layout/api_apps_list_activity.xml index a926ad1a8..e4657c107 100644 --- a/OpenPGP-Keychain/res/layout/api_app_settings_list_activity.xml +++ b/OpenPGP-Keychain/res/layout/api_apps_list_activity.xml @@ -5,7 +5,7 @@ <fragment android:id="@+id/crypto_consumers_list_fragment" - android:name="org.sufficientlysecure.keychain.remote_api.RegisteredAppsFragment" + android:name="org.sufficientlysecure.keychain.remote_api.RegisteredAppsListFragment" android:layout_width="match_parent" android:layout_height="match_parent" /> diff --git a/OpenPGP-Keychain/res/layout/api_register_activity.xml b/OpenPGP-Keychain/res/layout/api_register_activity.xml deleted file mode 100644 index 3af373956..000000000 --- a/OpenPGP-Keychain/res/layout/api_register_activity.xml +++ /dev/null @@ -1,102 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" > - - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:paddingBottom="3dip" > - - <TextView - android:id="@+id/register_crypto_consumer_select_key" - android:layout_width="0dip" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_weight="1" - android:text="Select key" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <Button - android:id="@+id/register_crypto_consumer_select_key_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:text="TD Select priv key" /> - </LinearLayout> - - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" > - - <CheckBox - android:id="@+id/asciiArmour" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:text="@string/label_asciiArmour" /> - </LinearLayout> - - <LinearLayout - android:id="@+id/register_crypto_consumer_register_layout" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:paddingBottom="3dip" > - - <TextView - android:id="@+id/register_crypto_consumer_question" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Package TODO requests permanent access to OpenPGP Keychain\'s API. Allow permanent access?" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <LinearLayout - android:id="@+id/register_crypto_consumer_register_layout" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:paddingBottom="3dip" > - - <Button - android:id="@+id/register_crypto_consumer_disallow" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Disallow access" /> - - <Button - android:id="@+id/register_crypto_consumer_allow" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Allow access" /> - </LinearLayout> - </LinearLayout> - - <LinearLayout - android:id="@+id/register_crypto_consumer_edit_layout" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:paddingBottom="3dip" > - - <Button - android:id="@+id/register_crypto_consumer_disallow" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Revoke access" /> - - <Button - android:id="@+id/register_crypto_consumer_allow" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Save" /> - </LinearLayout> - -</LinearLayout>
\ No newline at end of file diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java new file mode 100644 index 000000000..31fbdc8a6 --- /dev/null +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java @@ -0,0 +1,35 @@ +package org.sufficientlysecure.keychain.remote_api; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; + +import com.actionbarsherlock.app.SherlockFragmentActivity; + +public class AppSettingsActivity extends SherlockFragmentActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.api_app_settings_activity); + + // check if add new or edit existing + Intent intent = getIntent(); + Uri appUri = intent.getData(); + if (appUri == null) { + Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!"); + finish(); + return; + } + + Log.d(Constants.TAG, "uri: " + appUri); + + + } + +} diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java new file mode 100644 index 000000000..4bb09d50f --- /dev/null +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java @@ -0,0 +1,20 @@ +package org.sufficientlysecure.keychain.remote_api; + +import org.sufficientlysecure.keychain.R; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class AppSettingsFragment extends Fragment { + + /** + * Inflate the layout for this fragment + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.api_app_settings_fragment, container, false); + } +} diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListActivity.java index bf34e14f4..f5487e2a3 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListActivity.java @@ -19,7 +19,7 @@ public class RegisteredAppsListActivity extends SherlockFragmentActivity { mActionBar = getSupportActionBar(); - setContentView(R.layout.api_app_settings_list_activity); + setContentView(R.layout.api_apps_list_activity); mActionBar.setDisplayShowTitleEnabled(true); mActionBar.setDisplayHomeAsUpEnabled(true); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListFragment.java index b8fd649b4..52f4d1398 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListFragment.java @@ -1,11 +1,13 @@ package org.sufficientlysecure.keychain.remote_api; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumers; -import org.sufficientlysecure.keychain.util.Log; import com.actionbarsherlock.app.SherlockListFragment; +import android.content.ContentUris; +import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; @@ -13,9 +15,11 @@ import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; -public class RegisteredAppsFragment extends SherlockListFragment implements +public class RegisteredAppsListFragment extends SherlockListFragment implements LoaderManager.LoaderCallbacks<Cursor> { // This is the Adapter being used to display the list's data. @@ -28,6 +32,17 @@ public class RegisteredAppsFragment extends SherlockListFragment implements public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + getListView().setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { + // edit app settings + Intent intent = new Intent(getActivity(), AppSettingsActivity.class); + intent.setData(ContentUris.withAppendedId( + KeychainContract.CryptoConsumers.CONTENT_URI, id)); + startActivity(intent); + } + }); + // Give some text to display if there is no data. In a real // application this would come from a resource. setEmptyText(getString(R.string.api_no_apps)); @@ -44,12 +59,6 @@ public class RegisteredAppsFragment extends SherlockListFragment implements getLoaderManager().initLoader(0, null, this); } - @Override - public void onListItemClick(ListView l, View v, int position, long id) { - // Insert desired behavior here. - Log.i("FragmentComplexList", "Item clicked: " + id); - } - // These are the Contacts rows that we will retrieve. static final String[] CONSUMERS_SUMMARY_PROJECTION = new String[] { CryptoConsumers._ID, CryptoConsumers.PACKAGE_NAME }; diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java index ba09c9f56..5849fb80d 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java @@ -133,7 +133,7 @@ public class ServiceActivity extends SherlockFragmentActivity { if (ACTION_REGISTER.equals(action)) { final String packageName = extras.getString(EXTRA_PACKAGE_NAME); - setContentView(R.layout.api_register_activity); + setContentView(R.layout.api_app_settings_activity); LinearLayout layoutRegister = (LinearLayout) findViewById(R.id.register_crypto_consumer_register_layout); LinearLayout layoutEdit = (LinearLayout) findViewById(R.id.register_crypto_consumer_edit_layout); |