mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Improve menu setting for cleaner logic
This commit is contained in:
@@ -249,44 +249,27 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
|
||||
if (mSlidingMenu.isMenuShowing() || mContent == null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
|
||||
setTitle(getString(R.string.title_conversation_list));
|
||||
inflater.inflate(R.menu.coversation_list, menu);
|
||||
|
||||
} else {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (mContent instanceof MessageListFragment) {
|
||||
inflater.inflate(R.menu.conversation, menu);
|
||||
((MessageListFragment) mContent).setTitle();
|
||||
|
||||
} else if (mContent instanceof SearchFragment) {
|
||||
setTitle(getString(R.string.title_search));
|
||||
inflater.inflate(R.menu.search, menu);
|
||||
|
||||
} else if (mContent instanceof SettingsFragment) {
|
||||
setTitle(getString(R.string.title_settings));
|
||||
inflater.inflate(R.menu.settings, menu);
|
||||
MenuItem simplePrefs = menu.findItem(R.id.simple_settings);
|
||||
if (mPrefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)) {
|
||||
simplePrefs.setTitle(R.string.menu_show_all_prefs);
|
||||
} else {
|
||||
simplePrefs.setTitle(R.string.menu_show_fewer_prefs);
|
||||
}
|
||||
|
||||
} else if (mContent instanceof ComposeFragment) {
|
||||
setTitle(getString(R.string.title_compose));
|
||||
inflater.inflate(R.menu.compose, menu);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
menu.clear();
|
||||
|
||||
if (mSlidingMenu.isMenuShowing() || mContent == null) {
|
||||
showBackButton(false);
|
||||
setTitle(getString(R.string.title_conversation_list));
|
||||
inflater.inflate(R.menu.coversation_list, menu);
|
||||
} else {
|
||||
showBackButton(true);
|
||||
((Fragment) mContent).onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Fragment getConversationList() {
|
||||
return mConversationList;
|
||||
}
|
||||
@@ -590,7 +573,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
// Hide the soft keyboard
|
||||
KeyboardUtils.hide(this, getCurrentFocus());
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
showBackButton(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -608,7 +591,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
// Hide the soft keyboard
|
||||
KeyboardUtils.hide(this, getCurrentFocus());
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
showBackButton(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,6 +64,10 @@ public class QKActivity extends ActionBarActivity {
|
||||
ThemeManager.loadThemeProperties(this);
|
||||
}
|
||||
|
||||
protected void showBackButton(boolean show) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(show);
|
||||
}
|
||||
|
||||
public SharedPreferences getPrefs() {
|
||||
if (mPrefs == null) {
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.moez.QKSMS.ui.compose;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import android.widget.AdapterView;
|
||||
import com.android.ex.chips.recipientchip.DrawableRecipientChip;
|
||||
import com.moez.QKSMS.mmssms.Utils;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.interfaces.ActivityLauncher;
|
||||
import com.moez.QKSMS.interfaces.RecipientProvider;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.PhoneNumberUtils;
|
||||
import com.moez.QKSMS.interfaces.ActivityLauncher;
|
||||
import com.moez.QKSMS.interfaces.RecipientProvider;
|
||||
import com.moez.QKSMS.mmssms.Utils;
|
||||
import com.moez.QKSMS.ui.MainActivity;
|
||||
import com.moez.QKSMS.ui.base.QKContentFragment;
|
||||
import com.moez.QKSMS.ui.view.AutoCompleteContactView;
|
||||
@@ -42,8 +42,6 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
||||
public static final String FOCUS_RECIPIENTS = "recipients";
|
||||
public static final String FOCUS_REPLY = "reply";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private AutoCompleteContactView mRecipients;
|
||||
private ComposeView mComposeView;
|
||||
private StarredContactsView mStarredContactsView;
|
||||
@@ -94,12 +92,6 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
||||
mPendingFocus = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mContext = getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
@@ -121,6 +113,14 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.compose, menu);
|
||||
mContext.setTitle(R.string.title_compose);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
+1
-1
@@ -217,7 +217,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
|
||||
case MENU_NOTIFICATION_SETTINGS:
|
||||
ConversationNotificationSettingsDialog.newInstance(threadId, name).setContext(mContext)
|
||||
.show(((MainActivity) mContext).getFragmentManager(), "notification prefs");
|
||||
.show(getFragmentManager(), "notification prefs");
|
||||
break;
|
||||
|
||||
case MENU_VIEW_DETAILS:
|
||||
|
||||
@@ -52,6 +52,12 @@ import com.moez.QKSMS.LogTag;
|
||||
import com.moez.QKSMS.MmsConfig;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.common.utils.DrmUtils;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||
import com.moez.QKSMS.common.vcard.ContactOperations;
|
||||
import com.moez.QKSMS.data.Contact;
|
||||
import com.moez.QKSMS.data.ContactList;
|
||||
import com.moez.QKSMS.data.Conversation;
|
||||
@@ -59,12 +65,6 @@ import com.moez.QKSMS.data.ConversationLegacy;
|
||||
import com.moez.QKSMS.data.Message;
|
||||
import com.moez.QKSMS.interfaces.ActivityLauncher;
|
||||
import com.moez.QKSMS.model.SlideshowModel;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.common.utils.DrmUtils;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||
import com.moez.QKSMS.common.vcard.ContactOperations;
|
||||
import com.moez.QKSMS.transaction.NotificationManager;
|
||||
import com.moez.QKSMS.transaction.SmsHelper;
|
||||
import com.moez.QKSMS.ui.MainActivity;
|
||||
@@ -293,7 +293,10 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.conversation, menu);
|
||||
setTitle();
|
||||
|
||||
//super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -329,7 +332,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
new LoadConversationTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
|
||||
}
|
||||
|
||||
public void setTitle() {
|
||||
private void setTitle() {
|
||||
if (mContext != null && mConversation != null) {
|
||||
mContext.setTitle(mConversation.getRecipients().formatNames(", "));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import android.provider.Telephony;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@@ -99,6 +101,14 @@ public class SearchFragment extends QKContentFragment implements RecyclerCursorA
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.search, menu);
|
||||
mContext.setTitle(R.string.title_search);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
private void query() {
|
||||
Contact.addListener(mContactListener);
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
@@ -680,6 +682,21 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.settings, menu);
|
||||
mContext.setTitle(R.string.title_settings);
|
||||
|
||||
MenuItem simplePrefs = menu.findItem(R.id.simple_settings);
|
||||
if (mPrefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)) {
|
||||
simplePrefs.setTitle(R.string.menu_show_all_prefs);
|
||||
} else {
|
||||
simplePrefs.setTitle(R.string.menu_show_fewer_prefs);
|
||||
}
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
|
||||
Reference in New Issue
Block a user