Commit 9d4716df authored by Ishankha K.C's avatar Ishankha K.C

add device contacts

parent 65f7e087
...@@ -340,10 +340,16 @@ public class ActivityLogsActivity extends AppCompatActivity { ...@@ -340,10 +340,16 @@ public class ActivityLogsActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -48,10 +48,16 @@ public class ApplicationSettingsActivity extends AppCompatActivity { ...@@ -48,10 +48,16 @@ public class ApplicationSettingsActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -186,10 +186,16 @@ public class BabyDashboardActivity extends AppCompatActivity implements AddBabyD ...@@ -186,10 +186,16 @@ public class BabyDashboardActivity extends AppCompatActivity implements AddBabyD
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -85,10 +85,16 @@ public class DashboardActivity extends AppCompatActivity { ...@@ -85,10 +85,16 @@ public class DashboardActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -44,10 +44,16 @@ public class DeviceControlsActivity extends AppCompatActivity { ...@@ -44,10 +44,16 @@ public class DeviceControlsActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
package com.kaluwa.enterprises.babycare.activities; package com.kaluwa.enterprises.babycare.activities;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.clearToken; import static com.kaluwa.enterprises.babycare.config.TokenSaver.clearToken;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.getToken;
import static com.kaluwa.enterprises.babycare.utils.Utils.animationChanger; import static com.kaluwa.enterprises.babycare.utils.Utils.animationChanger;
import static com.kaluwa.enterprises.babycare.utils.Utils.loader;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
...@@ -20,11 +31,35 @@ import androidx.core.graphics.Insets; ...@@ -20,11 +31,35 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.ybq.android.spinkit.SpinKitView;
import com.google.gson.Gson;
import com.kaluwa.enterprises.babycare.MainActivity; import com.kaluwa.enterprises.babycare.MainActivity;
import com.kaluwa.enterprises.babycare.R; import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.config.ApiConfig;
import com.kaluwa.enterprises.babycare.dto.BabyDto;
import com.kaluwa.enterprises.babycare.dto.ContactInfoDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.error.ErrorDto;
import com.kaluwa.enterprises.babycare.service.ContactInfoService;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class DeviceSettingsActivity extends AppCompatActivity { public class DeviceSettingsActivity extends AppCompatActivity {
private final static String TAG = "DeviceSettingsActivity";
private AuthenticationDto authDto;
private LinearLayout btnSetCradleCont, btnSetNannyCont;
private ContactInfoService contactInfoService;
private ContactInfoDto contactInfoDto = new ContactInfoDto();
private View overlay;
private SpinKitView progressbar;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -32,7 +67,253 @@ public class DeviceSettingsActivity extends AppCompatActivity { ...@@ -32,7 +67,253 @@ public class DeviceSettingsActivity extends AppCompatActivity {
// define actionbar // define actionbar
defineActionbar(); defineActionbar();
// initialize user api service
try {
authDto = getToken(getApplicationContext());
} catch (JsonProcessingException e) {
Log.e(TAG, "Error: "+e.getMessage());
Toast.makeText(this, "Error getting token, Please refresh", Toast.LENGTH_SHORT).show();
}
contactInfoService = ApiConfig.getInstance().getContactInfoApi(authDto.getTokenDto().getToken());
// find view by id
btnSetCradleCont = findViewById(R.id.btnSetCradleCont);
btnSetNannyCont = findViewById(R.id.btnSetNannyCont);
overlay = findViewById(R.id.overlay);
progressbar = findViewById(R.id.progress_bar);
// set on click listener
onClickers();
}
private void onClickers() {
btnSetCradleCont.setOnClickListener(v -> {
String type = "cradle";
getContactInfoByType(type);
});
btnSetNannyCont.setOnClickListener(v -> {
String type = "nanny";
getContactInfoByType(type);
});
}
private void getContactInfoByType(String type) {
Call<ContactInfoDto> call = contactInfoService.getContactInfoByUserIdAndType(authDto.getUserId(), type);
loader(overlay, progressbar, true);
call.enqueue(new Callback<ContactInfoDto>() {
@Override
public void onResponse(Call<ContactInfoDto> call, Response<ContactInfoDto> response) {
if (response.isSuccessful()) {
contactInfoDto = new ContactInfoDto();
if (response.body() != null) {
contactInfoDto = response.body();
}
loader(overlay, progressbar, false);
showAddEditViewDialog(type);
} else {
try {
Gson gson = new Gson();
assert response.errorBody() != null;
String errorBodyString = response.errorBody().string();
// Check if the error body is in JSON format
if (errorBodyString.startsWith("{")) {
ErrorDto errorDto = gson.fromJson(errorBodyString, ErrorDto.class);
Toast.makeText(DeviceSettingsActivity.this, errorDto.getMessage(), Toast.LENGTH_LONG).show();
showAddEditViewDialog(type);
} else {
// If the error body is not in JSON format, display a generic error message
Log.e(TAG, errorBodyString);
Toast.makeText(DeviceSettingsActivity.this, "An unexpected error occurred", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e(TAG, "else-error: " + e.getMessage());
// Toast.makeText(DeviceSettingsActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
loader(overlay, progressbar, false);
} }
}
@Override
public void onFailure(Call<ContactInfoDto> call, Throwable throwable) {
Log.e(TAG, throwable.getMessage());
Toast.makeText(DeviceSettingsActivity.this, "Error to Failure", Toast.LENGTH_LONG).show();
loader(overlay, progressbar, false);
}
});
}
private void showAddEditViewDialog(String type) {
String titleType = type.substring(0, 1).toUpperCase() + type.substring(1);
String action;
if (contactInfoDto.getContactInfoId() != null) {
action = "edit";
} else {
action = "add";
}
// Inflate the dialog layout
View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_configure_contact_info, null);
// Initialize the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialogView);
// Find views within the dialog
EditText etContName = dialogView.findViewById(R.id.aci_et_cont_name);
EditText etMobileNo = dialogView.findViewById(R.id.aci_et_mobile);
// Set dialog behavior based on action
TextView title = new TextView(this);
title.setBackgroundColor(getResources().getColor(R.color.purple));
title.setPadding(10, 10, 10, 10);
title.setGravity(Gravity.CENTER);
title.setTextColor(Color.WHITE);
title.setTextSize(20);
switch (action) {
case "add":
title.setText("Add "+titleType+" Contact Info");
break;
case "edit":
title.setText("Edit "+titleType+" Contact Info");
etContName.setText(contactInfoDto.getContactName());
etMobileNo.setText(contactInfoDto.getContactNo());
break;
}
builder.setCustomTitle(title);
// Add positive button (Save) action
builder.setPositiveButton(contactInfoDto.getContactInfoId() == null ? "Save" : "Edit", null);
// Add negative button (Cancel) action
builder.setNegativeButton("Cancel", (dialog, which) -> {
contactInfoDto = new ContactInfoDto();
dialog.dismiss();
});
// Create and show the dialog
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnShowListener(dialogInterface -> {
// Set the negative button action
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(getResources().getColor(R.color.line_outline));
// set the positive button action
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
// Get data from EditTexts
String contactName = etContName.getText().toString();
String contactNo = etMobileNo.getText().toString();
// Validate input fields
if (TextUtils.isEmpty(contactName)) {
etContName.setError("Contact name is required");
etContName.requestFocus();
} else if (TextUtils.isEmpty(contactNo)) {
etMobileNo.setError("Contact number is required");
etMobileNo.requestFocus();
} else {
// If no errors, proceed to save or update
if (action.equals("add")) {
// Create and save new contact
ContactInfoDto newContactInfoDto = new ContactInfoDto();
newContactInfoDto.setUserId(authDto.getUserId());
newContactInfoDto.setContactName(contactName);
newContactInfoDto.setContactNo(contactNo);
newContactInfoDto.setType(type);
// call api to save contact info
Call<ContactInfoDto> call = contactInfoService.createContactInfo(newContactInfoDto);
loader(overlay, progressbar, true);
call.enqueue(new Callback<ContactInfoDto>() {
@Override
public void onResponse(Call<ContactInfoDto> call, Response<ContactInfoDto> response) {
if (response.isSuccessful()) {
Toast.makeText(DeviceSettingsActivity.this, titleType+" contact info saved successfully", Toast.LENGTH_LONG).show();
loader(overlay, progressbar, false);
dialog.dismiss();
} else {
try {
Gson gson = new Gson();
assert response.errorBody() != null;
String errorBodyString = response.errorBody().string();
// Check if the error body is in JSON format
if (errorBodyString.startsWith("{")) {
ErrorDto errorDto = gson.fromJson(errorBodyString, ErrorDto.class);
Toast.makeText(DeviceSettingsActivity.this, errorDto.getMessage(), Toast.LENGTH_LONG).show();
} else {
// If the error body is not in JSON format, display a generic error message
Log.e(TAG, errorBodyString);
Toast.makeText(DeviceSettingsActivity.this, "An unexpected error occurred", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e(TAG, "else-error: " + e.getMessage());
Toast.makeText(DeviceSettingsActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
loader(overlay, progressbar, false);
}
}
@Override
public void onFailure(Call<ContactInfoDto> call, Throwable throwable) {
Log.e(TAG, throwable.getMessage());
Toast.makeText(DeviceSettingsActivity.this, "Error to Failure", Toast.LENGTH_LONG).show();
loader(overlay, progressbar, false);
}
});
} else {
// Update existing contact
contactInfoDto.setContactName(contactName);
contactInfoDto.setContactNo(contactNo);
// call api to update contact info
Call<ContactInfoDto> call = contactInfoService.updateContactInfo(contactInfoDto.getContactInfoId(), contactInfoDto);
loader(overlay, progressbar, true);
call.enqueue(new Callback<ContactInfoDto>() {
@Override
public void onResponse(Call<ContactInfoDto> call, Response<ContactInfoDto> response) {
if (response.isSuccessful()) {
Toast.makeText(DeviceSettingsActivity.this, titleType+" contact info updated successfully", Toast.LENGTH_LONG).show();
loader(overlay, progressbar, false);
dialog.dismiss();
} else {
try {
Gson gson = new Gson();
assert response.errorBody() != null;
String errorBodyString = response.errorBody().string();
// Check if the error body is in JSON format
if (errorBodyString.startsWith("{")) {
ErrorDto errorDto = gson.fromJson(errorBodyString, ErrorDto.class);
Toast.makeText(DeviceSettingsActivity.this, errorDto.getMessage(), Toast.LENGTH_LONG).show();
} else {
// If the error body is not in JSON format, display a generic error message
Log.e(TAG, errorBodyString);
Toast.makeText(DeviceSettingsActivity.this, "An unexpected error occurred", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e(TAG, "else-error: " + e.getMessage());
Toast.makeText(DeviceSettingsActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
loader(overlay, progressbar, false);
}
}
@Override
public void onFailure(Call<ContactInfoDto> call, Throwable throwable) {
Log.e(TAG, throwable.getMessage());
Toast.makeText(DeviceSettingsActivity.this, "Error to Failure", Toast.LENGTH_LONG).show();
loader(overlay, progressbar, false);
}
});
}
}
});
});
dialog.show();
}
private void defineActionbar() { private void defineActionbar() {
Toolbar toolbar = findViewById(R.id.b_care_action_bar); Toolbar toolbar = findViewById(R.id.b_care_action_bar);
...@@ -48,10 +329,16 @@ public class DeviceSettingsActivity extends AppCompatActivity { ...@@ -48,10 +329,16 @@ public class DeviceSettingsActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -180,10 +180,16 @@ public class LiveFeedActivity extends AppCompatActivity { ...@@ -180,10 +180,16 @@ public class LiveFeedActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -67,10 +67,16 @@ public class LiveVocalActivity extends AppCompatActivity { ...@@ -67,10 +67,16 @@ public class LiveVocalActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -82,10 +82,16 @@ public class SettingsActivity extends AppCompatActivity { ...@@ -82,10 +82,16 @@ public class SettingsActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -481,10 +481,16 @@ public class UserProfileActivity extends AppCompatActivity { ...@@ -481,10 +481,16 @@ public class UserProfileActivity extends AppCompatActivity {
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> { popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.mm_device_setting) { if (id == R.id.mm_dashboard) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, DashboardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
animationChanger(this);
finish();
} else if (id == R.id.mm_app_setting) { } else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
} else if (id == R.id.mm_logout) { } else if (id == R.id.mm_logout) {
clearToken(getApplicationContext()); clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
......
...@@ -9,6 +9,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; ...@@ -9,6 +9,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.kaluwa.enterprises.babycare.service.ActivityLogsApiService; import com.kaluwa.enterprises.babycare.service.ActivityLogsApiService;
import com.kaluwa.enterprises.babycare.service.AuthApiService; import com.kaluwa.enterprises.babycare.service.AuthApiService;
import com.kaluwa.enterprises.babycare.service.BabyApiService; import com.kaluwa.enterprises.babycare.service.BabyApiService;
import com.kaluwa.enterprises.babycare.service.ContactInfoService;
import com.kaluwa.enterprises.babycare.service.DocumentApiService; import com.kaluwa.enterprises.babycare.service.DocumentApiService;
import com.kaluwa.enterprises.babycare.service.UserApiService; import com.kaluwa.enterprises.babycare.service.UserApiService;
...@@ -83,4 +84,9 @@ public class ApiConfig { ...@@ -83,4 +84,9 @@ public class ApiConfig {
AUTH_TOKEN = JWTToken; AUTH_TOKEN = JWTToken;
return retrofitOther.create(ActivityLogsApiService.class); return retrofitOther.create(ActivityLogsApiService.class);
} }
public ContactInfoService getContactInfoApi(String JWTToken) {
AUTH_TOKEN = JWTToken;
return retrofitOther.create(ContactInfoService.class);
}
} }
package com.kaluwa.enterprises.babycare.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ContactInfoDto {
private Long contactInfoId;
private String contactName;
private String contactNo;
private String type;
private UserDto user;
private Long userId;
}
package com.kaluwa.enterprises.babycare.service;
import com.kaluwa.enterprises.babycare.dto.ContactInfoDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.ResponseDto;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
public interface ContactInfoService {
@POST("contact-info")
Call<ContactInfoDto> createContactInfo(@Body ContactInfoDto contactInfoDto);
@GET("contact-info/user-id/{userId}/{type}")
Call<ContactInfoDto> getContactInfoByUserIdAndType(@Path("userId") Long userId, @Path("type") String type);
@PUT("contact-info/{contactInfoId}")
Call<ContactInfoDto> updateContactInfo(@Path("contactInfoId") Long contactInfoId, @Body ContactInfoDto contactInfoDto);
@DELETE("contact-info/{userId}/{type}")
Call<ResponseDto> deleteContactInfoByUserIdAndType(@Path("userId") Long userId, @Path("type") String type);
}
...@@ -126,4 +126,26 @@ ...@@ -126,4 +126,26 @@
</ScrollView> </ScrollView>
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99D5C5DF"
android:visibility="gone"
android:clickable="true"
android:focusable="true"/>
<com.github.ybq.android.spinkit.SpinKitView
android:id="@+id/progress_bar"
style="@style/SpinKitView.Large.DoubleBounce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:SpinKit_Color="@color/purple"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Contact Information"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/aci_et_cont_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/contact_name"
android:inputType="textPersonName"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
<EditText
android:id="@+id/aci_et_mobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/mobile_number_req"
android:inputType="textPersonName"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99D5C5DF"
android:visibility="gone"
android:clickable="true"
android:focusable="true"/>
<com.github.ybq.android.spinkit.SpinKitView
android:id="@+id/progress_bar"
style="@style/SpinKitView.Large.DoubleBounce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:SpinKit_Color="@color/purple"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/mm_dashboard"
android:title="Dashboard" />
<item <item
android:id="@+id/mm_app_setting" android:id="@+id/mm_app_setting"
android:title="App Settings" /> android:title="App Settings" />
<item
android:id="@+id/mm_device_setting"
android:title="Device Settings" />
<item <item
android:id="@+id/mm_logout" android:id="@+id/mm_logout"
android:title="Logout" /> android:title="Logout" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Childy</string>
<string name="action_settings">Settings</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string>
<string name="second_fragment_label">Second Fragment</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
<string name="forgot_password"><u>Forgot Password</u></string>
<string name="register"><u>Register</u></string>
<string name="login"><u>Login</u></string>
<string name="edit_btn_value">Edit</string>
<string name="update_btn_value">Update</string>
<string name="first_name_req">First name<font color="#FF0000"> *</font></string> <string name="first_name_req">First name<font color="#FF0000"> *</font></string>
<string name="email_req">Email<font color="#FF0000"> *</font></string> <string name="email_req">Email<font color="#FF0000"> *</font></string>
<string name="password_req">Password<font color="#FF0000"> *</font></string> <string name="password_req">Password<font color="#FF0000"> *</font></string>
...@@ -9,4 +21,7 @@ ...@@ -9,4 +21,7 @@
<string name="last_name_label">Last name</string> <string name="last_name_label">Last name</string>
<string name="birth_date_req">Birth date<font color="#FF0000"> *</font></string> <string name="birth_date_req">Birth date<font color="#FF0000"> *</font></string>
<string name="sex">Sex<font color="#FF0000"> *</font></string> <string name="sex">Sex<font color="#FF0000"> *</font></string>
<string name="about">A child is a human being between the stages of birth and puberty, or between the developmental periods of infancy and puberty. It may also refer to an unborn human being. The legal definition of a child generally refers to a minor, which is a person younger than the age of majority.</string>
<string name="version">Version 0.1</string>
<string name="contact_name">Contact Name<font color="#FF0000"> *</font></string>
</resources> </resources>
\ No newline at end of file
...@@ -22,4 +22,5 @@ ...@@ -22,4 +22,5 @@
<string name="sex">Sex<font color="#FF0000"> *</font></string> <string name="sex">Sex<font color="#FF0000"> *</font></string>
<string name="about">A child is a human being between the stages of birth and puberty, or between the developmental periods of infancy and puberty. It may also refer to an unborn human being. The legal definition of a child generally refers to a minor, which is a person younger than the age of majority.</string> <string name="about">A child is a human being between the stages of birth and puberty, or between the developmental periods of infancy and puberty. It may also refer to an unborn human being. The legal definition of a child generally refers to a minor, which is a person younger than the age of majority.</string>
<string name="version">Version 0.1</string> <string name="version">Version 0.1</string>
<string name="contact_name">Contact Name<font color="#FF0000"> *</font></string>
</resources> </resources>
\ No newline at end of file
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