From 6fb2050aaf6e992bf96d41c5f6b19f5c1a3771c3 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 25 Nov 2021 01:54:18 +0100 Subject: implement separate settings fragment --- .../base/fragments/ExcludeAppsFragment.java | 32 +++++++++------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/base/fragments/ExcludeAppsFragment.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/ExcludeAppsFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/ExcludeAppsFragment.java index 04745d42..f5d7f286 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/ExcludeAppsFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/ExcludeAppsFragment.java @@ -20,13 +20,15 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; -import android.widget.CompoundButton; import android.widget.Filter; import android.widget.Filterable; import android.widget.ImageView; import android.widget.ListView; import android.widget.SearchView; +import androidx.annotation.StringRes; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.AppCompatTextView; import androidx.fragment.app.Fragment; @@ -41,6 +43,8 @@ import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.utils.PreferenceHelper; import se.leap.bitmaskclient.base.views.SimpleCheckBox; +import static se.leap.bitmaskclient.R.string.exclude_apps_fragment_title; + /** * Created by arne on 16.11.14. */ @@ -51,20 +55,6 @@ public class ExcludeAppsFragment extends Fragment implements AdapterView.OnItemC private Set apps; - public interface ExcludedAppsCallback { - void onAppsExcluded(int number); - } - - private ExcludedAppsCallback callback; - - @Override - public void onAttach(Context context) { - super.onAttach(context); - if (context instanceof ExcludedAppsCallback) { - callback = (ExcludedAppsCallback) context; - } - } - @Override public void onItemClick(AdapterView parent, View view, int position, long id) { AppViewHolder avh = (AppViewHolder) view.getTag(); @@ -120,10 +110,6 @@ public class ExcludeAppsFragment extends Fragment implements AdapterView.OnItemC Log.d("openvpn", "removing from allowed apps" + packageName); apps.remove(packageName); } - - if (callback != null) { - callback.onAppsExcluded(apps.size()); - } } class PackageAdapter extends BaseAdapter implements Filterable { @@ -328,10 +314,18 @@ public class ExcludeAppsFragment extends Fragment implements AdapterView.OnItemC mListView.setOnItemClickListener(this); mListView.setEmptyView(v.findViewById(R.id.loading_container)); + setActionBarTitle(exclude_apps_fragment_title); new Thread(() -> mListAdapter.populateList(getActivity())).start(); return v; } + private void setActionBarTitle(@StringRes int stringId) { + ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); + if (actionBar != null) { + actionBar.setSubtitle(stringId); + } + } + } -- cgit v1.2.3