"No quick responses available" should display when all quick responses are deleted
b/14239989 We take advantage of ListView's feature that displays an entirely different view in place when the backing Adapter is empty. The empty view is simply a TextView displaying "No quick responses available". Change-Id: I244ffd21fc4c1557c73979d4bb7c99306b11ebb2
This commit is contained in:
parent
f3440d33a9
commit
6dce0b1819
37
res/layout/quick_responses.xml
Normal file
37
res/layout/quick_responses.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:minHeight="64dp">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/quick_responses"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/quick_responses_empty_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
style="@style/quick_response_text"
|
||||||
|
android:text="@string/no_quick_responses"
|
||||||
|
android:textColor="@color/button_text_disabled_color"
|
||||||
|
/>
|
||||||
|
</FrameLayout>
|
@ -860,4 +860,7 @@
|
|||||||
|
|
||||||
<string name="print_job_name" translatable="false">Email - <xliff:g id="subject">%1$s</xliff:g></string>
|
<string name="print_job_name" translatable="false">Email - <xliff:g id="subject">%1$s</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- This message indicates no quick responses exist to choose from -->
|
||||||
|
<string name="no_quick_responses">None available</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
package com.android.email.activity;
|
package com.android.email.activity;
|
||||||
|
|
||||||
import com.android.email.R;
|
|
||||||
import com.android.mail.providers.Account;
|
|
||||||
import com.android.mail.providers.UIProvider;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
@ -31,12 +27,17 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.SimpleCursorAdapter;
|
import android.widget.SimpleCursorAdapter;
|
||||||
|
|
||||||
|
import com.android.email.R;
|
||||||
|
import com.android.mail.providers.Account;
|
||||||
|
import com.android.mail.providers.UIProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog which lists QuickResponses for the specified account. On user selection, will call
|
* Dialog which lists QuickResponses for the specified account. On user selection, will call
|
||||||
* Callback.onQuickResponseSelected() with the selected QuickResponse text.
|
* Callback.onQuickResponseSelected() with the selected QuickResponse text.
|
||||||
@ -96,14 +97,21 @@ public class InsertQuickResponseDialog extends DialogFragment {
|
|||||||
// Now that Callback implementation is verified, build the dialog
|
// Now that Callback implementation is verified, build the dialog
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
|
|
||||||
final SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(),
|
final SimpleCursorAdapter adapter = new SimpleCursorAdapter(context,
|
||||||
R.layout.quick_response_item, null,
|
R.layout.quick_response_item, null,
|
||||||
new String[] {UIProvider.QuickResponseColumns.TEXT},
|
new String[] {UIProvider.QuickResponseColumns.TEXT},
|
||||||
new int[] {R.id.quick_response_text}, 0);
|
new int[] {R.id.quick_response_text}, 0);
|
||||||
|
|
||||||
final ListView listView = new ListView(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
listView.setAdapter(adapter);
|
|
||||||
|
|
||||||
|
// inflate the view to show in the dialog
|
||||||
|
final LayoutInflater li = LayoutInflater.from(builder.getContext());
|
||||||
|
final View quickResponsesView = li.inflate(R.layout.quick_responses, null);
|
||||||
|
|
||||||
|
// the view contains both a ListView and its associated empty view; wire them together
|
||||||
|
final ListView listView = (ListView) quickResponsesView.findViewById(R.id.quick_responses);
|
||||||
|
listView.setEmptyView(quickResponsesView.findViewById(R.id.quick_responses_empty_view));
|
||||||
|
listView.setAdapter(adapter);
|
||||||
listView.setOnItemClickListener(new OnItemClickListener() {
|
listView.setOnItemClickListener(new OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
@ -120,7 +128,7 @@ public class InsertQuickResponseDialog extends DialogFragment {
|
|||||||
getLoaderManager().initLoader(0, null, new LoaderManager.LoaderCallbacks<Cursor>() {
|
getLoaderManager().initLoader(0, null, new LoaderManager.LoaderCallbacks<Cursor>() {
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
return new CursorLoader(getActivity(), account.quickResponseUri,
|
return new CursorLoader(context, account.quickResponseUri,
|
||||||
UIProvider.QUICK_RESPONSE_PROJECTION, null, null, null);
|
UIProvider.QUICK_RESPONSE_PROJECTION, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,17 +143,19 @@ public class InsertQuickResponseDialog extends DialogFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final AlertDialog.Builder b = new AlertDialog.Builder(context);
|
final String dialogTitle = getResources()
|
||||||
b.setTitle(getResources()
|
.getString(R.string.message_compose_insert_quick_response_list_title);
|
||||||
.getString(R.string.message_compose_insert_quick_response_list_title))
|
|
||||||
.setView(listView)
|
return builder
|
||||||
|
.setTitle(dialogTitle)
|
||||||
|
.setView(quickResponsesView)
|
||||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return b.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Callback getCallback() {
|
private Callback getCallback() {
|
||||||
|
Loading…
Reference in New Issue
Block a user