Put logic into fragment for reuse

This commit is contained in:
Dominik Schürmann 2013-09-06 09:44:56 +02:00
parent 4030739a99
commit c9549befb2
6 changed files with 234 additions and 201 deletions

View File

@ -462,7 +462,7 @@
<activity <activity
android:name="org.sufficientlysecure.keychain.remote_api.ServiceActivity" android:name="org.sufficientlysecure.keychain.remote_api.ServiceActivity"
android:exported="false" android:exported="false"
android:label="TODO crypto activity" android:label="@string/app_name"
android:process=":crypto" > android:process=":crypto" >
<!-- Don't publish intents, they are only used internally! --> <!-- Don't publish intents, they are only used internally! -->

View File

@ -6,6 +6,14 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="8dp" > android:padding="8dp" >
<TextView
android:id="@+id/api_register_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="3dip"
android:text="@string/api_register_text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<fragment <fragment
android:id="@+id/api_app_settings_fragment" android:id="@+id/api_app_settings_fragment"
android:name="org.sufficientlysecure.keychain.remote_api.AppSettingsFragment" android:name="org.sufficientlysecure.keychain.remote_api.AppSettingsFragment"
@ -13,39 +21,4 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout="@layout/api_app_settings_fragment" /> tools:layout="@layout/api_app_settings_fragment" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="3dip" >
<TextView
android:id="@+id/api_register_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TODO: use string"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="3dip" >
<Button
android:id="@+id/api_register_disallow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/api_register_disallow" />
<Button
android:id="@+id/api_register_allow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/api_register_allow" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -369,7 +369,7 @@
<string name="api_settings_save">Save</string> <string name="api_settings_save">Save</string>
<string name="api_settings_cancel">Cancel</string> <string name="api_settings_cancel">Cancel</string>
<string name="api_settings_revoke">Revoke access</string> <string name="api_settings_revoke">Revoke access</string>
<string name="api_register_text">%1$s (%2$s) requests access to OpenPGP Keychain\'s API.\n\nAllow permanent access?</string> <string name="api_register_text">The following application requests access to OpenPGP Keychain\'s API.\n\nAllow permanent access?</string>
<string name="api_register_allow">Allow access</string> <string name="api_register_allow">Allow access</string>
<string name="api_register_disallow">Disallow access</string> <string name="api_register_disallow">Disallow access</string>

View File

