From ef0a86398a4aee43ff34089557f01924c7677fa5 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Tue, 31 Jul 2012 14:18:14 -0700 Subject: [PATCH] Fix for dialogs on GB. --- AndroidManifest.xml | 12 +++---- .../securesms/PassphraseActivity.java | 29 ++++++++-------- .../securesms/PassphrasePromptActivity.java | 34 +++++++++---------- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c6745ae674..9ef6273f78 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -33,13 +33,13 @@ android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> @@ -74,7 +74,7 @@ android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> diff --git a/src/org/thoughtcrime/securesms/PassphraseActivity.java b/src/org/thoughtcrime/securesms/PassphraseActivity.java index b666636242..03b979b34a 100644 --- a/src/org/thoughtcrime/securesms/PassphraseActivity.java +++ b/src/org/thoughtcrime/securesms/PassphraseActivity.java @@ -1,6 +1,6 @@ -/** +/** * Copyright (C) 2011 Whisper Systems - * + * * 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 @@ -10,46 +10,47 @@ * 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 . */ package org.thoughtcrime.securesms; -import org.thoughtcrime.securesms.crypto.MasterSecret; -import org.thoughtcrime.securesms.service.KeyCachingService; -import org.thoughtcrime.securesms.util.MemoryCleaner; - -import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.IBinder; +import com.actionbarsherlock.app.SherlockActivity; + +import org.thoughtcrime.securesms.crypto.MasterSecret; +import org.thoughtcrime.securesms.service.KeyCachingService; +import org.thoughtcrime.securesms.util.MemoryCleaner; + /** * Base Activity for changing/prompting local encryption passphrase. - * + * * @author Moxie Marlinspike */ -public abstract class PassphraseActivity extends Activity { +public abstract class PassphraseActivity extends SherlockActivity { private KeyCachingService keyCachingService; private MasterSecret masterSecret; - + protected void setMasterSecret(MasterSecret masterSecret) { this.masterSecret = masterSecret; Intent bindIntent = new Intent(this, KeyCachingService.class); bindService(bindIntent, serviceConnection, Context.BIND_AUTO_CREATE); } - + protected abstract void cleanup(); - + private ServiceConnection serviceConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { keyCachingService = ((KeyCachingService.KeyCachingBinder)service).getService(); keyCachingService.setMasterSecret(masterSecret); - + PassphraseActivity.this.unbindService(PassphraseActivity.this.serviceConnection); MemoryCleaner.clean(masterSecret); diff --git a/src/org/thoughtcrime/securesms/PassphrasePromptActivity.java b/src/org/thoughtcrime/securesms/PassphrasePromptActivity.java index e3f07f5e5f..cdd22037e2 100644 --- a/src/org/thoughtcrime/securesms/PassphrasePromptActivity.java +++ b/src/org/thoughtcrime/securesms/PassphrasePromptActivity.java @@ -1,6 +1,6 @@ -/** +/** * Copyright (C) 2011 Whisper Systems - * + * * 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 @@ -10,17 +10,12 @@ * 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 . */ package org.thoughtcrime.securesms; -import org.thoughtcrime.securesms.crypto.InvalidPassphraseException; -import org.thoughtcrime.securesms.crypto.MasterSecret; -import org.thoughtcrime.securesms.crypto.MasterSecretUtil; -import org.thoughtcrime.securesms.util.MemoryCleaner; - import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; @@ -28,17 +23,22 @@ import android.widget.Button; import android.widget.EditText; import android.widget.Toast; +import org.thoughtcrime.securesms.crypto.InvalidPassphraseException; +import org.thoughtcrime.securesms.crypto.MasterSecret; +import org.thoughtcrime.securesms.crypto.MasterSecretUtil; +import org.thoughtcrime.securesms.util.MemoryCleaner; + /** * Activity that prompts for a users's passphrase. - * - * @author Moxie Marlinspike + * + * @author Moxie Marlinspike */ public class PassphrasePromptActivity extends PassphraseActivity { private EditText passphraseText; private Button okButton; private Button cancelButton; - + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -46,22 +46,22 @@ public class PassphrasePromptActivity extends PassphraseActivity { setContentView(R.layout.prompt_passphrase_activity); initializeResources(); } - + private void initializeResources() { passphraseText = (EditText)findViewById(R.id.passphrase_edit); okButton = (Button)findViewById(R.id.ok_button); cancelButton = (Button)findViewById(R.id.cancel_button); - + okButton.setOnClickListener(new OkButtonClickListener()); cancelButton.setOnClickListener(new CancelButtonClickListener()); } - + private class OkButtonClickListener implements OnClickListener { public void onClick(View v) { try { String passphrase = passphraseText.getText().toString(); MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(PassphrasePromptActivity.this, passphrase); - + MemoryCleaner.clean(passphrase); setMasterSecret(masterSecret); } catch (InvalidPassphraseException ipe) { @@ -69,7 +69,7 @@ public class PassphrasePromptActivity extends PassphraseActivity { } } } - + private class CancelButtonClickListener implements OnClickListener { public void onClick(View v) { finish(); @@ -81,5 +81,5 @@ public class PassphrasePromptActivity extends PassphraseActivity { this.passphraseText = null; System.gc(); } - + }