Using Navigation Drawer
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 4 Sep 2016 01:09:39 +0000 (03:09 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 4 Sep 2016 01:11:00 +0000 (03:11 +0200)
22 files changed:
app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java
app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java
app/src/main/res/drawable-hdpi/ic_menu_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-hdpi/ic_perm_device_information_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-mdpi/ic_menu_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-mdpi/ic_perm_device_information_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-xhdpi/ic_menu_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-xhdpi/ic_perm_device_information_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-xxhdpi/ic_menu_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-xxhdpi/ic_perm_device_information_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-xxxhdpi/ic_menu_white_24dp.png [new file with mode: 0644]
app/src/main/res/drawable-xxxhdpi/ic_perm_device_information_white_24dp.png [new file with mode: 0644]
app/src/main/res/layout/weather_about.xml
app/src/main/res/layout/weather_general_toolbar.xml [new file with mode: 0644]
app/src/main/res/layout/weather_main_drawer_entry_list.xml [new file with mode: 0644]
app/src/main/res/layout/weather_main_drawer_header.xml [new file with mode: 0644]
app/src/main/res/layout/weather_main_tabs.xml
app/src/main/res/menu/weather_main_menu.xml
app/src/main/res/values-v11/styles.xml
app/src/main/res/values-v14/styles.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml

index 6ef65d0..452473f 100644 (file)
@@ -20,6 +20,7 @@ import android.net.Uri;
 import android.os.Bundle;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
 import android.view.View;
 
 import name.gumartinm.weather.information.R;
@@ -31,8 +32,10 @@ public class AboutActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         this.setContentView(R.layout.weather_about);
 
+        final Toolbar toolbar = (Toolbar) findViewById(R.id.weather_main_toolbar);
+        this.setSupportActionBar(toolbar);
+
         final ActionBar actionBar = this.getSupportActionBar();
-        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
         actionBar.setDisplayHomeAsUpEnabled(true);
         actionBar.setDisplayShowHomeEnabled(true);
         actionBar.setIcon(R.drawable.ic_launcher);
index 85090a9..fd3a004 100644 (file)
@@ -17,18 +17,24 @@ package name.gumartinm.weather.information.activity;
 
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
+import android.support.design.widget.NavigationView;
 import android.support.design.widget.TabLayout;
 import android.support.v4.app.DialogFragment;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentPagerAdapter;
 import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBar;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarDrawerToggle;
 import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.View;
 
 import java.text.MessageFormat;
 import java.util.Locale;
@@ -43,66 +49,40 @@ import name.gumartinm.weather.information.model.WeatherLocation;
 
 public class MainTabsActivity extends AppCompatActivity {
     private static final int NUM_ITEMS = 2;
-    private ViewPager mPager;
-    private TabLayout tabLayout;
+
+    private Toolbar mToolbar;
+    private TabLayout mTabLayout;
+    private DrawerLayout mDrawerLayout;
+    private NavigationView mNavigationView;
+    private ActionBarDrawerToggle mDrawerToggle;
     
     @Override
     protected void onCreate(final Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         this.setContentView(R.layout.weather_main_tabs);
 
-        this.mPager = (ViewPager)this.findViewById(R.id.pager);
-        this.mPager.setAdapter(new TabsAdapter(this.getSupportFragmentManager()));
-
-        // Give the TabLayout the ViewPager
-        tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
-        tabLayout.setupWithViewPager(mPager);
+        this.mToolbar = (Toolbar) findViewById(R.id.weather_main_toolbar);
+        this.mToolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
+        this.mToolbar.setNavigationContentDescription(R.string.drawer_open);
+        this.setSupportActionBar(mToolbar);
 
-        final ActionBar actionBar = this.getSupportActionBar();
-        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
-        actionBar.setDisplayUseLogoEnabled(true);
-        actionBar.setDisplayShowTitleEnabled(true);
-        actionBar.setDisplayHomeAsUpEnabled(true);
-        actionBar.setDisplayShowHomeEnabled(true);
-        actionBar.setIcon(R.drawable.ic_launcher);
+        this.mDrawerLayout = (DrawerLayout) findViewById(R.id.weather_main_drawer_layout);
+        this.mDrawerToggle = this.doDrawerToggle(this.mDrawerLayout, this.mToolbar);
+        // Set the drawer toggle as the DrawerListener
+        this.mDrawerLayout.addDrawerListener(mDrawerToggle);
 
-        PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false);
-    }
+        this.mNavigationView = (NavigationView) findViewById(R.id.weather_main_left_drawer);
+        // Set the list's click listener
+        this.mNavigationView.setNavigationItemSelectedListener(new NavigationViewClickListener());
 
-    @Override
-    public boolean onCreateOptionsMenu(final Menu menu) {
+        final ViewPager pager = (ViewPager)this.findViewById(R.id.pager);
+        pager.setAdapter(new TabsAdapter(this.getSupportFragmentManager()));
 
-        this.getMenuInflater().inflate(R.menu.weather_main_menu, menu);
-
-        return super.onCreateOptionsMenu(menu);
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(final MenuItem item) {
-        // Handle action bar item clicks here. The action bar will
-        // automatically handle clicks on the Home/Up button, so long
-        // as you specify a parent activity in AndroidManifest.xml.
-        super.onOptionsItemSelected(item);
-
-        Intent intent;
-        final int itemId = item.getItemId();
-        if (itemId == R.id.weather_menu_settings) {
-            intent = new Intent(this.getApplicationContext(), PreferencesActivity.class);
-            this.startActivity(intent);
-            return true;
-        } else if (itemId == R.id.weather_menu_map) {
-            intent = new Intent(this.getApplicationContext(), MapActivity.class);
-            this.startActivity(intent);
-            return true;
-        } else if (itemId == R.id.weather_menu_about) {
-            intent = new Intent(this.getApplicationContext(), AboutActivity.class);
-            this.startActivity(intent);
-            return true;
-        } else {
-        }
+        // Give the TabLayout the ViewPager
+        this.mTabLayout = (TabLayout) findViewById(R.id.weather_main_sliding_tabs);
+        this.mTabLayout.setupWithViewPager(pager);
 
-        // TODO: calling again super method?
-        return super.onOptionsItemSelected(item);
+        PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false);
     }
 
     @Override
@@ -133,7 +113,6 @@ public class MainTabsActivity extends AppCompatActivity {
 
 
         // 1. Update title.
-        final ActionBar actionBar = this.getSupportActionBar();
         final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
         final WeatherLocation weatherLocation = query.queryDataBase();
         if (weatherLocation != null) {
@@ -142,14 +121,14 @@ public class MainTabsActivity extends AppCompatActivity {
             array[1] = weatherLocation.getCountry();
             final MessageFormat message = new MessageFormat("{0},{1}", Locale.US);
             final String cityCountry = message.format(array);
-            actionBar.setTitle(cityCountry);
+            mToolbar.setTitle(cityCountry);
         } else {
-               actionBar.setTitle(this.getString(R.string.text_field_no_chosen_location));
+            mToolbar.setTitle(this.getString(R.string.text_field_no_chosen_location));
         }
 
         // 2. Set currently tab text.
         final String currently = this.getString(R.string.text_tab_currently);
-        tabLayout.getTabAt(0).setText(currently);
+        this.mTabLayout.getTabAt(0).setText(currently);
 
         // 3. Update forecast tab text.
         final String keyPreference = this.getString(R.string.weather_preferences_day_forecast_key);
@@ -162,7 +141,7 @@ public class MainTabsActivity extends AppCompatActivity {
         } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_fourteen_day))) {
             forecast = this.getString(R.string.text_tab_fourteen_days_forecast);
         }
-        tabLayout.getTabAt(1).setText(forecast);
+        this.mTabLayout.getTabAt(1).setText(forecast);
     }
 
     @Override
@@ -170,6 +149,56 @@ public class MainTabsActivity extends AppCompatActivity {
         super.onSaveInstanceState(savedInstanceState);
     }
 
+    @Override
+    protected void onPostCreate(Bundle savedInstanceState) {
+        super.onPostCreate(savedInstanceState);
+        // Sync the toggle state after onRestoreInstanceState has occurred.
+        mDrawerToggle.syncState();
+    }
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+
+        this.mDrawerToggle.onConfigurationChanged(newConfig);
+    }
+
+    /* Called whenever we call invalidateOptionsMenu() */
+    @Override
+    public boolean onPrepareOptionsMenu(Menu menu) {
+        // If the nav drawer is open, hide action items related to the content view
+        boolean drawerOpen = this.mDrawerLayout.isDrawerOpen(this.mNavigationView);
+        if (!drawerOpen) {
+            this.mToolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
+        }
+
+        return super.onPrepareOptionsMenu(menu);
+    }
+
+    private ActionBarDrawerToggle doDrawerToggle(final DrawerLayout drawerLayout, final Toolbar toolbar) {
+        // ActionBarDrawerToggle ties together the the proper interactions
+        // between the sliding drawer and the action bar app icon
+        return new ActionBarDrawerToggle(
+                this,
+                drawerLayout,
+                toolbar,
+                R.string.drawer_open,
+                R.string.drawer_close
+        ) {
+            @Override
+            public void onDrawerClosed(View drawerView) {
+                super.onDrawerOpened(drawerView);
+                MainTabsActivity.this.invalidateOptionsMenu();
+            }
+
+            @Override
+            public void onDrawerOpened(View drawerView) {
+                super.onDrawerOpened(drawerView);
+                MainTabsActivity.this.invalidateOptionsMenu();
+            }
+        };
+    }
+
     private class TabsAdapter extends FragmentPagerAdapter {
 
         public TabsAdapter(final FragmentManager fm) {
@@ -191,4 +220,39 @@ public class MainTabsActivity extends AppCompatActivity {
 
         }
     }
+
+    private class NavigationViewClickListener implements NavigationView.OnNavigationItemSelectedListener {
+
+        @Override
+        public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
+            //Checking if the item is in checked state or not, if not make it in checked state
+            if(item.isChecked()) {
+                item.setChecked(false);
+            }
+
+            final int itemId = item.getItemId();
+            if (itemId == R.id.weather_menu_settings) {
+                //Closing drawer on item click
+                MainTabsActivity.this.mDrawerLayout.closeDrawers();
+                Intent intent = new Intent(MainTabsActivity.this.getApplicationContext(), PreferencesActivity.class);
+                MainTabsActivity.this.startActivity(intent);
+                return true;
+            } else if (itemId == R.id.weather_menu_map) {
+                //Closing drawer on item click
+                MainTabsActivity.this.mDrawerLayout.closeDrawers();
+                Intent intent = new Intent(MainTabsActivity.this.getApplicationContext(), MapActivity.class);
+                MainTabsActivity.this.startActivity(intent);
+                return true;
+            } else if (itemId == R.id.weather_menu_about) {
+                //Closing drawer on item click
+                MainTabsActivity.this.mDrawerLayout.closeDrawers();
+                Intent intent = new Intent(MainTabsActivity.this.getApplicationContext(), AboutActivity.class);
+                MainTabsActivity.this.startActivity(intent);
+                return true;
+            } else {
+                return false;
+            }
+
+        }
+    }
 }
