Merge "Display message when no quick respones available"
This commit is contained in:
commit
7496b5ba2b
@ -23,14 +23,24 @@
|
||||
android:paddingRight="@dimen/settings_fragment_padding_right"
|
||||
>
|
||||
|
||||
<!-- List of quick responses -->
|
||||
<!-- List of quick responses and empty view for when there are none-->
|
||||
<ListView
|
||||
android:id="@+id/account_settings_quick_responses_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:focusable="true"
|
||||
android:visibility="gone"
|
||||
android:text="@string/quick_responses_empty_view"
|
||||
/>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -42,12 +52,14 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="@string/create_action" />
|
||||
android:text="@string/create_action"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/done"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/done_action" />
|
||||
android:text="@string/done_action"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@ -103,6 +103,9 @@
|
||||
<string name="create_action">Create new</string>
|
||||
<!-- Button name used to delete a quick response [CHAR_LIMIT=16] -->
|
||||
<string name="delete_quick_response_action">Delete</string>
|
||||
<!-- Message informing user when a list that would contain quick responses
|
||||
is empty [CHAR_LIMIT=80] -->
|
||||
<string name="quick_responses_empty_view">No quick responses</string>
|
||||
<!-- Menu item/button name -->
|
||||
<string name="discard_action">Discard</string>
|
||||
<!-- Menu item/button name [CHAR_LIMIT=16] -->
|
||||
|
@ -71,12 +71,15 @@ import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.internet.MimeUtility;
|
||||
import com.android.emailcommon.mail.Address;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Attachment;
|
||||
import com.android.emailcommon.provider.EmailContent.Body;
|
||||
import com.android.emailcommon.provider.EmailContent.BodyColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.EmailContent.MessageColumns;
|
||||
import com.android.emailcommon.provider.EmailContent.QuickResponseColumns;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.provider.QuickResponse;
|
||||
import com.android.emailcommon.utility.AttachmentUtilities;
|
||||
import com.android.emailcommon.utility.EmailAsyncTask;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
@ -199,6 +202,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
private boolean mDraftNeedsSaving;
|
||||
private boolean mMessageLoaded;
|
||||
private boolean mInitiallyEmpty;
|
||||
private Boolean mQuickResponsesAvailable = true;
|
||||
private final EmailAsyncTask.Tracker mTaskTracker = new EmailAsyncTask.Tracker();
|
||||
|
||||
private AccountSpecifier mAddressAdapterTo;
|
||||
@ -352,6 +356,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
// Some configurations don't show the from field.
|
||||
mFromView.setText(account.mEmailAddress);
|
||||
}
|
||||
|
||||
new QuickResponseChecker(mTaskTracker).executeParallel((Void) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -438,6 +444,35 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
setAction(intent.getAction());
|
||||
}
|
||||
|
||||
private void setQuickResponsesAvailable(boolean quickResponsesAvailable) {
|
||||
if (mQuickResponsesAvailable != quickResponsesAvailable) {
|
||||
mQuickResponsesAvailable = quickResponsesAvailable;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an accountId and context, finds if the database has any QuickResponse
|
||||
* entries and returns the result to the Callback.
|
||||
*/
|
||||
private class QuickResponseChecker extends EmailAsyncTask<Void, Void, Boolean> {
|
||||
public QuickResponseChecker(EmailAsyncTask.Tracker tracker) {
|
||||
super(tracker);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
return EmailContent.count(MessageCompose.this, QuickResponse.CONTENT_URI,
|
||||
QuickResponseColumns.ACCOUNT_KEY + "=?",
|
||||
new String[] {Long.toString(mAccount.mId)}) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSuccess(Boolean quickResponsesAvailable) {
|
||||
setQuickResponsesAvailable(quickResponsesAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@ -448,6 +483,11 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
// If activity paused and quick responses are removed/added, possibly update options menu
|
||||
if (mAccount != null) {
|
||||
new QuickResponseChecker(mTaskTracker).executeParallel((Void) null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1859,6 +1899,9 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||
menu.findItem(R.id.save).setEnabled(mDraftNeedsSaving);
|
||||
menu.findItem(R.id.add_cc_bcc).setVisible(
|
||||
(mCcBccContainer == null) || (mCcBccContainer.getVisibility() != View.VISIBLE));
|
||||
MenuItem insertQuickResponse = menu.findItem(R.id.show_quick_text_list_dialog);
|
||||
insertQuickResponse.setVisible(mQuickResponsesAvailable);
|
||||
insertQuickResponse.setEnabled(mQuickResponsesAvailable);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Lists quick responses associated with the specified email account. Allows users to create,
|
||||
@ -247,6 +248,9 @@ public class AccountSettingsEditQuickResponsesFragment extends Fragment
|
||||
|
||||
mQuickResponsesView = UiUtilities.getView(view,
|
||||
R.id.account_settings_quick_responses_list);
|
||||
TextView emptyView = (TextView)
|
||||
UiUtilities.getView(((ViewGroup) mQuickResponsesView.getParent()), R.id.empty_view);
|
||||
mQuickResponsesView.setEmptyView(emptyView);
|
||||
|
||||
new QuickResponseFinder(mTaskTracker, mAccount.mId, mQuickResponsesView,
|
||||
mContext, getFragmentManager(), null, true)
|
||||
|
Loading…
Reference in New Issue
Block a user