Skip to content

Commit bbd5456

Browse files
committed
Optimized ui
1 parent d29542f commit bbd5456

20 files changed

+178
-53
lines changed

CHANGE.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
##1.0.7 Beta
2+
3+
+ Optimized UI.
4+
15
##1.0.6 Beta
26

37
+ Fixed auto connect ANR when device startup.

Readme.cn.md

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* pdnsd: [GPLv3](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/pdnsd/COPYING)
3636
* libev: [GPLv2](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/libev/LICENSE)
3737
* libevent: [BSD](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/libevent/LICENSE)
38-
* SystemBarTint: [ApacheV2](https://github.com/jgilfelt/SystemBarTint)
3938
* Hawk: [ApacheV2](https://github.com/orhanobut/hawk/blob/master/LICENSE)
4039
* libsuperuser: [ApacheV2](https://github.com/Chainfire/libsuperuser/blob/master/LICENSE)
4140

Readme.md

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ If you have any advices or questions, You can pull request, submit issue or send
3535
* pdnsd: [GPLv3](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/pdnsd/COPYING)
3636
* libev: [GPLv2](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/libev/LICENSE)
3737
* libevent: [BSD](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/libevent/LICENSE)
38-
* SystemBarTint: [ApacheV2](https://github.com/jgilfelt/SystemBarTint)
3938
* Hawk: [ApacheV2](https://github.com/orhanobut/hawk/blob/master/LICENSE)
4039
* libsuperuser: [ApacheV2](https://github.com/Chainfire/libsuperuser/blob/master/LICENSE)
4140

app/app.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
9595
<orderEntry type="sourceFolder" forTests="false" />
9696
<orderEntry type="library" exported="" name="org.xbill.dns_2.1.7" level="project" />
97-
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
9897
<orderEntry type="library" exported="" name="core-2.0" level="project" />
98+
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
9999
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
100100
<orderEntry type="library" exported="" name="core-3.1.0" level="project" />
101101
<orderEntry type="library" exported="" name="android-2.0" level="project" />

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "com.proxy.shadowsocksr"
1111
minSdkVersion 14
1212
targetSdkVersion 23
13-
versionCode 7
14-
versionName "1.0.6 Beta"
13+
versionCode 8
14+
versionName "1.0.7 Beta"
1515
}
1616
buildTypes {
1717
debug {

app/src/main/AndroidManifest.xml

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@
1313
<uses-permission-sdk-23 android:name="android.permission.ACCESS_SUPERUSER"/>
1414
<uses-permission-sdk-23 android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
1515

16+
<supports-screens
17+
android:anyDensity="true"
18+
android:largeScreens="true"
19+
android:normalScreens="true"
20+
android:smallScreens="true"
21+
android:xlargeScreens="true"/>
22+
1623
<application
1724
android:name=".SSRApplication"
1825
android:allowBackup="true"
1926
android:fullBackupContent="true"
27+
android:hardwareAccelerated="true"
2028
android:icon="@mipmap/ic_launcher"
2129
android:label="@string/app_name"
2230
android:multiArch="true"
@@ -25,7 +33,7 @@
2533
android:name=".MainActivity"
2634
android:configChanges="orientation|screenSize"
2735
android:label="@string/app_name"
28-
android:theme="@style/AppTheme.NoActionBar">
36+
android:theme="@style/AppTheme">
2937
<intent-filter>
3038
<action android:name="android.intent.action.MAIN"/>
3139

@@ -34,7 +42,8 @@
3442
</activity>
3543

3644
<activity
37-
android:name=".ProxyAppsActivity"/>
45+
android:name=".ProxyAppsActivity"
46+
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
3847

3948
<activity
4049
android:name=".StubActivity"

app/src/main/java/com/proxy/shadowsocksr/MainActivity.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
import android.view.MenuItem;
2424
import android.view.View;
2525
import android.widget.AdapterView;
26-
import android.widget.ArrayAdapter;
2726
import android.widget.ImageView;
2827
import android.widget.Spinner;
2928
import android.widget.Toast;
3029

3130
import com.orhanobut.hawk.Hawk;
31+
import com.proxy.shadowsocksr.adapter.ToolbarSpinnerAdapter;
3232
import com.proxy.shadowsocksr.fragment.PrefFragment;
3333
import com.proxy.shadowsocksr.items.ConnectProfile;
3434
import com.proxy.shadowsocksr.items.GlobalProfile;
@@ -57,7 +57,7 @@ public class MainActivity extends Activity
5757
private NavigationView nav;
5858
private FloatingActionButton fab;
5959
//
60-
private ArrayAdapter<String> spinnerAdapter;
60+
private ToolbarSpinnerAdapter tsAdapter;
6161
private List<String> spinnerItemLst;
6262
//
6363
private PrefFragment pref;
@@ -221,10 +221,8 @@ private void setupUI()
221221
});
222222
//
223223
spinnerItemLst = new ArrayList<>();
224-
spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item,
225-
spinnerItemLst);
226-
spinnerAdapter.setDropDownViewResource(R.layout.spinner_list_item);
227-
spinner.setAdapter(spinnerAdapter);
224+
tsAdapter = new ToolbarSpinnerAdapter(spinnerItemLst);
225+
spinner.setAdapter(tsAdapter);
228226
//
229227
spinner.setOnItemSelectedListener(this);
230228
//
@@ -239,9 +237,9 @@ public void loadServerList()
239237
{
240238
spinnerItemLst.add(svr);
241239
}
242-
spinnerAdapter.notifyDataSetChanged();
240+
tsAdapter.notifyDataSetChanged();
243241
String cur = Hawk.get("CurrentServer");
244-
spinner.setSelection(spinnerAdapter.getPosition(cur));
242+
spinner.setSelection(tsAdapter.getPosition(cur));
245243
}
246244

247245
private void addNewServer(String server, int rmtPort, String method, String pwd)

app/src/main/java/com/proxy/shadowsocksr/ProxyAppsActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ProxyAppsActivity extends Activity implements AppsAdapter.OnItemCli
2727
@Override protected void onCreate(Bundle savedInstanceState)
2828
{
2929
super.onCreate(savedInstanceState);
30-
setContentView(R.layout.activity_choose_app_to_proxy);
30+
setContentView(R.layout.activity_proxy_apps);
3131
rvApps = (RecyclerView) findViewById(R.id.rv_proxy_apps);
3232
rvApps.setLayoutManager(new LinearLayoutManager(this));
3333
rvApps.setHasFixedSize(true);

app/src/main/java/com/proxy/shadowsocksr/StubActivity.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
public class StubActivity extends Activity implements ServiceConnection
2222
{
23-
private BroadcastReceiver receiver;
23+
private BroadcastReceiver receiver=null;
2424

25-
private ISSRService ssrs;
25+
private ISSRService ssrs=null;
2626

2727
@Override protected void onResume()
2828
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.proxy.shadowsocksr.adapter;
2+
3+
import android.view.LayoutInflater;
4+
import android.view.View;
5+
import android.view.ViewGroup;
6+
import android.widget.BaseAdapter;
7+
import android.widget.TextView;
8+
9+
import com.proxy.shadowsocksr.R;
10+
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
public class ToolbarSpinnerAdapter extends BaseAdapter
15+
{
16+
private List<String> items = new ArrayList<>();
17+
18+
public ToolbarSpinnerAdapter(List<String> items)
19+
{
20+
this.items = items;
21+
}
22+
23+
public int getPosition(String item)
24+
{
25+
return items.indexOf(item);
26+
}
27+
28+
@Override
29+
public int getCount()
30+
{
31+
return items.size();
32+
}
33+
34+
@Override
35+
public Object getItem(int position)
36+
{
37+
return items.get(position);
38+
}
39+
40+
@Override
41+
public long getItemId(int position)
42+
{
43+
return position;
44+
}
45+
46+
@Override
47+
public View getDropDownView(int position, View view, ViewGroup parent)
48+
{
49+
if (view == null || !view.getTag().toString().equals("DROPDOWN"))
50+
{
51+
view = LayoutInflater.from(parent.getContext())
52+
.inflate(R.layout.toolbar_spinner_dropdown_item, parent, false);
53+
view.setTag("DROPDOWN");
54+
}
55+
56+
TextView textView = (TextView) view.findViewById(android.R.id.text1);
57+
textView.setText(getTitle(position));
58+
59+
return view;
60+
}
61+
62+
@Override
63+
public View getView(int position, View view, ViewGroup parent)
64+
{
65+
if (view == null || !view.getTag().toString().equals("NON_DROPDOWN"))
66+
{
67+
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.
68+
toolbar_spinner_item,
69+
parent, false);
70+
view.setTag("NON_DROPDOWN");
71+
}
72+
TextView textView = (TextView) view.findViewById(android.R.id.text1);
73+
textView.setText(getTitle(position));
74+
return view;
75+
}
76+
77+
private String getTitle(int position)
78+
{
79+
return position >= 0 && position < items.size() ? items.get(position) : "";
80+
}
81+
}

app/src/main/res/layout/activity_apps.xml

-5
This file was deleted.

app/src/main/res/layout/activity_main.xml

+12-7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
<android.support.design.widget.CoordinatorLayout
1313
android:layout_width="match_parent"
14-
android:layout_height="match_parent"
15-
android:fitsSystemWindows="true">
14+
android:layout_height="match_parent">
1615

1716
<android.support.design.widget.AppBarLayout
1817
android:id="@+id/appbar"
@@ -22,15 +21,21 @@
2221
<android.support.v7.widget.Toolbar
2322
android:id="@+id/toolbar"
2423
android:layout_width="match_parent"
25-
android:layout_height="?attr/actionBarSize"
26-
android:background="?attr/colorPrimary">
24+
android:layout_height="wrap_content"
25+
android:background="?attr/colorPrimary"
26+
android:minHeight="?attr/actionBarSize"
27+
android:theme="@style/ThemeOverlay.AppCompat.Light"
28+
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
2729

2830
<Spinner
2931
android:id="@+id/spinner_nav"
30-
android:layout_marginStart="12dp"
32+
style="@style/AppTheme.Base.Spinner"
3133
android:layout_width="match_parent"
32-
android:layout_height="wrap_content"
33-
android:layout_marginEnd="16dp"/>
34+
android:layout_height="match_parent"
35+
android:layout_marginEnd="16dp"
36+
android:layout_marginLeft="12dp"
37+
android:layout_marginRight="16dp"
38+
android:layout_marginStart="12dp"/>
3439
</android.support.v7.widget.Toolbar>
3540
</android.support.design.widget.AppBarLayout>
3641

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<TextView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:id="@android:id/text1"
5+
android:layout_width="match_parent"
6+
android:layout_height="48dp"
7+
android:drawablePadding="8dp"
8+
android:gravity="center_vertical|start"
9+
android:paddingLeft="16dp"
10+
android:paddingRight="16dp"
11+
android:textColor="#ff333333"
12+
android:textSize="16sp"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<TextView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:id="@android:id/text1"
5+
android:layout_width="wrap_content"
6+
android:layout_height="wrap_content"
7+
android:drawablePadding="8dp"
8+
android:drawableRight="@mipmap/spinner_triangle"
9+
android:drawableEnd="@mipmap/spinner_triangle"
10+
android:textColor="#ffffffff"
11+
android:textStyle="bold"/>
+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
4-
<style name="AppTheme.NoActionBar">
5-
<item name="android:windowTranslucentNavigation">true</item>
3+
<style name="AppTheme" parent="AppTheme.Base">
64
<item name="android:windowTranslucentStatus">true</item>
5+
<item name="android:windowTranslucentNavigation">true</item>
76
</style>
87
</resources>
+11-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<resources>
22

3-
<style name="AppTheme.NoActionBar">
4-
<item name="windowActionBar">false</item>
5-
<item name="windowNoTitle">true</item>
3+
<style name="AppTheme" parent="AppTheme.Base">
4+
<item name="android:navigationBarColor">@android:color/transparent</item>
65
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
76
<item name="android:statusBarColor">@android:color/transparent</item>
7+
<item name="android:windowTranslucentStatus">true</item>
8+
<item name="android:windowTranslucentNavigation">true</item>
9+
</style>
10+
11+
<style name="AppTheme.Base.Spinner" parent="Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
12+
<item name="android:background">?android:selectableItemBackground</item>
13+
<item name="android:dropDownSelector">?android:selectableItemBackground</item>
14+
<item name="android:divider">@null</item>
15+
<item name="android:overlapAnchor">true</item>
816
</style>
917
</resources>

app/src/main/res/values/colors.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Palette generated by Material Palette - materialpalette.com/blue/light-blue -->
3+
<resources>
4+
<color name="primary">#2196F3</color>
5+
<color name="primary_dark">#1976D2</color>
6+
<color name="primary_light">#BBDEFB</color>
7+
<color name="accent">#03A9F4</color>
8+
<color name="primary_text">#212121</color>
9+
<color name="secondary_text">#727272</color>
10+
<color name="icons">#FFFFFF</color>
11+
<color name="divider">#B6B6B6</color>
12+
</resources>

app/src/main/res/values/styles.xml

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
<resources>
22

3-
<style name="AppTheme" parent="Theme.AppCompat.Light">
4-
<item name="colorAccent">#03A9F4</item>
5-
<item name="colorPrimary">#2196F3</item>
6-
<item name="colorPrimaryDark">#1976D2</item>
3+
<style name="AppTheme" parent="AppTheme.Base">
74
</style>
85

9-
<style name="AppTheme.NoActionBar">
6+
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
107
<item name="windowActionBar">false</item>
118
<item name="windowNoTitle">true</item>
9+
<item name="colorAccent">@color/accent</item>
10+
<item name="colorPrimary">@color/primary</item>
11+
<item name="colorPrimaryDark">@color/primary_dark</item>
1212
</style>
1313

14-
<style name="AppTheme.NoActionBar.FullScreen">
15-
<item name="windowActionBar">false</item>
16-
<item name="windowNoTitle">true</item>
17-
<item name="android:windowFullscreen">true</item>
18-
</style>
19-
20-
<style name="AppTheme.Spinner" parent="Widget.AppCompat.Light.DropDownItem.Spinner">
21-
<item name="android:textColorPrimary">@android:color/primary_text_dark</item>
14+
<style name="AppTheme.Base.Spinner" parent="Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
15+
<item name="android:background">?android:selectableItemBackground</item>
16+
<item name="android:dropDownSelector">?android:selectableItemBackground</item>
17+
<item name="android:divider">@null</item>
18+
<item name="overlapAnchor">true</item>
2219
</style>
23-
24-
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Light"/>
25-
26-
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
2720
</resources>

0 commit comments

Comments
 (0)