diff --git a/app/src/main/res/drawable-hdpi/ic_menu_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_menu_white_24dp.png
new file mode 100644 (file)
index 0000000..238cfd6
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_menu_white_24dp.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_perm_device_information_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_perm_device_information_white_24dp.png
new file mode 100644 (file)
index 0000000..e7c1ea3
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_perm_device_information_white_24dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_menu_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_menu_white_24dp.png
new file mode 100644 (file)
index 0000000..d3cec05
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_menu_white_24dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_perm_device_information_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_perm_device_information_white_24dp.png
new file mode 100644 (file)
index 0000000..7e37ba1
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_perm_device_information_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_menu_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_menu_white_24dp.png
new file mode 100644 (file)
index 0000000..193185f
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_menu_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_perm_device_information_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_perm_device_information_white_24dp.png
new file mode 100644 (file)
index 0000000..3c658c8
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_perm_device_information_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_menu_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_menu_white_24dp.png
new file mode 100644 (file)
index 0000000..9cb0348
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_menu_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_perm_device_information_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_perm_device_information_white_24dp.png
new file mode 100644 (file)
index 0000000..9f70599
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_perm_device_information_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_menu_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_menu_white_24dp.png
new file mode 100644 (file)
index 0000000..623d147
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_menu_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_perm_device_information_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_perm_device_information_white_24dp.png
new file mode 100644 (file)
index 0000000..f467eb2
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_perm_device_information_white_24dp.png differ
index 659570e..3316c59 100644 (file)
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<!-- The main content view -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:padding="0dip"
+    android:gravity="center_horizontal"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-    <LinearLayout
-        android:orientation="vertical"
+    <include layout="@layout/weather_general_toolbar"/>
+
+    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-
-        <ImageView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:contentDescription="@string/icon_weather_description"
-            android:orientation="horizontal"
-            android:src="@drawable/ic_launcher" />
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application"
-            android:textColor="?android:attr/colorForeground"
-            android:padding="5dp"
-            android:layout_gravity="start" />
-        <View style="@style/Divider"
-            android:layout_height="2dp"/>
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_version"
-            android:padding="20dp"
-            android:layout_gravity="start" />
-        <View style="@style/Divider"/>
-
-        <TextView
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_legal"
-            android:padding="20dp"
-            android:layout_gravity="start"
-            android:clickable="true"
-            android:background="?android:attr/selectableItemBackground"
-            android:onClick="onClickLegalInformation"/>
-        <View style="@style/Divider"/>
-
-        <TextView
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_source_code"
-            android:padding="20dp"
-            android:layout_gravity="start"
-            android:clickable="true"
-            android:background="?android:attr/selectableItemBackground"
-            android:onClick="onClickSourceCode"/>
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_remote_data"
-            android:textColor="?android:attr/colorForeground"
-            android:padding="5dp"
-            android:layout_gravity="start" />
-        <View style="@style/Divider"
-            android:layout_height="2dp"/>
-
-        <TextView
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_remote_data_openweathermap"
-            android:padding="20dp"
-            android:layout_gravity="start"
-            android:clickable="true"
-            android:background="?android:attr/selectableItemBackground"
-            android:onClick="onClickRemoteData"/>
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_developer"
-            android:textColor="?android:attr/colorForeground"
-            android:padding="5dp"
-            android:layout_gravity="start" />
-        <View style="@style/Divider"
-            android:layout_height="2dp"/>
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_developer_name"
-            android:padding="20dp"
-            android:layout_gravity="start" />
-        <View style="@style/Divider"/>
-
-        <TextView
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="@string/weather_about_application_developer_web"
-            android:padding="20dp"
-            android:layout_gravity="start"
-            android:clickable="true"
-            android:background="?android:attr/selectableItemBackground"
-            android:onClick="onClickMyWeb"/>
-        <View style="@style/Divider"/>
-    </LinearLayout>
-</ScrollView>
\ No newline at end of file
+        android:layout_height="match_parent">
+
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+
+            <ImageView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:contentDescription="@string/icon_weather_description"
+                android:orientation="horizontal"
+                android:src="@drawable/ic_launcher" />
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application"
+                android:textColor="?android:attr/colorForeground"
+                android:padding="5dp"
+                android:layout_gravity="start" />
+            <View style="@style/Divider"
+                android:layout_height="2dp"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_version"
+                android:padding="20dp"
+                android:layout_gravity="start" />
+            <View style="@style/Divider"/>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_legal"
+                android:padding="20dp"
+                android:layout_gravity="start"
+                android:clickable="true"
+                android:background="?android:attr/selectableItemBackground"
+                android:onClick="onClickLegalInformation"/>
+            <View style="@style/Divider"/>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_source_code"
+                android:padding="20dp"
+                android:layout_gravity="start"
+                android:clickable="true"
+                android:background="?android:attr/selectableItemBackground"
+                android:onClick="onClickSourceCode"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_remote_data"
+                android:textColor="?android:attr/colorForeground"
+                android:padding="5dp"
+                android:layout_gravity="start" />
+            <View style="@style/Divider"
+                android:layout_height="2dp"/>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_remote_data_openweathermap"
+                android:padding="20dp"
+                android:layout_gravity="start"
+                android:clickable="true"
+                android:background="?android:attr/selectableItemBackground"
+                android:onClick="onClickRemoteData"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_developer"
+                android:textColor="?android:attr/colorForeground"
+                android:padding="5dp"
+                android:layout_gravity="start" />
+            <View style="@style/Divider"
+                android:layout_height="2dp"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_developer_name"
+                android:padding="20dp"
+                android:layout_gravity="start" />
+            <View style="@style/Divider"/>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/weather_about_application_developer_web"
+                android:padding="20dp"
+                android:layout_gravity="start"
+                android:clickable="true"
+                android:background="?android:attr/selectableItemBackground"
+                android:onClick="onClickMyWeb"/>
+            <View style="@style/Divider"/>
+        </LinearLayout>
+    </ScrollView>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/weather_general_toolbar.xml b/app/src/main/res/layout/weather_general_toolbar.xml
new file mode 100644 (file)
index 0000000..08ac0de
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/weather_main_toolbar"
+    android:layout_width="match_parent"
+    android:layout_height="?attr/actionBarSize"
+    android:background="?attr/colorPrimary"
+    android:elevation="4dp"
+    app:logo="@drawable/ic_launcher"
+    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
+    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
diff --git a/app/src/main/res/layout/weather_main_drawer_entry_list.xml b/app/src/main/res/layout/weather_main_drawer_entry_list.xml
new file mode 100644 (file)
index 0000000..d5082ec
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/weather_main_drawer_entry"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    android:text="@string/weather_preferences_action_settings"
+    android:textAlignment="center"
+    android:textStyle="bold" />
+
+
diff --git a/app/src/main/res/layout/weather_main_drawer_header.xml b/app/src/main/res/layout/weather_main_drawer_header.xml
new file mode 100644 (file)
index 0000000..cd9fef8
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <ImageView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:contentDescription="@string/icon_weather_description"
+        android:layout_margin="20dp"
+        android:src="@drawable/ic_launcher" />
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:textAppearance="?android:attr/textAppearanceLarge"
+        android:text="@string/app_name"
+        android:textColor="?android:attr/colorForeground"
+        android:layout_margin="20dp"/>
+
+</LinearLayout>
index c1e137a..5636a08 100644 (file)
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:orientation="vertical"
-    android:padding="4dip"
-    android:gravity="center_horizontal"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/weather_main_drawer_layout"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    tools:context="name.gumartinm.weather.information.activity.MainTabsActivity">
 
