diff options
author | Rohit Yengisetty <rohit@cyngn.com> | 2016-03-16 10:48:06 -0700 |
---|---|---|
committer | Richard MacGregor <rmacgregor@cyngn.com> | 2016-03-25 11:42:20 -0700 |
commit | d2c67d9868d49e7a157453d6130f4ca49965f255 (patch) | |
tree | 816b33dcb934a686f7b9794f721a05d95496696f /src | |
parent | 1d2d16a146413697e67b8d01ba035d680fabccaf (diff) | |
download | android_packages_apps_ContactsCommon-d2c67d9868d49e7a157453d6130f4ca49965f255.tar.gz android_packages_apps_ContactsCommon-d2c67d9868d49e7a157453d6130f4ca49965f255.tar.bz2 android_packages_apps_ContactsCommon-d2c67d9868d49e7a157453d6130f4ca49965f255.zip |
Add BlockContactActivity
Change-Id: Ice36988a3773dbc36b1d59cbb45cb607b07885de
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/contacts/common/activity/BlockContactActivity.java | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/com/android/contacts/common/activity/BlockContactActivity.java b/src/com/android/contacts/common/activity/BlockContactActivity.java new file mode 100644 index 00000000..4dff6180 --- /dev/null +++ b/src/com/android/contacts/common/activity/BlockContactActivity.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2016 The CyanogenMod 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. + */ + +package com.android.contacts.common.activity; + +import android.app.Activity; +import android.app.DialogFragment; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.WindowManager; + +import com.android.contacts.common.activity.fragment.BlockContactDialogFragment; +import com.android.contacts.common.util.BlockContactHelper; +import com.cyanogen.lookup.phonenumber.provider.LookupProviderImpl; + +/** + * Wrapper activity to display a block contact dialog + */ +public class BlockContactActivity extends Activity implements BlockContactDialogFragment.Callbacks { + public static final String EXTRA_PHONE_NUMBER = "extra_phone_number"; + + private BlockContactHelper mBlockContactHelper; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + String phoneNumber = getIntent().getStringExtra(EXTRA_PHONE_NUMBER); + if (TextUtils.isEmpty(phoneNumber)) { + finish(); + return; + } + + mBlockContactHelper = new BlockContactHelper(this, new LookupProviderImpl(this)); + mBlockContactHelper.setContactInfo(phoneNumber); + } + + @Override + protected void onResume() { + super.onResume(); + DialogFragment f = mBlockContactHelper.getBlockContactDialog( + mBlockContactHelper.isContactBlacklisted() ? + BlockContactHelper.BlockOperation.UNBLOCK : + BlockContactHelper.BlockOperation.BLOCK + ); + f.show(getFragmentManager(), "block_contact"); + } + + @Override + public void onBlockSelected(boolean notifyLookupProvider) { + mBlockContactHelper.blockContactAsync(notifyLookupProvider); + } + + @Override + public void onUnblockSelected(boolean notifyLookupProvider) { + mBlockContactHelper.unblockContactAsync(notifyLookupProvider); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mBlockContactHelper.destroy(); + } +} |