Commit abef905b authored by Administrator's avatar Administrator

settings demo

parent 8ec9bb6f
...@@ -43,9 +43,9 @@ dependencies { ...@@ -43,9 +43,9 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:design:28.0.0'
//compile 'com.android.support:support-v4:24.2.0' //compile 'com.android.support:support-v4:24.2.0'
api project(':echo-lib') api project(':echo-lib')
...@@ -53,5 +53,6 @@ dependencies { ...@@ -53,5 +53,6 @@ dependencies {
//引入netty之后,class直接就爆炸了。考虑实现API精简 //引入netty之后,class直接就爆炸了。考虑实现API精简
implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.preference:preference:1.1.0'
annotationProcessor 'org.projectlombok:lombok:1.18.2' annotationProcessor 'org.projectlombok:lombok:1.18.2'
} }
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.virjar.echo.adr"> package="com.virjar.echo.adr">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application <application
android:allowBackup="true" android:allowBackup="true"
...@@ -10,13 +16,16 @@ ...@@ -10,13 +16,16 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity
android:name=".ui.SettingsActivity"
android:label="@string/title_activity_settings" />
<activity android:name=".MainActivity" /> <activity android:name=".MainActivity" />
<activity
android:name=".ui.LoginActivity"
<activity android:name=".ui.LoginActivity" android:configChanges="orientation|screenSize"
android:theme="@style/Theme.AppCompat.NoActionBar" android:theme="@style/Theme.AppCompat.NoActionBar"
android:windowSoftInputMode="stateHidden|adjustPan" android:windowSoftInputMode="stateHidden|adjustPan"
android:configChanges="orientation|screenSize"> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
...@@ -25,7 +34,7 @@ ...@@ -25,7 +34,7 @@
</activity> </activity>
<receiver <receiver
android:name="com.virjar.echo.adr.StartOnBootBroadcastReceiver" android:name=".StartOnBootBroadcastReceiver"
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true">
<intent-filter android:priority="1000"> <intent-filter android:priority="1000">
...@@ -45,27 +54,20 @@ ...@@ -45,27 +54,20 @@
<data android:scheme="package" /> <data android:scheme="package" />
</intent-filter> </intent-filter>
</receiver> </receiver> <!-- 开机自启服务 -->
<!--开机自启服务-->
<service <service
android:name="com.virjar.echo.adr.HttpProxyService" android:name=".HttpProxyService"
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
tools:ignore="ExportedService"> tools:ignore="ExportedService">
<intent-filter android:priority="1000"> <intent-filter android:priority="1000">
<action android:name="com.virjar.g4proxy.service" /> <action android:name="com.virjar.g4proxy.service" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</service> </service>
</application> </application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest> </manifest>
\ No newline at end of file
...@@ -10,9 +10,10 @@ import android.graphics.BitmapFactory; ...@@ -10,9 +10,10 @@ import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.virjar.echo.nat.client.EchoClient; import com.virjar.echo.nat.client.EchoClient;
import com.virjar.echo.nat.log.EchoLogger; import com.virjar.echo.nat.log.EchoLogger;
......
...@@ -2,7 +2,8 @@ package com.virjar.echo.adr; ...@@ -2,7 +2,8 @@ package com.virjar.echo.adr;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
......
package com.virjar.echo.adr.ui; package com.virjar.echo.adr.ui;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.virjar.echo.adr.R; import com.virjar.echo.adr.R;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
...@@ -18,11 +22,26 @@ public class LoginActivity extends AppCompatActivity { ...@@ -18,11 +22,26 @@ public class LoginActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
imageView = findViewById(R.id.imageView); imageView = findViewById(R.id.imageView);
textView = findViewById(R.id.textView); textView = findViewById(R.id.textView);
setupAnimation();
Button btnSetting = findViewById(R.id.btn_setting);
btnSetting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
startActivity(new Intent(LoginActivity.this, SettingsActivity.class));
}
});
}
private void setupAnimation() {
imageView.setOnTouchListener(new OnSwipeTouchListener(getApplicationContext()) { imageView.setOnTouchListener(new OnSwipeTouchListener(getApplicationContext()) {
public void onSwipeTop() { public void onSwipeTop() {
} }
...@@ -56,4 +75,5 @@ public class LoginActivity extends AppCompatActivity { ...@@ -56,4 +75,5 @@ public class LoginActivity extends AppCompatActivity {
}); });
} }
} }
package com.virjar.echo.adr.ui;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceFragmentCompat;
import com.virjar.echo.adr.R;
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings, new SettingsFragment())
.commit();
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
public static class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
}
}
}
\ No newline at end of file
...@@ -94,11 +94,7 @@ ...@@ -94,11 +94,7 @@
android:paddingRight="32dp"> android:paddingRight="32dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#96ffffff"
android:theme="@style/EditScreenTextInputLayoutStyle">
<EditText <EditText
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -111,13 +107,7 @@ ...@@ -111,13 +107,7 @@
android:maxLines="1" android:maxLines="1"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="16sp" /> android:textSize="16sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#96ffffff"
android:theme="@style/EditScreenTextInputLayoutStyle">
<EditText <EditText
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -130,7 +120,7 @@ ...@@ -130,7 +120,7 @@
android:maxLines="1" android:maxLines="1"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="16sp" /> android:textSize="16sp" />
</android.support.design.widget.TextInputLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -153,6 +143,7 @@ ...@@ -153,6 +143,7 @@
android:textSize="16dp" /> android:textSize="16dp" />
<Button <Button
android:id="@+id/btn_setting"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<resources>
<!-- Reply Preference -->
<string-array name="reply_entries">
<item>Reply</item>
<item>Reply to all</item>
</string-array>
<string-array name="reply_values">
<item>reply</item>
<item>reply_all</item>
</string-array>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#2196f3</color>
<color name="colorPrimaryDark">#1976d2</color>
<color name="colorPrimary">#FFFFFF</color> <color name="colorAccent">#FF9800</color>
<color name="colorPrimaryDark">#FFFFFF</color>
<color name="colorAccent">#FFFFFF</color>
<color name="textInputLayout">#96ffffff</color> <color name="textInputLayout">#96ffffff</color>
</resources> </resources>
<resources> <resources>
<string name="app_name">EchoProxy</string> <string name="app_name">EchoProxy</string>
<string name="title_activity_settings">SettingsActivity</string>
<!-- Preference Titles -->
<string name="messages_header">Messages</string>
<string name="sync_header">Sync</string>
<!-- Messages Preferences -->
<string name="signature_title">Your signature</string>
<string name="reply_title">Default reply action</string>
<!-- Sync Preferences -->
<string name="sync_title">Sync email periodically</string>
<string name="attachment_title">Download incoming attachments</string>
<string name="attachment_summary_on">Automatically download attachments for incoming emails
</string>
<string name="attachment_summary_off">Only download attachments when manually requested</string>
</resources> </resources>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:title="@string/messages_header">
<EditTextPreference
app:key="signature"
app:title="@string/signature_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"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/sync_header">
<SwitchPreferenceCompat
app:key="sync"
app:title="@string/sync_title" />
<SwitchPreferenceCompat
app:dependency="sync"
app:key="attachment"
app:summaryOff="@string/attachment_summary_off"
app:summaryOn="@string/attachment_summary_on"
app:title="@string/attachment_title" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
...@@ -14,7 +14,7 @@ org.gradle.jvmargs=-Xmx1536m ...@@ -14,7 +14,7 @@ org.gradle.jvmargs=-Xmx1536m
# AndroidX package structure to make it clearer which packages are bundled with the # AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK # Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn # https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=false android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX # Automatically convert third-party libraries to use AndroidX
android.enableJetifier=false android.enableJetifier=true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment