Move the "Add new quick response" button into the action bar

Change-Id: I433fb686837d0de125fb277f5055bc33b7769eff
This commit is contained in:
Tony Mantler 2013-08-12 12:03:56 -07:00
parent 8c13dcd950
commit cef6c19be2
5 changed files with 54 additions and 30 deletions

View File

@ -18,9 +18,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="@dimen/settings_fragment_padding_top"
android:paddingLeft="@dimen/settings_fragment_padding_left"
android:paddingRight="@dimen/settings_fragment_padding_right"
>
<!-- List of quick responses and empty view for when there are none-->
@ -41,10 +38,4 @@
android:visibility="gone"
android:text="@string/quick_responses_empty_view"
/>
<Button
android:id="@+id/create_new"
android:layout_gravity="center"
style="@style/accountSettingsButton"
android:text="@string/create_action"
/>
</LinearLayout>

View File

@ -28,7 +28,6 @@
android:id="@+id/quick_response_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
style="@style/accountSetupInfoText"
android:ellipsize="end"
android:focusable="false"

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2013 Google Inc.
Licensed to 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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/create_new"
android:showAsAction="ifRoom"
android:title="@string/create_action"/>
<item
android:id="@+id/feedback_menu_item"
android:icon="@android:drawable/ic_menu_send"
android:title="@string/feedback"/>
<!-- TODO add help menu item, once help support has been moved to UnifiedEmail -->
</menu>

View File

@ -65,7 +65,7 @@
<string name="favorite_action">Star</string>
<!-- Button name used to complete a multi-step process -->
<string name="done_action">Done</string>
<!-- Button name used to create a new quick response [CHAR_LIMIT=16] -->
<!-- Menu item used to create a new quick response [CHAR_LIMIT=16] -->
<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>

View File

@ -22,31 +22,25 @@ import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.QuickResponse;
import com.android.emailcommon.utility.EmailAsyncTask;
import com.android.mail.utils.LogUtils;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.LoaderManager;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
@ -126,6 +120,8 @@ public class AccountSettingsEditQuickResponsesFragment extends Fragment {
Bundle args = getArguments();
mAccount = args.getParcelable("account");
setHasOptionsMenu(true);
}
@Override
@ -155,16 +151,23 @@ public class AccountSettingsEditQuickResponsesFragment extends Fragment {
.show(getFragmentManager(), null);
}
});
final View createNewView =
UiUtilities.getView((ViewGroup) listView.getParent(), R.id.create_new);
createNewView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Uri baseUri = Uri.parse(EmailContent.CONTENT_URI + "/quickresponse");
EditQuickResponseDialog.newInstance(null, baseUri, mAccount.getId(), true)
.show(getFragmentManager(), null);
}
});
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.quick_response_prefs_fragment_menu, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.create_new) {
final Uri baseUri = Uri.parse(EmailContent.CONTENT_URI + "/quickresponse");
EditQuickResponseDialog.newInstance(null, baseUri, mAccount.getId(), true)
.show(getFragmentManager(), null);
return true;
}
return super.onOptionsItemSelected(item);
}
}