Files
labsage-app/app/src/main/java/com/smi/smartlab/NavigationTop.java
2022-01-29 02:26:38 +05:30

130 lines
4.5 KiB
Java

package com.smi.smartlab;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
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 com.google.android.material.navigation.NavigationView;
public class NavigationTop extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
protected DrawerLayout draw;
private LinearLayout line;
private Toolbar tool;
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId())
{
case R.id.nav_contact_us:
Intent intent3=new Intent(this, About.class);
startActivity(intent3);
break;
// open();
case R.id.nav_home:
Intent intent2=new Intent(this, Home.class);
startActivity(intent2);
break;
case R.id.nav_logout:
Intent intent8=new Intent(this, LoginScreen.class);
SharedPreferences preferences = getSharedPreferences("PhoneBook_number", MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
// editor.putString(Name, phonenum);
editor.putString("Phone", null);
editor.putString("Name",null);
editor.commit();
startActivity(intent8);
break;
}
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_navigation__top);
draw = findViewById(R.id.Drawer);
line = findViewById(R.id.line);
tool = findViewById(R.id.tollbar);
NavigationView navigationView = findViewById(R.id.navigation);
navigationView.setNavigationItemSelectedListener(this);
setSupportActionBar(tool);
Window window = getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, draw, tool, R.string.open_navigation_drawer, R.string.close_navigation_drawer) {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
float sidebar = drawerView.getWidth() * slideOffset;
line.setTranslationX(sidebar);
}
};
draw.addDrawerListener(toggle);
toggle.syncState();
View headerView = navigationView.getHeaderView(0);
TextView textView=headerView.findViewById(R.id.text);
TextView textView1=headerView.findViewById(R.id.not_sign_in);
SharedPreferences preferences=getSharedPreferences("PhoneBook_number",MODE_PRIVATE);
String string1 = preferences.getString("Phone", null);
String string2 = preferences.getString("Name", null);
textView.setText(string2);
textView1.setText(string1);
}
public void open(){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setMessage("Contact Us :ShanMukha Innovations Pvt Ltd\n" +
"No. 25, 2nd floor, Ram Thulasi Chambers\n" +
"MS Ramaiah Road , Mathikere\n" +
"Bangalore, Karnataka 560054.\n" +
"\n" +
"Tel: +91 9742255674\n" +
"Email : info@sminnovations.in");
alertDialogBuilder.setPositiveButton("Okay",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
Intent intent = new Intent(NavigationTop.this, Home.class);
startActivity(intent);
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}