diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java index a766ee074..383390506 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.settings; -import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -51,16 +50,11 @@ public class SelectKioskFragment extends DialogFragment { private SelectKioskAdapter selectKioskAdapter = null; private OnSelectedListener onSelectedListener = null; - private OnCancelListener onCancelListener = null; public void setOnSelectedListener(final OnSelectedListener listener) { onSelectedListener = listener; } - public void setOnCancelListener(final OnCancelListener listener) { - onCancelListener = listener; - } - /*////////////////////////////////////////////////////////////////////////// // Init //////////////////////////////////////////////////////////////////////////*/ @@ -91,14 +85,6 @@ public class SelectKioskFragment extends DialogFragment { // Handle actions //////////////////////////////////////////////////////////////////////////*/ - @Override - public void onCancel(@NonNull final DialogInterface dialogInterface) { - super.onCancel(dialogInterface); - if (onCancelListener != null) { - onCancelListener.onCancel(); - } - } - private void clickedItem(final SelectKioskAdapter.Entry entry) { if (onSelectedListener != null) { onSelectedListener.onKioskSelected(entry.serviceId, entry.kioskId, entry.kioskName); @@ -114,10 +100,6 @@ public class SelectKioskFragment extends DialogFragment { void onKioskSelected(int serviceId, String kioskId, String kioskName); } - public interface OnCancelListener { - void onCancel(); - } - private class SelectKioskAdapter extends RecyclerView.Adapter { private final List kioskList = new Vector<>(); diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java index 95f7f50ba..490e299bd 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java @@ -44,8 +44,6 @@ import java.util.List; import static org.schabi.newpipe.settings.tabs.Tab.typeFrom; public class ChooseTabsFragment extends Fragment { - private static final int MENU_ITEM_RESTORE_ID = 123456; - private TabsManager tabsManager; private final List tabList = new ArrayList<>(); @@ -110,21 +108,14 @@ public class ChooseTabsFragment extends Fragment { @NonNull final MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - final MenuItem restoreItem = menu.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE, - R.string.restore_defaults); + final MenuItem restoreItem = menu.add(R.string.restore_defaults); restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(), R.drawable.ic_settings_backup_restore)); - } - - @Override - public boolean onOptionsItemSelected(final MenuItem item) { - if (item.getItemId() == MENU_ITEM_RESTORE_ID) { + restoreItem.setOnMenuItemClickListener(ev -> { restoreDefaults(); return true; - } - - return super.onOptionsItemSelected(item); + }); } /*////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/res/layout/settings_layout.xml b/app/src/main/res/layout/settings_layout.xml index 33237d7b0..1b7b8b5e2 100644 --- a/app/src/main/res/layout/settings_layout.xml +++ b/app/src/main/res/layout/settings_layout.xml @@ -6,14 +6,14 @@ android:orientation="vertical" tools:context="org.schabi.newpipe.MainActivity"> + + - - diff --git a/app/src/main/res/xml/update_settings.xml b/app/src/main/res/xml/update_settings.xml index ef121ec4e..a44555edf 100644 --- a/app/src/main/res/xml/update_settings.xml +++ b/app/src/main/res/xml/update_settings.xml @@ -1,7 +1,6 @@