Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions app/src/main/java/com/example/healthlog/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
Expand All @@ -26,6 +24,7 @@ public class MainActivity extends AppCompatActivity {

// COMPLETED(SHANK) add logout button in appBar


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -38,7 +37,7 @@ protected void onCreate(Bundle savedInstanceState) {
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration =
new AppBarConfiguration.Builder(
R.id.navigation_dashboard, R.id.navigation_doctor, R.id.navigation_hospitals)
R.id.navigation_dashboard, R.id.navigation_doctor, R.id.navigation_hospitals)
.build();

NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
Expand Down Expand Up @@ -85,7 +84,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
case R.id.about:
showAboutAppPage();break;
case R.id.setting:
showSettingsAppPage();
showSettingsAppPage(); break;
default:
super.onOptionsItemSelected(item);
}
Expand Down
45 changes: 45 additions & 0 deletions app/src/main/java/com/example/healthlog/SettingsActivity.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.example.healthlog;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.Toast;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
Expand All @@ -19,6 +23,11 @@

public class SettingsActivity extends AppCompatActivity {

private Switch mSwitch;
private static final String MyPREFERENCES = "nightModePrefs";
private static final String KEY_ISNIGHTMODE = "isNightMode";
SharedPreferences mSharedPreferences;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -37,6 +46,42 @@ protected void onCreate(Bundle savedInstanceState) {
actionBar.setTitle(R.string.setting);
actionBar.setDisplayHomeAsUpEnabled(true);
}
mSharedPreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
mSwitch = findViewById(R.id.theme_toggle);
checkNightModeActivated();

mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
saveNightMode(true);
recreate();
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
saveNightMode(false);
recreate();
}
}
});
}

//save night or dark mode
private void saveNightMode(boolean nightMode) {
SharedPreferences.Editor editor =mSharedPreferences.edit();
editor.putBoolean(KEY_ISNIGHTMODE,nightMode);
editor.apply();
}

