Walter Jang | 3f990ba | 2015-01-27 17:38:30 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.contacts.activities; |
| 18 | |
| 19 | import com.android.contacts.R; |
| 20 | import com.android.contacts.editor.CompactContactEditorFragment; |
Brian Attwell | bdd3264 | 2015-05-08 17:03:15 -0700 | [diff] [blame^] | 21 | import com.android.contacts.common.activity.RequestPermissionsActivity; |
Walter Jang | 3f990ba | 2015-01-27 17:38:30 +0000 | [diff] [blame] | 22 | |
| 23 | import android.content.Intent; |
| 24 | import android.net.Uri; |
| 25 | import android.os.Bundle; |
| 26 | |
| 27 | /** |
| 28 | * Contact editor with only the most important fields displayed initially. |
| 29 | */ |
| 30 | public class CompactContactEditorActivity extends ContactEditorBaseActivity { |
| 31 | |
Walter Jang | e2797da | 2015-04-23 11:08:46 -0700 | [diff] [blame] | 32 | private static final String TAG_COMPACT_EDITOR = "compact_editor"; |
| 33 | |
Walter Jang | 3f990ba | 2015-01-27 17:38:30 +0000 | [diff] [blame] | 34 | @Override |
| 35 | public void onCreate(Bundle savedState) { |
| 36 | super.onCreate(savedState); |
| 37 | |
Brian Attwell | bdd3264 | 2015-05-08 17:03:15 -0700 | [diff] [blame^] | 38 | if (RequestPermissionsActivity.startPermissionActivity(this)) { |
| 39 | return; |
| 40 | } |
| 41 | |
Walter Jang | 3f990ba | 2015-01-27 17:38:30 +0000 | [diff] [blame] | 42 | setContentView(R.layout.compact_contact_editor_activity); |
| 43 | |
Walter Jang | e2797da | 2015-04-23 11:08:46 -0700 | [diff] [blame] | 44 | mFragment = (CompactContactEditorFragment) getFragmentManager().findFragmentByTag( |
| 45 | TAG_COMPACT_EDITOR); |
Walter Jang | a69f58f | 2015-04-02 10:26:56 -0700 | [diff] [blame] | 46 | if (mFragment == null) { |
| 47 | mFragment = new CompactContactEditorFragment(); |
| 48 | getFragmentManager().beginTransaction() |
| 49 | .add(R.id.compact_contact_editor_fragment_container, |
Walter Jang | e2797da | 2015-04-23 11:08:46 -0700 | [diff] [blame] | 50 | (CompactContactEditorFragment) mFragment, TAG_COMPACT_EDITOR) |
Walter Jang | a69f58f | 2015-04-02 10:26:56 -0700 | [diff] [blame] | 51 | .commit(); |
| 52 | } |
Walter Jang | 3f990ba | 2015-01-27 17:38:30 +0000 | [diff] [blame] | 53 | 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 Jang | 5a7a23b | 2015-03-06 10:54:26 -0800 | [diff] [blame] | 59 | |
| 60 | @Override |
| 61 | public void onBackPressed() { |
| 62 | if (mFragment != null) { |
| 63 | mFragment.save(ContactEditor.SaveMode.CLOSE); |
| 64 | } |
| 65 | } |
Walter Jang | 3f990ba | 2015-01-27 17:38:30 +0000 | [diff] [blame] | 66 | } |