X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FDomainsListFragment.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FDomainsListFragment.java;h=0000000000000000000000000000000000000000;hp=92d4b885eaa2d123883cca94058e612f616cb4cb;hb=a156c3942ca31a1afca3271245cc2bda7ed5aed8;hpb=9f1863318116a641a455a05d722a2ff7938a13c4 diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainsListFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainsListFragment.java deleted file mode 100644 index 92d4b885..00000000 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainsListFragment.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright © 2017-2020,2022 Soren Stoutner . - * - * This file is part of Privacy Browser Android . - * - * Privacy Browser Android is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Privacy Browser Android is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser Android. If not, see . - */ - -package com.stoutner.privacybrowser.fragments; - -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ListView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; - -import com.stoutner.privacybrowser.R; -import com.stoutner.privacybrowser.activities.DomainsActivity; - -public class DomainsListFragment extends Fragment { - // Instantiate the dismiss snackbar interface. - private DismissSnackbarInterface dismissSnackbarInterface; - - // Define the public dismiss snackbar interface. - public interface DismissSnackbarInterface { - void dismissSnackbar(); - } - - public void onAttach(@NonNull Context context) { - // Run the default commands. - super.onAttach(context); - - // Populate the dismiss snackbar interface. - dismissSnackbarInterface = (DismissSnackbarInterface) context; - } - - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Inflate `domains_list_fragment`. `false` does not attach it to the root `container`. - View domainsListFragmentView = inflater.inflate(R.layout.domains_list_fragment, container, false); - - // Get a handle for the domains listview. - ListView domainsListView = domainsListFragmentView.findViewById(R.id.domains_listview); - - // Remove the incorrect lint error below that `.getSupportFragmentManager()` might be null. - assert getActivity() != null; - - // Get a handle for the support fragment manager. - final FragmentManager supportFragmentManager = getActivity().getSupportFragmentManager(); - - domainsListView.setOnItemClickListener((AdapterView parent, View view, int position, long id) -> { - // Dismiss the snackbar if it is visible. - dismissSnackbarInterface.dismissSnackbar(); - - // Save the current domain settings if operating in two-paned mode and a domain is currently selected. - if (DomainsActivity.twoPanedMode && DomainsActivity.deleteMenuItem.isEnabled()) { - // Get a handle for the domain settings fragment. - Fragment domainSettingsFragment = supportFragmentManager.findFragmentById(R.id.domain_settings_fragment_container); - - // Remove the incorrect lint warning below that the domain settings fragment might be null. - assert domainSettingsFragment != null; - - // Get a handle for the domain settings fragment view. - View domainSettingsFragmentView = domainSettingsFragment.getView(); - - // Remove the incorrect lint warning below that the domain settings fragment view might be null. - assert domainSettingsFragmentView != null; - - // Get a handle for the domains activity. - DomainsActivity domainsActivity = new DomainsActivity(); - - // Save the domain settings. - domainsActivity.saveDomainSettings(domainSettingsFragmentView, getResources()); - } - - // Store the new `currentDomainDatabaseId`, converting it from `long` to `int` to match the format of the domains database. - DomainsActivity.currentDomainDatabaseId = (int) id; - - // Add `currentDomainDatabaseId` to `argumentsBundle`. - Bundle argumentsBundle = new Bundle(); - argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, DomainsActivity.currentDomainDatabaseId); - - // Add the arguments bundle to the domain settings fragment. - DomainSettingsFragment domainSettingsFragment = new DomainSettingsFragment(); - domainSettingsFragment.setArguments(argumentsBundle); - - // Check to see if the device is in two paned mode. - if (DomainsActivity.twoPanedMode) { // The device in in two-paned mode. - // enable `deleteMenuItem` if the system is not waiting for a `Snackbar` to be dismissed. - if (!DomainsActivity.dismissingSnackbar) { - // Enable the delete menu item. - DomainsActivity.deleteMenuItem.setEnabled(true); - - // Set the delete icon. - DomainsActivity.deleteMenuItem.setIcon(R.drawable.delete_enabled); - } - - // Display the domain settings fragment. - supportFragmentManager.beginTransaction().replace(R.id.domain_settings_fragment_container, domainSettingsFragment).commit(); - } else { // The device in in single-paned mode - // Save the domains listview position. - DomainsActivity.domainsListViewPosition = domainsListView.getFirstVisiblePosition(); - - // Show `deleteMenuItem` if the system is not waiting for a `Snackbar` to be dismissed. - if (!DomainsActivity.dismissingSnackbar) { - DomainsActivity.deleteMenuItem.setVisible(true); - } - - // Hide the add domain FAB. - FloatingActionButton addDomainFAB = getActivity().findViewById(R.id.add_domain_fab); - addDomainFAB.hide(); - - // Display the domain settings fragment. - supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit(); - } - }); - - // Return the domains list fragment. - return domainsListFragmentView; - } -} \ No newline at end of file