-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from QiubyZ/Dev
Dev
- Loading branch information
Showing
8 changed files
with
134 additions
and
13 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
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
48 changes: 48 additions & 0 deletions
48
app/src/main/java/qz/userdictionary/Service/AddItemOnService.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,48 @@ | ||
package qz.userdictionary.Service; | ||
|
||
import android.content.Context; | ||
import android.provider.UserDictionary; | ||
import androidx.annotation.NonNull; | ||
import androidx.work.Worker; | ||
import androidx.work.WorkerParameters; | ||
import qz.userdictionary.Model.TextItems; | ||
import qz.userdictionary.Model.UserDictionaryHelper; | ||
import androidx.core.app.NotificationCompat; | ||
import androidx.core.app.NotificationManagerCompat; | ||
|
||
/** | ||
* AddItemOnService | ||
*/ | ||
public class AddItemOnService extends Worker { | ||
public AddItemOnService(@NonNull Context ctx, @NonNull WorkerParameters workerParams) { | ||
super(ctx, workerParams); | ||
|
||
} | ||
|
||
@NonNull | ||
@Override | ||
public Result doWork() { | ||
String key1 = getInputData().getString("key1"); | ||
String key2 = getInputData().getString("key2"); | ||
new UserDictionaryHelper(getApplicationContext()) | ||
.add( | ||
new TextItems( | ||
key2, | ||
key1, | ||
"250", | ||
String.valueOf(UserDictionary.Words.LOCALE_TYPE_ALL))); | ||
showSuccessNotification("QZ UserDic", String.format("%s : %s", key1, key2)); | ||
return Result.success(); | ||
} | ||
|
||
private void showSuccessNotification(String title, String message) { | ||
int notificationId = 1; | ||
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), "channel_id") // Anda | ||
.setSmallIcon(android.R.drawable.ic_notification_overlay) | ||
.setContentTitle(title) | ||
.setContentText(message) | ||
.setPriority(NotificationCompat.PRIORITY_DEFAULT); | ||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext()); | ||
notificationManager.notify(notificationId, builder.build()); | ||
} | ||
} |
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,15 @@ | ||
package qz.userdictionary.Service; | ||
|
||
import android.app.Service; | ||
import android.content.Intent; | ||
import android.os.IBinder; | ||
|
||
/** | ||
* testing | ||
*/ | ||
public class testing extends Service { | ||
@Override | ||
public IBinder onBind(Intent arg0) { | ||
return null; | ||
} | ||
} |
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