Browse Source

main fab

tags/v1.0.0
Robin Thoni 8 years ago
parent
commit
7b0fd53fe4

+ 1
- 0
app/build.gradle View File

@@ -53,6 +53,7 @@ dependencies {
53 53
     compile 'com.google.android.gms:play-services:9.6.1'
54 54
     compile 'com.android.support:multidex:1.0.1'
55 55
     compile 'com.google.maps.android:android-maps-utils:0.4+'
56
+    compile 'com.github.clans:fab:1.6.4'
56 57
 }
57 58
 
58 59
 apply plugin: 'com.google.gms.google-services'

+ 23
- 8
app/src/main/java/com/rthoni/stssaguenay/ui/activities/MainActivity.java View File

@@ -5,7 +5,6 @@ import android.content.Context;
5 5
 import android.content.DialogInterface;
6 6
 import android.content.Intent;
7 7
 import android.os.Bundle;
8
-import android.support.design.widget.FloatingActionButton;
9 8
 import android.support.design.widget.NavigationView;
10 9
 import android.support.multidex.MultiDex;
11 10
 import android.support.v4.app.FragmentManager;
@@ -32,6 +31,8 @@ import com.facebook.GraphResponse;
32 31
 import com.facebook.login.LoginManager;
33 32
 import com.facebook.login.LoginResult;
34 33
 import com.facebook.login.widget.LoginButton;
34
+import com.github.clans.fab.FloatingActionButton;
35
+import com.github.clans.fab.FloatingActionMenu;
35 36
 import com.google.android.gms.ads.AdRequest;
36 37
 import com.google.android.gms.ads.AdView;
37 38
 import com.google.android.gms.ads.MobileAds;
@@ -63,7 +64,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
63 64
     private boolean _goToHome = false;
64 65
 
65 66
     @BindView(R.id.fab)
66
-    FloatingActionButton _fab;
67
+    FloatingActionMenu _fab;
68
+
69
+    @BindView(R.id.fab_item_add_map)
70
+    FloatingActionButton _fabMap;
71
+
72
+    @BindView(R.id.fab_item_add_list)
73
+    FloatingActionButton _fabList;
67 74
 
68 75
     @BindView(R.id.nav_view)
69 76
     NavigationView _navigationView;
@@ -114,10 +121,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
114 121
         _textUserEmail = ButterKnife.findById(headerView, R.id.textUserEmail);
115 122
         _textHelpMessage = ButterKnife.findById(headerView, R.id.text_help_message);
116 123
 
