forked from upstream-mirrors/quik
Move ComposeFragment to new activity
This commit is contained in:
@@ -81,8 +81,8 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.messagelist.MessageListActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:launchMode="singleTask">
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
@@ -98,8 +98,15 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ui.settings.SettingsActivity" />
|
||||
<activity android:name=".ui.search.SearchActivity" />
|
||||
<activity
|
||||
android:name=".ui.settings.SettingsActivity"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".ui.search.SearchActivity"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".ui.compose.ComposeActivity"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
|
||||
<activity-alias
|
||||
android:name=".ui.MainActivity-Teal"
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.moez.QKSMS.receiver.IconColorReceiver;
|
||||
import com.moez.QKSMS.transaction.NotificationManager;
|
||||
import com.moez.QKSMS.transaction.SmsHelper;
|
||||
import com.moez.QKSMS.ui.base.QKActivity;
|
||||
import com.moez.QKSMS.ui.compose.ComposeFragment;
|
||||
import com.moez.QKSMS.ui.conversationlist.ConversationListFragment;
|
||||
import com.moez.QKSMS.ui.dialog.ConversationSettingsDialog;
|
||||
import com.moez.QKSMS.ui.dialog.DefaultSmsHelper;
|
||||
@@ -114,14 +113,6 @@ public class MainActivity extends QKActivity implements SlidingMenu.SlidingMenuL
|
||||
menuTransaction.replace(R.id.menu_frame, mConversationList);
|
||||
menuTransaction.commit();
|
||||
|
||||
mContent = (ContentFragment) fm.findFragmentById(R.id.content_frame);
|
||||
if (mContent == null) {
|
||||
mContent = ComposeFragment.getInstance(null);
|
||||
}
|
||||
FragmentTransaction contentTransaction = fm.beginTransaction();
|
||||
contentTransaction.replace(R.id.content_frame, (Fragment) mContent);
|
||||
contentTransaction.commit();
|
||||
|
||||
onNewIntent(getIntent());
|
||||
showDialogIfNeeded(savedInstanceState);
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.moez.QKSMS.ui.compose;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.ui.base.QKSwipeBackActivity;
|
||||
|
||||
public class ComposeActivity extends QKSwipeBackActivity {
|
||||
|
||||
private ComposeFragment mComposeFragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTitle(R.string.title_compose);
|
||||
|
||||
FragmentManager fm = getFragmentManager();
|
||||
mComposeFragment = (ComposeFragment) fm.findFragmentById(R.id.content_frame);
|
||||
if (mComposeFragment == null) {
|
||||
mComposeFragment = new ComposeFragment();
|
||||
}
|
||||
|
||||
fm.beginTransaction()
|
||||
.replace(R.id.content_frame, mComposeFragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
new MenuInflater(this).inflate(R.menu.compose, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.moez.QKSMS.ui.compose;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
@@ -18,81 +14,22 @@ 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.QKActivity;
|
||||
import com.moez.QKSMS.ui.base.QKContentFragment;
|
||||
import com.moez.QKSMS.ui.base.QKFragment;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageListActivity;
|
||||
import com.moez.QKSMS.ui.view.AutoCompleteContactView;
|
||||
import com.moez.QKSMS.ui.view.ComposeView;
|
||||
import com.moez.QKSMS.ui.view.StarredContactsView;
|
||||
|
||||
public class ComposeFragment extends QKContentFragment implements ActivityLauncher, RecipientProvider,
|
||||
public class ComposeFragment extends QKFragment implements ActivityLauncher, RecipientProvider,
|
||||
ComposeView.OnSendListener, AdapterView.OnItemClickListener {
|
||||
|
||||
private final String TAG = "ComposeFragment";
|
||||
|
||||
/**
|
||||
* Set to true in the bundle if the ComposeFragment should show the keyboard. Defaults to false.
|
||||
*/
|
||||
public static final String ARG_SHOW_KEYBOARD = "showKeyboard";
|
||||
|
||||
/**
|
||||
* Set a FOCUS string to indicate where the focus should be for the keyboard. Defaults to
|
||||
* FOCUS_NOTHING.
|
||||
*/
|
||||
public static final String ARG_FOCUS = "focus";
|
||||
|
||||
public static final String FOCUS_NOTHING = "nothing";
|
||||
public static final String FOCUS_RECIPIENTS = "recipients";
|
||||
public static final String FOCUS_REPLY = "reply";
|
||||
|
||||
private AutoCompleteContactView mRecipients;
|
||||
private ComposeView mComposeView;
|
||||
private StarredContactsView mStarredContactsView;
|
||||
|
||||
// True if the fragment's arguments have changed, and we need to potentially perform a focus
|
||||
// operation when the fragment opens.
|
||||
private boolean mPendingFocus = false;
|
||||
|
||||
/**
|
||||
* Returns a new ComposeFragment, configured with the args.
|
||||
*
|
||||
* @param args A Bundle with options for configuring this fragment. See the ARG_ constants for
|
||||
* configuration options.
|
||||
* @return the new ComposeFragment
|
||||
*/
|
||||
public static ComposeFragment getInstance(Bundle args) {
|
||||
return getInstance(args, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ComposeFragment, configured with the args. If possible, the given fragment
|
||||
* is used instead of creating a new ComposeFragment.
|
||||
*
|
||||
* @param args A Bundle with options for configuring this fragment. See the ARG_ constants for
|
||||
* configuration options.
|
||||
* @param reuseFragment A fragment that can be used instead of creating a new one.
|
||||
* @return the ComposeFragment, which may be recycled
|
||||
*/
|
||||
public static ComposeFragment getInstance(Bundle args, Fragment reuseFragment) {
|
||||
ComposeFragment f;
|
||||
|
||||
// Check if we can reuse the passed fragment.
|
||||
if (reuseFragment != null && reuseFragment instanceof ComposeFragment) {
|
||||
f = (ComposeFragment) reuseFragment;
|
||||
} else {
|
||||
f = new ComposeFragment();
|
||||
}
|
||||
|
||||
// Set the arguments in this fragment.
|
||||
f.updateArguments(args);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewArguments() {
|
||||
// Set pending focus, because the new configuration means that we may need to focus.
|
||||
mPendingFocus = true;
|
||||
public ComposeFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,19 +51,11 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
||||
mStarredContactsView = (StarredContactsView) view.findViewById(R.id.starred_contacts);
|
||||
mStarredContactsView.setComposeScreenViews(mRecipients, mComposeView);
|
||||
|
||||
new Handler().postDelayed(() -> KeyboardUtils.showAndFocus(mContext, mRecipients), 100);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
boolean handledByComposeView = mComposeView.onActivityResult(requestCode, resultCode, data);
|
||||
if (!handledByComposeView) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(String[] recipients, String body) {
|
||||
long threadId = Utils.getOrCreateThreadId(mContext, recipients[0]);
|
||||
@@ -137,47 +66,6 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentOpened() {
|
||||
setupInput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the keyboard and focuses on the recipients text view.
|
||||
*/
|
||||
public void setupInput() {
|
||||
Bundle args = getArguments() == null ? new Bundle() : getArguments();
|
||||
|
||||
if (mPendingFocus) {
|
||||
if (args.getBoolean(ARG_SHOW_KEYBOARD, false)) {
|
||||
KeyboardUtils.show(mContext);
|
||||
}
|
||||
|
||||
String focus = args.getString(ARG_FOCUS, FOCUS_NOTHING);
|
||||
if (FOCUS_RECIPIENTS.equals(focus)) {
|
||||
mRecipients.requestFocus();
|
||||
} else if (FOCUS_REPLY.equals(focus)) {
|
||||
mComposeView.requestReplyTextFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentClosing() {
|
||||
// Clear the focus from this fragment.
|
||||
if (getActivity() != null && getActivity().getCurrentFocus() != null) {
|
||||
getActivity().getCurrentFocus().clearFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentClosed() {
|
||||
super.onContentClosed();
|
||||
if (mComposeView != null) {
|
||||
mComposeView.saveDraft();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -186,19 +74,6 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuChanging(float percentOpen) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
|
||||
inflater.inflate(R.menu.compose, menu);
|
||||
((QKActivity) context).setTitle(R.string.title_compose);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the addresses of all the contacts in the AutoCompleteContactsView.
|
||||
*/
|
||||
|
||||
+2
-14
@@ -1,6 +1,5 @@
|
||||
package com.moez.QKSMS.ui.conversationlist;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Context;
|
||||
import android.content.CursorLoader;
|
||||
@@ -31,12 +30,11 @@ import com.moez.QKSMS.data.Conversation;
|
||||
import com.moez.QKSMS.data.ConversationLegacy;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.transaction.SmsHelper;
|
||||
import com.moez.QKSMS.ui.ContentFragment;
|
||||
import com.moez.QKSMS.ui.MainActivity;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.base.QKFragment;
|
||||
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
|
||||
import com.moez.QKSMS.ui.compose.ComposeFragment;
|
||||
import com.moez.QKSMS.ui.compose.ComposeActivity;
|
||||
import com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageListActivity;
|
||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||
@@ -112,13 +110,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
if (mAdapter.isInMultiSelectMode()) {
|
||||
mAdapter.disableMultiSelectMode(true);
|
||||
} else {
|
||||
// Show the compose fragment, showing the keyboard and focusing on the recipients edittext.
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(ComposeFragment.ARG_SHOW_KEYBOARD, true);
|
||||
args.putString(ComposeFragment.ARG_FOCUS, ComposeFragment.FOCUS_RECIPIENTS);
|
||||
|
||||
Fragment content = getFragmentManager().findFragmentById(R.id.content_frame);
|
||||
switchFragment(ComposeFragment.getInstance(args, content));
|
||||
mContext.startActivity(ComposeActivity.class);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -275,10 +267,6 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
|
||||
private void switchFragment(ContentFragment fragment) {
|
||||
((MainActivity) getActivity()).switchContent(fragment, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
Reference in New Issue
Block a user