导航菜单

页面标题

页面副标题

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

正在查看: Delta Chat v1.58.3 应用的 ApplicationPreferencesActivity.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.content.SharedPreferences;
import android.os.Bundle;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import com.b44t.messenger.DcEvent;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.preferences.AdvancedPreferenceFragment;
import org.thoughtcrime.securesms.preferences.AppearancePreferenceFragment;
import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
import org.thoughtcrime.securesms.preferences.CorrectedPreferenceFragment;
import org.thoughtcrime.securesms.preferences.NotificationsPreferenceFragment;
import org.thoughtcrime.securesms.preferences.widgets.ProfilePreference;
import org.thoughtcrime.securesms.qr.BackupTransferActivity;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.Prefs;

public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
    private static final String PREFERENCE_CATEGORY_ADVANCED = "preference_category_advanced";
    private static final String PREFERENCE_CATEGORY_APPEARANCE = "preference_category_appearance";
    private static final String PREFERENCE_CATEGORY_CHATS = "preference_category_chats";
    private static final String PREFERENCE_CATEGORY_CONNECTIVITY = "preference_category_connectivity";
    private static final String PREFERENCE_CATEGORY_DONATE = "preference_category_donate";
    private static final String PREFERENCE_CATEGORY_HELP = "preference_category_help";
    private static final String PREFERENCE_CATEGORY_MULTIDEVICE = "preference_category_multidevice";
    private static final String PREFERENCE_CATEGORY_NOTIFICATIONS = "preference_category_notifications";
    private static final String PREFERENCE_CATEGORY_PROFILE = "preference_category_profile";
    public static final int REQUEST_CODE_SET_BACKGROUND = 11;

    @Override
    protected void onCreate(Bundle bundle, boolean z) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        if (bundle == null) {
            initFragment(android.R.id.content, new ApplicationPreferenceFragment());
        }
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i2 == -1 && i == 1001) {
            showBackupProvider();
        } else {
            getSupportFragmentManager().findFragmentById(android.R.id.content).onActivityResult(i, i2, intent);
        }
    }

    public boolean onSupportNavigateUp() {
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        if (supportFragmentManager.getBackStackEntryCount() > 0) {
            supportFragmentManager.popBackStack();
            return true;
        }
        Intent intent = new Intent((Context) this, (Class<?>) ConversationListActivity.class);
        intent.setFlags(67108864);
        startActivity(intent);
        finish();
        return true;
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
        if (str.equals(Prefs.THEME_PREF)) {
            DynamicTheme.setDefaultDayNightMode(this);
            recreate();
        }
    }

    public void showBackupProvider() {
        Intent intent = new Intent((Context) this, (Class<?>) BackupTransferActivity.class);
        intent.putExtra(BackupTransferActivity.TRANSFER_MODE, BackupTransferActivity.TransferMode.SENDER_SHOW_QR.getInt());
        startActivity(intent);
        overridePendingTransition(0, 0);
        finishAffinity();
    }

    public static class ApplicationPreferenceFragment extends CorrectedPreferenceFragment implements DcEventCenter.DcEventDelegate {
        @Override
        public boolean runOnMain() {
            return DcEventCenter.DcEventDelegate.CC.$default$runOnMain(this);
        }

        @Override
        public void onCreate(Bundle bundle) {
            super.onCreate(bundle);
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_PROFILE).setOnPreferenceClickListener(new ProfileClickListener());
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_NOTIFICATIONS).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_NOTIFICATIONS));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_CONNECTIVITY).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_CONNECTIVITY));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_APPEARANCE).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_APPEARANCE));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_CHATS).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_CHATS));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_MULTIDEVICE).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_MULTIDEVICE));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_ADVANCED).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_ADVANCED));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_DONATE).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_DONATE));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_HELP).setOnPreferenceClickListener(new CategoryClickListener(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_HELP));
            DcHelper.getEventCenter(getActivity()).addObserver(2100, this);
        }

        public void onCreatePreferences(Bundle bundle, String str) {
            addPreferencesFromResource(R.xml.preferences);
        }

        public void onResume() {
            super.onResume();
            getActivity().getSupportActionBar().setTitle(R.string.menu_settings);
            setCategorySummaries();
        }

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

        @Override
        public void handleEvent(DcEvent dcEvent) {
            if (dcEvent.getId() == 2100) {
                findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_CONNECTIVITY).setSummary(DcHelper.getConnectivitySummary(getActivity(), getString(R.string.connectivity_connected)));
            }
        }

        private void setCategorySummaries() {
            ((ProfilePreference) findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_PROFILE)).refresh();
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_NOTIFICATIONS).setSummary(NotificationsPreferenceFragment.getSummary(getActivity()));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_APPEARANCE).setSummary(AppearancePreferenceFragment.getSummary(getActivity()));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_CHATS).setSummary(ChatsPreferenceFragment.getSummary(getActivity()));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_CONNECTIVITY).setSummary(DcHelper.getConnectivitySummary(getActivity(), getString(R.string.connectivity_connected)));
            findPreference(ApplicationPreferencesActivity.PREFERENCE_CATEGORY_HELP).setSummary(AdvancedPreferenceFragment.getVersion(getActivity()));
        }

        class CategoryClickListener implements Preference.OnPreferenceClickListener {
            private final String category;

            CategoryClickListener(String str) {
                this.category = str;
            }

            public boolean onPreferenceClick(androidx.preference.Preference r7) {
                throw new UnsupportedOperationException("Method not decompiled: org.thoughtcrime.securesms.ApplicationPreferencesActivity.ApplicationPreferenceFragment.CategoryClickListener.onPreferenceClick(androidx.preference.Preference):boolean");
            }

            void m1162xe50e5c77(DialogInterface dialogInterface, int i) {
                ApplicationPreferenceFragment.this.getActivity().startActivity(Permissions.getApplicationSettingsIntent(ApplicationPreferenceFragment.this.getActivity()));
            }

            void m1163xb3f5fab8(DialogInterface dialogInterface, int i) {
                ApplicationPreferenceFragment.this.getActivity().showBackupProvider();
            }
        }

        private class ProfileClickListener implements Preference.OnPreferenceClickListener {
            private ProfileClickListener() {
            }

            public boolean onPreferenceClick(Preference preference) {
                ApplicationPreferenceFragment.this.getActivity().startActivity(new Intent(preference.getContext(), (Class<?>) CreateProfileActivity.class));
                return true;
            }
        }
    }

    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        Permissions.onRequestPermissionsResult((Activity) this, i, strArr, iArr);
    }
}