117
-        _fab.setOnClickListener(new View.OnClickListener() {
124
+        _fabMap.setOnClickListener(new View.OnClickListener() {
125
+            @Override
126
+            public void onClick(View v) {
127
+                goToAddStop(true);
128
+            }
129
+        });
130
+
131
+        _fabList.setOnClickListener(new View.OnClickListener() {
118 132
             @Override
119
-            public void onClick(View view) {
120
-                goToAddStop();
133
+            public void onClick(View v) {
134
+                goToAddStop(false);
121 135
             }
122 136
         });
123 137
 
@@ -202,7 +216,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
202 216
 
203 217
     public void goToHome()
204 218
     {
205
-        _fab.show();
219
+        _fab.setVisibility(View.VISIBLE);
206 220
         HomeFragment f = new HomeFragment();
207 221
         f.setOnFavouriteStopClicked(new LuPromise.LuConsumer<UserFavouriteStopsDbo>() {
208 222
             @Override
@@ -215,7 +229,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
215 229
 
216 230
     public void goToStop(StopsDbo stopsDbo)
217 231
     {
218
-        _fab.hide();
232
+        _fab.setVisibility(View.GONE);
219 233
         StopViewerFragment f = new StopViewerFragment();
220 234
         f.setStopsDbo(stopsDbo);
221 235
         getSupportFragmentManager()
@@ -225,9 +239,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
225 239
                 .commit();
226 240
     }
227 241
 
228
-    public void goToAddStop()
242
+    public void goToAddStop(boolean map)
229 243
     {
230 244
         Intent intent = new Intent(this, StopPickerActivity.class);
245
+        intent.putExtra(StopPickerActivity.MAP_EXTRA_NAME, map);
231 246
         startActivityForResult(intent, ADD_FAVOURITE_STOP_REQUEST_CODE);
232 247
     }
233 248
 

+ 32
- 12
app/src/main/java/com/rthoni/stssaguenay/ui/activities/StopPickerActivity.java View File

@@ -18,13 +18,19 @@ import com.rthoni.stssaguenay.ui.fragments.StopRoutesPickerFragment;
18 18
 
19 19
 public class StopPickerActivity extends AppCompatActivity {
20 20
 
21
+    public static String MAP_EXTRA_NAME = "MAP_EXTRA";
22
+
21 23
     public static String STOP_EXTRA_NAME = "STOP_EXTRA";
22 24
 
25
+    private boolean _map;
26
+
23 27
     @Override
24 28
     protected void onCreate(Bundle savedInstanceState) {
25 29
         super.onCreate(savedInstanceState);
26 30
         setContentView(R.layout.activity_stop_picker);
27 31
 
32
+        _map = getIntent().getBooleanExtra(MAP_EXTRA_NAME, false);
33
+
28 34
         MobileAds.initialize(getApplicationContext(), getString(R.string.ad_init));
29 35
         AdView mAdView = (AdView) findViewById(R.id.adView);
30 36
         AdRequest adRequest = new AdRequest.Builder().build();
@@ -47,18 +53,32 @@ public class StopPickerActivity extends AppCompatActivity {
47 53
 
48 54
     public void goToStops()
49 55
     {
50
-//        StopListPickerFragment f = new StopListPickerFragment();
51
-        StopMapPickerFragment f = new StopMapPickerFragment();
52
-        f.setOnStopSelectedConsumer(new LuPromise.LuConsumer<StopsDbo>() {
53
-            @Override
54
-            public void execute(StopsDbo data) {
55
-                goToRoutes(data);
56
-            }
57
-        });
58
-        getSupportFragmentManager()
59
-                .beginTransaction()
60
-                .replace(R.id.container, f)
61
-                .commit();
56
+        if (_map) {
57
+            StopMapPickerFragment f = new StopMapPickerFragment();
58
+            f.setOnStopSelectedConsumer(new LuPromise.LuConsumer<StopsDbo>() {
59
+                @Override
60
+                public void execute(StopsDbo data) {
61
+                    goToRoutes(data);
62
+                }
63
+            });
64
+            getSupportFragmentManager()
65
+                    .beginTransaction()
66
+                    .replace(R.id.container, f)
67
+                    .commit();
68
+        }
69
+        else {
70
+            StopListPickerFragment f = new StopListPickerFragment();
71
+            f.setOnStopSelectedConsumer(new LuPromise.LuConsumer<StopsDbo>() {
72
+                @Override
73
+                public void execute(StopsDbo data) {
74
+                    goToRoutes(data);
75
+                }
76
+            });
77
+            getSupportFragmentManager()
78
+                    .beginTransaction()
79
+                    .replace(R.id.container, f)
80
+                    .commit();
81
+        }
62 82
     }
63 83
 
64 84
     public void goToRoutes(final StopsDbo stopDbo)

app/src/main/res/drawable/ic_add_black_24dp.xml → app/src/main/res/drawable/ic_add_white_24dp.xml View File


app/src/main/res/drawable/ic_archive_black_24dp.xml → app/src/main/res/drawable/ic_archive_white_24dp.xml View File

@@ -4,6 +4,6 @@
4 4
         android:viewportWidth="24.0"
5 5
         android:viewportHeight="24.0">
6 6
     <path
7
-        android:fillColor="#FF000000"
7
+        android:fillColor="#e9e9e9"
8 8
         android:pathData="M20.54,5.23l-1.39,-1.68C18.88,3.21 18.47,3 18,3H6c-0.47,0 -0.88,0.21 -1.16,0.55L3.46,5.23C3.17,5.57 3,6.02 3,6.5V19c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V6.5c0,-0.48 -0.17,-0.93 -0.46,-1.27zM12,17.5L6.5,12H10v-2h4v2h3.5L12,17.5zM5.12,5l0.81,-1h12l0.94,1H5.12z"/>
9 9
 </vector>

+ 9
- 0
app/src/main/res/drawable/ic_dehaze_white_24dp.xml View File

@@ -0,0 +1,9 @@
1
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+        android:width="24dp"
3
+        android:height="24dp"
4
+        android:viewportWidth="24.0"
5
+        android:viewportHeight="24.0">
6
+    <path
7
+        android:fillColor="#e9e9e9"
8
+        android:pathData="M2,15.5v2h20v-2L2,15.5zM2,10.5v2h20v-2L2,10.5zM2,5.5v2h20v-2L2,5.5z"/>
9
+</vector>

+ 9
- 0
app/src/main/res/drawable/ic_map_white_24dp.xml View File

@@ -0,0 +1,9 @@
1
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+        android:width="24dp"
3
+        android:height="24dp"
4
+        android:viewportWidth="24.0"
5
+        android:viewportHeight="24.0">
6
+    <path
7
+        android:fillColor="#e9e9e9"
8
+        android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
9
+</vector>

app/src/main/res/drawable/ic_open_in_new_black_24dp.xml → app/src/main/res/drawable/ic_open_in_new_white_24dp.xml View File

@@ -4,6 +4,6 @@
4 4
         android:viewportWidth="24.0"
5 5
         android:viewportHeight="24.0">
6 6
     <path
7
-        android:fillColor="#FF000000"
7
+        android:fillColor="#e9e9e9"
8 8
         android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/>
9 9
 </vector>

app/src/main/res/drawable/ic_unarchive_black_24dp.xml → app/src/main/res/drawable/ic_unarchive_white_24dp.xml View File

@@ -4,6 +4,6 @@
4 4
         android:viewportWidth="24.0"
5 5
         android:viewportHeight="24.0">
6 6
     <path
7
-        android:fillColor="#FF000000"
7
+        android:fillColor="#e9e9e9"
8 8
         android:pathData="M20.55,5.22l-1.39,-1.68C18.88,3.21 18.47,3 18,3H6c-0.47,0 -0.88,0.21 -1.15,0.55L3.46,5.22C3.17,5.57 3,6.01 3,6.5V19c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V6.5c0,-0.49 -0.17,-0.93 -0.45,-1.28zM12,9.5l5.5,5.5H14v2h-4v-2H6.5L12,9.5zM5.12,5l0.82,-1h12l0.93,1H5.12z"/>
9 9
 </vector>

+ 55
- 6
app/src/main/res/layout/app_bar_main.xml View File

@@ -4,6 +4,7 @@
4 4
                                                  xmlns:tools="http://schemas.android.com/tools"
5 5
                                                  android:layout_width="match_parent"
6 6
                                                  android:layout_height="match_parent"
7
+                                                 xmlns:fab="http://schemas.android.com/apk/res-auto"
7 8
                                                  android:fitsSystemWindows="true"
8 9
                                                  tools:context=".ui.activities.MainActivity">
9 10
 
@@ -23,12 +24,60 @@
23 24
 
24 25
     <include layout="@layout/content_main" />
25 26
 
26
-    <android.support.design.widget.FloatingActionButton
27
+    <com.github.clans.fab.FloatingActionMenu
27 28
         android:id="@+id/fab"
28
-        android:layout_width="wrap_content"
29
-        android:layout_height="wrap_content"
30
-        android:layout_gravity="bottom|end"
31
-        android:layout_margin="@dimen/fab_margin"
32
-        android:src="@drawable/ic_add_black_24dp"/>
29
+        android:layout_width="match_parent"
30
+        android:layout_height="match_parent"
31
+        android:layout_alignParentBottom="true"
32
+        fab:menu_fab_size="normal"
33
+        fab:menu_showShadow="true"
34
+        fab:menu_shadowColor="#66000000"
35
+        fab:menu_shadowRadius="4dp"
36
+        fab:menu_shadowXOffset="1dp"
37
+        fab:menu_shadowYOffset="3dp"
38
+        fab:menu_colorNormal="#DA4336"
39
+        fab:menu_colorPressed="#E75043"
40
+        fab:menu_colorRipple="#99FFFFFF"
41
+        fab:menu_animationDelayPerItem="50"
42
+        fab:menu_buttonSpacing="0dp"
43
+        fab:menu_labels_margin="0dp"
44
+        fab:menu_labels_showAnimation="@anim/fab_slide_in_from_right"
45
+        fab:menu_labels_hideAnimation="@anim/fab_slide_out_to_right"
46
+        fab:menu_labels_paddingRight="8dp"
47
+        fab:menu_labels_paddingBottom="4dp"
48
+        fab:menu_labels_padding="8dp"
49
+        fab:menu_labels_textColor="#FFFFFF"
50
+        fab:menu_labels_textSize="14sp"
51
+        fab:menu_labels_cornerRadius="3dp"
52
+        fab:menu_labels_colorNormal="#333333"
53
+        fab:menu_labels_colorPressed="#444444"
54
+        fab:menu_labels_colorRipple="#66FFFFFF"
55
+        fab:menu_labels_showShadow="true"
56
+        fab:menu_labels_singleLine="false"
57
+        fab:menu_labels_ellipsize="none"
58
+        fab:menu_labels_maxLines="-1"
59
+        fab:menu_labels_position="left"
60
+        fab:menu_openDirection="up"
61
+        fab:menu_backgroundColor="@android:color/transparent"
62
+        fab:menu_fab_label="@string/stop_add"
63
+        app:menu_icon="@drawable/ic_add_white_24dp">
64
+
65
+        <com.github.clans.fab.FloatingActionButton
66
+            android:id="@+id/fab_item_add_map"
67
+            android:layout_width="wrap_content"
68
+            android:layout_height="wrap_content"
69
+            android:src="@drawable/ic_map_white_24dp"
70
+            fab:fab_size="mini"
71
+            fab:fab_label="@string/stop_add_map" />
72
+
73
+        <com.github.clans.fab.FloatingActionButton
74
+            android:id="@+id/fab_item_add_list"
75
+            android:layout_width="wrap_content"
76
+            android:layout_height="wrap_content"
77
+            android:src="@drawable/ic_dehaze_white_24dp"
78
+            fab:fab_size="mini"
79
+            fab:fab_label="@string/stop_add_list" />
80
+
81
+    </com.github.clans.fab.FloatingActionMenu>
33 82
 
34 83
 </android.support.design.widget.CoordinatorLayout>

+ 1
- 1
app/src/main/res/layout/route_recycler_view_item.xml View File

@@ -12,7 +12,7 @@
12 12
     <ImageView
13 13
         android:layout_width="50dp"
14 14
         android:layout_height="50dp"
15
-        android:src="@drawable/ic_add_black_24dp"
15
+        android:src="@drawable/ic_add_white_24dp"
16 16
         android:id="@+id/imageView"
17 17
         android:paddingBottom="2.5dp"
18 18
         android:paddingRight="5dp"

+ 1
- 1
app/src/main/res/layout/route_schedules_recycler_view_item.xml View File

@@ -13,7 +13,7 @@
13 13
     <ImageView
14 14
         android:layout_width="50dp"
15 15
         android:layout_height="50dp"
16
-        android:src="@drawable/ic_add_black_24dp"
16
+        android:src="@drawable/ic_add_white_24dp"
17 17
         android:id="@+id/imageView"
18 18
         android:paddingBottom="2.5dp"
19 19
         android:paddingRight="5dp"

+ 3
- 3
app/src/main/res/menu/activity_main_drawer.xml View File

@@ -3,14 +3,14 @@
3 3
 
4 4
         <item
5 5
             android:id="@+id/nav_restore"
6
-            android:icon="@drawable/ic_archive_black_24dp"
6
+            android:icon="@drawable/ic_archive_white_24dp"
7 7
             android:title="@string/restore" />
8 8
         <item
9 9
             android:id="@+id/nav_backup"
10
-            android:icon="@drawable/ic_unarchive_black_24dp"
10
+            android:icon="@drawable/ic_unarchive_white_24dp"
11 11
             android:title="@string/backup" />
12 12
         <item
13 13
             android:id="@+id/nav_logout"
14
-            android:icon="@drawable/ic_open_in_new_black_24dp"
14
+            android:icon="@drawable/ic_open_in_new_white_24dp"
15 15
             android:title="@string/logout" />
16 16
 </menu>

+ 4
- 0
app/src/main/res/values/strings.xml View File

@@ -19,6 +19,10 @@
19 19
     <string name="save">Save</string>
20 20
     <string name="error_try_again">Error. Please try again.</string>
21 21
 
22
+    <string name="stop_add">Add a favourite stop</string>
23
+    <string name="stop_add_map">Add from map</string>
24
+    <string name="stop_add_list">Add from list</string>
25
+
22 26
     <string name="loading">Loading&#8230;</string>
23 27
     <string name="loading_schedules">Loading schedules&#8230;</string>
24 28
     <string name="loading_routes">Loading routes&#8230;</string>

Loading…
Cancel
Save