From fe4ebb6244a5dada9856bf8626cf4cef2b1d951f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 16 Feb 2018 12:30:46 +0100 Subject: [PATCH] reference support actionbar in all activities --- .../siacs/conversations/ui/ChooseContactActivity.java | 4 ++-- .../conversations/ui/ConferenceDetailsActivity.java | 6 +++--- .../siacs/conversations/ui/ContactDetailsActivity.java | 6 +++--- .../eu/siacs/conversations/ui/EditAccountActivity.java | 9 ++++----- .../siacs/conversations/ui/ManageAccountActivity.java | 6 ++---- .../conversations/ui/ShareViaAccountActivity.java | 6 ++---- .../eu/siacs/conversations/ui/ShareWithActivity.java | 6 +++--- .../eu/siacs/conversations/ui/TrustKeysActivity.java | 10 +++++----- .../eu/siacs/conversations/ui/VerifyOTRActivity.java | 4 ++-- .../eu/siacs/conversations/ui/WelcomeActivity.java | 8 ++++---- .../java/eu/siacs/conversations/ui/XmppActivity.java | 5 ++--- 11 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java index 53f628ec0..5eb1410f0 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java @@ -1,10 +1,10 @@ package eu.siacs.conversations.ui; -import android.app.ActionBar; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.StringRes; +import android.support.v7.app.ActionBar; import android.view.ActionMode; import android.view.Menu; import android.view.MenuInflater; @@ -140,7 +140,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity { Intent intent = getIntent(); @StringRes 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) { try { bar.setTitle(res); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 139ab410d..95dcd6240 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -245,9 +245,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers mInviteButton = (Button) findViewById(R.id.invite); mInviteButton.setOnClickListener(inviteListener); mConferenceType = (TextView) findViewById(R.id.muc_conference_type); - if (getActionBar() != null) { - getActionBar().setHomeButtonEnabled(true); - getActionBar().setDisplayHomeAsUpEnabled(true); + if (getSupportActionBar() != null) { + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } mEditNickButton.setOnClickListener(new OnClickListener() { diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 0e517cf1b..19fcdff45 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -224,9 +224,9 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp keysWrapper = (LinearLayout) findViewById(R.id.keys_wrapper); tags = (FlowLayout) findViewById(R.id.tags); mShowInactiveDevicesButton = (Button) findViewById(R.id.show_inactive_devices); - if (getActionBar() != null) { - getActionBar().setHomeButtonEnabled(true); - getActionBar().setDisplayHomeAsUpEnabled(true); + if (getSupportActionBar() != null) { + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } mShowInactiveDevicesButton.setOnClickListener(new OnClickListener() { @Override diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index e775fa5fb..e1dd9c517 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -1,6 +1,5 @@ package eu.siacs.conversations.ui; -import android.app.ActionBar; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.PendingIntent; @@ -15,8 +14,8 @@ import android.provider.Settings; import android.security.KeyChain; import android.security.KeyChainAliasCallback; import android.support.v4.content.ContextCompat; +import android.support.v7.app.ActionBar; import android.text.Editable; -import android.text.InputType; import android.text.TextWatcher; import android.view.Menu; import android.view.MenuItem; @@ -653,12 +652,12 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.messageFingerprint = getIntent().getStringExtra("fingerprint"); if (!mInitMode) { this.mRegisterNew.setVisibility(View.GONE); - if (getActionBar() != null) { - getActionBar().setTitle(getString(R.string.account_details)); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(getString(R.string.account_details)); } } else { this.mAvatar.setVisibility(View.GONE); - ActionBar ab = getActionBar(); + ActionBar ab = getSupportActionBar(); if (ab != null) { if (init && Config.MAGIC_CREATE_DOMAIN == null) { ab.setDisplayShowHomeEnabled(false); diff --git a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java index db2296320..cd42e7c1c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -1,14 +1,12 @@ package eu.siacs.conversations.ui; -import android.app.ActionBar; import android.app.AlertDialog; import android.content.ActivityNotFoundException; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.os.Bundle; import android.security.KeyChain; import android.security.KeyChainAliasCallback; +import android.support.v7.app.ActionBar; import android.util.Pair; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; @@ -62,7 +60,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda accountList.clear(); accountList.addAll(xmppConnectionService.getAccounts()); } - ActionBar actionBar = getActionBar(); + ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(this.accountList.size() > 0); actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0); diff --git a/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java index dcee4c039..a05775f05 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java @@ -1,13 +1,11 @@ package eu.siacs.conversations.ui; -import android.app.ActionBar; -import android.content.Intent; import android.os.Bundle; +import android.support.v7.app.ActionBar; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; -import android.widget.Toast; import java.util.ArrayList; import java.util.List; @@ -33,7 +31,7 @@ public class ShareViaAccountActivity extends XmppActivity { accountList.clear(); accountList.addAll(xmppConnectionService.getAccounts()); } - ActionBar actionBar = getActionBar(); + ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(this.accountList.size() > 0); actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0); diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 9457a2ef3..2ff04a54e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -168,9 +168,9 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new EmojiService(this).init(); - if (getActionBar() != null) { - getActionBar().setDisplayHomeAsUpEnabled(false); - getActionBar().setHomeButtonEnabled(false); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(false); + getSupportActionBar().setHomeButtonEnabled(false); } setContentView(R.layout.share_with); diff --git a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java index 6bb371b4c..26931f07a 100644 --- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java @@ -1,8 +1,8 @@ package eu.siacs.conversations.ui; -import android.app.ActionBar; import android.content.Intent; import android.os.Bundle; +import android.support.v7.app.ActionBar; import android.util.Log; import android.view.Gravity; import android.view.Menu; @@ -107,9 +107,9 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat mSaveButton.setOnClickListener(mSaveButtonListener); - if (getActionBar() != null) { - getActionBar().setHomeButtonEnabled(true); - getActionBar().setDisplayHomeAsUpEnabled(true); + if (getSupportActionBar() != null) { + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } if (savedInstanceState != null) { @@ -133,7 +133,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat private void showCameraToast() { 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.show(); } diff --git a/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java b/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java index c8f5b8767..5633fcb94 100644 --- a/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java @@ -1,10 +1,10 @@ package eu.siacs.conversations.ui; -import android.app.ActionBar; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.support.v7.app.ActionBar; import android.view.Menu; import android.view.View; import android.widget.Button; @@ -251,7 +251,7 @@ public class VerifyOTRActivity extends XmppActivity implements XmppConnectionSer protected void updateView() { if (this.mConversation != null && this.mConversation.hasValidOtrSession()) { - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); this.mVerificationExplain.setText(R.string.no_otr_session_found); invalidateOptionsMenu(); switch(this.mode) { diff --git a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java index 8a64bdcba..26d18b7ae 100644 --- a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java @@ -1,10 +1,10 @@ package eu.siacs.conversations.ui; -import android.app.ActionBar; -import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; import android.widget.Button; import java.util.List; @@ -50,7 +50,7 @@ public class WelcomeActivity extends XmppActivity { } super.onCreate(savedInstanceState); setContentView(R.layout.welcome); - final ActionBar ab = getActionBar(); + final ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayShowHomeEnabled(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.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.startActivity(intent); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 3c6e8acb2..2705d89ce 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -3,8 +3,6 @@ package eu.siacs.conversations.ui; import android.Manifest; import android.annotation.SuppressLint; import android.annotation.TargetApi; -import android.app.ActionBar; -import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.PendingIntent; @@ -38,6 +36,7 @@ import android.os.PowerManager; import android.os.SystemClock; import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; +import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.text.InputType; import android.util.DisplayMetrics; @@ -406,7 +405,7 @@ public abstract class XmppActivity extends AppCompatActivity { this.mUsingEnterKey = usingEnterKey(); mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject)); - final ActionBar ab = getActionBar(); + final ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); }