Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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.

48 changes: 48 additions & 0 deletions app/src/main/java/com/example/healthlog/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.healthlog;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
Expand All @@ -9,9 +10,13 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.CompoundButton;
import android.widget.Switch;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
Expand All @@ -24,6 +29,11 @@ public class MainActivity extends AppCompatActivity {

// COMPLETED(SHANK) add logout button in appBar

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 @@ -43,7 +53,45 @@ protected void onCreate(Bundle savedInstanceState) {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);

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 void dialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.CustomDialogTheme);
// Set the message show for the Alert time
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<Switch
android:id="@+id/theme_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="50dp"
android:text="Switch"></Switch>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
Expand All @@ -20,9 +28,10 @@
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="642dp"
android:layout_above="@id/nav_view"
android:layout_alignParentTop="true"
android:layout_marginTop="33dp"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/attributes.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>
42 changes: 42 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!--<color name="colorPrimary">#4f3b78</color>-->
<color name="colorPrimary">#000</color>
<color name="colorPrimaryLight">#252525</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorBar">#515585</color>
<color name="colorAccent">#fff</color>
<color name="colorLight">#ececec</color>

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

<!-- confirmed colors-->
<color name="confirmBox">#E2E2F4</color>
<color name="confirmLightText">#6B70C4</color>
<color name="confirmDarkText">#383AAE</color>

<!-- active colors-->
<color name="activeBox">#FFE5E6</color>
<color name="activeLightText">#FF7582</color>
<color name="activeDarkText">#FF0E3C</color>

<!-- recovered colors-->
<color name="recoveredBox">#E6F4E8</color>
<color name="recoveredLightText">#80C689</color>
<color name="recoveredDarkText">#2DA747</color>

<!-- deceased colors-->
<color name="deceasedBox">#F6F6F7</color>
<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>
7 changes: 7 additions & 0 deletions app/src/main/res/values-night/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>

<dimen name="status_bg_corner_radius">10dp</dimen>
</resources>
44 changes: 44 additions & 0 deletions app/src/main/res/values-night/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<resources>
Comment thread
spacemonkey1101 marked this conversation as resolved.
Outdated
<string name="app_name">Health Log</string>
<string name="title_doctor">Doctor</string>
<string name="title_dashboard">Dashboard</string>
<string name="title_hospital">Hospital Info</string>
<string name="hospital_id">Hospital ID</string>
<string name="login">Login</string>
<string name="enter_your_hospital_id">Enter Hospital ID</string>
<string name="doctor">Doctor</string>
<string name="hospital">Hospital</string>
<string name="search">Search</string>
<string name="enter_patient_id">Enter patient ID or patient name</string>
<string name="patient_id">Patient ID or Patient name</string>
<string name="add_log">Add Log</string>
<string name="write_current_log">Write current log</string>
<string name="save">Save</string>
<string name="ask_logout">Do you want to logout</string>
<string name="alert">Alert!</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="logout">Logout</string>
<string name="_678">678</string>
<string name="confirmed">Confirmed</string>
<string name="_56">56</string>
<string name="deceased">Deceased</string>
<string name="cured">Cured</string>
<string name="_556">556</string>
<string name="active">Active</string>
<string name="add_patient">Do you want to add this patient</string>
<string name="send">Send to other hospital</string>
<string name="doctor_id_or_doctor_name">Doctor ID or Doctor Name</string>
<string name="choose_language">Choose Language</string>


<string-array name="statusArray">
<item>Active</item>
<item>Cured</item>
<item>Deceased</item>
<item>All</item>
</string-array>

<string name="date_not_selected">Date not selected properly</string>

</resources>
61 changes: 61 additions & 0 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<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>

<!-- 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/attributes.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>
7 changes: 7 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
1 change: 1 addition & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<item name="colorPrimaryDark">@color/colorPrimaryLight</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:statusBarColor">@color/colorPrimary</item>
<item name="primaryTitleColor">@color/primaryTitleColor</item>
</style>

<style name="CustomDialogTheme" parent="ThemeOverlay.AppCompat.Dialog.Alert">
Expand Down