Merge pull request #1324 from mcginty/actionbar-cleanup

use normal means to set actionbar icon
This commit is contained in:
Moxie Marlinspike 2014-04-10 17:57:53 -07:00
commit ef77dc9d6d
17 changed files with 48 additions and 115 deletions

View File

@ -21,6 +21,8 @@
parent="@style/Widget.Sherlock.ActionBar">
<item name="android:background">#ff111111</item>
<item name="background">#ff111111</item>
<item name="android:icon">@drawable/actionbar_icon_holo_dark</item>
<item name="icon">@drawable/actionbar_icon_holo_dark</item>
</style>
<style name="TextSecure.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
@ -37,6 +39,8 @@
<item name="titleTextStyle">@style/TextSecure.TitleTextStyle</item>
<item name="android:subtitleTextStyle">@style/TextSecure.SubtitleTextStyle</item>
<item name="subtitleTextStyle">@style/TextSecure.SubtitleTextStyle</item>
<item name="android:icon">@drawable/actionbar_icon_holo_light</item>
<item name="icon">@drawable/actionbar_icon_holo_light</item>
</style>
<style name="transparent_progress">

View File

@ -53,7 +53,6 @@ import org.thoughtcrime.securesms.contacts.ContactIdentityManager;
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
import org.thoughtcrime.securesms.push.PushServiceSocketFactory;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.Dialogs;
import org.thoughtcrime.securesms.util.DirectoryHelper;
import org.thoughtcrime.securesms.util.DynamicLanguage;
@ -101,7 +100,6 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
super.onCreate(icicle);
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
addPreferencesFromResource(R.xml.preferences);

View File

@ -30,7 +30,6 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DynamicTheme;
import java.util.ArrayList;
@ -61,7 +60,6 @@ public class ContactSelectionActivity extends PassphraseRequiredSherlockFragment
super.onCreate(icicle);
final ActionBar actionBar = this.getSupportActionBar();
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayHomeAsUpEnabled(true);

View File

@ -87,7 +87,6 @@ import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage;
import org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.BitmapDecodingException;
import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.CharacterCalculator;
@ -181,7 +180,6 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
setContentView(R.layout.conversation_activity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
initializeReceivers();
initializeResources();

View File

@ -31,7 +31,6 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.service.SendReceiveService;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MemoryCleaner;
@ -64,7 +63,7 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
setContentView(R.layout.conversation_list_activity);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar(), R.string.app_name);
getSupportActionBar().setTitle(R.string.app_name);
initializeNavigationDrawer();
initializeSenderReceiverService();

View File

@ -55,7 +55,6 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
@ -130,7 +129,6 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
setContentView(R.layout.group_create_activity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar(), R.string.GroupCreateActivity_actionbar_title);
selectedContacts = new HashSet<Recipient>();
initializeResources();
@ -141,6 +139,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
getSupportActionBar().setTitle(R.string.GroupCreateActivity_actionbar_title);
if (!TextSecurePreferences.isPushRegistered(this)) {
disableWhisperGroupUi(R.string.GroupCreateActivity_you_dont_support_push);
}

View File

@ -10,7 +10,6 @@ import android.support.v4.view.ViewPager;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.MenuItem;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.whispersystems.textsecure.crypto.MasterSecret;
@ -25,7 +24,6 @@ public class ImportExportActivity extends PassphraseRequiredSherlockFragmentActi
super.onCreate(savedInstanceState);
setContentView(R.layout.import_export_activity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
initializeResources();
initializeViewPager();

View File

@ -1,7 +1,6 @@
package org.thoughtcrime.securesms;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.text.ClipboardManager;
import android.content.DialogInterface;
import android.os.AsyncTask;
@ -19,24 +18,10 @@ import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.google.thoughtcrimegson.Gson;
import com.google.thoughtcrimegson.JsonIOException;
import com.google.thoughtcrimegson.JsonParseException;
import com.google.thoughtcrimegson.JsonSyntaxException;
import com.google.thoughtcrimegson.reflect.TypeToken;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.ProgressDialogAsyncTask;
import org.thoughtcrime.securesms.util.Util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@ -45,12 +30,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
@ -70,7 +52,6 @@ public class LogSubmitActivity extends SherlockActivity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.log_submit_activity);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
initializeResources();
}

