Search in sources :

Example 1 with TrustedNetworkHelper

use of org.kde.kdeconnect.Helpers.TrustedNetworkHelper in project kdeconnect-android by KDE.

the class TrustedNetworksActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    ThemeUtil.setUserPreferredTheme(this);
    super.onCreate(savedInstanceState);
    binding = TrustedNetworkListBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    trustedNetworksView = binding.list;
    setSupportActionBar(binding.toolbarLayout.toolbar);
    Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    trustedNetworkHelper = new TrustedNetworkHelper(getApplicationContext());
    trustedNetworks = new ArrayList<>();
    Collections.addAll(trustedNetworks, trustedNetworkHelper.read());
    allowAllCheckBox = binding.trustAllNetworksCheckBox;
    allowAllCheckBox.setOnCheckedChangeListener((v, isChecked) -> {
        if (trustedNetworkHelper.hasPermissions()) {
            trustedNetworkHelper.allAllowed(isChecked);
            updateTrustedNetworkListView();
            addNetworkButton();
        } else {
            // Disable unchecking it
            allowAllCheckBox.setChecked(true);
            new PermissionsAlertDialogFragment.Builder().setTitle(R.string.location_permission_needed_title).setMessage(R.string.location_permission_needed_desc).setPositiveButton(R.string.ok).setNegativeButton(R.string.cancel).setPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION }).setRequestCode(0).create().show(getSupportFragmentManager(), null);
        }
    });
    allowAllCheckBox.setChecked(trustedNetworkHelper.allAllowed());
    updateTrustedNetworkListView();
}
Also used : TrustedNetworkHelper(org.kde.kdeconnect.Helpers.TrustedNetworkHelper)

Aggregations

TrustedNetworkHelper (org.kde.kdeconnect.Helpers.TrustedNetworkHelper)1