-    <android.support.design.widget.TabLayout
-        android:id="@+id/sliding_tabs"
+    <!-- The main content view -->
+    <LinearLayout
+        android:orientation="vertical"
+        android:padding="0dip"
+        android:gravity="center_horizontal"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_gravity="top"
-        app:tabMaxWidth="0dp"
-        app:tabGravity="fill"
-        app:tabMode="fixed"
-        android:fillViewport="false">
-    </android.support.design.widget.TabLayout>
-
-    <android.support.v4.view.ViewPager
+        android:layout_height="match_parent">
+
+        <include layout="@layout/weather_general_toolbar"/>
+
+        <android.support.design.widget.TabLayout
+            android:id="@+id/weather_main_sliding_tabs"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="top"
+            android:layout_margin="4dip"
+            app:tabMaxWidth="0dp"
+            app:tabGravity="fill"
+            app:tabMode="fixed"
+            android:fillViewport="false">
+        </android.support.design.widget.TabLayout>
+
+        <android.support.v4.view.ViewPager
             android:id="@+id/pager"
             android:layout_width="match_parent"
             android:layout_height="0px"
-            android:layout_weight="1">
-    </android.support.v4.view.ViewPager>
+            android:layout_weight="1"
+            android:layout_margin="4dip">
+        </android.support.v4.view.ViewPager>
+    </LinearLayout>
+
+
+    <!-- The navigation drawer -->
+    <android.support.design.widget.NavigationView
+        android:id="@+id/weather_main_left_drawer"
+        android:layout_height="match_parent"
+        android:layout_width="wrap_content"
+        android:layout_gravity="start"
+        app:headerLayout="@layout/weather_main_drawer_header"
+        app:menu="@menu/weather_main_menu"/>
+
+</android.support.v4.widget.DrawerLayout>
+
+
 
