Skip to content

Commit

Permalink
Navigation Drawer Added
Browse files Browse the repository at this point in the history
  • Loading branch information
foram-patel-0201 committed Oct 15, 2021
1 parent 809bfc7 commit 174b368
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 97 additions & 1 deletion app/src/main/java/com/example/us_2_0/LandingPage.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,108 @@
package com.example.us_2_0;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.drawerlayout.widget.DrawerLayout;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

import com.google.android.material.navigation.NavigationView;

public class LandingPage extends AppCompatActivity {

private ActionBarDrawerToggle actionBarDrawerToggle;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_landing_page);


Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
actionBarDrawerToggle = new ActionBarDrawerToggle(LandingPage.this, drawerLayout, R.string.drawer_open, R.string.drawer_close);
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();

NavigationView navigationView = findViewById(R.id.navigationView);
View view = navigationView.inflateHeaderView(R.layout.navigation_header);
navigationView.setItemIconTintList(null);
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
UserItemSelected(item);
return false;
}
});
}


private void UserItemSelected(MenuItem item) {

switch (item.getItemId()){

case R.id.share:

Intent myIntent = new Intent(Intent.ACTION_SEND);
myIntent.setType("text/plain");
String shareBody = "http://play.google.com/store/apps/details?id="+getPackageName();
String shareSub = " Thanks for Sharing";
myIntent.putExtra(Intent.EXTRA_SUBJECT,shareSub);
myIntent.putExtra(Intent.EXTRA_TEXT,shareBody);
startActivity(Intent.createChooser(myIntent,"Share using"));
break;

case R.id.more:


//onclick more
break;

case R.id.rate:

//onclick rate
break;

case R.id.privacy:

//onclick privacy
break;
}

}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (actionBarDrawerToggle.onOptionsItemSelected(item)){
return true;
}

else if (item.getItemId()==R.id.about){

//onclick for about

}else if (item.getItemId()==R.id.disclaimer){

//onclick for disclaimer

}
return super.onOptionsItemSelected(item);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.action_bar_menu,menu);
return super.onCreateOptionsMenu(menu);
}
}
}
22 changes: 21 additions & 1 deletion app/src/main/java/com/example/us_2_0/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
package com.example.us_2_0;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.drawerlayout.widget.DrawerLayout;

import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;

import com.google.android.material.navigation.NavigationView;
import com.sawolabs.androidsdk.Sawo;

public class MainActivity extends AppCompatActivity {
//Trying to figure out how things work


private Handler H = new Handler();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);



}

public void Log(View view) {
Expand Down
55 changes: 43 additions & 12 deletions app/src/main/res/layout/activity_landing_page.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LandingPage">
android:background="#2196F3"
android:backgroundTint="#ECECEC"
android:foregroundTint="#8C7676"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView3"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#5BB4BA"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#119499"
android:theme="@style/ThemeOverlay.AppCompat.DayNight"
app:titleTextColor="#FFFFFF"
app:subtitleTextColor="#FFFFFF"

/>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">


</androidx.constraintlayout.widget.ConstraintLayout>

</LinearLayout>

<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/navigation_menu"
android:background="#FFFFFF"
app:itemTextColor="#000000"/>


</androidx.drawerlayout.widget.DrawerLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/navigation_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@android:color/transparent"
android:contentDescription="@string/todo"
android:contentDescription="todo"
android:src="@mipmap/ic_launcher" />

<TextView
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/menu/action_bar_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/about"
android:title="About"
android:iconTint="#5E5E5E"
app:showAsAction="never"/>
<item
android:id="@+id/disclaimer"
android:title="Disclaimer"
android:iconTint="#5E5E5E"
app:showAsAction="never"/>



</menu>
24 changes: 24 additions & 0 deletions app/src/main/res/menu/navigation_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/share"
android:title="Share"
/>
<item
android:id="@+id/more"
android:title="More Apps"
/>
<item
android:id="@+id/rate"
android:title="Feedback"
/>
<item
android:id="@+id/privacy"
android:title="Privacy"
/>




</menu>
2 changes: 1 addition & 1 deletion app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.US_2_0" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.US_2_0" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">US_2_0</string>

<string name="drawer_open">Drawer Open</string>
<string name="drawer_close">Drawer Close</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.US_2_0" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.US_2_0" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand Down

0 comments on commit 174b368

Please sign in to comment.