From 8cca1a447d7e80d4434fcea6d03abbeb675662d4 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 3 Jul 2016 17:33:11 +0300 Subject: [PATCH] Navbar experiment --- app/build.gradle | 39 ++++--- app/src/main/AndroidManifest.xml | 13 ++- .../sagi/thesocialnotework/MainActivity.java | 110 ++++++++++++++++++ .../thesocialnotework/PersonalFragment.java | 52 +++++++++ .../main/res/drawable-v21/ic_menu_camera.xml | 12 ++ .../main/res/drawable-v21/ic_menu_gallery.xml | 9 ++ .../main/res/drawable-v21/ic_menu_manage.xml | 9 ++ .../main/res/drawable-v21/ic_menu_send.xml | 9 ++ .../main/res/drawable-v21/ic_menu_share.xml | 9 ++ .../res/drawable-v21/ic_menu_slideshow.xml | 9 ++ app/src/main/res/drawable/side_nav_bar.xml | 9 ++ app/src/main/res/layout/activity_main.xml | 25 ++++ app/src/main/res/layout/app_bar_main.xml | 38 ++++++ app/src/main/res/layout/content_main.xml | 15 +++ app/src/main/res/layout/fragment_personal.xml | 54 +++++++++ app/src/main/res/layout/nav_header_main.xml | 34 ++++++ .../main/res/menu/activity_main_drawer.xml | 32 +++++ app/src/main/res/menu/main.xml | 9 ++ app/src/main/res/values/dimens.xml | 3 + app/src/main/res/values/drawables.xml | 8 ++ app/src/main/res/values/strings.xml | 11 +- 21 files changed, 484 insertions(+), 25 deletions(-) create mode 100644 app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java create mode 100644 app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java create mode 100644 app/src/main/res/drawable-v21/ic_menu_camera.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_gallery.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_manage.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_send.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_share.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_slideshow.xml create mode 100644 app/src/main/res/drawable/side_nav_bar.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/app_bar_main.xml create mode 100644 app/src/main/res/layout/content_main.xml create mode 100644 app/src/main/res/layout/fragment_personal.xml create mode 100644 app/src/main/res/layout/nav_header_main.xml create mode 100644 app/src/main/res/menu/activity_main_drawer.xml create mode 100644 app/src/main/res/menu/main.xml create mode 100644 app/src/main/res/values/drawables.xml diff --git a/app/build.gradle b/app/build.gradle index 6e84724..b0751b4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,28 +1,29 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 23 + buildToolsVersion "23.0.3" - defaultConfig { - applicationId "com.android_app.matan.ara.sagi.thesocialnotework" - minSdkVersion 19 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + defaultConfig { + applicationId "com.android_app.matan.ara.sagi.thesocialnotework" + minSdkVersion 19 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } } - } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.3.0' - compile 'com.android.support:design:23.3.0' - compile 'com.android.volley:volley:1.0.0' + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.3.0' + compile 'com.android.support:design:23.3.0' + compile 'com.android.volley:volley:1.0.0' + compile 'com.android.support:support-v4:23.3.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 914731c..bec0f35 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,11 +2,10 @@ - - - + + @@ -20,7 +19,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> @@ -28,8 +27,12 @@ - + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java new file mode 100644 index 0000000..209aca0 --- /dev/null +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java @@ -0,0 +1,110 @@ +package com.android_app.matan.ara.sagi.thesocialnotework; + +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v4.app.FragmentTransaction; +import android.util.Log; +import android.view.View; +import android.support.design.widget.NavigationView; +import android.support.v4.view.GravityCompat; +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; + +public class MainActivity extends AppCompatActivity + implements NavigationView.OnNavigationItemSelectedListener { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( + this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + drawer.setDrawerListener(toggle); + toggle.syncState(); + + NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); + navigationView.setNavigationItemSelectedListener(this); + + //Change Layout + PersonalFragment personalFragment = new PersonalFragment(); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container, personalFragment); + ft.commit(); + Log.d("TAG", "asdasdasdasdasdsssssssssssssssssssssssssssssssss"); + } + + @Override + public void onBackPressed() { + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(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. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @SuppressWarnings("StatementWithEmptyBody") + @Override + public boolean onNavigationItemSelected(MenuItem item) { + // Handle navigation view item clicks here. + int id = item.getItemId(); + + if (id == R.id.nav_explore) { + // Handle the camera action + } else if (id == R.id.nav_map) { + + } else if (id == R.id.nav_personal) { + + } else if (id == R.id.nav_settings) { + + } else if (id == R.id.nav_logout) { + + } + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + drawer.closeDrawer(GravityCompat.START); + return true; + } + + +} diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java new file mode 100644 index 0000000..82c1c74 --- /dev/null +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java @@ -0,0 +1,52 @@ +package com.android_app.matan.ara.sagi.thesocialnotework; + +import android.content.Context; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +/** + * A simple {@link Fragment} subclass. + * Activities that contain this fragment must implement the + * to handle interaction events. + */ +public class PersonalFragment extends Fragment { + + + public PersonalFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_personal, container, false); + } + + + + @Override + public void onAttach(Context context) { + super.onAttach(context); +// if (context instanceof OnFragmentInteractionListener) { +// mListener = (OnFragmentInteractionListener) context; +// } else { +// throw new RuntimeException(context.toString() +// + " must implement OnFragmentInteractionListener"); +// } + } + + @Override + public void onDetach() { + super.onDetach(); +// mListener = null; + } + + +} diff --git a/app/src/main/res/drawable-v21/ic_menu_camera.xml b/app/src/main/res/drawable-v21/ic_menu_camera.xml new file mode 100644 index 0000000..0d9ea10 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_camera.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_gallery.xml b/app/src/main/res/drawable-v21/ic_menu_gallery.xml new file mode 100644 index 0000000..f6872c4 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_gallery.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_manage.xml b/app/src/main/res/drawable-v21/ic_menu_manage.xml new file mode 100644 index 0000000..c1be60b --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_manage.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v21/ic_menu_send.xml b/app/src/main/res/drawable-v21/ic_menu_send.xml new file mode 100644 index 0000000..00c668c --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_send.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_share.xml b/app/src/main/res/drawable-v21/ic_menu_share.xml new file mode 100644 index 0000000..a28fb9e --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_share.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_slideshow.xml b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml new file mode 100644 index 0000000..209aa64 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml new file mode 100644 index 0000000..4e5523d --- /dev/null +++ b/app/src/main/res/drawable/side_nav_bar.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..a61d8a6 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml new file mode 100644 index 0000000..85577dc --- /dev/null +++ b/app/src/main/res/layout/app_bar_main.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..ce1fbf2 --- /dev/null +++ b/app/src/main/res/layout/content_main.xml @@ -0,0 +1,15 @@ + + + + diff --git a/app/src/main/res/layout/fragment_personal.xml b/app/src/main/res/layout/fragment_personal.xml new file mode 100644 index 0000000..1f43f6c --- /dev/null +++ b/app/src/main/res/layout/fragment_personal.xml @@ -0,0 +1,54 @@ + + + + + + + + + +