Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Takeya-Yuki
RubyLib
提交
42d13da9
R
RubyLib
项目概览
Takeya-Yuki
/
RubyLib
8 个月 前同步成功
通知
39
Star
19
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RubyLib
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
42d13da9
编写于
8月 28, 2017
作者:
T
Takeya Yuki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Push Service
上级
0993a844
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
139 addition
and
6 deletion
+139
-6
README.md
README.md
+2
-1
app/build.gradle
app/build.gradle
+1
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+8
-0
rubylib/build.gradle
rubylib/build.gradle
+4
-4
rubylib/src/main/java/yuki/msg/extended/NotificationController.java
...c/main/java/yuki/msg/extended/NotificationController.java
+23
-0
rubylib/src/main/java/yuki/msg/extended/YukiPushService.java
rubylib/src/main/java/yuki/msg/extended/YukiPushService.java
+101
-0
未找到文件。
README.md
浏览文件 @
42d13da9
...
...
@@ -9,6 +9,7 @@ Command Line Support<br/>
UI Control Features (Status Bar and Navigation Bar)
<br/>
TTS Features
<br/>
Volume Control Features
<br/>
Yuki Push Service
<br/>
## Current Version
1.
0
-git-201708111646
1.
0
.7-git-201708281423
app/build.gradle
浏览文件 @
42d13da9
...
...
@@ -5,7 +5,7 @@ android {
buildToolsVersion
"26.0.0"
defaultConfig
{
applicationId
"jp.ruby.rubylibrary"
minSdkVersion
19
minSdkVersion
21
targetSdkVersion
26
versionCode
1
versionName
"1.0"
...
...
app/src/main/AndroidManifest.xml
浏览文件 @
42d13da9
...
...
@@ -19,9 +19,17 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<service
android:name=
"jp.ruby.rubylibrary.TestService"
android:description=
"@string/app_name"
android:process=
"Yuki.Test.Service"
android:exported=
"true"
>
<intent-filter>
<action
android:name=
"AAA"
/>
</intent-filter>
</service>
</application>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_MEDIA_STORAGE"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NOTIFICATION_POLICY"
/>
<uses-permission
android:name=
"android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
/>
</manifest>
\ No newline at end of file
rubylib/build.gradle
浏览文件 @
42d13da9
...
...
@@ -7,7 +7,7 @@ publish {
userOrg
=
'takeya-yuki-studio'
//bintray注册的用户名
groupId
=
'jp.ruby.rubylib'
//compile引用时的第1部分groupId
artifactId
=
'rubylib'
//compile引用时的第2部分项目名
publishVersion
=
'1.0.
6
'
//compile引用时的第3部分版本号
publishVersion
=
'1.0.
7
'
//compile引用时的第3部分版本号
desc
=
'Ruby Extended Controls'
website
=
'https://github.com/Takeya-Yuki/RubyLib.git'
}
...
...
@@ -18,10 +18,10 @@ android {
buildToolsVersion
"26.0.0"
defaultConfig
{
minSdkVersion
17
minSdkVersion
21
targetSdkVersion
26
versionCode
6
versionName
"1.0.
6
"
versionCode
7
versionName
"1.0.
7
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
...
...
rubylib/src/main/java/yuki/msg/extended/NotificationController.java
0 → 100644
浏览文件 @
42d13da9
package
yuki.msg.extended
;
import
android.app.Notification
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Parcel
;
/**
* Created by Akeno on 2017/08/28.
*/
public
class
NotificationController
{
public
static
void
Notify
(
Context
context
,
int
id
,
int
icon
,
PendingIntent
pendingIntent
,
String
ticker
,
String
title
,
String
content
,
int
flags
){
NotificationManager
nm
=(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
Notification
.
Builder
nb
=
new
Notification
.
Builder
(
context
);
nb
.
setSmallIcon
(
icon
).
setContentIntent
(
pendingIntent
).
setTicker
(
ticker
).
setContentTitle
(
title
).
setContentText
(
content
).
setWhen
(
System
.
currentTimeMillis
());
Notification
notification
=
nb
.
build
();
notification
.
flags
=
flags
;
nm
.
notify
(
id
,
notification
);
}
}
rubylib/src/main/java/yuki/msg/extended/YukiPushService.java
0 → 100644
浏览文件 @
42d13da9
package
yuki.msg.extended
;
import
android.app.Notification
;
import
android.app.PendingIntent
;
import
android.app.Service
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.IBinder
;
import
android.support.annotation.IntDef
;
import
android.support.annotation.Nullable
;
import
android.util.Log
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.Socket
;
/**
* Created by Akeno on 2017/08/28.
*/
public
abstract
class
YukiPushService
extends
Service
{
public
abstract
String
GetRemoteEndPoint
();
private
Socket
socket
;
public
abstract
int
GetIcon
();
public
abstract
int
GetServiceID
();
public
void
MessagePushed
(
String
msg
){
Intent
i
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
"msg://msg"
));
PendingIntent
pi
=
PendingIntent
.
getActivity
(
getApplicationContext
(),
0
,
i
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
NotificationController
.
Notify
(
getApplicationContext
(),
GetServiceID
(),
GetIcon
(),
pi
,
"Yuki Push Service"
,
"Yuki Push Service"
,
msg
,
Notification
.
FLAG_NO_CLEAR
|
Notification
.
FLAG_AUTO_CANCEL
);
}
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
return
null
;
}
@Override
public
void
onCreate
(){
super
.
onCreate
();
}
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
final
String
EndPoint
=
GetRemoteEndPoint
();
Log
.
e
(
"ep"
,
EndPoint
);
Log
.
e
(
"eph"
,
EndPoint
.
split
(
":"
)[
0
]);
Log
.
e
(
"epp"
,
EndPoint
.
split
(
":"
)[
1
]);
socket
=
new
Socket
(
EndPoint
.
split
(
":"
)[
0
],
Integer
.
parseInt
(
EndPoint
.
split
(
":"
)[
1
]));
BufferedReader
sin
=
new
BufferedReader
(
new
InputStreamReader
(
socket
.
getInputStream
()));
String
readline
;
readline
=
sin
.
readLine
();
while
(
readline
!=
null
){
readline
=
sin
.
readLine
();
if
(
readline
.
isEmpty
()){
continue
;}
if
(
readline
==
null
){
break
;
}
MessagePushed
(
readline
);
}
socket
.
close
();
}
catch
(
IOException
ex
)
{
}
catch
(
Exception
ex
){
}
finally
{
if
(
socket
.
isClosed
()){
}
else
if
(
socket
.
isConnected
()){
try
{
socket
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
});
thread
.
start
();
return
Service
.
START_STICKY
;
//return super.onStartCommand(intent, flags, startId);
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录