Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
majora-adr
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
majora
majora-adr
Commits
01f694af
Commit
01f694af
authored
Sep 29, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.支持选择是否自动重播 2.设置重播时间间隔 3. 设置页面展示summary
parent
7c364648
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
155 additions
and
22 deletions
+155
-22
build.gradle
app/build.gradle
+2
-2
MajoraClientService.java
...ava/com/virjar/majora/adr/majora/MajoraClientService.java
+35
-10
MainPanelFragment.java
...main/java/com/virjar/majora/adr/ui/MainPanelFragment.java
+37
-0
EditSummaryPreference.java
...om/virjar/majora/adr/ui/widget/EditSummaryPreference.java
+31
-0
tab_main_panel.xml
app/src/main/res/layout/tab_main_panel.xml
+33
-0
strings.xml
app/src/main/res/values/strings.xml
+2
-1
prefs.xml
app/src/main/res/xml/prefs.xml
+15
-9
No files found.
app/build.gradle
View file @
01f694af
...
...
@@ -9,8 +9,8 @@ android {
minSdkVersion
19
//noinspection ExpiredTargetSdkVersion
targetSdkVersion
23
versionCode
4
versionName
"1.
4
"
versionCode
5
versionName
"1.
5
"
archivesBaseName
=
"Majora_${versionName}"
.
replace
(
' '
,
'_'
)
}
...
...
app/src/main/java/com/virjar/majora/adr/majora/MajoraClientService.java
View file @
01f694af
...
...
@@ -10,16 +10,43 @@ import com.virjar.majora.adr.utils.PermissionUtils;
import
com.virjar.majora.client.sdk.client.MajoraClient
;
import
com.virjar.majora.client.sdk.log.MajoraLogger
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
eu.chainfire.libsuperuser.Shell
;
public
class
MajoraClientService
{
private
static
boolean
started
=
false
;
private
static
MajoraClient
majoraClient
;
// 重播任务定时器
private
static
final
Timer
timer
=
new
Timer
(
"reDial"
);
private
static
class
RedialThread
extends
Thread
{
private
static
final
RedialThread
mInstance
=
new
RedialThread
();
@Override
public
void
run
()
{
while
(
Thread
.
currentThread
().
isAlive
())
{
SharedPreferences
spf
=
PreferenceManager
.
getDefaultSharedPreferences
(
TheApp
.
getApplication
());
boolean
autoRedial
=
spf
.
getBoolean
(
"auto_redial"
,
true
);
int
sleepMinutes
=
spf
.
getInt
(
"auto_redial_duration"
,
5
);
if
(
sleepMinutes
<
1
)
{
sleepMinutes
=
1
;
}
if
(
sleepMinutes
>
600
)
{
sleepMinutes
=
600
;
}
if
(!
autoRedial
)
{
sleepMinutes
=
5
;
}
try
{
Thread
.
sleep
(
sleepMinutes
*
60
*
1000
);
}
catch
(
InterruptedException
e
)
{
//ignore
return
;
}
if
(
autoRedial
)
{
reDial
();
}
}
}
}
public
static
void
startup
()
{
...
...
@@ -32,12 +59,10 @@ public class MajoraClientService {
}
startProxyService
();
timer
.
scheduleAtFixedRate
(
new
TimerTask
()
{
@Override
public
void
run
()
{
reDial
();
RedialThread
redialThread
=
RedialThread
.
mInstance
;
if
(!
redialThread
.
isAlive
())
{
redialThread
.
start
();
}
},
5
*
60
*
1000
,
5
*
60
*
1000
);
started
=
true
;
}
...
...
app/src/main/java/com/virjar/majora/adr/ui/MainPanelFragment.java
View file @
01f694af
...
...
@@ -3,6 +3,7 @@ package com.virjar.majora.adr.ui;
import
android.app.Fragment
;
import
android.content.SharedPreferences
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
import
android.support.annotation.Nullable
;
...
...
@@ -10,6 +11,7 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
import
android.widget.Toast
;
...
...
@@ -22,6 +24,17 @@ import com.virjar.majora.adr.utils.CommonUtils;
import
eu.chainfire.libsuperuser.Shell
;
public
class
MainPanelFragment
extends
Fragment
{
private
View
autoRedialPanel
;
@Override
public
void
onResume
()
{
super
.
onResume
();
SharedPreferences
spf
=
PreferenceManager
.
getDefaultSharedPreferences
(
TheApp
.
getApplication
());
boolean
autoRedial
=
spf
.
getBoolean
(
"auto_redial"
,
true
)
&&
Shell
.
SU
.
available
();
autoRedialPanel
.
setVisibility
(
autoRedial
?
View
.
VISIBLE
:
View
.
GONE
);
}
@Nullable
@Override
...
...
@@ -65,6 +78,30 @@ public class MainPanelFragment extends Fragment {
}
});
TextView
reDialConfigTextView
=
view
.
findViewById
(
R
.
id
.
tv_redial_view
);
autoRedialPanel
=
view
.
findViewById
(
R
.
id
.
auto_redial_panel
);
SeekBar
seekBar
=
view
.
findViewById
(
R
.
id
.
reDialSeekBar
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
seekBar
.
setMin
(
1
);
}
seekBar
.
setOnSeekBarChangeListener
(
new
SeekBar
.
OnSeekBarChangeListener
()
{
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
reDialConfigTextView
.
setText
(
String
.
valueOf
(
progress
));
SharedPreferences
spf
=
PreferenceManager
.
getDefaultSharedPreferences
(
TheApp
.
getApplication
());
spf
.
edit
().
putInt
(
"auto_redial_duration"
,
progress
).
apply
();
}
@Override
public
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
}
@Override
public
void
onStopTrackingTouch
(
SeekBar
seekBar
)
{
}
});
return
view
;
}
...
...
app/src/main/java/com/virjar/majora/adr/ui/widget/EditSummaryPreference.java
0 → 100644
View file @
01f694af
package
com
.
virjar
.
majora
.
adr
.
ui
.
widget
;
import
android.content.Context
;
import
android.os.Build
;
import
android.preference.EditTextPreference
;
import
android.support.annotation.RequiresApi
;
import
android.util.AttributeSet
;
public
class
EditSummaryPreference
extends
EditTextPreference
{
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
LOLLIPOP
)
public
EditSummaryPreference
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
,
int
defStyleRes
)
{
super
(
context
,
attrs
,
defStyleAttr
,
defStyleRes
);
}
public
EditSummaryPreference
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
}
public
EditSummaryPreference
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
public
EditSummaryPreference
(
Context
context
)
{
super
(
context
);
}
@Override
public
CharSequence
getSummary
()
{
return
getText
();
}
}
app/src/main/res/layout/tab_main_panel.xml
View file @
01f694af
...
...
@@ -214,6 +214,39 @@
</LinearLayout>
<LinearLayout
android:id=
"@+id/auto_redial_panel"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"5dp"
android:orientation=
"horizontal"
>
<TextView
android:padding=
"5dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"重播间隔(分钟): "
/>
<TextView
android:padding=
"5dp"
android:minWidth=
"5dp"
android:id=
"@+id/tv_redial_view"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:text=
"0"
/>
<SeekBar
android:id=
"@+id/reDialSeekBar"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:max=
"60"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
...
...
app/src/main/res/values/strings.xml
View file @
01f694af
...
...
@@ -15,7 +15,6 @@
<string
name=
"nav_item_about"
>
关于
</string>
<string
name=
"settings_group_app"
>
应用
</string>
<string
name=
"settings_group_user"
>
用户
</string>
<string
name=
"phone_identifier"
>
结算账户
</string>
<string
name=
"support_framework_label"
>
框架/安装支持
</string>
...
...
@@ -66,5 +65,7 @@
<string
name=
"client_id"
>
clientId
</string>
<string
name=
"server_config"
>
服务器配置
</string>
<string
name=
"binding_account"
>
结算账号
</string>
<string
name=
"settings_group_local"
>
本地配置
</string>
<string
name=
"auto_redial"
>
自动重播
</string>
</resources>
app/src/main/res/xml/prefs.xml
View file @
01f694af
...
...
@@ -3,17 +3,23 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<PreferenceCategory
android:title=
"@string/server"
>
<
EditText
Preference
<
com.virjar.majora.adr.ui.widget.EditSummary
Preference
android:defaultValue=
"@string/default_server_host"
android:key=
"server_host"
android:persistent=
"true"
android:title=
"@string/server_host"
/>
<
EditText
Preference
<
com.virjar.majora.adr.ui.widget.EditSummary
Preference
android:defaultValue=
"@string/default_server_port"
android:digits=
"0123456789"
android:inputType=
"numberDecimal"
android:key=
"server_port"
android:title=
"@string/port"
/>
<com.virjar.majora.adr.ui.widget.EditSummaryPreference
android:defaultValue=
""
android:key=
"account_identifier"
android:title=
"@string/phone_identifier"
>
</com.virjar.majora.adr.ui.widget.EditSummaryPreference>
</PreferenceCategory>
<PreferenceCategory
...
...
@@ -44,14 +50,14 @@
<PreferenceCategory
android:key=
"group_
user
"
android:title=
"@string/settings_group_
user
"
>
android:key=
"group_
local
"
android:title=
"@string/settings_group_
local
"
>
<EditTextPreference
android:defaultValue=
""
android:key=
"account_identifier"
android:title=
"@string/phone_identifier"
>
<SwitchPreference
android:title=
"@string/auto_redial"
android:key=
"auto_redial"
android:defaultValue=
"true"
/>
</EditTextPreference>
</PreferenceCategory>
</PreferenceScreen>
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