Exclude non-functional notification settings screen from settings search for android versions 26+ (#5011)
This commit is contained in:
parent
9d2467a4e2
commit
0d1241be66
|
@ -1,10 +1,14 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -105,8 +109,17 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe
|
|||
|
||||
public PreferenceFragmentCompat openScreen(int screen) {
|
||||
PreferenceFragmentCompat fragment = getPreferenceScreen(screen);
|
||||
if (screen == R.xml.preferences_notifications && Build.VERSION.SDK_INT >= 26) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName());
|
||||
startActivity(intent);
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.content, fragment)
|
||||
.addToBackStack(getString(getTitleOfPage(screen))).commit();
|
||||
}
|
||||
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
@ -138,6 +151,8 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe
|
|||
builder.setMessage(R.string.pref_feed_settings_dialog_msg);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.show();
|
||||
} else if (screen == R.xml.preferences_notifications) {
|
||||
openScreen(screen);
|
||||
} else {
|
||||
PreferenceFragmentCompat fragment = openScreen(result.getResourceFile());
|
||||
result.highlight(fragment);
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package de.danoeh.antennapod.fragment.preferences;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.bytehamster.lib.preferencesearch.SearchConfiguration;
|
||||
import com.bytehamster.lib.preferencesearch.SearchPreference;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.BugReportActivity;
|
||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||
|
@ -81,14 +82,7 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat {
|
|||
return true;
|
||||
});
|
||||
findPreference(PREF_NOTIFICATION).setOnPreferenceClickListener(preference -> {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getActivity().getPackageName());
|
||||
startActivity(intent);
|
||||
} else {
|
||||
((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_notifications);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
findPreference(PREF_ABOUT).setOnPreferenceClickListener(
|
||||
|
|
Loading…
Reference in New Issue