-</LinearLayout>
index 3be5333..7efc69b 100644 (file)
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto" >
-    
-    
-    <item android:id="@+id/weather_menu_settings"
-        android:menuCategory="system"
-        android:title="@string/weather_preferences_action_settings"
-        android:titleCondensed="@string/weather_preferences_action_settings"
-        android:checked="false"
-        android:visible="true"
-        android:checkable="false"
-        android:enabled="true"
-        android:icon="@drawable/ic_action_settings"
-        app:showAsAction="ifRoom">
-    </item>
-    <item android:id="@+id/weather_menu_map"
-        android:icon="@drawable/ic_action_map"
-        app:showAsAction="ifRoom"
-        android:visible="true"
-        android:checkable="false"
-        android:enabled="true"
-        android:checked="false"
-        android:title="@string/weather_map_action_map"
-        android:titleCondensed="@string/weather_map_action_map">
-    </item>
-    <item android:id="@+id/weather_menu_about"
-        app:showAsAction="never"
-        android:visible="true"
-        android:checkable="false"
-        android:enabled="true"
-        android:checked="false"
-        android:orderInCategory="100"
-        android:title="@string/weather_about_action"
-        android:titleCondensed="@string/weather_about_action">
-    </item>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <group android:checkableBehavior="single">
+
+        <item android:id="@+id/weather_menu_map"
+            android:icon="@drawable/ic_action_map"
+            android:visible="true"
+            android:enabled="true"
+            android:checked="false"
+            android:title="@string/weather_map_action_map"
+            android:titleCondensed="@string/weather_map_action_map">
+        </item>
+        <item android:id="@+id/weather_menu_settings"
+            android:icon="@drawable/ic_action_settings"
+            android:title="@string/weather_preferences_action_settings"
+            android:titleCondensed="@string/weather_preferences_action_settings"
+            android:checked="false"
+            android:visible="true"
+            android:enabled="true">
+        </item>
+        <item android:id="@+id/weather_menu_about"
+            android:icon="@drawable/ic_perm_device_information_white_24dp"
+            android:visible="true"
+            android:enabled="true"
+            android:checked="false"
+            android:orderInCategory="100"
+            android:title="@string/weather_about_action"
+            android:titleCondensed="@string/weather_about_action">
+        </item>
+
+    </group>
 
 </menu>