View File

@ -26,7 +26,6 @@ import android.widget.Toast;
import com.actionbarsherlock.view.MenuItem;
import org.thoughtcrime.securesms.mms.MmsDownloadHelper;
import org.thoughtcrime.securesms.service.SendReceiveService;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MemoryCleaner;
@ -47,7 +46,6 @@ public class MmsPreferencesActivity extends PassphraseRequiredSherlockPreference
super.onCreate(icicle);
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
initializePreferences();
masterSecret = getIntent().getParcelableExtra("master_secret");

View File

@ -20,7 +20,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
@ -32,8 +31,8 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DirectoryHelper;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.NumberUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@ -55,7 +54,8 @@ public class NewConversationActivity extends PassphraseRequiredSherlockFragmentA
private final static String TAG = "ContactSelectActivity";
public final static String MASTER_SECRET_EXTRA = "master_secret";
private final DynamicTheme dynamicTheme = new DynamicTheme();
private final DynamicTheme dynamicTheme = new DynamicTheme ();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
private MasterSecret masterSecret;
private PushContactSelectionListFragment contactsFragment;
@ -63,11 +63,10 @@ public class NewConversationActivity extends PassphraseRequiredSherlockFragmentA
@Override
protected void onCreate(Bundle icicle) {
dynamicTheme.onCreate(this);
dynamicLanguage.onCreate(this);
super.onCreate(icicle);
final ActionBar actionBar = this.getSupportActionBar();
ActionBarUtil.initializeDefaultActionBar(this, actionBar);
actionBar.setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.new_conversation_activity);
initializeResources();
@ -77,6 +76,8 @@ public class NewConversationActivity extends PassphraseRequiredSherlockFragmentA
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
getSupportActionBar().setTitle(R.string.AndroidManifest__select_contacts);
masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
}

View File

@ -19,32 +19,17 @@ package org.thoughtcrime.securesms;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import org.thoughtcrime.securesms.components.SingleRecipientPanel;
import org.thoughtcrime.securesms.contacts.ContactAccessor;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DirectoryHelper;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.NumberUtil;
import org.thoughtcrime.securesms.util.ProgressDialogAsyncTask;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.textsecure.crypto.MasterSecret;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import static org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData;
@ -59,18 +44,18 @@ public class PushContactSelectionActivity extends PassphraseRequiredSherlockFrag
private final static String TAG = "ContactSelectActivity";
public final static String PUSH_ONLY_EXTRA = "push_only";
private final DynamicTheme dynamicTheme = new DynamicTheme();
private final DynamicTheme dynamicTheme = new DynamicTheme ();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
private PushContactSelectionListFragment contactsFragment;
@Override
protected void onCreate(Bundle icicle) {
dynamicTheme.onCreate(this);
dynamicLanguage.onCreate(this);
super.onCreate(icicle);
final ActionBar actionBar = this.getSupportActionBar();
ActionBarUtil.initializeDefaultActionBar(this, actionBar);
actionBar.setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.push_contact_selection_activity);
initializeResources();
@ -80,6 +65,8 @@ public class PushContactSelectionActivity extends PassphraseRequiredSherlockFrag
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
getSupportActionBar().setTitle(R.string.AndroidManifest__select_contacts);
}
@Override

View File

@ -1,11 +1,9 @@
package org.thoughtcrime.securesms;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
@ -17,7 +15,6 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.google.android.gcm.GCMRegistrar;
import com.google.i18n.phonenumbers.AsYouTypeFormatter;
@ -25,7 +22,6 @@ import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.whispersystems.textsecure.crypto.MasterSecret;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Dialogs;
@ -58,7 +54,7 @@ public class RegistrationActivity extends SherlockActivity {
super.onCreate(icicle);
setContentView(R.layout.registration_activity);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar(), getString(R.string.RegistrationActivity_connect_with_textsecure));
getSupportActionBar().setTitle(getString(R.string.RegistrationActivity_connect_with_textsecure));
initializeResources();
initializeSpinner();

