rename crypto consumers to api apps
This commit is contained in:
@@ -6,6 +6,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -13,6 +14,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
@@ -20,22 +23,24 @@ import android.widget.TextView;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
|
||||
public class AppSettingsActivity extends SherlockFragmentActivity {
|
||||
|
||||
private PackageManager pm;
|
||||
|
||||
// model
|
||||
Uri appUri;
|
||||
long id;
|
||||
|
||||
String packageName;
|
||||
long keyId;
|
||||
boolean asciiArmor;
|
||||
|
||||
// derived
|
||||
// model, derived
|
||||
String appName;
|
||||
|
||||
// view
|
||||
TextView selectedKey;
|
||||
Button selectKeyButton;
|
||||
CheckBox asciiArmorCheckBox;
|
||||
Button saveButton;
|
||||
Button revokeButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -48,9 +53,26 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
|
||||
selectedKey = (TextView) findViewById(R.id.api_app_settings_selected_key);
|
||||
selectKeyButton = (Button) findViewById(R.id.api_app_settings_select_key_button);
|
||||
asciiArmorCheckBox = (CheckBox) findViewById(R.id.api_app_ascii_armor);
|
||||
revokeButton = (Button) findViewById(R.id.api_app_settings_revoke);
|
||||
saveButton = (Button) findViewById(R.id.api_app_settings_save);
|
||||
|
||||
revokeButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
revokeAccess();
|
||||
}
|
||||
});
|
||||
saveButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
save();
|
||||
}
|
||||
});
|
||||
|
||||
Intent intent = getIntent();
|
||||
Uri appUri = intent.getData();
|
||||
appUri = intent.getData();
|
||||
if (appUri == null) {
|
||||
Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
|
||||
finish();
|
||||
@@ -67,7 +89,7 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
|
||||
if (cur.moveToFirst()) {
|
||||
do {
|
||||
packageName = cur.getString(cur
|
||||
.getColumnIndex(KeychainContract.CryptoConsumers.PACKAGE_NAME));
|
||||
.getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME));
|
||||
// get application name
|
||||
try {
|
||||
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
||||
@@ -76,15 +98,35 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
|
||||
} catch (final NameNotFoundException e) {
|
||||
appName = getString(R.string.api_unknown_app);
|
||||
}
|
||||
// asciiArmor = (cur.getInt(cur
|
||||
// .getColumnIndex(KeychainContract.CryptoConsumers.ASCII_ARMOR)) == 1);
|
||||
|
||||
// display values
|
||||
// asciiArmorCheckBox.setChecked(asciiArmor);
|
||||
try {
|
||||
asciiArmor = (cur.getInt(cur
|
||||
.getColumnIndexOrThrow(KeychainContract.ApiApps.ASCII_ARMOR)) == 1);
|
||||
|
||||
// display values
|
||||
asciiArmorCheckBox.setChecked(asciiArmor);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(Constants.TAG, "AppSettingsActivity", e);
|
||||
}
|
||||
|
||||
} while (cur.moveToNext());
|
||||
}
|
||||
}
|
||||
|
||||
private void revokeAccess() {
|
||||
Uri calUri = ContentUris.withAppendedId(appUri, id);
|
||||
getContentResolver().delete(calUri, null, null);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void save() {
|
||||
final ContentValues cv = new ContentValues();
|
||||
cv.put(KeychainContract.ApiApps.PACKAGE_NAME, packageName);
|
||||
cv.put(KeychainContract.ApiApps.ASCII_ARMOR, asciiArmor);
|
||||
// TODO: other parameter
|
||||
getContentResolver().update(appUri, cv, null, null);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user