regActivity

 <?xml version="1.0" encoding="utf-8"?>

<LinearLayout 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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".act.RegActivity">

<TextView
android:layout_width="match_parent"
android:text="@string/email_id"
android:gravity="center"
android:id="@+id/email_address"
android:layout_height="wrap_content"/>


<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="13dp"
android:gravity="center"
app:boxStrokeWidth="3dp"
app:endIconDrawable="@drawable/ic_baseline_keyboard_arrow_down_24"
app:endIconTint="@color/black">

<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/only"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|start"
android:gravity="center|start"
android:text="Select One"
android:inputType="none"
android:maxLines="1"
android:shadowRadius="3"
android:singleLine="true"
android:textStyle="bold"
app:autoSizeMaxTextSize="1000sp"
app:autoSizeMinTextSize="1sp"
app:autoSizeTextType="uniform">

</com.google.android.material.textfield.MaterialAutoCompleteTextView>

</com.google.android.material.textfield.TextInputLayout>




<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_gravity="top"
android:focusable="true"
app:boxStrokeWidth="3dp"
app:boxStrokeErrorColor="@color/design_default_color_error"
android:layout_height="wrap_content"
android:layout_margin="13dp"
android:hint="Your Budget"
app:helperTextEnabled="true"
app:helperText="How many money you can spent"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:endIconMode="clear_text"
app:endIconCheckable="true"
app:startIconDrawable="@drawable/ic_twotone_currency_rupee_24">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ThemeOverlay.Material3.TextInputEditText"
android:inputType="textEmailAddress">
</com.google.android.material.textfield.TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_gravity="top"
android:focusable="true"
app:boxStrokeWidth="3dp"
app:boxStrokeErrorColor="@color/design_default_color_error"
android:layout_height="wrap_content"
android:layout_margin="13dp"
android:hint="Phone Number"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:helperTextEnabled="true"
app:helperText="Optional | if you want to get call"
app:endIconMode="clear_text"
app:endIconCheckable="true"
app:startIconDrawable="@drawable/ic_twotone_smartphone_24">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"

android:layout_height="wrap_content"
style="@style/ThemeOverlay.Material3.TextInputEditText"
android:inputType="textEmailAddress">
</com.google.android.material.textfield.TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
app:strokeColor="@color/theme"
android:backgroundTint="@color/black"
android:textColor="@color/white"
android:elevation="20dp"
app:elevation="20dp"
android:text="Register"
android:drawableTint="@color/white"
android:id="@+id/signin"
android:layout_marginStart="40dp"
app:strokeWidth="2dp"
android:layout_marginEnd="40dp"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</com.google.android.material.button.MaterialButton>
</LinearLayout>




















package com.rscit.rscitapp.act;

import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.firebase.auth.FirebaseAuth;
import com.rscit.rscitapp.R;
import com.rscit.rscitapp.databinding.ActivityRegBinding;

import java.util.Objects;

public class RegActivity extends AppCompatActivity {
ActivityRegBinding binding;
String[] items = {"YouTube", "WebSite"};
ArrayAdapter<String> adapter1;
FirebaseAuth auth;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityRegBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

auth = FirebaseAuth.getInstance();

if (auth.getCurrentUser() == null) {
// User not signed in, handle appropriately (e.g., redirect to sign-in activity)
startActivity(new Intent(this, ContinueWithGoogle.class));
finish(); // Finish the current activity
return;
}

String email = Objects.requireNonNull(auth.getCurrentUser()).getEmail();
binding.emailAddress.setText(email);

adapter1 = new ArrayAdapter<>(this, R.layout.dropdownitemlist, items);
binding.only.setAdapter(adapter1);

binding.only.setOnItemClickListener((adapterView, view, i, l) -> {
String item = adapterView.getItemAtPosition(i).toString();
if (item.equals("YouTube")) {
Toast.makeText(this, "YouTube", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Website", Toast.LENGTH_SHORT).show();
}
});
}

@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}

private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager =
(ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);

if (connectivityManager != null) {
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}

return false;
}

@Override
protected void onResume() {
super.onResume();
if (!isNetworkAvailable()) {
Toast.makeText(this, "No internet connection. Some features may not work.", Toast.LENGTH_SHORT).show();
}
}
}

Comments

Post a Comment