//checking the dark theme switch
public void checkNightModeActivated(){
if(mSharedPreferences.getBoolean(KEY_ISNIGHTMODE,false)){
mSwitch.setChecked(true);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
mSwitch.setChecked(false);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}

public static class SettingsFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener {
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_baseline_nights_stay_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M11.1,12.08C8.77,7.57 10.6,3.6 11.63,2.01C6.27,2.2 1.98,6.59 1.98,12c0,0.14 0.02,0.28 0.02,0.42C2.62,12.15 3.29,12 4,12c1.66,0 3.18,0.83 4.1,2.15C9.77,14.63 11,16.17 11,18c0,1.52 -0.87,2.83 -2.12,3.51c0.98,0.32 2.03,0.5 3.11,0.5c3.5,0 6.58,-1.8 8.37,-4.52C18,17.72 13.38,16.52 11.1,12.08z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M7,16l-0.18,0C6.4,14.84 5.3,14 4,14c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.62,0 2.49,0 3,0c1.1,0 2,-0.9 2,-2C9,16.9 8.1,16 7,16z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_wb_sunny_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6.76,4.84l-1.8,-1.79 -1.41,1.41 1.79,1.79 1.42,-1.41zM4,10.5L1,10.5v2h3v-2zM13,0.55h-2L11,3.5h2L13,0.55zM20.45,4.46l-1.41,-1.41 -1.79,1.79 1.41,1.41 1.79,-1.79zM17.24,18.16l1.79,1.8 1.41,-1.41 -1.8,-1.79 -1.4,1.4zM20,10.5v2h3v-2h-3zM12,5.5c-3.31,0 -6,2.69 -6,6s2.69,6 6,6 6,-2.69 6,-6 -2.69,-6 -6,-6zM11,22.45h2L13,19.5h-2v2.95zM3.55,18.54l1.41,1.41 1.79,-1.8 -1.41,-1.41 -1.79,1.8z"/>
</vector>
39 changes: 36 additions & 3 deletions app/src/main/res/layout/settings_activity.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>
<Switch
android:id="@+id/theme_toggle"
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_marginTop="199dp"
android:layout_marginEnd="31dp"
app:layout_constraintEnd_toStartOf="@+id/iconNight"
app:layout_constraintStart_toEndOf="@+id/iconSunny"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/iconSunny"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="70dp"
android:layout_marginEnd="29dp"
app:layout_constraintBottom_toBottomOf="@+id/theme_toggle"
app:layout_constraintEnd_toStartOf="@+id/theme_toggle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/theme_toggle"
app:srcCompat="@drawable/ic_baseline_wb_sunny_24" />

<ImageView
android:id="@+id/iconNight"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="77dp"
app:layout_constraintBottom_toBottomOf="@+id/theme_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/theme_toggle"
app:layout_constraintTop_toTopOf="@+id/theme_toggle"
app:srcCompat="@drawable/ic_baseline_nights_stay_24" />
</androidx.constraintlayout.widget.ConstraintLayout>
41 changes: 41 additions & 0 deletions app/src/main/res/layout/switch_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<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:layout_width="match_parent"
android:layout_height="match_parent">

<Switch
android:id="@+id/theme_toggle"
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_marginTop="199dp"
android:layout_marginEnd="31dp"
app:layout_constraintEnd_toStartOf="@+id/iconNight"
app:layout_constraintStart_toEndOf="@+id/iconSunny"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/iconSunny"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="70dp"
android:layout_marginEnd="29dp"
app:layout_constraintBottom_toBottomOf="@+id/theme_toggle"
app:layout_constraintEnd_toStartOf="@+id/theme_toggle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/theme_toggle"
app:srcCompat="@drawable/ic_baseline_wb_sunny_24" />

<ImageView
android:id="@+id/iconNight"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="77dp"
app:layout_constraintBottom_toBottomOf="@+id/theme_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/theme_toggle"
app:layout_constraintTop_toTopOf="@+id/theme_toggle"
app:srcCompat="@drawable/ic_baseline_nights_stay_24" />

</androidx.constraintlayout.widget.ConstraintLayout>

7 changes: 0 additions & 7 deletions app/src/main/res/menu/menu_logout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/search"
android:title="@string/search"
android:icon="@android:drawable/ic_menu_search"
app:showAsAction="always|collapseActionView"
app:actionViewClass="androidx.appcompat.widget.SearchView">
</item>
<item
android:id="@+id/about"
android:icon="@android:drawable/ic_menu_info_details"
Expand Down
69 changes: 69 additions & 0 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimaryNight</item>
<item name="colorPrimaryDark">@color/colorPrimaryDarkNight</item>
<item name="colorAccent">@color/colorAccentNight</item>
<item name="android:statusBarColor">@color/colorPrimary</item>

<item name="android:windowBackground">@color/colorPrimaryNight</item>
<item name="primaryTitleColor">@color/primaryTitleColorNight</item>
</style>

<style name="CustomDialogTheme" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<!--<item name="android:windowBackground">#191616</item>-->
<item name="android:background">#000</item>
<item name="android:colorPrimary">#000</item>
<item name="colorAccent">@color/ColorAccentSec</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textSize">16sp</item>
</style>

<!-- Settings Page Theme -->
<style name="SettingsTheme" parent="Theme.MaterialComponents.DayNight">
<item name="colorPrimary">@color/ColorAccentSec</item>
<item name="colorAccent">@color/ColorAccentSec</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:windowBackground">#000</item>
</style>

<!-- new patient layout editText theme. -->
<style name="NewPatientEditTextTheme" parent="Widget.AppCompat.EditText">
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingBottom">16dp</item>
<item name="android:layout_marginLeft">32dp</item>
<item name="android:layout_marginRight">32dp</item>
</style>

<!-- patient layout textView theme. -->
<style name="PatientLayoutTextViewTheme" parent="Widget.AppCompat.TextView">
<item name="android:layout_marginLeft">16dp</item>
<item name="android:layout_marginBottom">16dp</item>
</style>


<!--hospital fragment top box text styles-->
<style name="hospitalFragmentTextHeadingStyle" parent="Widget.AppCompat.TextView">
<item name="android:textSize">16sp</item>
<item name="android:layout_margin">8dp</item>
<item name="android:textStyle">bold</item>
<item name="android:minLines">1</item>
<item name="android:maxLines">1</item>
<item name="android:ellipsize">end</item>
</style>

<style name="hospitalFragmentTextValueStyle" parent="Widget.AppCompat.TextView">
<item name="android:textSize">16sp</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:textStyle">bold</item>
</style>

<!--Splash Screen Theme-->
<style name="splashScreenTheme" parent="Theme.MaterialComponents.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:statusBarColor">@color/colorPrimary</item>
</style>

</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="primaryTitleColor" format="color" />
</resources>
9 changes: 8 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<color name="ColorAccentSec">#FFBE00</color>

<!-- confirmed colors-->
<!-- confirmed colors-->
<color name="confirmBox">#E2E2F4</color>
<color name="confirmLightText">#6B70C4</color>
<color name="confirmDarkText">#383AAE</color>
Expand All @@ -31,5 +31,12 @@
<color name="deceasedLightText">#A7ACB1</color>
<color name="deceasedDarkText">#6E777E</color>

<!-- dark theme colors -->
<color name="colorPrimaryNight">#16202c</color>
<color name="colorPrimaryDarkNight">#141d26</color>
<color name="colorAccentNight">#ffffff</color>

<color name="primaryTitleColor">#212121</color>
<color name="primaryTitleColorNight">#ffffff</color>

</resources>
Loading