mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
872984b33c
commit
23fe035085
|
@ -540,7 +540,7 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
jexport.put("answers", janswers);
|
||||
jexport.put("settings", jsettings);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
jexport.put("channels", ((ApplicationEx) getApplication()).channelsToJSON());
|
||||
jexport.put("channels", ApplicationEx.channelsToJSON(context));
|
||||
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
DocumentFile file = DocumentFile.fromSingleUri(context, uri);
|
||||
|
@ -755,7 +755,7 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
if (jimport.has("channels")) {
|
||||
JSONArray jchannels = jimport.getJSONArray("channels");
|
||||
((ApplicationEx) getApplication()).channelsFromJSON(jchannels);
|
||||
ApplicationEx.channelsFromJSON(context, jchannels);
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
|
|
|
@ -127,10 +127,10 @@ public class ApplicationEx extends Application {
|
|||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public JSONArray channelsToJSON() throws JSONException {
|
||||
static JSONArray channelsToJSON(Context context) throws JSONException {
|
||||
JSONArray jchannels = new JSONArray();
|
||||
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
for (NotificationChannel channel : nm.getNotificationChannels())
|
||||
if (!DEFAULT_CHANNEL_NAMES.contains(channel.getId())) {
|
||||
JSONObject jchannel = new JSONObject();
|
||||
|
@ -163,8 +163,8 @@ public class ApplicationEx extends Application {
|
|||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public void channelsFromJSON(JSONArray jchannels) throws JSONException {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
static void channelsFromJSON(Context context, JSONArray jchannels) throws JSONException {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
for (int c = 0; c < jchannels.length(); c++) {
|
||||
JSONObject jchannel = (JSONObject) jchannels.get(c);
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class ApplicationEx extends Application {
|
|||
|
||||
if (jchannel.has("sound") && !jchannel.isNull("sound")) {
|
||||
Uri uri = Uri.parse(jchannel.getString("sound"));
|
||||
Ringtone ringtone = RingtoneManager.getRingtone(this, uri);
|
||||
Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
|
||||
if (ringtone != null)
|
||||
channel.setSound(uri, Notification.AUDIO_ATTRIBUTES_DEFAULT);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue