Fix for dialogs on GB.

This commit is contained in:
Moxie Marlinspike 2012-07-31 14:18:14 -07:00
parent edb286a44d
commit ef0a86398a
3 changed files with 38 additions and 37 deletions

View File

@ -33,13 +33,13 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".PassphraseCreateActivity" <activity android:name=".PassphraseCreateActivity"
android:theme="@style/Theme.Sherlock.Dialog" android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="Create Passphrase" android:label="Create Passphrase"
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".PassphrasePromptActivity" <activity android:name=".PassphrasePromptActivity"
android:theme="@style/Theme.Sherlock.Dialog" android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="Enter Passphrase" android:label="Enter Passphrase"
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:windowSoftInputMode="stateVisible" android:windowSoftInputMode="stateVisible"
@ -50,17 +50,17 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".AutoInitiateActivity" <activity android:name=".AutoInitiateActivity"
android:theme="@style/Theme.Sherlock.Dialog" android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="TextSecure Messaging Detected" android:label="TextSecure Messaging Detected"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".ViewIdentityActivity" <activity android:name=".ViewIdentityActivity"
android:theme="@style/Theme.Sherlock.Dialog" android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="Public Identity Key" android:label="Public Identity Key"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".PassphraseChangeActivity" <activity android:name=".PassphraseChangeActivity"
android:theme="@style/Theme.Sherlock.Dialog" android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="Change Passphrase" android:label="Change Passphrase"
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
@ -74,7 +74,7 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".SaveIdentityActivity" <activity android:name=".SaveIdentityActivity"
android:theme="@style/Theme.Sherlock.Dialog" android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="Save Identity" android:label="Save Identity"
android:windowSoftInputMode="stateVisible" android:windowSoftInputMode="stateVisible"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>

View File

@ -1,6 +1,6 @@
/** /**
* Copyright (C) 2011 Whisper Systems * Copyright (C) 2011 Whisper Systems
* *
* 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
* the Free Software Foundation, either version 3 of the License, or * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.thoughtcrime.securesms; 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.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.IBinder; 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. * Base Activity for changing/prompting local encryption passphrase.
* *
* @author Moxie Marlinspike * @author Moxie Marlinspike
*/ */
public abstract class PassphraseActivity extends Activity { public abstract class PassphraseActivity extends SherlockActivity {
private KeyCachingService keyCachingService; private KeyCachingService keyCachingService;
private MasterSecret masterSecret; private MasterSecret masterSecret;
protected void setMasterSecret(MasterSecret masterSecret) { protected void setMasterSecret(MasterSecret masterSecret) {
this.masterSecret = masterSecret; this.masterSecret = masterSecret;
Intent bindIntent = new Intent(this, KeyCachingService.class); Intent bindIntent = new Intent(this, KeyCachingService.class);
bindService(bindIntent, serviceConnection, Context.BIND_AUTO_CREATE); bindService(bindIntent, serviceConnection, Context.BIND_AUTO_CREATE);
} }
protected abstract void cleanup(); protected abstract void cleanup();
private ServiceConnection serviceConnection = new ServiceConnection() { private ServiceConnection serviceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) { public void onServiceConnected(ComponentName className, IBinder service) {
keyCachingService = ((KeyCachingService.KeyCachingBinder)service).getService(); keyCachingService = ((KeyCachingService.KeyCachingBinder)service).getService();
keyCachingService.setMasterSecret(masterSecret); keyCachingService.setMasterSecret(masterSecret);
PassphraseActivity.this.unbindService(PassphraseActivity.this.serviceConnection); PassphraseActivity.this.unbindService(PassphraseActivity.this.serviceConnection);
MemoryCleaner.clean(masterSecret); MemoryCleaner.clean(masterSecret);

View File

@ -1,6 +1,6 @@
/** /**
* Copyright (C) 2011 Whisper Systems * Copyright (C) 2011 Whisper Systems
* *
* 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
* the Free Software Foundation, either version 3 of the License, or * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.thoughtcrime.securesms; 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.os.Bundle;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -28,17 +23,22 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; 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. * Activity that prompts for a users's passphrase.
* *
* @author Moxie Marlinspike * @author Moxie Marlinspike
*/ */
public class PassphrasePromptActivity extends PassphraseActivity { public class PassphrasePromptActivity extends PassphraseActivity {
private EditText passphraseText; private EditText passphraseText;
private Button okButton; private Button okButton;
private Button cancelButton; private Button cancelButton;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -46,22 +46,22 @@ public class PassphrasePromptActivity extends PassphraseActivity {
setContentView(R.layout.prompt_passphrase_activity); setContentView(R.layout.prompt_passphrase_activity);
initializeResources(); initializeResources();
} }
private void initializeResources() { private void initializeResources() {
passphraseText = (EditText)findViewById(R.id.passphrase_edit); passphraseText = (EditText)findViewById(R.id.passphrase_edit);
okButton = (Button)findViewById(R.id.ok_button); okButton = (Button)findViewById(R.id.ok_button);
cancelButton = (Button)findViewById(R.id.cancel_button); cancelButton = (Button)findViewById(R.id.cancel_button);
okButton.setOnClickListener(new OkButtonClickListener()); okButton.setOnClickListener(new OkButtonClickListener());
cancelButton.setOnClickListener(new CancelButtonClickListener()); cancelButton.setOnClickListener(new CancelButtonClickListener());
} }
private class OkButtonClickListener implements OnClickListener { private class OkButtonClickListener implements OnClickListener {
public void onClick(View v) { public void onClick(View v) {
try { try {
String passphrase = passphraseText.getText().toString(); String passphrase = passphraseText.getText().toString();
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(PassphrasePromptActivity.this, passphrase); MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(PassphrasePromptActivity.this, passphrase);
MemoryCleaner.clean(passphrase); MemoryCleaner.clean(passphrase);
setMasterSecret(masterSecret); setMasterSecret(masterSecret);
} catch (InvalidPassphraseException ipe) { } catch (InvalidPassphraseException ipe) {
@ -69,7 +69,7 @@ public class PassphrasePromptActivity extends PassphraseActivity {
} }
} }
} }
private class CancelButtonClickListener implements OnClickListener { private class CancelButtonClickListener implements OnClickListener {
public void onClick(View v) { public void onClick(View v) {
finish(); finish();
@ -81,5 +81,5 @@ public class PassphrasePromptActivity extends PassphraseActivity {
this.passphraseText = null; this.passphraseText = null;
System.gc(); System.gc();
} }
} }