Accounts API, user interface
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.NFC" />
|
<uses-permission android:name="android.permission.NFC" />
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
|
|
||||||
<!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! -->
|
<!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! -->
|
||||||
<application
|
<application
|
||||||
@@ -98,14 +98,12 @@
|
|||||||
android:name=".ui.SelectPublicKeyActivity"
|
android:name=".ui.SelectPublicKeyActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/title_select_recipients"
|
android:label="@string/title_select_recipients"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTop"></activity>
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.SelectSecretKeyActivity"
|
android:name=".ui.SelectSecretKeyActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/title_select_secret_key"
|
android:label="@string/title_select_secret_key"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTop"></activity>
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.EncryptActivity"
|
android:name=".ui.EncryptActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
@@ -144,23 +142,23 @@
|
|||||||
|
|
||||||
<!--<!– VIEW with mimeType: TODO (from email app) –>-->
|
<!--<!– VIEW with mimeType: TODO (from email app) –>-->
|
||||||
<!--<intent-filter android:label="@string/intent_import_key">-->
|
<!--<intent-filter android:label="@string/intent_import_key">-->
|
||||||
<!--<action android:name="android.intent.action.VIEW" />-->
|
<!--<action android:name="android.intent.action.VIEW" />-->
|
||||||
|
|
||||||
<!--<category android:name="android.intent.category.BROWSABLE" />-->
|
<!--<category android:name="android.intent.category.BROWSABLE" />-->
|
||||||
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
||||||
|
|
||||||
<!--<!– mime type as defined in http://tools.ietf.org/html/rfc3156 –>-->
|
<!--<!– mime type as defined in http://tools.ietf.org/html/rfc3156 –>-->
|
||||||
<!--<data android:mimeType="application/pgp-signature" />-->
|
<!--<data android:mimeType="application/pgp-signature" />-->
|
||||||
<!--</intent-filter>-->
|
<!--</intent-filter>-->
|
||||||
<!--<!– VIEW with mimeType: TODO (from email app) –>-->
|
<!--<!– VIEW with mimeType: TODO (from email app) –>-->
|
||||||
<!--<intent-filter android:label="@string/intent_import_key">-->
|
<!--<intent-filter android:label="@string/intent_import_key">-->
|
||||||
<!--<action android:name="android.intent.action.VIEW" />-->
|
<!--<action android:name="android.intent.action.VIEW" />-->
|
||||||
|
|
||||||
<!--<category android:name="android.intent.category.BROWSABLE" />-->
|
<!--<category android:name="android.intent.category.BROWSABLE" />-->
|
||||||
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
||||||
|
|
||||||
<!--<!– mime type as defined in http://tools.ietf.org/html/rfc3156 –>-->
|
<!--<!– mime type as defined in http://tools.ietf.org/html/rfc3156 –>-->
|
||||||
<!--<data android:mimeType="application/pgp-encrypted" />-->
|
<!--<data android:mimeType="application/pgp-encrypted" />-->
|
||||||
<!--</intent-filter>-->
|
<!--</intent-filter>-->
|
||||||
<!-- Keychain's own Actions -->
|
<!-- Keychain's own Actions -->
|
||||||
<!-- DECRYPT with text as extra -->
|
<!-- DECRYPT with text as extra -->
|
||||||
@@ -236,7 +234,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".ui.PreferencesActivity"
|
android:name=".ui.PreferencesActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/title_preferences" >
|
android:label="@string/title_preferences">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="org.sufficientlysecure.keychain.ui.PREFS_GEN" />
|
<action android:name="org.sufficientlysecure.keychain.ui.PREFS_GEN" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -374,17 +372,17 @@
|
|||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:process=":passphrase_cache" />
|
android:process=":passphrase_cache" />
|
||||||
<service
|
<service
|
||||||
android:name="org.sufficientlysecure.keychain.service.KeychainIntentService"
|
android:name=".service.KeychainIntentService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="org.sufficientlysecure.keychain.provider.KeychainProvider"
|
android:name=".provider.KeychainProvider"
|
||||||
android:authorities="org.sufficientlysecure.keychain.provider"
|
android:authorities="org.sufficientlysecure.keychain.provider"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<!-- Internal classes of the remote APIs (not exported) -->
|
<!-- Internal classes of the remote APIs (not exported) -->
|
||||||
<activity
|
<activity
|
||||||
android:name="org.sufficientlysecure.keychain.remote.ui.RemoteServiceActivity"
|
android:name=".remote.ui.RemoteServiceActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/app_name" />
|
android:label="@string/app_name" />
|
||||||
<!--android:launchMode="singleTop"-->
|
<!--android:launchMode="singleTop"-->
|
||||||
@@ -395,23 +393,28 @@
|
|||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/title_api_registered_apps" />
|
android:label="@string/title_api_registered_apps" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.sufficientlysecure.keychain.remote.ui.AppSettingsActivity"
|
android:name=".remote.ui.AppSettingsActivity"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
|
android:exported="false">
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".remote.ui.AppsListActivity" />
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".remote.ui.AccountSettingsActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<!-- OpenPGP Remote API -->
|
<!-- OpenPGP Remote API -->
|
||||||
<service
|
<service
|
||||||
android:name="org.sufficientlysecure.keychain.remote.OpenPgpService"
|
android:name=".remote.OpenPgpService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:process=":remote_api">
|
android:process=":remote_api">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="org.openintents.openpgp.IOpenPgpService" />
|
<action android:name="org.openintents.openpgp.IOpenPgpService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="api_version"
|
|
||||||
android:value="1" />
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- Extended Remote API -->
|
<!-- Extended Remote API -->
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.remote.ui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||||
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
public class AccountSettingsActivity extends ActionBarActivity {
|
||||||
|
private Uri mAccountUri;
|
||||||
|
|
||||||
|
private AccountSettingsFragment mAccountSettingsFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Inflate a "Done" custom action bar
|
||||||
|
ActionBarHelper.setOneButtonView(getSupportActionBar(),
|
||||||
|
R.string.api_settings_save, R.drawable.ic_action_done,
|
||||||
|
new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// "Done"
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setContentView(R.layout.api_account_settings_activity);
|
||||||
|
|
||||||
|
mAccountSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById(
|
||||||
|
R.id.api_account_settings_fragment);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
mAccountUri = intent.getData();
|
||||||
|
if (mAccountUri == null) {
|
||||||
|
Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Log.d(Constants.TAG, "uri: " + mAccountUri);
|
||||||
|
loadData(savedInstanceState, mAccountUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// super.onCreateOptionsMenu(menu);
|
||||||
|
// getMenuInflater().inflate(R.menu.api_app_settings, menu);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_api_settings_revoke:
|
||||||
|
deleteAccount();
|
||||||
|
return true;
|
||||||
|
case R.id.menu_api_settings_cancel:
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadData(Bundle savedInstanceState, Uri accountUri) {
|
||||||
|
// TODO: load this also like other fragment with newInstance arguments?
|
||||||
|
AccountSettings settings = ProviderHelper.getApiAccountSettings(this, accountUri);
|
||||||
|
mAccountSettingsFragment.setAccSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteAccount() {
|
||||||
|
if (getContentResolver().delete(mAccountUri, null, null) <= 0) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save() {
|
||||||
|
ProviderHelper.updateApiAccount(this, mAccountSettingsFragment.getAccSettings(), mAccountUri);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,35 +17,35 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.remote.ui;
|
package org.sufficientlysecure.keychain.remote.ui;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.content.Context;
|
||||||
import android.content.ContentUris;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
import android.support.v4.widget.CursorAdapter;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.SimpleCursorAdapter;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
// TODO: make compat with < 11
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
|
||||||
public class AccountsListFragment extends ListFragment implements
|
public class AccountsListFragment extends ListFragment implements
|
||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
private static final String ARG_DATA_URI = "uri";
|
private static final String ARG_DATA_URI = "uri";
|
||||||
|
|
||||||
// This is the Adapter being used to display the list's data.
|
// This is the Adapter being used to display the list's data.
|
||||||
SimpleCursorAdapter mAdapter;
|
AccountsAdapter mAdapter;
|
||||||
|
|
||||||
private Uri mDataUri;
|
private Uri mDataUri;
|
||||||
|
|
||||||
@@ -72,10 +72,14 @@ public class AccountsListFragment extends ListFragment implements
|
|||||||
getListView().setOnItemClickListener(new OnItemClickListener() {
|
getListView().setOnItemClickListener(new OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
||||||
// // edit app settings
|
String selectedAccountName = mAdapter.getItemAccountName(position);
|
||||||
// Intent intent = new Intent(getActivity(), AppSettingsActivity.class);
|
Uri accountUri = mDataUri.buildUpon().appendEncodedPath(selectedAccountName).build();
|
||||||
// intent.setData(ContentUris.withAppendedId(ApiApps.CONTENT_URI, id));
|
Log.d(Constants.TAG, "accountUri: " + accountUri);
|
||||||
// startActivity(intent);
|
|
||||||
|
// edit account settings
|
||||||
|
Intent intent = new Intent(getActivity(), AccountSettingsActivity.class);
|
||||||
|
intent.setData(accountUri);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,12 +91,7 @@ public class AccountsListFragment extends ListFragment implements
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
// Create an empty adapter we will use to display the loaded data.
|
// Create an empty adapter we will use to display the loaded data.
|
||||||
mAdapter = new SimpleCursorAdapter(getActivity(),
|
mAdapter = new AccountsAdapter(getActivity(), null, 0);
|
||||||
android.R.layout.simple_list_item_1,
|
|
||||||
null,
|
|
||||||
new String[]{KeychainContract.ApiAccounts.ACCOUNT_NAME},
|
|
||||||
new int[]{android.R.id.text1},
|
|
||||||
0);
|
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
|
|
||||||
// Prepare the loader. Either re-connect with an existing one,
|
// Prepare the loader. Either re-connect with an existing one,
|
||||||
@@ -102,15 +101,13 @@ public class AccountsListFragment extends ListFragment implements
|
|||||||
|
|
||||||
// These are the Contacts rows that we will retrieve.
|
// These are the Contacts rows that we will retrieve.
|
||||||
static final String[] PROJECTION = new String[]{
|
static final String[] PROJECTION = new String[]{
|
||||||
KeychainContract.ApiAccounts._ID,
|
KeychainContract.ApiAccounts._ID, // 0
|
||||||
KeychainContract.ApiAccounts.ACCOUNT_NAME};
|
KeychainContract.ApiAccounts.ACCOUNT_NAME // 1
|
||||||
|
};
|
||||||
|
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
// This is called when a new Loader needs to be created. This
|
// This is called when a new Loader needs to be created. This
|
||||||
// sample only has one Loader, so we don't care about the ID.
|
// sample only has one Loader, so we don't care about the ID.
|
||||||
// First, pick the base URI to use depending on whether we are
|
|
||||||
// currently filtering.
|
|
||||||
// Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(mPackageName);
|
|
||||||
|
|
||||||
// Now create and return a CursorLoader that will take care of
|
// Now create and return a CursorLoader that will take care of
|
||||||
// creating a Cursor for the data being displayed.
|
// creating a Cursor for the data being displayed.
|
||||||
@@ -131,46 +128,46 @@ public class AccountsListFragment extends ListFragment implements
|
|||||||
mAdapter.swapCursor(null);
|
mAdapter.swapCursor(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private class RegisteredAppsAdapter extends CursorAdapter {
|
private class AccountsAdapter extends CursorAdapter {
|
||||||
//
|
private LayoutInflater mInflater;
|
||||||
// private LayoutInflater mInflater;
|
|
||||||
// private PackageManager mPM;
|
public AccountsAdapter(Context context, Cursor c, int flags) {
|
||||||
//
|
super(context, c, flags);
|
||||||
// public RegisteredAppsAdapter(Context context, Cursor c, int flags) {
|
|
||||||
// super(context, c, flags);
|
mInflater = LayoutInflater.from(context);
|
||||||
//
|
}
|
||||||
// mInflater = LayoutInflater.from(context);
|
|
||||||
// mPM = context.getApplicationContext().getPackageManager();
|
/**
|
||||||
// }
|
* Similar to CursorAdapter.getItemId().
|
||||||
//
|
* Required to build Uris for api app view, which is not based on row ids
|
||||||
// @Override
|
*
|
||||||
// public void bindView(View view, Context context, Cursor cursor) {
|
* @param position
|
||||||
// TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name);
|
* @return
|
||||||
// ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon);
|
*/
|
||||||
//
|
public String getItemAccountName(int position) {
|
||||||
// String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME));
|
if (mDataValid && mCursor != null) {
|
||||||
// if (packageName != null) {
|
if (mCursor.moveToPosition(position)) {
|
||||||
// // get application name
|
return mCursor.getString(1);
|
||||||
// try {
|
} else {
|
||||||
// ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0);
|
return null;
|
||||||
//
|
}
|
||||||
// text.setText(mPM.getApplicationLabel(ai));
|
} else {
|
||||||
// icon.setImageDrawable(mPM.getApplicationIcon(ai));
|
return null;
|
||||||
// } catch (final PackageManager.NameNotFoundException e) {
|
}
|
||||||
// // fallback
|
}
|
||||||
// text.setText(packageName);
|
|
||||||
// }
|
@Override
|
||||||
// } else {
|
public void bindView(View view, Context context, Cursor cursor) {
|
||||||
// // fallback
|
TextView text = (TextView) view.findViewById(R.id.api_accounts_adapter_item_name);
|
||||||
// text.setText(packageName);
|
|
||||||
// }
|
String accountName = cursor.getString(1);
|
||||||
//
|
text.setText(accountName);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||||
// return mInflater.inflate(R.layout.api_apps_adapter_list_item, null);
|
return mInflater.inflate(R.layout.api_accounts_adapter_list_item, null);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,16 +18,17 @@
|
|||||||
package org.sufficientlysecure.keychain.remote.ui;
|
package org.sufficientlysecure.keychain.remote.ui;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.remote.AppSettings;
|
import org.sufficientlysecure.keychain.remote.AppSettings;
|
||||||
@@ -43,16 +44,11 @@ public class AppSettingsActivity extends ActionBarActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// Inflate a "Done" custom action bar
|
// let the actionbar look like Android's contact app
|
||||||
ActionBarHelper.setOneButtonView(getSupportActionBar(),
|
ActionBar actionBar = getSupportActionBar();
|
||||||
R.string.api_settings_save, R.drawable.ic_action_done,
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
new View.OnClickListener() {
|
actionBar.setIcon(android.R.color.transparent);
|
||||||
@Override
|
actionBar.setHomeButtonEnabled(true);
|
||||||
public void onClick(View v) {
|
|
||||||
// "Done"
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setContentView(R.layout.api_app_settings_activity);
|
setContentView(R.layout.api_app_settings_activity);
|
||||||
|
|
||||||
@@ -96,6 +92,18 @@ public class AppSettingsActivity extends ActionBarActivity {
|
|||||||
AppSettings settings = ProviderHelper.getApiAppSettings(this, appUri);
|
AppSettings settings = ProviderHelper.getApiAppSettings(this, appUri);
|
||||||
mSettingsFragment.setAppSettings(settings);
|
mSettingsFragment.setAppSettings(settings);
|
||||||
|
|
||||||
|
String appName;
|
||||||
|
PackageManager pm = getPackageManager();
|
||||||
|
try {
|
||||||
|
ApplicationInfo ai = pm.getApplicationInfo(settings.getPackageName(), 0);
|
||||||
|
appName = (String) pm.getApplicationLabel(ai);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
// fallback
|
||||||
|
appName = settings.getPackageName();
|
||||||
|
}
|
||||||
|
setTitle(appName);
|
||||||
|
|
||||||
|
|
||||||
Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build();
|
Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build();
|
||||||
Log.d(Constants.TAG, "accountsUri: " + accountsUri);
|
Log.d(Constants.TAG, "accountsUri: " + accountsUri);
|
||||||
startListFragment(savedInstanceState, accountsUri);
|
startListFragment(savedInstanceState, accountsUri);
|
||||||
@@ -128,10 +136,4 @@ public class AppSettingsActivity extends ActionBarActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
|
||||||
ProviderHelper.updateApiApp(this, mSettingsFragment.getAppSettings(), mAppUri);
|
|
||||||
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,19 +26,13 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.remote.AppSettings;
|
import org.sufficientlysecure.keychain.remote.AppSettings;
|
||||||
import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment;
|
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter;
|
|
||||||
import org.sufficientlysecure.keychain.util.AlgorithmNames;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
@@ -100,14 +94,14 @@ public class AppSettingsFragment extends Fragment {
|
|||||||
PackageManager pm = getActivity().getApplicationContext().getPackageManager();
|
PackageManager pm = getActivity().getApplicationContext().getPackageManager();
|
||||||
|
|
||||||
// get application name and icon from package manager
|
// get application name and icon from package manager
|
||||||
String appName = null;
|
String appName;
|
||||||
Drawable appIcon = null;
|
Drawable appIcon = null;
|
||||||
try {
|
try {
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
||||||
|
|
||||||
appName = (String) pm.getApplicationLabel(ai);
|
appName = (String) pm.getApplicationLabel(ai);
|
||||||
appIcon = pm.getApplicationIcon(ai);
|
appIcon = pm.getApplicationIcon(ai);
|
||||||
} catch (final NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
// fallback
|
// fallback
|
||||||
appName = packageName;
|
appName = packageName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/api_account_settings_fragment"
|
||||||
|
android:name="org.sufficientlysecure.keychain.remote.ui.AccountSettingsFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/api_accounts_adapter_item_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:text="Account Name"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user