Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
echo-adr-Deprecated
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
echo
echo-adr-Deprecated
Commits
8e95a880
Commit
8e95a880
authored
Jul 20, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设置页面
parent
abef905b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
32 deletions
+103
-32
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
EchoApplication.java
app/src/main/java/com/virjar/echo/adr/EchoApplication.java
+14
-0
HttpProxyService.java
app/src/main/java/com/virjar/echo/adr/HttpProxyService.java
+3
-8
EchoConfig.java
app/src/main/java/com/virjar/echo/adr/repo/EchoConfig.java
+46
-0
SettingsActivity.java
...rc/main/java/com/virjar/echo/adr/ui/SettingsActivity.java
+15
-0
activity_login.xml
app/src/main/res/layout/activity_login.xml
+1
-1
strings.xml
app/src/main/res/values/strings.xml
+10
-3
root_preferences.xml
app/src/main/res/xml/root_preferences.xml
+13
-20
No files found.
app/src/main/AndroidManifest.xml
View file @
8e95a880
...
...
@@ -10,6 +10,7 @@
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<application
android:name=
".EchoApplication"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
...
...
app/src/main/java/com/virjar/echo/adr/EchoApplication.java
0 → 100644
View file @
8e95a880
package
com
.
virjar
.
echo
.
adr
;
import
android.app.Application
;
import
com.virjar.echo.adr.repo.EchoConfig
;
public
class
EchoApplication
extends
Application
{
@Override
public
void
onCreate
()
{
super
.
onCreate
();
EchoConfig
.
init
(
this
);
}
}
app/src/main/java/com/virjar/echo/adr/HttpProxyService.java
View file @
8e95a880
...
...
@@ -11,13 +11,12 @@ import android.graphics.Color;
import
android.os.Build
;
import
android.os.IBinder
;
import
androidx.annotation.Nullable
;
import
com.virjar.echo.adr.repo.EchoConfig
;
import
com.virjar.echo.nat.client.EchoClient
;
import
com.virjar.echo.nat.log.EchoLogger
;
import
java.util.UUID
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
static
android
.
app
.
PendingIntent
.
FLAG_UPDATE_CURRENT
;
...
...
@@ -85,15 +84,11 @@ public class HttpProxyService extends Service {
notification
.
defaults
=
Notification
.
DEFAULT_SOUND
;
startForeground
(
110
,
notification
);
//TODO 设备ID生成算法
String
clientKey
=
UUID
.
randomUUID
().
toString
();
EchoLogger
.
getLogger
().
info
(
"start EchoProxy front service"
);
//TODO 设置服务器信息
echoClient
=
new
EchoClient
(
"echo.virjar.com"
,
5698
,
clientKey
);
EchoConfig
.
getEchoServer
(),
EchoConfig
.
getEchoServerPort
()
,
EchoConfig
.
getClientId
()
);
new
Thread
()
{
@Override
public
void
run
()
{
...
...
app/src/main/java/com/virjar/echo/adr/repo/EchoConfig.java
0 → 100644
View file @
8e95a880
package
com
.
virjar
.
echo
.
adr
.
repo
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.text.TextUtils
;
import
com.virjar.echo.adr.R
;
import
java.util.UUID
;
public
class
EchoConfig
{
public
static
final
String
configFile
=
"echo_config"
;
public
static
SharedPreferences
sharedPreferences
;
private
static
String
defaultServerHost
;
private
static
int
defaultServerPort
;
public
static
void
init
(
Context
context
)
{
sharedPreferences
=
context
.
getSharedPreferences
(
configFile
,
Context
.
MODE_PRIVATE
);
defaultServerHost
=
context
.
getString
(
R
.
string
.
default_server_host
);
defaultServerPort
=
Integer
.
parseInt
(
context
.
getString
(
R
.
string
.
default_server_port
));
getClientId
();
}
public
static
String
getEchoServer
()
{
return
sharedPreferences
.
getString
(
"server_host"
,
defaultServerHost
);
}
public
static
int
getEchoServerPort
()
{
return
sharedPreferences
.
getInt
(
"server_port"
,
defaultServerPort
);
}
public
static
String
getClientId
()
{
String
echoClientId
=
sharedPreferences
.
getString
(
"echo_clientId"
,
""
);
if
(
TextUtils
.
isEmpty
(
echoClientId
))
{
echoClientId
=
System
.
currentTimeMillis
()
+
"_"
+
UUID
.
randomUUID
().
toString
();
sharedPreferences
.
edit
().
putString
(
"echo_clientId"
,
echoClientId
).
apply
();
}
else
{
return
echoClientId
;
}
return
getClientId
();
}
}
app/src/main/java/com/virjar/echo/adr/ui/SettingsActivity.java
View file @
8e95a880
package
com
.
virjar
.
echo
.
adr
.
ui
;
import
android.os.Bundle
;
import
android.view.MenuItem
;
import
androidx.appcompat.app.ActionBar
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.preference.PreferenceFragmentCompat
;
import
com.virjar.echo.adr.R
;
import
com.virjar.echo.adr.repo.EchoConfig
;
public
class
SettingsActivity
extends
AppCompatActivity
{
...
...
@@ -24,9 +26,22 @@ public class SettingsActivity extends AppCompatActivity {
}
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
android
.
R
.
id
.
home
:
finish
();
break
;
default
:
break
;
}
return
super
.
onOptionsItemSelected
(
item
);
}
public
static
class
SettingsFragment
extends
PreferenceFragmentCompat
{
@Override
public
void
onCreatePreferences
(
Bundle
savedInstanceState
,
String
rootKey
)
{
getPreferenceManager
().
setSharedPreferencesName
(
EchoConfig
.
configFile
);
setPreferencesFromResource
(
R
.
xml
.
root_preferences
,
rootKey
);
}
}
...
...
app/src/main/res/layout/activity_login.xml
View file @
8e95a880
...
...
@@ -164,7 +164,7 @@
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:fontFamily=
"@font/calibri"
android:text=
"powered by virjar@i
ntiin
.inc"
android:text=
"powered by virjar@i
inti
.inc"
android:textAlignment=
"center"
android:textColor=
"#96ffffff"
android:textSize=
"16sp"
/>
...
...
app/src/main/res/values/strings.xml
View file @
8e95a880
...
...
@@ -3,11 +3,18 @@
<string
name=
"title_activity_settings"
>
SettingsActivity
</string>
<!-- Preference Titles -->
<string
name=
"
messages_header"
>
Messages
</string>
<string
name=
"
sync_header"
>
Sync
</string>
<string
name=
"
server_header"
>
Server
</string>
<string
name=
"
client_header"
>
Client
</string>
<!-- Messages Preferences -->
<string
name=
"signature_title"
>
Your signature
</string>
<string
name=
"server_host_title"
>
ServerHost
</string>
<string
name=
"default_server_host"
>
echo.virjar.com
</string>
<string
name=
"server_port_title"
>
ServerPort
</string>
<string
name=
"default_server_port"
>
5698
</string>
<string
name=
"client_id_title"
>
ClientId
</string>
<string
name=
"reply_title"
>
Default reply action
</string>
<!-- Sync Preferences -->
...
...
app/src/main/res/xml/root_preferences.xml
View file @
8e95a880
<PreferenceScreen
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<PreferenceCategory
app:title=
"@string/
messages
_header"
>
<PreferenceCategory
app:title=
"@string/
server
_header"
>
<EditTextPreference
app:key=
"signature"
app:title=
"@string/signature_title"
app:defaultValue=
"@string/default_server_host"
app:key=
"server_host"
app:title=
"@string/server_host_title"
app:useSimpleSummaryProvider=
"true"
/>
<ListPreference
app:defaultValue=
"reply"
app:entries=
"@array/reply_entries"
app:entryValues=
"@array/reply_values"
app:key=
"reply"
app:title=
"@string/reply_title"
<EditTextPreference
app:defaultValue=
"@string/default_server_port"
app:key=
"server_port"
app:title=
"@string/server_port_title"
app:useSimpleSummaryProvider=
"true"
/>
</PreferenceCategory>
<PreferenceCategory
app:title=
"@string/sync_header"
>
<SwitchPreferenceCompat
app:key=
"sync"
app:title=
"@string/sync_title"
/>
<PreferenceCategory
app:title=
"@string/client_header"
>
<SwitchPreferenceCompat
app:dependency=
"sync"
app:key=
"attachment"
app:summaryOff=
"@string/attachment_summary_off"
app:summaryOn=
"@string/attachment_summary_on"
app:title=
"@string/attachment_title"
/>
<EditTextPreference
app:key=
"echo_clientId"
app:title=
"@string/client_id_title"
app:useSimpleSummaryProvider=
"true"
/>
</PreferenceCategory>
...
...
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