From 6fb4eb97510b6e980c95daa35664c46c45f5234d Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 9 Mar 2018 20:27:18 +0100 Subject: started work on migrating to appcompat --- .../pixart/messenger/ui/ConversationActivity.java | 8 ++-- .../messenger/ui/StartConversationActivity.java | 53 ++++++++++------------ .../java/de/pixart/messenger/ui/XmppActivity.java | 4 +- src/main/res/menu/change_presence.xml | 7 +-- src/main/res/menu/choose_contact.xml | 9 ++-- src/main/res/menu/contact_details.xml | 11 +++-- src/main/res/menu/conversations.xml | 29 ++++++------ src/main/res/menu/editaccount.xml | 23 +++++----- src/main/res/menu/manageaccounts.xml | 9 ++-- src/main/res/menu/manageaccounts_context.xml | 5 +- src/main/res/menu/muc_details.xml | 13 +++--- src/main/res/menu/publish_avatar.xml | 5 +- src/main/res/menu/select_multiple.xml | 5 +- src/main/res/menu/share_with.xml | 5 +- src/main/res/menu/showlocation.xml | 5 +- src/main/res/menu/start_conversation.xml | 17 +++---- src/main/res/menu/trust_keys.xml | 5 +- src/main/res/menu/verify_otr.xml | 7 +-- src/main/res/values-v21/themes.xml | 20 +++++--- src/main/res/values/attrs.xml | 2 +- 20 files changed, 131 insertions(+), 111 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index 192979083..aabb8c1fe 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -1,7 +1,7 @@ package de.pixart.messenger.ui; import android.annotation.SuppressLint; -import android.app.ActionBar; +import android.support.v7.app.ActionBar; import android.app.AlertDialog; import android.app.FragmentTransaction; import android.app.PendingIntent; @@ -18,7 +18,7 @@ import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Typeface; -import android.media.ExifInterface; +import android.support.media.ExifInterface; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -250,7 +250,7 @@ public class ConversationActivity extends XmppActivity this.listAdapter = new ConversationAdapter(this, conversationList); listView.setAdapter(this.listAdapter); - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE); } @@ -364,7 +364,7 @@ public class ConversationActivity extends XmppActivity } private void updateActionBarTitle(boolean titleShouldBeName) { - final ActionBar ab = getActionBar(); + final ActionBar ab = getSupportActionBar(); final Conversation conversation = getSelectedConversation(); if (ab != null) { if (titleShouldBeName && conversation != null) { diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index c1cd8a015..7a11a0e08 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -2,15 +2,8 @@ package de.pixart.messenger.ui; import android.Manifest; import android.annotation.SuppressLint; -import android.app.ActionBar; -import android.app.ActionBar.Tab; -import android.app.ActionBar.TabListener; import android.app.AlertDialog; import android.app.Dialog; -import android.app.Fragment; -import android.app.FragmentManager; -import android.app.FragmentTransaction; -import android.app.ListFragment; import android.app.PendingIntent; import android.content.ActivityNotFoundException; import android.content.Context; @@ -21,8 +14,14 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; +import android.support.v4.app.ListFragment; +import android.support.v4.view.MenuItemCompat; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; +import android.support.v7.app.ActionBar; import android.text.Editable; import android.text.SpannableString; import android.text.Spanned; @@ -82,8 +81,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU private final int REQUEST_CREATE_CONFERENCE = 0x3b39da; public int conference_context_id; public int contact_context_id; - private Tab mContactsTab; - private Tab mConferencesTab; + private ActionBar.Tab mContactsTab; + private ActionBar.Tab mConferencesTab; private ViewPager mViewPager; private ListPagerAdapter mListPagerAdapter; private List contacts = new ArrayList<>(); @@ -119,29 +118,30 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU return true; } }; - private TabListener mTabListener = new TabListener() { + private ActionBar.TabListener mTabListener = new ActionBar.TabListener() { @Override - public void onTabUnselected(Tab tab, FragmentTransaction ft) { + public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { return; } @Override - public void onTabSelected(Tab tab, FragmentTransaction ft) { + public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { mViewPager.setCurrentItem(tab.getPosition()); onTabChanged(); } @Override - public void onTabReselected(Tab tab, FragmentTransaction ft) { + public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { return; } }; private ViewPager.SimpleOnPageChangeListener mOnPageChangeListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { - if (getActionBar() != null) { - getActionBar().setSelectedNavigationItem(position); + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setSelectedNavigationItem(position); } onTabChanged(); } @@ -166,7 +166,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU private TextView.OnEditorActionListener mSearchDone = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - int pos = getActionBar().getSelectedNavigationIndex(); + int pos = getSupportActionBar().getSelectedNavigationIndex(); if (pos == 0) { if (contacts.size() == 1) { openConversationForContact((Contact) contacts.get(0)); @@ -257,18 +257,16 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU new EmojiService(this).init(useBundledEmoji()); setContentView(R.layout.activity_start_conversation); mViewPager = findViewById(R.id.start_conversation_view_pager); - ActionBar actionBar = getActionBar(); + ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); - mContactsTab = actionBar.newTab().setText(R.string.contacts) - .setTabListener(mTabListener); - mConferencesTab = actionBar.newTab().setText(R.string.conferences) - .setTabListener(mTabListener); + mContactsTab = actionBar.newTab().setText(R.string.contacts).setTabListener(mTabListener); + mConferencesTab = actionBar.newTab().setText(R.string.conferences).setTabListener(mTabListener); actionBar.addTab(mContactsTab); actionBar.addTab(mConferencesTab); mViewPager.setOnPageChangeListener(mOnPageChangeListener); - mListPagerAdapter = new ListPagerAdapter(getFragmentManager()); + mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mListPagerAdapter); mConferenceAdapter = new ListItemAdapter(this, conferences); @@ -607,18 +605,17 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU menuHideOffline.setChecked(this.mHideOfflineContacts); mMenuSearchView = menu.findItem(R.id.action_search); mMenuSearchView.setOnActionExpandListener(mOnActionExpandListener); - View mSearchView = mMenuSearchView.getActionView(); - mSearchEditText = mSearchView - .findViewById(R.id.search_field); + View mSearchView = MenuItemCompat.getActionView(mMenuSearchView); + mSearchEditText = (EditText) mSearchView.findViewById(R.id.search_field); mSearchEditText.addTextChangedListener(mSearchTextWatcher); mSearchEditText.setOnEditorActionListener(mSearchDone); - if (getActionBar().getSelectedNavigationIndex() == 0) { + if (getSupportActionBar().getSelectedNavigationIndex() == 0) { menuCreateConference.setVisible(false); } else { menuCreateContact.setVisible(false); } if (mInitialJid != null) { - mMenuSearchView.expandActionView(); + MenuItemCompat.expandActionView(mMenuSearchView); mSearchEditText.append(mInitialJid); filter(mInitialJid); } @@ -778,7 +775,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } } final Intent intent = getIntent(); - final ActionBar ab = getActionBar(); + final ActionBar ab = getSupportActionBar(); boolean init = intent != null && intent.getBooleanExtra("init", false); boolean noConversations = xmppConnectionService.getConversations().size() == 0; if ((init || noConversations) && ab != null) { diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 79f528f93..3881b3569 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -4,7 +4,6 @@ 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; @@ -39,6 +38,7 @@ import android.os.SystemClock; import android.preference.PreferenceManager; import android.provider.Settings; import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; import android.text.InputType; import android.util.DisplayMetrics; import android.util.Log; @@ -83,7 +83,7 @@ import de.pixart.messenger.xmpp.OnUpdateBlocklist; import de.pixart.messenger.xmpp.jid.InvalidJidException; import de.pixart.messenger.xmpp.jid.Jid; -public abstract class XmppActivity extends Activity { +public abstract class XmppActivity extends AppCompatActivity { protected static final int REQUEST_ANNOUNCE_PGP = 0x0101; protected static final int REQUEST_INVITE_TO_CONVERSATION = 0x0102; diff --git a/src/main/res/menu/change_presence.xml b/src/main/res/menu/change_presence.xml index 34af0a679..5417076b6 100644 --- a/src/main/res/menu/change_presence.xml +++ b/src/main/res/menu/change_presence.xml @@ -1,12 +1,13 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/choose_contact.xml b/src/main/res/menu/choose_contact.xml index 382e96017..fb52a3a1a 100644 --- a/src/main/res/menu/choose_contact.xml +++ b/src/main/res/menu/choose_contact.xml @@ -1,24 +1,25 @@ - + diff --git a/src/main/res/menu/contact_details.xml b/src/main/res/menu/contact_details.xml index 29ef166e5..50243150b 100644 --- a/src/main/res/menu/contact_details.xml +++ b/src/main/res/menu/contact_details.xml @@ -1,18 +1,19 @@ - + diff --git a/src/main/res/menu/conversations.xml b/src/main/res/menu/conversations.xml index 992371fc7..b748a065e 100644 --- a/src/main/res/menu/conversations.xml +++ b/src/main/res/menu/conversations.xml @@ -1,71 +1,72 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/editaccount.xml b/src/main/res/menu/editaccount.xml index 698c648ee..13e8db4a6 100644 --- a/src/main/res/menu/editaccount.xml +++ b/src/main/res/menu/editaccount.xml @@ -1,9 +1,10 @@ - + + app:showAsAction="always"> @@ -42,28 +43,28 @@ android:id="@+id/action_server_info_show_more" android:checkable="true" android:checked="false" - android:showAsAction="never" + app:showAsAction="never" android:title="@string/server_info_show_more" /> \ No newline at end of file diff --git a/src/main/res/menu/manageaccounts.xml b/src/main/res/menu/manageaccounts.xml index 38b82010b..044c715c5 100644 --- a/src/main/res/menu/manageaccounts.xml +++ b/src/main/res/menu/manageaccounts.xml @@ -1,21 +1,22 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/manageaccounts_context.xml b/src/main/res/menu/manageaccounts_context.xml index beca7b8ec..a49b770df 100644 --- a/src/main/res/menu/manageaccounts_context.xml +++ b/src/main/res/menu/manageaccounts_context.xml @@ -1,5 +1,6 @@ - + - + @@ -29,19 +30,19 @@ \ No newline at end of file diff --git a/src/main/res/menu/publish_avatar.xml b/src/main/res/menu/publish_avatar.xml index 39478c0a4..72ceb2d17 100644 --- a/src/main/res/menu/publish_avatar.xml +++ b/src/main/res/menu/publish_avatar.xml @@ -1,8 +1,9 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/select_multiple.xml b/src/main/res/menu/select_multiple.xml index efd6e4d0a..51f05e21a 100644 --- a/src/main/res/menu/select_multiple.xml +++ b/src/main/res/menu/select_multiple.xml @@ -1,9 +1,10 @@ - + + app:showAsAction="always" /> diff --git a/src/main/res/menu/share_with.xml b/src/main/res/menu/share_with.xml index ff87edc1a..5c57eedd8 100644 --- a/src/main/res/menu/share_with.xml +++ b/src/main/res/menu/share_with.xml @@ -1,11 +1,12 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/showlocation.xml b/src/main/res/menu/showlocation.xml index 3eb0647c9..c7049a5b0 100644 --- a/src/main/res/menu/showlocation.xml +++ b/src/main/res/menu/showlocation.xml @@ -1,8 +1,9 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/start_conversation.xml b/src/main/res/menu/start_conversation.xml index ea7572b41..79cce252c 100644 --- a/src/main/res/menu/start_conversation.xml +++ b/src/main/res/menu/start_conversation.xml @@ -1,21 +1,22 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/trust_keys.xml b/src/main/res/menu/trust_keys.xml index 7c63bd7fe..e40295eea 100644 --- a/src/main/res/menu/trust_keys.xml +++ b/src/main/res/menu/trust_keys.xml @@ -1,9 +1,10 @@ - + \ No newline at end of file diff --git a/src/main/res/menu/verify_otr.xml b/src/main/res/menu/verify_otr.xml index 7dadffce8..b6dd79610 100644 --- a/src/main/res/menu/verify_otr.xml +++ b/src/main/res/menu/verify_otr.xml @@ -1,14 +1,15 @@ - + + app:showAsAction="never" /> \ No newline at end of file diff --git a/src/main/res/values-v21/themes.xml b/src/main/res/values-v21/themes.xml index 0c0b3cefb..8d0de873f 100644 --- a/src/main/res/values-v21/themes.xml +++ b/src/main/res/values-v21/themes.xml @@ -1,11 +1,11 @@ - - \ No newline at end of file diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index 83598c041..17c1c5607 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -53,5 +53,5 @@ - + \ No newline at end of file -- cgit v1.2.3