mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-18 11:58:52 +01:00
Fixed crash when opening settings
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
package com.moez.QKSMS.ui;
|
package com.moez.QKSMS.ui;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is for fragments that must extend something other than a vanilla Fragment. It
|
* This interface is for fragments that must extend something other than a vanilla Fragment. It
|
||||||
* allows the fragment to get content animation callbacks without the developer having to
|
* allows the fragment to get content animation callbacks without the developer having to
|
||||||
@@ -27,4 +31,9 @@ public interface ContentFragment {
|
|||||||
* been closed immediately.
|
* been closed immediately.
|
||||||
*/
|
*/
|
||||||
void onContentClosed();
|
void onContentClosed();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the MainActivity to delegate setting of the Toolbar title and menu
|
||||||
|
*/
|
||||||
|
void inflateToolbar(Menu menu, MenuInflater inflater, Context context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
|||||||
inflater.inflate(R.menu.coversation_list, menu);
|
inflater.inflate(R.menu.coversation_list, menu);
|
||||||
} else {
|
} else {
|
||||||
showBackButton(true);
|
showBackButton(true);
|
||||||
((Fragment) mContent).onCreateOptionsMenu(menu, inflater);
|
mContent.inflateToolbar(menu, inflater, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import com.moez.QKSMS.ui.settings.SettingsFragment;
|
|||||||
* - Manages the current state of the fragment in terms of the animation, i.e. opening, fully
|
* - Manages the current state of the fragment in terms of the animation, i.e. opening, fully
|
||||||
* opened, etc.
|
* opened, etc.
|
||||||
*/
|
*/
|
||||||
public class QKContentFragment extends QKFragment implements LiveView, ContentFragment {
|
public abstract class QKContentFragment extends QKFragment implements LiveView, ContentFragment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's not strictly necessary, but subclasses should call through to super() in their
|
* It's not strictly necessary, but subclasses should call through to super() in their
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.moez.QKSMS.ui.compose;
|
package com.moez.QKSMS.ui.compose;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -65,8 +66,8 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
|||||||
* Returns a ComposeFragment, configured with the args. If possible, the given fragment
|
* Returns a ComposeFragment, configured with the args. If possible, the given fragment
|
||||||
* is used instead of creating a new ComposeFragment.
|
* is used instead of creating a new ComposeFragment.
|
||||||
*
|
*
|
||||||
* @param args A Bundle with options for configuring this fragment. See the ARG_ constants for
|
* @param args A Bundle with options for configuring this fragment. See the ARG_ constants for
|
||||||
* configuration options.
|
* configuration options.
|
||||||
* @param reuseFragment A fragment that can be used instead of creating a new one.
|
* @param reuseFragment A fragment that can be used instead of creating a new one.
|
||||||
* @return the ComposeFragment, which may be recycled
|
* @return the ComposeFragment, which may be recycled
|
||||||
*/
|
*/
|
||||||
@@ -75,7 +76,7 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
|||||||
|
|
||||||
// Check if we can reuse the passed fragment.
|
// Check if we can reuse the passed fragment.
|
||||||
if (reuseFragment != null && reuseFragment instanceof ComposeFragment) {
|
if (reuseFragment != null && reuseFragment instanceof ComposeFragment) {
|
||||||
f = (ComposeFragment)reuseFragment;
|
f = (ComposeFragment) reuseFragment;
|
||||||
} else {
|
} else {
|
||||||
f = new ComposeFragment();
|
f = new ComposeFragment();
|
||||||
}
|
}
|
||||||
@@ -113,14 +114,6 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
|||||||
return view;
|
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
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
@@ -174,6 +167,14 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
|
||||||
|
inflater.inflate(R.menu.compose, menu);
|
||||||
|
mContext.setTitle(R.string.title_compose);
|
||||||
|
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the addresses of all the contacts in the AutoCompleteContactsView.
|
* @return the addresses of all the contacts in the AutoCompleteContactsView.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -291,14 +291,6 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
inflater.inflate(R.menu.conversation, menu);
|
|
||||||
setTitle();
|
|
||||||
|
|
||||||
//super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -765,6 +757,14 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
|
||||||
|
inflater.inflate(R.menu.conversation, menu);
|
||||||
|
setTitle();
|
||||||
|
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event) {
|
||||||
if (event.values[0] == 0) {
|
if (event.values[0] == 0) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.moez.QKSMS.ui.search;
|
package com.moez.QKSMS.ui.search;
|
||||||
|
|
||||||
import android.content.AsyncQueryHandler;
|
import android.content.AsyncQueryHandler;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@@ -101,14 +102,6 @@ public class SearchFragment extends QKContentFragment implements RecyclerCursorA
|
|||||||
return view;
|
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() {
|
private void query() {
|
||||||
Contact.addListener(mContactListener);
|
Contact.addListener(mContactListener);
|
||||||
|
|
||||||
@@ -141,6 +134,14 @@ public class SearchFragment extends QKContentFragment implements RecyclerCursorA
|
|||||||
KeyboardUtils.showAndFocus(mContext, mQuery);
|
KeyboardUtils.showAndFocus(mContext, mQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
|
||||||
|
inflater.inflate(R.menu.search, menu);
|
||||||
|
mContext.setTitle(R.string.title_search);
|
||||||
|
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(SearchData data, View view) {
|
public void onItemClick(SearchData data, View view) {
|
||||||
MainActivity mainActivity = (MainActivity) mContext;
|
MainActivity mainActivity = (MainActivity) mContext;
|
||||||
|
|||||||
@@ -21,12 +21,10 @@ import android.preference.PreferenceFragment;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -682,33 +680,6 @@ 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);
|
|
||||||
mContext.colorMenuIcons(menu, ThemeManager.getTextOnColorPrimary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@@ -745,4 +716,22 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
public void onContentClosed() {
|
public void onContentClosed() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
|
||||||
|
if (mContext == null) {
|
||||||
|
mContext = (MainActivity) context;
|
||||||
|
mPrefs = mContext.getPrefs();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user