导航菜单

页面标题

页面副标题

Delta Chat v1.58.3 - ProfileActivity.java 源代码

正在查看: Delta Chat v1.58.3 应用的 ProfileActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package org.thoughtcrime.securesms;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.b44t.messenger.DcChat;
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.rpc.Rpc;
import com.b44t.messenger.rpc.RpcException;
import com.google.android.material.tabs.TabLayout;
import java.io.File;
import java.util.ArrayList;
import org.thoughtcrime.securesms.MuteDialog;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.RelayUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;

public class ProfileActivity extends PassphraseRequiredActionBarActivity implements DcEventCenter.DcEventDelegate {
    public static final String CHAT_ID_EXTRA = "chat_id";
    public static final String CONTACT_ID_EXTRA = "contact_id";
    public static final String FORCE_TAB_EXTRA = "force_tab";
    public static final String FROM_CHAT = "from_chat";
    private static final int REQUEST_CODE_PICK_RINGTONE = 1;
    public static final int TAB_AUDIO = 25;
    public static final int TAB_DOCS = 30;
    public static final int TAB_GALLERY = 20;
    public static final int TAB_LINKS = 40;
    public static final int TAB_MAP = 50;
    public static final int TAB_SETTINGS = 10;
    public static final int TAB_WEBXDC = 35;
    private int chatId;
    private boolean chatIsBroadcast;
    private boolean chatIsDeviceTalk;
    private boolean chatIsMailingList;
    private boolean chatIsMultiUser;
    private int contactId;
    private DcContext dcContext;
    private boolean fromChat;
    private Rpc rpc;
    private TabLayout tabLayout;
    private ConversationTitleView titleView;
    private Toolbar toolbar;
    private ViewPager viewPager;
    private final ArrayList<Integer> tabs = new ArrayList<>();
    boolean backPressed = false;

    @Override
    public boolean runOnMain() {
        return DcEventCenter.DcEventDelegate.CC.$default$runOnMain(this);
    }

    @Override
    protected void onPreCreate() {
        this.dynamicTheme = new DynamicNoActionBarTheme();
        super.onPreCreate();
        this.dcContext = DcHelper.getContext(this);
        this.rpc = DcHelper.getRpc(this);
    }

