blob: 0db435e966af902bcfc080d6eba25ca6def3c525 [file] [log] [blame]
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -08001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.contacts.interactions;
17
Dmitri Plotnikov18ffaa22010-12-03 14:28:00 -080018import com.android.contacts.ContactSaveService;
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080019import com.android.contacts.R;
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080020
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080021import android.app.FragmentManager;
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080022import android.os.Bundle;
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080023import android.widget.EditText;
24
25/**
26 * A dialog for renaming a group.
27 */
Dmitri Plotnikov1ac58b62010-11-19 16:12:09 -080028public class GroupRenamingDialogFragment extends GroupNameDialogFragment {
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080029
30 private static final String ARG_GROUP_ID = "groupId";
31 private static final String ARG_LABEL = "label";
32
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080033 public static void show(FragmentManager fragmentManager, long groupId, String label) {
34 GroupRenamingDialogFragment dialog = new GroupRenamingDialogFragment();
35 Bundle args = new Bundle();
36 args.putLong(ARG_GROUP_ID, groupId);
37 args.putString(ARG_LABEL, label);
38 dialog.setArguments(args);
39 dialog.show(fragmentManager, "renameGroup");
40 }
41
42 @Override
Dmitri Plotnikov1ac58b62010-11-19 16:12:09 -080043 protected void initializeGroupLabelEditText(EditText editText) {
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080044 String label = getArguments().getString(ARG_LABEL);
Dmitri Plotnikov1ac58b62010-11-19 16:12:09 -080045 editText.setText(label);
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080046 if (label != null) {
Dmitri Plotnikov1ac58b62010-11-19 16:12:09 -080047 editText.setSelection(label.length());
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080048 }
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080049 }
50
Dmitri Plotnikov1ac58b62010-11-19 16:12:09 -080051 @Override
52 protected int getTitleResourceId() {
53 return R.string.rename_group_dialog_title;
54 }
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080055
Dmitri Plotnikov1ac58b62010-11-19 16:12:09 -080056 @Override
57 protected void onCompleted(String groupLabel) {
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080058 Bundle arguments = getArguments();
59 long groupId = arguments.getLong(ARG_GROUP_ID);
60
61 getActivity().startService(ContactSaveService.createGroupRenameIntent(
Dmitri Plotnikov1ac58b62010-11-19 16:12:09 -080062 getActivity(), groupId, groupLabel));
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -080063 }
64}