@ -1,31 +1,18 @@
package org.sufficientlysecure.keychain.remote_api; package org.sufficientlysecure.keychain.remote_api;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.PgpHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.SelectSecretKeyActivity;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
@ -34,28 +21,21 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
public class AppSettingsActivity extends SherlockFragmentActivity { public class AppSettingsActivity extends SherlockFragmentActivity {
private PackageManager pm;
// model // model
Uri mAppUri; Uri mAppUri;
String mPackageName; String mPackageName;
long mSecretKeyId = Id.key.none;
// view // view
TextView appNameView;
ImageView appIconView;
TextView keyUserId;
TextView keyUserIdRest;
Button selectKeyButton;
CheckBox asciiArmorCheckBox;
Button saveButton; Button saveButton;
Button revokeButton; Button revokeButton;
AppSettingsFragment settingsFragment;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
pm = getApplicationContext().getPackageManager(); // pm = getApplicationContext().getPackageManager();
// BEGIN_INCLUDE (inflate_set_custom_view) // BEGIN_INCLUDE (inflate_set_custom_view)
// Inflate a "Done" custom action bar view to serve as the "Up" affordance. // Inflate a "Done" custom action bar view to serve as the "Up" affordance.
@ -84,20 +64,8 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
setContentView(R.layout.api_app_settings_activity); setContentView(R.layout.api_app_settings_activity);
appNameView = (TextView) findViewById(R.id.api_app_settings_app_name); settingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById(
appIconView = (ImageView) findViewById(R.id.api_app_settings_app_icon); R.id.api_app_settings_fragment);
keyUserId = (TextView) findViewById(R.id.api_app_settings_user_id);
keyUserIdRest = (TextView) findViewById(R.id.api_app_settings_user_id_rest);
selectKeyButton = (Button) findViewById(R.id.api_app_settings_select_key_button);
asciiArmorCheckBox = (CheckBox) findViewById(R.id.api_app_ascii_armor);
selectKeyButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
selectSecretKey();
}
});
Intent intent = getIntent(); Intent intent = getIntent();
mAppUri = intent.getData(); mAppUri = intent.getData();
@ -136,30 +104,17 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
if (cur.moveToFirst()) { if (cur.moveToFirst()) {
mPackageName = cur.getString(cur.getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME)); mPackageName = cur.getString(cur.getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME));
// get application name and icon from package manager settingsFragment.setPackage(mPackageName);
String appName = null;
Drawable appIcon = null;
try {
ApplicationInfo ai = pm.getApplicationInfo(mPackageName, 0);
appName = (String) pm.getApplicationLabel(ai);
appIcon = pm.getApplicationIcon(ai);
} catch (final NameNotFoundException e) {
// fallback
appName = mPackageName;
}
appNameView.setText(appName);
appIconView.setImageDrawable(appIcon);
try { try {
mSecretKeyId = (cur.getLong(cur long secretKeyId = (cur.getLong(cur
.getColumnIndexOrThrow(KeychainContract.ApiApps.KEY_ID))); .getColumnIndexOrThrow(KeychainContract.ApiApps.KEY_ID)));
Log.d(Constants.TAG, "mSecretKeyId: " + mSecretKeyId); Log.d(Constants.TAG, "mSecretKeyId: " + secretKeyId);
updateSelectedKeyView(mSecretKeyId); settingsFragment.setSecretKey(secretKeyId);
boolean asciiArmor = (cur.getInt(cur boolean asciiArmor = (cur.getInt(cur
.getColumnIndexOrThrow(KeychainContract.ApiApps.ASCII_ARMOR)) == 1); .getColumnIndexOrThrow(KeychainContract.ApiApps.ASCII_ARMOR)) == 1);
asciiArmorCheckBox.setChecked(asciiArmor); settingsFragment.setAsciiArmor(asciiArmor);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.e(Constants.TAG, "AppSettingsActivity", e); Log.e(Constants.TAG, "AppSettingsActivity", e);
@ -176,9 +131,9 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
private void save() { private void save() {
final ContentValues cv = new ContentValues(); final ContentValues cv = new ContentValues();
cv.put(KeychainContract.ApiApps.KEY_ID, mSecretKeyId); cv.put(KeychainContract.ApiApps.KEY_ID, settingsFragment.getSecretKeyId());
cv.put(KeychainContract.ApiApps.ASCII_ARMOR, asciiArmorCheckBox.isChecked()); cv.put(KeychainContract.ApiApps.ASCII_ARMOR, settingsFragment.isAsciiArmor());
// TODO: other parameters // TODO: other parameters
if (getContentResolver().update(mAppUri, cv, null, null) <= 0) { if (getContentResolver().update(mAppUri, cv, null, null) <= 0) {
@ -188,57 +143,4 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
finish(); finish();
} }
private void selectSecretKey() {
Intent intent = new Intent(this, SelectSecretKeyActivity.class);
startActivityForResult(intent, Id.request.secret_keys);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case Id.request.secret_keys: {
if (resultCode == RESULT_OK) {
Bundle bundle = data.getExtras();
mSecretKeyId = bundle.getLong(SelectSecretKeyActivity.RESULT_EXTRA_MASTER_KEY_ID);
} else {
mSecretKeyId = Id.key.none;
}
updateSelectedKeyView(mSecretKeyId);
break;
}
default: {
break;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
private void updateSelectedKeyView(long secretKeyId) {
if (secretKeyId == Id.key.none) {
keyUserId.setText(R.string.api_settings_no_key);
keyUserIdRest.setText("");
} else {
String uid = getResources().getString(R.string.unknownUserId);
String uidExtra = "";
PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this,
secretKeyId);
if (keyRing != null) {
PGPSecretKey key = PgpHelper.getMasterKey(keyRing);
if (key != null) {
String userId = PgpHelper.getMainUserIdSafe(this, key);
String chunks[] = userId.split(" <", 2);
uid = chunks[0];
if (chunks.length > 1) {
uidExtra = "<" + chunks[1];
}
}
}
keyUserId.setText(uid);
keyUserIdRest.setText(uidExtra);
}
}
} }

View File

@ -1,10 +1,21 @@
package org.sufficientlysecure.keychain.remote_api; package org.sufficientlysecure.keychain.remote_api;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.PgpHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.SelectSecretKeyActivity; import org.sufficientlysecure.keychain.ui.SelectSecretKeyActivity;
import org.sufficientlysecure.keychain.util.Log;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -14,29 +25,72 @@ import android.view.ViewGroup;
import android.view.animation.AlphaAnimation; import android.view.animation.AlphaAnimation;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
public class AppSettingsFragment extends Fragment { public class AppSettingsFragment extends Fragment {
private LinearLayout advancedSettingsContainer; // model
private Button advancedSettingsButton; private long mSecretKeyId = Id.key.none;
// view
private LinearLayout mAdvancedSettingsContainer;
private Button mAdvancedSettingsButton;
private TextView mAppNameView;
private ImageView mAppIconView;
private TextView mKeyUserId;
private TextView mKeyUserIdRest;
private Button mSelectKeyButton;
private CheckBox mAsciiArmorCheckBox;
public void setSecretKey(long keyId) {
mSecretKeyId = keyId;
updateSelectedKeyView(keyId);
}
public long getSecretKeyId() {
return mSecretKeyId;
}
public void setAsciiArmor(boolean value) {
mAsciiArmorCheckBox.setChecked(value);
}
public boolean isAsciiArmor() {
return mAsciiArmorCheckBox.isChecked();
}
/** /**
* Inflate the layout for this fragment * Inflate the layout for this fragment
*/ */
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.api_app_settings_fragment, container, false); View view = inflater.inflate(R.layout.api_app_settings_fragment, container, false);
initView(view);
return view;
} }
@Override private void initView(View view) {
public void onActivityCreated(Bundle savedInstanceState) { mAdvancedSettingsButton = (Button) view.findViewById(R.id.api_app_settings_advanced_button);
super.onActivityCreated(savedInstanceState); mAdvancedSettingsContainer = (LinearLayout) view
.findViewById(R.id.api_app_settings_advanced);
advancedSettingsButton = (Button) getActivity().findViewById( mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name);
R.id.api_app_settings_advanced_button); mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon);
advancedSettingsContainer = (LinearLayout) getActivity().findViewById( mKeyUserId = (TextView) view.findViewById(R.id.api_app_settings_user_id);
R.id.api_app_settings_advanced); mKeyUserIdRest = (TextView) view.findViewById(R.id.api_app_settings_user_id_rest);
mSelectKeyButton = (Button) view.findViewById(R.id.api_app_settings_select_key_button);
mAsciiArmorCheckBox = (CheckBox) view.findViewById(R.id.api_app_ascii_armor);
mSelectKeyButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
selectSecretKey();
}
});
final Animation visibleAnimation = new AlphaAnimation(0.0f, 1.0f); final Animation visibleAnimation = new AlphaAnimation(0.0f, 1.0f);
visibleAnimation.setDuration(250); visibleAnimation.setDuration(250);
@ -49,21 +103,102 @@ public class AppSettingsFragment extends Fragment {
// Animation.RELATIVE_TO_SELF, 0.0f); // Animation.RELATIVE_TO_SELF, 0.0f);
// animation2.setDuration(150); // animation2.setDuration(150);
advancedSettingsButton.setOnClickListener(new OnClickListener() { mAdvancedSettingsButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (advancedSettingsContainer.getVisibility() == View.VISIBLE) { if (mAdvancedSettingsContainer.getVisibility() == View.VISIBLE) {
advancedSettingsContainer.startAnimation(invisibleAnimation); mAdvancedSettingsContainer.startAnimation(invisibleAnimation);
advancedSettingsContainer.setVisibility(View.INVISIBLE); mAdvancedSettingsContainer.setVisibility(View.INVISIBLE);
advancedSettingsButton.setText(R.string.api_settings_show_advanced); mAdvancedSettingsButton.setText(R.string.api_settings_show_advanced);
} else { } else {
advancedSettingsContainer.startAnimation(visibleAnimation); mAdvancedSettingsContainer.startAnimation(visibleAnimation);
advancedSettingsContainer.setVisibility(View.VISIBLE); mAdvancedSettingsContainer.setVisibility(View.VISIBLE);
advancedSettingsButton.setText(R.string.api_settings_hide_advanced); mAdvancedSettingsButton.setText(R.string.api_settings_hide_advanced);
} }
} }
}); });
} }
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
private void selectSecretKey() {
Intent intent = new Intent(getActivity(), SelectSecretKeyActivity.class);
startActivityForResult(intent, Id.request.secret_keys);
}
public void setPackage(String packageName) {
PackageManager pm = getActivity().getApplicationContext().getPackageManager();
// get application name and icon from package manager
String appName = null;
Drawable appIcon = null;
try {
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
appName = (String) pm.getApplicationLabel(ai);
appIcon = pm.getApplicationIcon(ai);
} catch (final NameNotFoundException e) {
// fallback
appName = packageName;
}
mAppNameView.setText(appName);
mAppIconView.setImageDrawable(appIcon);
}
private void updateSelectedKeyView(long secretKeyId) {
if (secretKeyId == Id.key.none) {
mKeyUserId.setText(R.string.api_settings_no_key);
mKeyUserIdRest.setText("");
} else {
String uid = getResources().getString(R.string.unknownUserId);
String uidExtra = "";
PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(
getActivity(), secretKeyId);
if (keyRing != null) {
PGPSecretKey key = PgpHelper.getMasterKey(keyRing);
if (key != null) {
String userId = PgpHelper.getMainUserIdSafe(getActivity(), key);
String chunks[] = userId.split(" <", 2);
uid = chunks[0];
if (chunks.length > 1) {
uidExtra = "<" + chunks[1];
}
}
}
mKeyUserId.setText(uid);
mKeyUserIdRest.setText(uidExtra);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(Constants.TAG, "onactivityresult " + requestCode + " " + resultCode);
switch (requestCode) {
case Id.request.secret_keys: {
if (resultCode == Activity.RESULT_OK) {
Bundle bundle = data.getExtras();
mSecretKeyId = bundle.getLong(SelectSecretKeyActivity.RESULT_EXTRA_MASTER_KEY_ID);
Log.d(Constants.TAG, "jo " + mSecretKeyId);
} else {
mSecretKeyId = Id.key.none;
}
updateSelectedKeyView(mSecretKeyId);
break;
}
default: {
break;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
} }

View File

@ -16,8 +16,6 @@
package org.sufficientlysecure.keychain.remote_api; package org.sufficientlysecure.keychain.remote_api;
import java.util.ArrayList;
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_api.IServiceActivityCallback; import org.sufficientlysecure.keychain.remote_api.IServiceActivityCallback;
@ -26,6 +24,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import android.content.ComponentName; import android.content.ComponentName;
@ -38,10 +37,10 @@ import android.os.IBinder;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
import android.os.RemoteException; import android.os.RemoteException;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.ViewGroup;
import android.widget.Button; import android.widget.TextView;
import android.widget.LinearLayout;
public class ServiceActivity extends SherlockFragmentActivity { public class ServiceActivity extends SherlockFragmentActivity {
@ -133,8 +132,63 @@ public class ServiceActivity extends SherlockFragmentActivity {
if (ACTION_REGISTER.equals(action)) { if (ACTION_REGISTER.equals(action)) {
final String packageName = extras.getString(EXTRA_PACKAGE_NAME); final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
// BEGIN_INCLUDE (inflate_set_custom_view)
// Inflate a "Done"/"Cancel" custom action bar view
final LayoutInflater inflater = (LayoutInflater) getSupportActionBar()
.getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
R.layout.actionbar_custom_view_done_cancel, null);
((TextView) customActionBarView.findViewById(R.id.actionbar_done_text))
.setText(R.string.api_register_allow);
customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
// Allow
ProviderHelper.addCryptoConsumer(ServiceActivity.this, packageName);
// Intent data = new Intent();
try {
mServiceCallback.onRegistered(true, packageName);
} catch (RemoteException e) {
Log.e(Constants.TAG, "ServiceActivity");
}
finish();
}
});
((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text))
.setText(R.string.api_register_disallow);
customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
// Disallow
try {
mServiceCallback.onRegistered(false, packageName);
} catch (RemoteException e) {
Log.e(Constants.TAG, "ServiceActivity");
}
finish();
}
});
// Show the custom action bar view and hide the normal Home icon and title.
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME
| ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// END_INCLUDE (inflate_set_custom_view)
setContentView(R.layout.api_app_register_activity); setContentView(R.layout.api_app_register_activity);
AppSettingsFragment settingsFragment = (AppSettingsFragment) getSupportFragmentManager()
.findFragmentById(R.id.api_app_settings_fragment);
settingsFragment.setPackage(packageName);
// TODO: handle if app is already registered // TODO: handle if app is already registered
// LinearLayout layoutRegister = (LinearLayout) // LinearLayout layoutRegister = (LinearLayout)
// findViewById(R.id.register_crypto_consumer_register_layout); // findViewById(R.id.register_crypto_consumer_register_layout);
@ -152,37 +206,6 @@ public class ServiceActivity extends SherlockFragmentActivity {
// layoutEdit.setVisibility(View.GONE); // layoutEdit.setVisibility(View.GONE);
// } // }
Button allowButton = (Button) findViewById(R.id.api_register_allow);
Button disallowButton = (Button) findViewById(R.id.api_register_disallow);
allowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ProviderHelper.addCryptoConsumer(ServiceActivity.this, packageName);
// Intent data = new Intent();
try {
mServiceCallback.onRegistered(true, packageName);
} catch (RemoteException e) {
Log.e(Constants.TAG, "ServiceActivity");
}
finish();
}
});
disallowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
mServiceCallback.onRegistered(false, packageName);
} catch (RemoteException e) {
Log.e(Constants.TAG, "ServiceActivity");
}
finish();
}
});
} else if (ACTION_CACHE_PASSPHRASE.equals(action)) { } else if (ACTION_CACHE_PASSPHRASE.equals(action)) {
long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID); long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID);