reference support actionbar in all activities

This commit is contained in:
Daniel Gultsch 2018-02-16 12:30:46 +01:00
parent 6e89427d5e
commit fe4ebb6244
11 changed files with 32 additions and 38 deletions

View File

@ -1,10 +1,10 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.ActionBar;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v7.app.ActionBar;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -140,7 +140,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
Intent intent = getIntent(); Intent intent = getIntent();
@StringRes @StringRes
int res = intent != null ? intent.getIntExtra(EXTRA_TITLE_RES_ID,R.string.title_activity_choose_contact) : R.string.title_activity_choose_contact; int res = intent != null ? intent.getIntExtra(EXTRA_TITLE_RES_ID,R.string.title_activity_choose_contact) : R.string.title_activity_choose_contact;
ActionBar bar = getActionBar(); ActionBar bar = getSupportActionBar();
if (bar != null) { if (bar != null) {
try { try {
bar.setTitle(res); bar.setTitle(res);

View File

@ -245,9 +245,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
mInviteButton = (Button) findViewById(R.id.invite); mInviteButton = (Button) findViewById(R.id.invite);
mInviteButton.setOnClickListener(inviteListener); mInviteButton.setOnClickListener(inviteListener);
mConferenceType = (TextView) findViewById(R.id.muc_conference_type); mConferenceType = (TextView) findViewById(R.id.muc_conference_type);
if (getActionBar() != null) { if (getSupportActionBar() != null) {
getActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
mEditNickButton.setOnClickListener(new OnClickListener() { mEditNickButton.setOnClickListener(new OnClickListener() {

View File

@ -224,9 +224,9 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
keysWrapper = (LinearLayout) findViewById(R.id.keys_wrapper); keysWrapper = (LinearLayout) findViewById(R.id.keys_wrapper);
tags = (FlowLayout) findViewById(R.id.tags); tags = (FlowLayout) findViewById(R.id.tags);
mShowInactiveDevicesButton = (Button) findViewById(R.id.show_inactive_devices); mShowInactiveDevicesButton = (Button) findViewById(R.id.show_inactive_devices);
if (getActionBar() != null) { if (getSupportActionBar() != null) {
getActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
mShowInactiveDevicesButton.setOnClickListener(new OnClickListener() { mShowInactiveDevicesButton.setOnClickListener(new OnClickListener() {
@Override @Override

View File

@ -1,6 +1,5 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.ActionBar;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.app.PendingIntent; import android.app.PendingIntent;
@ -15,8 +14,8 @@ import android.provider.Settings;
import android.security.KeyChain; import android.security.KeyChain;
import android.security.KeyChainAliasCallback; import android.security.KeyChainAliasCallback;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.text.Editable; import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -653,12 +652,12 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.messageFingerprint = getIntent().getStringExtra("fingerprint"); this.messageFingerprint = getIntent().getStringExtra("fingerprint");
if (!mInitMode) { if (!mInitMode) {
this.mRegisterNew.setVisibility(View.GONE); this.mRegisterNew.setVisibility(View.GONE);
if (getActionBar() != null) { if (getSupportActionBar() != null) {
getActionBar().setTitle(getString(R.string.account_details)); getSupportActionBar().setTitle(getString(R.string.account_details));
} }
} else { } else {
this.mAvatar.setVisibility(View.GONE); this.mAvatar.setVisibility(View.GONE);
ActionBar ab = getActionBar(); ActionBar ab = getSupportActionBar();
if (ab != null) { if (ab != null) {
if (init && Config.MAGIC_CREATE_DOMAIN == null) { if (init && Config.MAGIC_CREATE_DOMAIN == null) {
ab.setDisplayShowHomeEnabled(false); ab.setDisplayShowHomeEnabled(false);

View File

@ -1,14 +1,12 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.ActionBar;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.security.KeyChain; import android.security.KeyChain;
import android.security.KeyChainAliasCallback; import android.security.KeyChainAliasCallback;
import android.support.v7.app.ActionBar;
import android.util.Pair; import android.util.Pair;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
@ -62,7 +60,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
accountList.clear(); accountList.clear();
accountList.addAll(xmppConnectionService.getAccounts()); accountList.addAll(xmppConnectionService.getAccounts());
} }
ActionBar actionBar = getActionBar(); ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
actionBar.setHomeButtonEnabled(this.accountList.size() > 0); actionBar.setHomeButtonEnabled(this.accountList.size() > 0);
actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0); actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0);

View File

@ -1,13 +1,11 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -33,7 +31,7 @@ public class ShareViaAccountActivity extends XmppActivity {
accountList.clear(); accountList.clear();
accountList.addAll(xmppConnectionService.getAccounts()); accountList.addAll(xmppConnectionService.getAccounts());
} }
ActionBar actionBar = getActionBar(); ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
actionBar.setHomeButtonEnabled(this.accountList.size() > 0); actionBar.setHomeButtonEnabled(this.accountList.size() > 0);
actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0); actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0);

View File

@ -168,9 +168,9 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new EmojiService(this).init(); new EmojiService(this).init();
if (getActionBar() != null) { if (getSupportActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getActionBar().setHomeButtonEnabled(false); getSupportActionBar().setHomeButtonEnabled(false);
} }
setContentView(R.layout.share_with); setContentView(R.layout.share_with);

View File

@ -1,8 +1,8 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.ActionBar;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
@ -107,9 +107,9 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
mSaveButton.setOnClickListener(mSaveButtonListener); mSaveButton.setOnClickListener(mSaveButtonListener);
if (getActionBar() != null) { if (getSupportActionBar() != null) {
getActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
if (savedInstanceState != null) { if (savedInstanceState != null) {
@ -133,7 +133,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
private void showCameraToast() { private void showCameraToast() {
mUseCameraHintToast = Toast.makeText(this,R.string.use_camera_icon_to_scan_barcode,Toast.LENGTH_LONG); mUseCameraHintToast = Toast.makeText(this,R.string.use_camera_icon_to_scan_barcode,Toast.LENGTH_LONG);
ActionBar actionBar = getActionBar(); ActionBar actionBar = getSupportActionBar();
mUseCameraHintToast.setGravity(Gravity.TOP | Gravity.END, 0 ,actionBar == null ? 0 : actionBar.getHeight()); mUseCameraHintToast.setGravity(Gravity.TOP | Gravity.END, 0 ,actionBar == null ? 0 : actionBar.getHeight());
mUseCameraHintToast.show(); mUseCameraHintToast.show();
} }

View File

@ -1,10 +1,10 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.ActionBar;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -251,7 +251,7 @@ public class VerifyOTRActivity extends XmppActivity implements XmppConnectionSer
protected void updateView() { protected void updateView() {
if (this.mConversation != null && this.mConversation.hasValidOtrSession()) { if (this.mConversation != null && this.mConversation.hasValidOtrSession()) {
final ActionBar actionBar = getActionBar(); final ActionBar actionBar = getSupportActionBar();
this.mVerificationExplain.setText(R.string.no_otr_session_found); this.mVerificationExplain.setText(R.string.no_otr_session_found);
invalidateOptionsMenu(); invalidateOptionsMenu();
switch(this.mode) { switch(this.mode) {

View File

@ -1,10 +1,10 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button; import android.widget.Button;
import java.util.List; import java.util.List;
@ -50,7 +50,7 @@ public class WelcomeActivity extends XmppActivity {
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.welcome); setContentView(R.layout.welcome);
final ActionBar ab = getActionBar(); final ActionBar ab = getSupportActionBar();
if (ab != null) { if (ab != null) {
ab.setDisplayShowHomeEnabled(false); ab.setDisplayShowHomeEnabled(false);
ab.setDisplayHomeAsUpEnabled(false); ab.setDisplayHomeAsUpEnabled(false);
@ -94,7 +94,7 @@ public class WelcomeActivity extends XmppActivity {
} }
} }
public static void launch(Activity activity) { public static void launch(AppCompatActivity activity) {
Intent intent = new Intent(activity, WelcomeActivity.class); Intent intent = new Intent(activity, WelcomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
activity.startActivity(intent); activity.startActivity(intent);

View File

@ -3,8 +3,6 @@ package eu.siacs.conversations.ui;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.app.PendingIntent; import android.app.PendingIntent;
@ -38,6 +36,7 @@ import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.InputType; import android.text.InputType;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -406,7 +405,7 @@ public abstract class XmppActivity extends AppCompatActivity {
this.mUsingEnterKey = usingEnterKey(); this.mUsingEnterKey = usingEnterKey();
mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject)); mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject));
final ActionBar ab = getActionBar(); final ActionBar ab = getSupportActionBar();
if (ab != null) { if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true); ab.setDisplayHomeAsUpEnabled(true);
} }