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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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();
}
}