Commit 0d1f8020 authored by MUTTINENI NAVYA's avatar MUTTINENI NAVYA

added logout and my_posts in navigation

parent f027c249
......@@ -74,6 +74,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private void LDAPLogin()
{
final String ldap = ldap_id.getText().toString().trim();
String id = ldap_id.getText().toString().trim()+"@iitb.ac.in";
String password = ldap_password.getText().toString().trim();
if (id.isEmpty())
......@@ -95,7 +96,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
{
Toast.makeText(MainActivity.this,"LOGIN SUCCESSFUL",Toast.LENGTH_LONG).show();
Intent intent = new Intent(MainActivity.this, Navigation.class);
//intent.putExtra(ID, id);
intent.putExtra("username", ldap);
startActivity(intent);
}
......
......@@ -10,20 +10,25 @@ import androidx.drawerlayout.widget.DrawerLayout;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.navigation.NavigationView;
public class Navigation extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
private String username = null;
private DrawerLayout drawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation);
NavigationView navigationView = findViewById(R.id.nav);
username = getIntent().getStringExtra("username");
NavigationView navigationView = (NavigationView) findViewById(R.id.nav);
navigationView.setNavigationItemSelectedListener(this);
TextView ldapname = (TextView) navigationView.getHeaderView(0).findViewById(R.id.username);
ldapname.setText(username);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
......@@ -52,16 +57,23 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa
switch ((menuItem.getItemId())){
case R.id.post_found:
Intent intent = new Intent(Navigation.this, FoundItem.class);
//intent.putExtra(ID, id);
intent.putExtra("username", username);
startActivity(intent);
break;
case R.id.post_lost:
intent = new Intent(Navigation.this, LostItem.class);
//intent.putExtra(ID, id);
intent.putExtra("username", username);
startActivity(intent);
break;
case R.id.home:
Toast.makeText(this, "home", Toast.LENGTH_SHORT).show();
finish();
startActivity(getIntent());
break;
case R.id.my_posts:
// Redirect to myposts "FRAGMENT"
break;
case R.id.logout:
finish();
break;
}
......
......@@ -41,6 +41,21 @@
app:menu="@menu/menu_navigation"
android:layout_gravity="start">
<!-- <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<TextView
android:id="@+id/logout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/logout"/>
</LinearLayout>
-->
</com.google.android.material.navigation.NavigationView>
......
......@@ -14,4 +14,10 @@
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
<TextView
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
/>
</LinearLayout>
\ No newline at end of file
......@@ -16,6 +16,19 @@
<item
android:id="@+id/post_found"
android:title="@string/post_found_item" />
<item
android:id="@+id/my_posts"
android:title="@string/my_posts" />
</group>
<group android:checkableBehavior="single">
<item
android:id="@+id/logout"
android:title="@string/logout" />
</group>
</menu>
\ No newline at end of file
<resources>
<string name="app_name">HelloWorld</string>
<string name="app_name">Insti Lost and Found</string>
<string name="ldap_id">LDAP Id</string>
<string name="password">password</string>
<string name="login">Login</string>
......@@ -16,5 +16,7 @@
<string name="post_found_item">Post Found Item</string>
<string name="open_navigation">Open Navigation</string>
<string name="close_navigation">Close Navigation</string>
<string name="my_posts">My Posts</string>
<string name="logout">Logout</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment