You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
notification support using libportal
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
package android.content;
|
||||
|
||||
public class BroadcastReceiver {
|
||||
public abstract class BroadcastReceiver {
|
||||
|
||||
public abstract void onReceive(Context context, Intent intent);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ public class Context extends Object {
|
||||
File obb_dir = null;
|
||||
File cache_dir = null;
|
||||
|
||||
private static Map<IntentFilter, BroadcastReceiver> receiverMap = new HashMap<IntentFilter, BroadcastReceiver>();
|
||||
|
||||
static {
|
||||
assets = new AssetManager();
|
||||
dm = new DisplayMetrics();
|
||||
@@ -202,6 +204,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
|
||||
receiverMap.put(filter, receiver);
|
||||
return new Intent();
|
||||
}
|
||||
|
||||
@@ -467,7 +470,13 @@ public class Context extends Object {
|
||||
return new File(databaseDir, dbName);
|
||||
}
|
||||
|
||||
public void sendBroadcast(Intent intent) {}
|
||||
public void sendBroadcast(Intent intent) {
|
||||
for (IntentFilter filter : receiverMap.keySet()) {
|
||||
if (filter.matchAction(intent.getAction())) {
|
||||
receiverMap.get(filter).onReceive(this, intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean stopService(Intent intent) {return false;}
|
||||
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
package android.content;
|
||||
|
||||
public class IntentFilter {
|
||||
public IntentFilter() {}
|
||||
public IntentFilter(String dummy) {}
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public void addAction(String action) {}
|
||||
public int countActions() { return 0; /*maybe?*/ }
|
||||
public class IntentFilter {
|
||||
|
||||
private Set<String> actions = new HashSet<>();
|
||||
|
||||
public IntentFilter() {}
|
||||
public IntentFilter(String action) {
|
||||
addAction(action);
|
||||
}
|
||||
|
||||
public void addAction(String action) {
|
||||
actions.add(action);
|
||||
}
|
||||
public int countActions() {
|
||||
return actions.size();
|
||||
}
|
||||
|
||||
public final boolean matchAction(String action) {
|
||||
return actions.contains(action);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user