index 175d9eb..2da02d1 100644 (file)
@@ -20,7 +20,7 @@
         Base application theme for API 11+. This theme completely replaces
         AppBaseTheme from res/values/styles.xml on API 11+ devices.
     -->
-    <style name="AppBaseTheme" parent="Theme.AppCompat">
+    <style name="AppBaseTheme" parent="Theme.AppCompat.NoActionBar">
         <!-- API 11 theme customizations can go here. -->
     </style>
 
index 4fb0b9c..0ad62e2 100644 (file)
@@ -21,7 +21,7 @@
         AppBaseTheme from BOTH res/values/styles.xml and
         res/values-v11/styles.xml on API 14+ devices.
     -->
-    <style name="AppBaseTheme" parent="Theme.AppCompat">
+    <style name="AppBaseTheme" parent="Theme.AppCompat.NoActionBar">
         <!-- API 14 theme customizations can go here. -->
     </style>
 
index 72942c5..a263002 100644 (file)
     <string name="weather_preferences_day_forecast_five_day">5</string>
     <string name="weather_preferences_day_forecast_ten_day">10</string>
     <string name="weather_preferences_day_forecast_fourteen_day">14</string>
+    <string name="drawer_open">Open navigation drawer</string>
+    <string name="drawer_close">Close navigation drawer</string>
 
 
     <!-- BootReceiver -->
index 8d14eff..b270ece 100644 (file)
@@ -20,7 +20,7 @@
         Base application theme, dependent on API level. This theme is replaced
         by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
     -->
-    <style name="AppBaseTheme" parent="Theme.AppCompat">
+    <style name="AppBaseTheme" parent="Theme.AppCompat.NoActionBar">
         <!--
             Theme customizations available in newer API levels can go in
             res/values-vXX/styles.xml, while customizations related to