-
-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix visibility of notification preferences
- hide notification preferences based on android version
- Loading branch information
Showing
3 changed files
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
app/src/main/java/fr/neamar/kiss/preference/NotificationPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
package fr.neamar.kiss.preference; | ||
|
||
import android.content.Context; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
import android.preference.DialogPreference; | ||
import android.provider.Settings; | ||
import android.util.AttributeSet; | ||
|
||
public class NotificationPreference extends DialogPreference { | ||
private static final String ACTION_NOTIFICATION_LISTENER_SETTINGS = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"; | ||
|
||
public NotificationPreference(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
super.onClick(dialog, which); | ||
if (which == DialogInterface.BUTTON_POSITIVE) { | ||
getContext().startActivity(new Intent(ACTION_NOTIFICATION_LISTENER_SETTINGS)); | ||
protected void onDialogClosed(boolean positiveResult) { | ||
if (positiveResult && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { | ||
getContext().startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS)); | ||
} | ||
} | ||
} |