Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
65b0d0bd
Commit
65b0d0bd
authored
May 24, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
构建新功能
parent
91e5065a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
278 additions
and
1 deletion
+278
-1
mobile/build.gradle
mobile/build.gradle
+1
-1
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+2
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
...ava/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
+213
-0
mobile/src/main/res/layout/duel_assistant_service.xml
mobile/src/main/res/layout/duel_assistant_service.xml
+62
-0
No files found.
mobile/build.gradle
View file @
65b0d0bd
...
...
@@ -54,7 +54,7 @@ android {
exclude
'META-INF/LICENSE'
}
aaptOptions
{
noCompress
'dll'
noCompress
'dll'
,
"config"
}
buildToolsVersion
'27.0.3'
}
...
...
mobile/src/main/AndroidManifest.xml
View file @
65b0d0bd
...
...
@@ -151,6 +151,8 @@
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
android:theme=
"@style/AppTheme"
/>
<service
android:name=
"cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant"
/>
<activity
android:name=
"com.base.bj.trpayjar.TrPayAcitivity"
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
0 → 100644
View file @
65b0d0bd
package
cn.garymb.ygomobile.ui.plus
;
import
android.app.*
;
import
android.content.*
;
import
android.graphics.*
;
import
android.os.*
;
import
android.view.*
;
import
android.view.View.*
;
import
android.widget.*
;
import
com.feihua.dialogutils.util.*
;
import
com.ourygo.cardutils.bean.*
;
import
com.ourygo.duelassistant.*
;
import
com.ourygo.duelassistant.adapter.*
;
import
com.ourygo.duelassistant.service.*
;
import
com.ourygo.duelassistant.utils.*
;
import
java.util.*
;
import
android.support.v7.widget.*
;
public
class
ServiceDuelAssistant
extends
Service
{
private
LinearLayout
mFloatLayout
;
private
TextView
ds_text
;
private
Button
ds_join
,
ds_qx
;
//是否可以移除悬浮窗上面的视图
private
boolean
isdis
=
false
;
String
[]
passwordPrefix
={
"M,"
,
"T,"
,
"PR,"
,
"M#"
,
"T#"
,
"PR#"
,
"S#"
};
//private List<Card> lc;
private
WindowManager
.
LayoutParams
wmParams
;
private
WindowManager
mWindowManager
;
//private CardListRecyclerViewAdapter cladp;
//private DialogUtils du;
@Override
public
IBinder
onBind
(
Intent
p1
)
{
// TODO: Implement this method
return
null
;
}
@Override
public
void
onCreate
()
{
// TODO: Implement this method
super
.
onCreate
();
//lc = new ArrayList<Card>();
//cladp = new CardListRecyclerViewAdapter(this, lc);
// du = DialogUtils.getdx(this);
final
ClipboardManager
cm
=(
ClipboardManager
)
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
createFloatView
();
cm
.
addPrimaryClipChangedListener
(
new
ClipboardManager
.
OnPrimaryClipChangedListener
()
{
@Override
public
void
onPrimaryClipChanged
()
{
final
String
ss
=
cm
.
getText
().
toString
().
trim
();
/*final int ssi=ss.indexOf("卡查");
if (ssi != -1) {
cxCard(ss, ssi);
} else {*/
int
start
=-
1
;
for
(
String
st:
passwordPrefix
)
{
start
=
ss
.
indexOf
(
st
);
if
(
start
!=
-
1
)
{
break
;
}
}
if
(
start
!=
-
1
)
{
joinRoom
(
ss
,
start
);
}
//}
}
});
}
private
void
joinRoom
(
String
ss
,
int
start
)
{
if
(
DAUtils
.
isygo
(
this
))
{
final
String
password
=
ss
.
substring
(
start
,
ss
.
length
());
ds_text
.
setText
(
"加入房间\""
+
password
+
"\""
);
ds_join
.
setText
(
"加入"
);
ds_qx
.
setText
(
"关闭"
);
disJoinDialog
();
showJoinDialog
();
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
// TODO Auto-generated method stub
if
(
isdis
)
{
isdis
=
false
;
mWindowManager
.
removeView
(
mFloatLayout
);
}
}
},
2000
);
ds_qx
.
setOnClickListener
(
new
OnClickListener
(){
@Override
public
void
onClick
(
View
p1
)
{
disJoinDialog
();
// TODO: Implement this method
}
});
ds_join
.
setOnClickListener
(
new
OnClickListener
(){
@Override
public
void
onClick
(
View
p1
)
{
if
(
isdis
)
{
isdis
=
false
;
mWindowManager
.
removeView
(
mFloatLayout
);
}
IntentUtil
.
duelIntent
(
ServiceDuelAssistant
.
this
,
SharedPreferenceUtil
.
getDuelIp
(),
SharedPreferenceUtil
.
getDuelPort
(),
SharedPreferenceUtil
.
getDuelName
(),
password
);
// TODO: Implement this method
}
});
}
// TODO: Implement this method
}
private
void
disJoinDialog
()
{
if
(
isdis
)
{
isdis
=
false
;
mWindowManager
.
removeView
(
mFloatLayout
);
}
}
private
void
showJoinDialog
(){
if
(!
isdis
){
mWindowManager
.
addView
(
mFloatLayout
,
wmParams
);
isdis
=
true
;
}
}
private
void
createFloatView
()
{
wmParams
=
new
WindowManager
.
LayoutParams
();
//获取的是WindowManagerImpl.CompatModeWrapper
mWindowManager
=
(
WindowManager
)
getApplication
().
getSystemService
(
getApplication
().
WINDOW_SERVICE
);
//设置window type
wmParams
.
type
=
android
.
view
.
WindowManager
.
LayoutParams
.
TYPE_SYSTEM_ALERT
;
//设置背景透明
wmParams
.
format
=
PixelFormat
.
TRANSLUCENT
;
//设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作)
//实现悬浮窗到状态栏
wmParams
.
flags
=
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
|
WindowManager
.
LayoutParams
.
FLAG_BLUR_BEHIND
;
//调整悬浮窗显示的停靠位置为左侧置顶
wmParams
.
gravity
=
Gravity
.
LEFT
|
Gravity
.
TOP
;
// 以屏幕左上角为原点,设置x、y初始值,相对于gravity
wmParams
.
x
=
0
;
wmParams
.
y
=
0
;
//设置悬浮窗口长宽数据
wmParams
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
;
wmParams
.
height
=
WindowManager
.
LayoutParams
.
WRAP_CONTENT
;
LayoutInflater
inflater
=
LayoutInflater
.
from
(
this
);
//获取浮动窗口视图所在布局
mFloatLayout
=
(
LinearLayout
)
inflater
.
inflate
(
R
.
layout
.
duel_assistant_service
,
null
);
//添加mFloatLayout
ds_join
=
mFloatLayout
.
findViewById
(
R
.
id
.
ds_join
);
ds_text
=
mFloatLayout
.
findViewById
(
R
.
id
.
ds_text
);
ds_qx
=
mFloatLayout
.
findViewById
(
R
.
id
.
ds_qx
);
}
/*private void cxCard(String ss, int ssi) {
final String card=ss.substring(ssi + 2, ss.length());
if (isdis) {
mWindowManager.removeView(mFloatLayout);
}
ds_join.setText("查询");
ds_text.setText("查询卡片\"" + card + "\"");
ds_join.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View p1) {
lc.clear();
for (Card c:DACardUtils.cardQuery(card)) {
lc.add(c);
}
cladp.notifyDataSetChanged();
LinearLayoutManager llm=new LinearLayoutManager(ServiceDuelAssistant.this);
du.dialogRec("\"" + card + "\"的搜索结果", cladp, llm);
// TODO: Implement this method
}
});
mWindowManager.addView(mFloatLayout, wmParams);
isdis = true;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
if (isdis) {
isdis = false;
mWindowManager.removeView(mFloatLayout);
}
}
}, 2000);
// TODO: Implement this method
}*/
}
mobile/src/main/res/layout/duel_assistant_service.xml
0 → 100644
View file @
65b0d0bd
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_height=
"wrap_content"
android:layout_width=
"match_parent"
android:orientation=
"vertical"
android:background=
"#00000000"
>
<android.support.v7.widget.CardView
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:cardCornerRadius=
"@dimen/dialog_corner_radius"
app:elevation=
"15dp"
app:cardBackgroundColor=
"@color/colorDialogBackground"
android:layout_margin=
"10dp"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:gravity=
"center_horizontal"
>
<TextView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:text=
"Text"
android:layout_margin=
"10dp"
android:id=
"@+id/ds_text"
android:textColor=
"#000000"
/>
<LinearLayout
android:layout_height=
"wrap_content"
android:layout_width=
"match_parent"
android:orientation=
"horizontal"
>
<Button
android:textColor=
"@color/colorPrimary"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:text=
"加入"
android:layout_weight=
"1"
android:id=
"@+id/ds_join"
/>
<Button
android:textColor=
"@color/colorPrimary"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:text=
"关闭"
android:layout_weight=
"1"
android:id=
"@+id/ds_qx"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment