Put actionbar methods in helper

This commit is contained in:
Dominik Schürmann
2013-09-08 15:30:05 +02:00
parent 70fb36d5d6
commit a890ba5e4f
14 changed files with 179 additions and 139 deletions

View File

@@ -19,17 +19,15 @@ package org.sufficientlysecure.keychain.remote_api;
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.util.Log;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
@@ -44,14 +42,7 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
super.onCreate(savedInstanceState);
// Inflate a "Done" custom action bar view to serve as the "Up" affordance.
final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater
.inflate(R.layout.actionbar_custom_view_done, null);
((TextView) customActionBarView.findViewById(R.id.actionbar_done_text))
.setText(R.string.api_settings_save);
customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
ActionBarHelper.setDoneView(getSupportActionBar(), R.string.api_settings_save,
new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -60,12 +51,6 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
}
});
// 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);
setContentView(R.layout.api_app_settings_activity);
settingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById(

View File

@@ -205,6 +205,8 @@ public class CryptoService extends Service {
long inputLength = inputBytes.length;
InputData inputData = new InputData(inputStream, inputLength);
Log.d(Constants.TAG, "in: " + new String(inputBytes));
OutputStream outputStream = new ByteArrayOutputStream();
// TODO: This allows to decrypt messages with ALL secret keys, not only the one for the
@@ -382,6 +384,12 @@ public class CryptoService extends Service {
}
@Override
public void onSelectedPublicKeys(long[] keyIds) throws RemoteException {
// TODO Auto-generated method stub
}
};
private void checkAndEnqueue(Runnable r) {

View File

@@ -20,6 +20,8 @@ package org.sufficientlysecure.keychain.remote_api;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.helper.PgpMain;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
@@ -46,8 +48,11 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
public class CryptoServiceActivity extends SherlockFragmentActivity {
public static final String ACTION_REGISTER = "org.sufficientlysecure.keychain.remote_api.REGISTER";
public static final String ACTION_CACHE_PASSPHRASE = "org.sufficientlysecure.keychain.remote_api.CRYPTO_CACHE_PASSPHRASE";
public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER";
public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX
+ "API_ACTIVITY_CACHE_PASSPHRASE";
public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX
+ "API_ACTIVITY_SELECT_PUB_KEYS";
public static final String EXTRA_SECRET_KEY_ID = "secretKeyId";
public static final String EXTRA_PACKAGE_NAME = "packageName";
@@ -55,7 +60,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
private IServiceActivityCallback mServiceCallback;
private boolean mServiceBound;
// view
// register view
AppSettingsFragment settingsFragment;
private ServiceConnection mServiceActivityConnection = new ServiceConnection() {
@@ -139,14 +144,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
// 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(
ActionBarHelper.setDoneCancelView(getSupportActionBar(), R.string.api_register_allow,
new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -169,11 +167,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
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() {
}, R.string.api_register_disallow, new View.OnClickListener() {
@Override
public void onClick(View v) {
// Disallow
@@ -186,14 +180,6 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
}
});
// 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));
setContentView(R.layout.api_app_register_activity);
settingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById(
@@ -201,7 +187,6 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
AppSettings settings = new AppSettings(packageName);
settingsFragment.setAppSettings(settings);
// TODO: handle if app is already registered
// LinearLayout layoutRegister = (LinearLayout)
@@ -223,6 +208,10 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
} else if (ACTION_CACHE_PASSPHRASE.equals(action)) {
long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID);
showPassphraseDialog(secretKeyId);
} else if (ACTION_SELECT_PUB_KEYS.equals(action)) {
long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID);
showPassphraseDialog(secretKeyId);
} else {
Log.e(Constants.TAG, "Wrong action!");

View File

@@ -23,5 +23,7 @@ interface IServiceActivityCallback {
oneway void onRegistered(in boolean success, in String packageName);
oneway void onCachedPassphrase(in boolean success);
oneway void onSelectedPublicKeys(in long[] keyIds);
}