-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c2920a
commit acd2481
Showing
21 changed files
with
632 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
7 changes: 7 additions & 0 deletions
7
...src/main/java/com/scrappers/superiorExtendedEngine/menuStates/uiPager/ActionInjector.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.scrappers.superiorExtendedEngine.menuStates.uiPager; | ||
|
||
import android.view.View; | ||
|
||
public interface ActionInjector { | ||
void execute(View uiState, int position); | ||
} |
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
104 changes: 104 additions & 0 deletions
104
...ava/com/scrappers/superiorExtendedEngine/tasksUtil/backgroundTask/BackgroundNotifier.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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.scrappers.superiorExtendedEngine.tasksUtil.backgroundTask; | ||
|
||
import android.app.Notification; | ||
import android.app.NotificationChannel; | ||
import android.app.NotificationManager; | ||
import android.content.Context; | ||
import android.os.Build; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.RemoteViews; | ||
|
||
import androidx.annotation.LayoutRes; | ||
import androidx.annotation.Nullable; | ||
import androidx.core.app.NotificationCompat; | ||
|
||
/** | ||
* <b>Code design</b> | ||
* <ol> | ||
*<li> <s> BackgroundNotifier does have a builder class to build notification UI & handle the click listeners inside it </s></li> | ||
*<li> BackgroundNotifier register a notifier to the system with some delay inputs, some data constraints(Binders), System flags</li> | ||
*<li> Another class for Nominations stacks </li> | ||
* </ol> | ||
* @author pavl_g | ||
*/ | ||
public class BackgroundNotifier { | ||
|
||
/** | ||
* A subclass that would inflate notifications with UI-Layouts | ||
*/ | ||
public static class NotificationInflater{ | ||
private final Context context; | ||
public NotificationInflater(final Context context){ | ||
this.context = context; | ||
} | ||
public View inflateNotification(@LayoutRes int resId){ | ||
return LayoutInflater.from(context).inflate(resId, null); | ||
} | ||
} | ||
|
||
public static class Builder{ | ||
private final Context context; | ||
public Builder(final Context context){ | ||
this.context = context; | ||
} | ||
|
||
/** | ||
* Build a notiification using custom design | ||
* @param inflatedView | ||
* @param constraints | ||
* @param systemFlags | ||
* @return | ||
*/ | ||
public NotificationCompat.Builder buildNotification(@Nullable View inflatedView){ | ||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | ||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ){ | ||
NotificationChannel channel = new NotificationChannel(String.valueOf(inflatedView.getId()), String.valueOf(inflatedView.getId()), NotificationManager.IMPORTANCE_HIGH); | ||
channel.enableLights(true); | ||
channel.enableVibration(true); | ||
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); | ||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ){ | ||
channel.setAllowBubbles(true); | ||
} | ||
notificationManager.createNotificationChannel(channel); | ||
} | ||
assert inflatedView != null; | ||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, String.valueOf(inflatedView.getId())); | ||
if(inflatedView != null){ | ||
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), inflatedView.getId()); | ||
builder.setCustomContentView(remoteViews); | ||
} | ||
builder.setPriority(NotificationCompat.PRIORITY_HIGH); | ||
builder.setAutoCancel(false); | ||
return builder; | ||
} | ||
|
||
/** | ||
* Build regular notification | ||
*/ | ||
public NotificationCompat.Builder buildNotification(String channelID){ | ||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | ||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ){ | ||
NotificationChannel channel = new NotificationChannel(channelID, channelID, NotificationManager.IMPORTANCE_HIGH); | ||
channel.enableLights(true); | ||
channel.enableVibration(true); | ||
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); | ||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ){ | ||
channel.setAllowBubbles(true); | ||
} | ||
notificationManager.createNotificationChannel(channel); | ||
} | ||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID); | ||
builder.setPriority(NotificationCompat.PRIORITY_HIGH); | ||
builder.setAutoCancel(false); | ||
return builder; | ||
} | ||
|
||
public Context getContext() { | ||
return context; | ||
} | ||
|
||
} | ||
|
||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...java/com/scrappers/superiorExtendedEngine/tasksUtil/backgroundTask/BackgroundService.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.scrappers.superiorExtendedEngine.tasksUtil.backgroundTask; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.job.JobParameters; | ||
import android.app.job.JobService; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
import android.os.Handler; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
@SuppressLint("SpecifyJobSchedulerIdRange") | ||
@RequiresApi(api = Build.VERSION_CODES.M) | ||
public abstract class BackgroundService extends JobService { | ||
private final Task task = new Task(); | ||
private final Handler handler = new Handler(); | ||
@Override | ||
public boolean onStartJob(JobParameters params) { | ||
synchronized(task){ | ||
handler.post(task); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onStopJob(JobParameters params) { | ||
synchronized(task){ | ||
handler.removeCallbacks(task); | ||
} | ||
return true; | ||
} | ||
public class Task implements Runnable{ | ||
@SuppressLint("SpecifyJobSchedulerIdRange") | ||
@Override | ||
public void run() { | ||
listen(null); | ||
} | ||
} | ||
public abstract void listen(Intent intent); | ||
} |
Oops, something went wrong.