implementation("de.hdodenhof:circleimageview:3.1.0")
UI Faces | Free AI-generated avatars for your creative projects
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="<http://schemas.android.com/apk/res/android>"
xmlns:app="<http://schemas.android.com/apk/res-auto>"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="Admin Dashboard" />
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<!-- Welcome Text -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome Back"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jane Doe"
android:textSize="32sp"
android:textStyle="bold" />
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Admin" />
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/profile" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="20dp" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Actions"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="20dp"
android:background="#ccc" />
<!-- CARDs SECTION-->
<com.google.android.material.card.MaterialCardView
android:id="@+id/manage_users"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/team" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_weight="1"
android:text="Manage Users"
android:textAlignment="center"
android:textStyle="bold" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/chevron_right" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/manage_technicians"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/medical_team" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_weight="1"
android:text="Manage Technicians"
android:textAlignment="center"
android:textStyle="bold" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/chevron_right" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
package com.example.techsupporthub;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.card.MaterialCardView;
import com.google.firebase.auth.FirebaseAuth;
public class AdminActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
private Button logoutButton;
private MaterialCardView manageUsers, manageTechnicians;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin);
// Initialize Firebase Auth
mAuth = FirebaseAuth.getInstance();
// Initialize the variables
manageUsers = findViewById(R.id.manage_users);
manageTechnicians = findViewById(R.id.manage_technicians);
// Find the MaterialToolbar and set it as the action bar
MaterialToolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
manageUsers.setOnClickListener(v -> {
Toast.makeText(this, "Manage Users", Toast.LENGTH_SHORT).show();
});
manageTechnicians.setOnClickListener(v -> {
Toast.makeText(this, "Manage Technicians", Toast.LENGTH_SHORT).show();
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.admin_main_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
// Handle action bar item clicks here.
int id = item.getItemId();
if (id == R.id.action_notifications) {
// Handle the notifications action
showNotifications();
return true;
} else if (id == R.id.action_logout) {
// Handle the logout action
showLogoutConfirmationDialog();
return true;
}
return super.onOptionsItemSelected(item);
}
private void showLogoutConfirmationDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Logout Confirmation")
.setMessage("Are you sure you want to logout?")
.setIcon(R.drawable.logo) // Set the app icon
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
logoutUser();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
private void logoutUser() {
// Logout the user from Firebase
mAuth.signOut();
// Redirect to login activity
Intent intent = new Intent(AdminActivity.this, LoginActivity.class);
startActivity(intent);
finish(); // Close the current activity
}
private void showNotifications() {
Toast.makeText(this, "Notifications", Toast.LENGTH_SHORT).show();
// Implement the logic to show notifications
// For example, you can start a new activity or open a fragment
}
@Override
public void onBackPressed() {
showExitConfirmationDialog();
}
private void showExitConfirmationDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Exit Confirmation")
.setMessage("Are you sure you want to exit the app?")
.setIcon(R.drawable.logo) // Set the app icon
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish(); // Close the current activity
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
<?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/action_logout"
app:showAsAction="never"
android:title="Logout"/><item android:id="@+id/action_notifications"
app:showAsAction="never"
android:title="Notification"/>
</menu>
Happy Hunting 😊