blob: fcbb70ee727ca8edaad723c47569f36d571bc392 [file] [log] [blame]
Walter Jang3f990ba2015-01-27 17:38:30 +00001/*
2 * Copyright (C) 2015 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 */
16
17package com.android.contacts.activities;
18
19import com.android.contacts.R;
20import com.android.contacts.editor.CompactContactEditorFragment;
Brian Attwellbdd32642015-05-08 17:03:15 -070021import com.android.contacts.common.activity.RequestPermissionsActivity;
Walter Jang3f990ba2015-01-27 17:38:30 +000022
23import android.content.Intent;
24import android.net.Uri;
25import android.os.Bundle;
26
27/**
28 * Contact editor with only the most important fields displayed initially.
29 */
30public class CompactContactEditorActivity extends ContactEditorBaseActivity {
31
Walter Jange2797da2015-04-23 11:08:46 -070032 private static final String TAG_COMPACT_EDITOR = "compact_editor";
33
Walter Jang3f990ba2015-01-27 17:38:30 +000034 @Override
35 public void onCreate(Bundle savedState) {
36 super.onCreate(savedState);
37
Brian Attwellbdd32642015-05-08 17:03:15 -070038 if (RequestPermissionsActivity.startPermissionActivity(this)) {
39 return;
40 }
41
Walter Jang3f990ba2015-01-27 17:38:30 +000042 setContentView(R.layout.compact_contact_editor_activity);
43
Walter Jange2797da2015-04-23 11:08:46 -070044 mFragment = (CompactContactEditorFragment) getFragmentManager().findFragmentByTag(
45 TAG_COMPACT_EDITOR);
Walter Janga69f58f2015-04-02 10:26:56 -070046 if (mFragment == null) {
47 mFragment = new CompactContactEditorFragment();
48 getFragmentManager().beginTransaction()
49 .add(R.id.compact_contact_editor_fragment_container,
Walter Jange2797da2015-04-23 11:08:46 -070050 (CompactContactEditorFragment) mFragment, TAG_COMPACT_EDITOR)
Walter Janga69f58f2015-04-02 10:26:56 -070051 .commit();
52 }
Walter Jang3f990ba2015-01-27 17:38:30 +000053 mFragment.setListener(mFragmentListener);
54
55 final String action = getIntent().getAction();
56 final Uri uri = Intent.ACTION_EDIT.equals(action) ? getIntent().getData() : null;
57 mFragment.load(action, uri, getIntent().getExtras());
58 }
Walter Jang5a7a23b2015-03-06 10:54:26 -080059
60 @Override
61 public void onBackPressed() {
62 if (mFragment != null) {
63 mFragment.save(ContactEditor.SaveMode.CLOSE);
64 }
65 }
Walter Jang3f990ba2015-01-27 17:38:30 +000066}