    @Override
    protected void onCreate(Bundle bundle, boolean z) {
        int indexOf;
        setContentView(R.layout.profile_activity);
        initializeResources();
        setSupportActionBar(this.toolbar);
        ActionBar supportActionBar = getSupportActionBar();
        if (supportActionBar != null) {
            if (isGlobalProfile()) {
                supportActionBar.setDisplayHomeAsUpEnabled(true);
                supportActionBar.setHomeActionContentDescription(getString(R.string.back));
            } else {
                supportActionBar.setDisplayHomeAsUpEnabled(false);
                supportActionBar.setCustomView(R.layout.conversation_title_view);
                supportActionBar.setDisplayShowCustomEnabled(true);
                supportActionBar.setDisplayShowTitleEnabled(false);
                Toolbar parent = supportActionBar.getCustomView().getParent();
                parent.setPadding(0, 0, 0, 0);
                parent.setContentInsetsAbsolute(0, 0);
                ConversationTitleView conversationTitleView = (ConversationTitleView) supportActionBar.getCustomView();
                this.titleView = conversationTitleView;
                conversationTitleView.setOnBackClickedListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ProfileActivity.this.m1268lambda$onCreate$0$orgthoughtcrimesecuresmsProfileActivity(view);
                    }
                });
                this.titleView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ProfileActivity.this.m1269lambda$onCreate$1$orgthoughtcrimesecuresmsProfileActivity(view);
                    }
                });
                if (isContactProfile() && !isSelfProfile() && !this.chatIsDeviceTalk) {
                    this.titleView.registerForContextMenu(this);
                }
            }
        }
        updateToolbar();
        this.tabLayout.setupWithViewPager(this.viewPager);
        this.viewPager.setAdapter(new ProfilePagerAdapter(getSupportFragmentManager()));
        int intExtra = getIntent().getIntExtra(FORCE_TAB_EXTRA, -1);
        if (intExtra != -1 && (indexOf = this.tabs.indexOf(Integer.valueOf(intExtra))) != -1) {
            this.viewPager.setCurrentItem(indexOf);
        }
        DcEventCenter eventCenter = DcHelper.getEventCenter(this);
        eventCenter.addObserver(2020, this);
        eventCenter.addObserver(2030, this);
    }

    void m1268lambda$onCreate$0$orgthoughtcrimesecuresmsProfileActivity(View view) {
        onBackPressed();
    }

    void m1269lambda$onCreate$1$orgthoughtcrimesecuresmsProfileActivity(View view) {
        onEnlargeAvatar();
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        boolean z;
        if (!isSelfProfile() && !isGlobalProfile()) {
            getMenuInflater().inflate(R.menu.profile_common, menu);
            if (this.chatId != 0) {
                menu.findItem(R.id.menu_clone).setVisible(this.chatIsMultiUser && !this.chatIsMailingList);
                if (this.chatIsDeviceTalk) {
                    menu.findItem(R.id.edit_name).setVisible(false);
                    menu.findItem(R.id.show_encr_info).setVisible(false);
                    menu.findItem(R.id.share).setVisible(false);
                } else if (this.chatIsMultiUser) {
                    if (this.chatIsBroadcast) {
                        z = false;
                    } else {
                        DcChat chat = this.dcContext.getChat(this.chatId);
                        if (!this.chatIsMailingList && !chat.canSend()) {
                            menu.findItem(R.id.edit_name).setVisible(false);
                        }
                        z = true;
                    }
                    menu.findItem(R.id.share).setVisible(false);
                }
                z = true;
            } else {
                menu.findItem(R.id.menu_clone).setVisible(false);
                z = false;
            }
            if (!z) {
                menu.findItem(R.id.menu_mute_notifications).setVisible(false);
                menu.findItem(R.id.menu_sound).setVisible(false);
                menu.findItem(R.id.menu_vibrate).setVisible(false);
            }
            if (isContactProfile()) {
                menu.findItem(R.id.edit_name).setTitle(R.string.menu_edit_name);
            }
            if (!isContactProfile() || this.chatIsDeviceTalk) {
                menu.findItem(R.id.block_contact).setVisible(false);
            }
        }
        super.onCreateOptionsMenu(menu);
        return true;
    }

    public boolean onPrepareOptionsMenu(Menu menu) {
        MenuItem findItem = menu.findItem(R.id.block_contact);
        if (findItem != null) {
            findItem.setTitle(this.dcContext.getContact(this.contactId).isBlocked() ? R.string.menu_unblock_contact : R.string.menu_block_contact);
            Util.redMenuItem(menu, R.id.block_contact);
        }
        MenuItem findItem2 = menu.findItem(R.id.menu_mute_notifications);
        if (findItem2 != null) {
            findItem2.setTitle(this.dcContext.getChat(this.chatId).isMuted() ? R.string.menu_unmute : R.string.menu_mute);
        }
        super.onPrepareOptionsMenu(menu);
        return true;
    }

    public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
        super.onCreateContextMenu(contextMenu, view, contextMenuInfo);
        getMenuInflater().inflate(R.menu.profile_title_context, contextMenu);
    }

    public void onBackPressed() {
        this.backPressed = true;
        super.onBackPressed();
    }

    protected void onPause() {
        super.onPause();
        if (this.backPressed && this.fromChat) {
            overridePendingTransition(0, 0);
        }
    }

    public void onDestroy() {
        DcHelper.getEventCenter(this).removeObservers(this);
        super.onDestroy();
    }

    @Override
    public void handleEvent(DcEvent dcEvent) {
        updateToolbar();
    }

    private void initializeResources() {
        this.chatId = getIntent().getIntExtra("chat_id", 0);
        this.contactId = getIntent().getIntExtra("contact_id", 0);
        this.chatIsMultiUser = false;
        this.chatIsDeviceTalk = false;
        this.chatIsMailingList = false;
        this.chatIsBroadcast = false;
        this.fromChat = getIntent().getBooleanExtra(FROM_CHAT, false);
        int i = this.contactId;
        if (i != 0) {
            this.chatId = this.dcContext.getChatIdByContactId(i);
        } else {
            int i2 = this.chatId;
            if (i2 != 0) {
                DcChat chat = this.dcContext.getChat(i2);
                this.chatIsMultiUser = chat.isMultiUser();
                this.chatIsDeviceTalk = chat.isDeviceTalk();
                this.chatIsMailingList = chat.isMailingList();
                this.chatIsBroadcast = chat.isBroadcast();
                if (!this.chatIsMultiUser) {
                    int[] chatContacts = this.dcContext.getChatContacts(this.chatId);
                    this.contactId = chatContacts.length >= 1 ? chatContacts[0] : 0;
                }
            }
        }
        if (!isGlobalProfile() && !isSelfProfile() && !this.chatIsMailingList) {
            this.tabs.add(10);
        }
        this.tabs.add(20);
        this.tabs.add(25);
        this.tabs.add(30);
        this.tabs.add(35);
        this.viewPager = ViewUtil.findById((Activity) this, R.id.pager);
        this.toolbar = ViewUtil.findById((Activity) this, R.id.toolbar);
        this.tabLayout = ViewUtil.findById((Activity) this, R.id.tab_layout);
    }

    private void updateToolbar() {
        if (isGlobalProfile()) {
            getSupportActionBar().setTitle(R.string.menu_all_media);
            return;
        }
        int i = this.chatId;
        if (i > 0) {
            this.titleView.setTitle(GlideApp.with((FragmentActivity) this), this.dcContext.getChat(i), true);
        } else if (isContactProfile()) {
            this.titleView.setTitle(GlideApp.with((FragmentActivity) this), this.dcContext.getContact(this.contactId));
        }
    }

    public boolean isGlobalProfile() {
        return this.contactId == 0 && this.chatId == 0;
    }

    public boolean isContactProfile() {
        return this.contactId != 0 && (this.chatId == 0 || !this.chatIsMultiUser);
    }

    private boolean isSelfProfile() {
        return isContactProfile() && this.contactId == 1;
    }

    private class ProfilePagerAdapter extends FragmentStatePagerAdapter {
        private Object currentFragment;

        ProfilePagerAdapter(FragmentManager fragmentManager) {
            super(fragmentManager);
            this.currentFragment = null;
        }

        public void setPrimaryItem(ViewGroup viewGroup, int i, Object obj) {
            ActionMode actionMode;
            super.setPrimaryItem(viewGroup, i, obj);
            Object obj2 = this.currentFragment;
            if (obj2 != null && obj2 != obj) {
                if (obj2 instanceof MessageSelectorFragment) {
                    actionMode = ((MessageSelectorFragment) obj2).getActionMode();
                } else {
                    actionMode = obj2 instanceof ProfileSettingsFragment ? ((ProfileSettingsFragment) obj2).getActionMode() : null;
                }
                if (actionMode != null) {
                    actionMode.finish();
                }
            }
            this.currentFragment = obj;
        }

        public Fragment getItem(int i) {
            Fragment profileSettingsFragment;
            int intValue = ((Integer) ProfileActivity.this.tabs.get(i)).intValue();
            Bundle bundle = new Bundle();
            if (intValue == 10) {
                profileSettingsFragment = new ProfileSettingsFragment();
                bundle.putInt("chat_id", (ProfileActivity.this.chatId != 0 || ProfileActivity.this.isGlobalProfile()) ? ProfileActivity.this.chatId : -1);
                bundle.putInt("contact_id", (ProfileActivity.this.contactId != 0 || ProfileActivity.this.isGlobalProfile()) ? ProfileActivity.this.contactId : -1);
            } else if (intValue == 20) {
                profileSettingsFragment = new ProfileGalleryFragment();
                bundle.putInt("chat_id", (ProfileActivity.this.chatId != 0 || ProfileActivity.this.isGlobalProfile()) ? ProfileActivity.this.chatId : -1);
            } else if (intValue == 25) {
                profileSettingsFragment = new ProfileDocumentsFragment();
                bundle.putInt("chat_id", (ProfileActivity.this.chatId != 0 || ProfileActivity.this.isGlobalProfile()) ? ProfileActivity.this.chatId : -1);
                bundle.putBoolean(ProfileDocumentsFragment.SHOW_AUDIO_EXTRA, true);
            } else if (intValue == 35) {
                profileSettingsFragment = new ProfileDocumentsFragment();
                bundle.putInt("chat_id", (ProfileActivity.this.chatId != 0 || ProfileActivity.this.isGlobalProfile()) ? ProfileActivity.this.chatId : -1);
                bundle.putBoolean(ProfileDocumentsFragment.SHOW_WEBXDC_EXTRA, true);
            } else {
                profileSettingsFragment = new ProfileDocumentsFragment();
                bundle.putInt("chat_id", (ProfileActivity.this.chatId != 0 || ProfileActivity.this.isGlobalProfile()) ? ProfileActivity.this.chatId : -1);
            }
            profileSettingsFragment.setArguments(bundle);
            return profileSettingsFragment;
        }

        public int getCount() {
            return ProfileActivity.this.tabs.size();
        }

        public CharSequence getPageTitle(int i) {
            int intValue = ((Integer) ProfileActivity.this.tabs.get(i)).intValue();
            if (intValue == 10) {
                if (!ProfileActivity.this.chatIsDeviceTalk) {
                    if (ProfileActivity.this.isContactProfile()) {
                        if (ProfileActivity.this.dcContext.getContact(ProfileActivity.this.contactId).isBot()) {
                            return ProfileActivity.this.getString(R.string.bot);
                        }
                        return ProfileActivity.this.getString(R.string.tab_contact);
                    }
                    if (!ProfileActivity.this.chatIsBroadcast) {
                        if (ProfileActivity.this.chatIsMailingList) {
                            return ProfileActivity.this.getString(R.string.mailing_list);
                        }
                        return ProfileActivity.this.getString(R.string.tab_group);
                    }
                    return ProfileActivity.this.getString(R.string.broadcast_list);
                }
                return ProfileActivity.this.getString(R.string.profile);
            }
            if (intValue == 20) {
                return ProfileActivity.this.getString(R.string.tab_gallery);
            }
            if (intValue == 25) {
                return ProfileActivity.this.getString(R.string.audio);
            }
            if (intValue == 30) {
                return ProfileActivity.this.getString(R.string.files);
            }
            if (intValue == 35) {
                return ProfileActivity.this.getString(R.string.webxdc_apps);
            }
            if (intValue == 40) {
                return ProfileActivity.this.getString(R.string.tab_links);
            }
            if (intValue == 50) {
                return ProfileActivity.this.getString(R.string.tab_map);
            }
            throw new AssertionError();
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        super.onOptionsItemSelected(menuItem);
        int itemId = menuItem.getItemId();
        if (itemId == 16908332) {
            this.backPressed = true;
            finish();
            return true;
        }
        if (itemId == R.id.menu_mute_notifications) {
            onNotifyOnOff();
            return false;
        }
        if (itemId == R.id.menu_sound) {
            onSoundSettings();
            return false;
        }
        if (itemId == R.id.menu_vibrate) {
            onVibrateSettings();
            return false;
        }
        if (itemId == R.id.edit_name) {
            onEditName();
            return false;
        }
        if (itemId == R.id.share) {
            onShare();
            return false;
        }
        if (itemId == R.id.show_encr_info) {
            onEncrInfo();
            return false;
        }
        if (itemId == R.id.block_contact) {
            onBlockContact();
            return false;
        }
        if (itemId != R.id.menu_clone) {
            return false;
        }
        onClone();
        return false;
    }

    public boolean onContextItemSelected(MenuItem menuItem) {
        super.onContextItemSelected(menuItem);
        if (menuItem.getItemId() != R.id.copy_addr_to_clipboard) {
            return false;
        }
        onCopyAddrToClipboard();
        return false;
    }

    private void onNotifyOnOff() {
        if (this.dcContext.getChat(this.chatId).isMuted()) {
            setMuted(0L);
        } else {
            MuteDialog.show(this, new MuteDialog.MuteSelectionListener() {
                @Override
                public final void onMuted(long j) {
                    ProfileActivity.this.setMuted(j);
                }
            });
        }
    }

    public void setMuted(long j) {
        int i = this.chatId;
        if (i != 0) {
            this.dcContext.setChatMuteDuration(i, j);
        }
    }

    private void onSoundSettings() {
        Uri chatRingtone = Prefs.getChatRingtone(this, this.dcContext.getAccountId(), this.chatId);
        Uri notificationRingtone = Prefs.getNotificationRingtone(this);
        if (chatRingtone == null) {
            chatRingtone = Settings.System.DEFAULT_NOTIFICATION_URI;
        } else if (chatRingtone.toString().isEmpty()) {
            chatRingtone = null;
        }
        Intent intent = new Intent("android.intent.action.RINGTONE_PICKER");
        intent.putExtra("android.intent.extra.ringtone.SHOW_SILENT", true);
        intent.putExtra("android.intent.extra.ringtone.SHOW_DEFAULT", true);
        intent.putExtra("android.intent.extra.ringtone.DEFAULT_URI", notificationRingtone);
        intent.putExtra("android.intent.extra.ringtone.TYPE", 2);
        intent.putExtra("android.intent.extra.ringtone.EXISTING_URI", chatRingtone);
        startActivityForResult(intent, 1);
    }

    private void onVibrateSettings() {
        int id = Prefs.getChatVibrate(this, this.dcContext.getAccountId(), this.chatId).getId();
        final int[] iArr = {id};
        new AlertDialog.Builder(this).setTitle(R.string.pref_vibrate).setSingleChoiceItems(R.array.recipient_vibrate_entries, id, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ProfileActivity.lambda$onVibrateSettings$2(iArr, dialogInterface, i);
            }
        }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ProfileActivity.this.m1271x8c8932e1(iArr, dialogInterface, i);
            }
        }).setNegativeButton(R.string.cancel, (DialogInterface.OnClickListener) null).show();
    }

    static void lambda$onVibrateSettings$2(int[] iArr, DialogInterface dialogInterface, int i) {
        iArr[0] = i;
    }

    void m1271x8c8932e1(int[] iArr, DialogInterface dialogInterface, int i) {
        Prefs.setChatVibrate(this, this.dcContext.getAccountId(), this.chatId, Prefs.VibrateState.fromId(iArr[0]));
    }

    private void onEnlargeAvatar() {
        String profileImage;
        String displayName;
        int i = this.chatId;
        if (i != 0) {
            DcChat chat = this.dcContext.getChat(i);
            profileImage = chat.getProfileImage();
            displayName = chat.getName();
        } else {
            DcContact contact = this.dcContext.getContact(this.contactId);
            profileImage = contact.getProfileImage();
            displayName = contact.getDisplayName();
        }
        File file = new File(profileImage);
        if (file.exists()) {
            Uri fromFile = Uri.fromFile(file);
            String str = "image/" + profileImage.substring(profileImage.lastIndexOf(".") + 1);
            Intent intent = new Intent((Context) this, (Class<?>) MediaPreviewActivity.class);
            intent.setDataAndType(fromFile, str);
            intent.putExtra(MediaPreviewActivity.ACTIVITY_TITLE_EXTRA, displayName);
            intent.putExtra(MediaPreviewActivity.EDIT_AVATAR_CHAT_ID, this.chatIsMultiUser ? this.chatId : 0);
            startActivity(intent);
            return;
        }
        onEditName();
    }

    private void onEditName() {
        if (this.chatIsMultiUser) {
            DcChat chat = this.dcContext.getChat(this.chatId);
            if (this.chatIsMailingList || chat.canSend()) {
                Intent intent = new Intent((Context) this, (Class<?>) GroupCreateActivity.class);
                intent.putExtra(GroupCreateActivity.EDIT_GROUP_CHAT_ID, this.chatId);
                startActivity(intent);
                return;
            }
            return;
        }
        final int accountId = this.dcContext.getAccountId();
        DcContact contact = this.dcContext.getContact(this.contactId);
        String authName = contact.getAuthName();
        if (TextUtils.isEmpty(authName)) {
            authName = contact.getAddr();
        }
        View inflate = View.inflate(this, R.layout.single_line_input, null);
        final EditText editText = (EditText) inflate.findViewById(R.id.input_field);
        editText.setText(contact.getName());
        editText.setSelection(editText.getText().length());
        editText.setHint(getString(R.string.edit_name_placeholder, new Object[]{authName}));
        new AlertDialog.Builder(this).setTitle(R.string.menu_edit_name).setMessage(getString(R.string.edit_name_explain, new Object[]{authName})).setView(inflate).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ProfileActivity.this.m1270lambda$onEditName$4$orgthoughtcrimesecuresmsProfileActivity(editText, accountId, dialogInterface, i);
            }
        }).setNegativeButton(android.R.string.cancel, (DialogInterface.OnClickListener) null).setCancelable(false).show();
    }

    void m1270lambda$onEditName$4$orgthoughtcrimesecuresmsProfileActivity(EditText editText, int i, DialogInterface dialogInterface, int i2) {
        try {
            this.rpc.changeContactName(i, this.contactId, editText.getText().toString());
        } catch (RpcException e) {
            e.printStackTrace();
        }
    }

    private void onShare() {
        Intent intent = new Intent();
        RelayUtil.setSharedContactId(intent, this.contactId);
        ConversationListRelayingActivity.start((Activity) this, intent);
    }

    private void onCopyAddrToClipboard() {
        Util.writeTextToClipboard(this, this.dcContext.getContact(this.contactId).getAddr());
        Toast.makeText((Context) this, (CharSequence) getString(R.string.copied_to_clipboard), 0).show();
    }

    private void onEncrInfo() {
        new AlertDialog.Builder(this).setMessage(isContactProfile() ? this.dcContext.getContactEncrInfo(this.contactId) : this.dcContext.getChatEncrInfo(this.chatId)).setPositiveButton(android.R.string.ok, (DialogInterface.OnClickListener) null).show();
    }

    private void onBlockContact() {
        if (this.dcContext.getContact(this.contactId).isBlocked()) {
            new AlertDialog.Builder(this).setMessage(R.string.ask_unblock_contact).setCancelable(true).setNegativeButton(android.R.string.cancel, (DialogInterface.OnClickListener) null).setPositiveButton(R.string.menu_unblock_contact, new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ProfileActivity.this.m1266xa7c0bca6(dialogInterface, i);
                }
            }).show();
        } else {
            Util.redPositiveButton(new AlertDialog.Builder(this).setMessage(R.string.ask_block_contact).setCancelable(true).setNegativeButton(android.R.string.cancel, (DialogInterface.OnClickListener) null).setPositiveButton(R.string.menu_block_contact, new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ProfileActivity.this.m1267x6aad2605(dialogInterface, i);
                }
            }).show());
        }
    }

    void m1266xa7c0bca6(DialogInterface dialogInterface, int i) {
        this.dcContext.blockContact(this.contactId, 0);
    }

    void m1267x6aad2605(DialogInterface dialogInterface, int i) {
        this.dcContext.blockContact(this.contactId, 1);
    }

    private void onClone() {
        Intent intent = new Intent((Context) this, (Class<?>) GroupCreateActivity.class);
        intent.putExtra(GroupCreateActivity.CLONE_CHAT_EXTRA, this.chatId);
        startActivity(intent);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 1 && i2 == -1 && intent != null) {
            Uri uri = (Uri) intent.getParcelableExtra("android.intent.extra.ringtone.PICKED_URI");
            if (Prefs.getNotificationRingtone(this).equals(uri)) {
                uri = null;
            } else if (uri == null) {
                uri = Uri.EMPTY;
            }
            Prefs.setChatRingtone(this, this.dcContext.getAccountId(), this.chatId, uri);
        }
    }
}