View File

@ -32,7 +32,6 @@ import com.actionbarsherlock.app.SherlockActivity;
import org.thoughtcrime.securesms.push.PushServiceSocketFactory;
import org.thoughtcrime.securesms.service.RegistrationService;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.Dialogs;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.textsecure.crypto.MasterSecret;
@ -93,7 +92,7 @@ public class RegistrationProgressActivity extends SherlockActivity {
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar(), getString(R.string.RegistrationProgressActivity_verifying_number));
getSupportActionBar().setTitle(getString(R.string.RegistrationProgressActivity_verifying_number));
setContentView(R.layout.registration_progress_activity);
initializeResources();

View File

@ -21,26 +21,29 @@ import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
public class ReviewIdentitiesActivity extends SherlockFragmentActivity {
private final DynamicTheme dynamicTheme = new DynamicTheme();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
@Override
public void onCreate(Bundle bundle) {
dynamicTheme.onCreate(this);
dynamicLanguage.onCreate(this);
super.onCreate(bundle);
setContentView(R.layout.review_identities);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
}
@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
getSupportActionBar().setTitle(R.string.AndroidManifest__manage_identity_keys);
}
@Override

View File

@ -18,25 +18,16 @@
package org.thoughtcrime.securesms;
import android.content.Intent;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ListView;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.service.DirectoryRefreshListener;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MemoryCleaner;
@ -66,7 +57,6 @@ public class ShareActivity extends PassphraseRequiredSherlockFragmentActivity
super.onCreate(icicle);
setContentView(R.layout.share_activity);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar(), R.string.ShareActivity_share_with);
initializeResources();
}
@ -81,6 +71,7 @@ public class ShareActivity extends PassphraseRequiredSherlockFragmentActivity
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
getSupportActionBar().setTitle(R.string.ShareActivity_share_with);
}
@Override

View File

@ -23,7 +23,8 @@ import android.widget.Toast;
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.ActionBarUtil;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MemoryCleaner;
import org.whispersystems.textsecure.crypto.IdentityKey;
import org.whispersystems.textsecure.crypto.MasterSecret;
@ -46,17 +47,30 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
private int keyType;
private final DynamicTheme dynamicTheme = new DynamicTheme ();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
@Override
public void onCreate(Bundle state) {
dynamicTheme.onCreate(this);
dynamicLanguage.onCreate(this);
super.onCreate(state);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarUtil.initializeDefaultActionBar(this, getSupportActionBar());
setContentView(R.layout.verify_identity_activity);
initializeResources();
initializeFingerprints();
}
@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
getSupportActionBar().setTitle(R.string.AndroidManifest__verify_identity);
}
@Override
protected void onDestroy() {
MemoryCleaner.clean(masterSecret);

View File

@ -1,31 +0,0 @@
package org.thoughtcrime.securesms.util;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import com.actionbarsherlock.app.ActionBar;
import org.thoughtcrime.securesms.R;
public class ActionBarUtil {
public static void initializeDefaultActionBar(final Context c, final ActionBar actionBar, final int titleResId) {
actionBar.setTitle(titleResId);
initializeDefaultActionBar(c, actionBar);
}
public static void initializeDefaultActionBar(final Context c, final ActionBar actionBar, final String title) {
actionBar.setTitle(title);
initializeDefaultActionBar(c, actionBar);
}
public static void initializeDefaultActionBar(final Context c, final ActionBar actionBar) {
TypedValue iconResValue = new TypedValue();
c.getTheme().resolveAttribute(R.attr.actionbar_icon, iconResValue, true);
int attributeResourceId = iconResValue.resourceId;
Drawable icon = c.getResources().getDrawable(attributeResourceId);
actionBar.setIcon(icon);
}
}