Commit 368d7cd8 authored by Ishankha K.C's avatar Ishankha K.C

settings activity

parent 3954a365
......@@ -4,7 +4,7 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-09-03T20:20:16.727982200Z">
<DropdownSelection timestamp="2024-10-20T17:33:09.653038700Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=D:\Softwares\toolbox\.android\.android\avd\Pixel_XL_API_29.avd" />
......
......@@ -17,6 +17,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.BabyCare"
tools:targetApi="31">
<activity
android:name=".activities.SettingsActivity"
android:exported="false" />
<activity
android:name=".activities.ActivityLogsActivity"
android:exported="false" />
......
......@@ -58,7 +58,8 @@ public class DashboardActivity extends AppCompatActivity {
startActivity(intent);
});
btn6.setOnClickListener(v -> {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
});
}
......
package com.kaluwa.enterprises.babycare.activities;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.clearToken;
import static com.kaluwa.enterprises.babycare.utils.Utils.animationChanger;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.Toolbar;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.kaluwa.enterprises.babycare.MainActivity;
import com.kaluwa.enterprises.babycare.R;
public class SettingsActivity extends AppCompatActivity {
private LinearLayout btnDevSet, btnProfSet, btnAppSet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
// define actionbar
defineActionbar();
// initialize buttons
btnDevSet = findViewById(R.id.btnDeviceSettings);
btnProfSet = findViewById(R.id.btnProfileSettings);
btnAppSet = findViewById(R.id.btnAppSettings);
// set click listeners
onClickListeners();
}
private void onClickListeners() {
btnDevSet.setOnClickListener(v -> {
});
btnProfSet.setOnClickListener(v -> {
Intent intent = new Intent(this, UserProfileActivity.class);
startActivity(intent);
animationChanger(this);
});
btnAppSet.setOnClickListener(v -> {
});
}
private void defineActionbar() {
Toolbar toolbar = findViewById(R.id.b_care_action_bar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
toolbar.setNavigationIcon(R.drawable.ico_menu_32);
toolbar.setNavigationOnClickListener(v -> {
// Initializing the popup menu and giving the reference as current context
PopupMenu popupMenu = new PopupMenu(this, toolbar);
popupMenu.setGravity(Gravity.BOTTOM);
popupMenu.getMenuInflater().inflate(R.menu.menu_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> {
int id = item.getItemId();
if (id == R.id.mm_device_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show();
} else if (id == R.id.mm_app_setting) {
Toast.makeText(this, "You Clicked " + item.getTitle(), Toast.LENGTH_SHORT).show();
} else if (id == R.id.mm_logout) {
clearToken(getApplicationContext());
Toast.makeText(this, "Logout successful.", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
animationChanger(this);
}
return true;
});
popupMenu.show();
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.user_action_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
if (id == R.id.user) {
Intent intent = new Intent(this, UserProfileActivity.class);
startActivity(intent);
animationChanger(this);
} else {
Toast.makeText(this, "No item.", Toast.LENGTH_SHORT).show();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
super.onBackPressed();
animationChanger(this);
}
}
\ No newline at end of file
......@@ -414,8 +414,9 @@ public class UserProfileActivity extends AppCompatActivity {
etMobile.setText(user.getPhone());
if (user.getDob() != null) {
LocalDate localDate = Utils.getLocalDate(user.getDob());
// LocalDate localDate = LocalDate.parse(user.getDob().toString(), getDateTimeFormatter());
if (localDate != null) {
etDob.setText(localDate.format(getDateTimeFormatter()));
etDob.setText(localDate.toString());
}
}
loader(overlay, progressBar, false);
......
......@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
public class Utils {
public static final String DATE_FORMAT = "dd/M/yyyy";
public static final String DATE_FORMAT = "yyyy-M-dd";
public static final int PICK_IMAGE_REQUEST = 1;
private static final String TAG = "Utils";
......@@ -80,6 +80,7 @@ public class Utils {
// Check if EditText is not empty and parse the date
if (!TextUtils.isEmpty(editText.getText().toString())) {
try {
// yyyy-M-dd
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
calendar.setTime(Objects.requireNonNull(sdf.parse(editText.getText().toString())));
} catch (ParseException e) {
......@@ -241,11 +242,10 @@ public class Utils {
@SuppressLint("NewApi")
public static DateTimeFormatter getDateTimeFormatter() {
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder()
.parseCaseInsensitive().parseLenient()
// .appendPattern("[d/M/yyyy]")
// .appendPattern("[dd MMM yyyy]")
.appendPattern("[dd/MM/yyyy]")
.appendPattern("[yyyy-MM-dd]");
.parseCaseInsensitive()
.parseLenient()
.appendOptional(DateTimeFormatter.ofPattern("dd/MM/yyyy"))
.appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
return builder.toFormatter(Locale.ENGLISH);
}
......
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="32dp" android:viewportHeight="124" android:viewportWidth="124" android:width="32dp">
<path android:fillColor="#000000" android:pathData="M91.9,3c-2.6,2.9 -7.9,4.2 -7.9,2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path android:fillColor="#000000" android:pathData="M16.5,22c-3.5,1.4 -6.4,4.9 -7,8.2 -0.9,4.9 -0.1,61 0.9,63 0.7,1.6 0.2,1.8 -4.8,1.8 -3.1,-0 -5.6,0.4 -5.6,0.8 0,1.7 3,6.9 5.1,8.8 2,1.8 4.4,1.9 56.9,1.9 52.5,-0 54.9,-0.1 56.9,-1.9 2.1,-1.9 5.1,-7.1 5.1,-8.8 0,-0.4 -2.5,-0.8 -5.6,-0.8 -5,-0 -5.5,-0.2 -4.8,-1.8 0.8,-1.7 1.9,-30.2 1.1,-30.2 -0.2,-0 -1.8,0.7 -3.5,1.6l-3.2,1.5 0,11.3c0,7.4 -0.4,11.6 -1.2,12.4 -1.7,1.7 -87.9,1.7 -89.6,-0 -1.7,-1.7 -1.7,-57.9 0,-59.6 0.9,-0.9 6.9,-1.2 21,-1.2l19.8,-0 0,-2.4c0,-1.3 0.3,-3.1 0.6,-4 0.5,-1.4 -1.6,-1.6 -19.7,-1.5 -11.2,-0 -21.3,0.4 -22.4,0.9z" android:strokeColor="#00000000"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.SettingsActivity">
<include
layout="@layout/appbar"/>
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/b_care_action_bar"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/background"
android:contentDescription="background-image"
android:scaleType="centerCrop"
android:alpha="0.4"/>
<RelativeLayout
android:id="@+id/rl_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rl_background"
android:backgroundTint="#62178F"
app:layout_constraintTop_toTopOf="@+id/background"
app:layout_constraintStart_toStartOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
android:padding="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Settings"
android:textAlignment="center"
android:textColor="@color/white"
android:textAllCaps="true"
android:fontFamily="@font/inknut_antiqua_regular"
android:textSize="20sp"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/rl_header"
app:layout_constraintBottom_toBottomOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
app:layout_constraintStart_toStartOf="@id/background"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:id="@+id/btnDeviceSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@drawable/positive_btn_background"
android:backgroundTint="@color/white"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="30dp"
android:paddingEnd="30dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:fontFamily="@font/acme_regular"
android:text="Device Settings"
android:textColor="@color/black"
android:textSize="18sp" />
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ico_computer_settings"
app:tint="@color/icon_color" />
</LinearLayout>
<LinearLayout
android:id="@+id/btnProfileSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@drawable/positive_btn_background"
android:backgroundTint="@color/white"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="30dp"
android:paddingEnd="30dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:fontFamily="@font/acme_regular"
android:text="Profile Settings"
android:textColor="@color/black"
android:textSize="18sp" />
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ico_computer_settings"
app:tint="@color/icon_color" />
</LinearLayout>
<LinearLayout
android:id="@+id/btnAppSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@drawable/positive_btn_background"
android:backgroundTint="@color/white"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="30dp"
android:paddingEnd="30dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:fontFamily="@font/acme_regular"
android:text="Application Settings"
android:textColor="@color/black"
android:textSize="18sp" />
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ico_computer_settings"
app:tint="@color/icon_color" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="purple">#8147A4</color>
<color name="dark_purple">#673983</color>
<color name="link_blue">#0000EE</color>
<color name="transparent">#00FFFFFF</color>
<color name="icon_color">#585AAA</color>
......@@ -9,5 +12,5 @@
<color name="cancel_dark_red">#CC0000</color>
<color name="success_green">#28A745</color>
<color name="success_dark_green">#218838</color>
<color name="gray">#D3D3D3</color> <!-- Light gray color -->
<color name="gray">#D3D3D3</color>
</resources>
\ No newline at end of file
......@@ -12,5 +12,5 @@
<color name="cancel_dark_red">#CC0000</color>
<color name="success_green">#28A745</color>
<color name="success_dark_green">#218838</color>
<color name="gray">#D3D3D3</color> <!-- Light gray color -->
<color name="gray">#D3D3D3</color>
</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