-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20d3d71
commit dba5e63
Showing
55 changed files
with
1,419 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
4 changes: 4 additions & 0 deletions
4
P02_HealthCalculator/Somyaguglani/Day2 Task/.idea/encodings.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
P02_HealthCalculator/Somyaguglani/Day2 Task/.idea/gradle.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
P02_HealthCalculator/Somyaguglani/Day2 Task/.idea/render.experimental.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
P02_HealthCalculator/Somyaguglani/Day2 Task/.idea/runConfigurations.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
29 changes: 29 additions & 0 deletions
29
P02_HealthCalculator/Somyaguglani/Day2 Task/app/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.0" | ||
defaultConfig { | ||
applicationId "com.example.bmrcalculator" | ||
minSdkVersion 22 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'androidx.appcompat:appcompat:1.0.2' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test:runner:1.2.0' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
} |
21 changes: 21 additions & 0 deletions
21
P02_HealthCalculator/Somyaguglani/Day2 Task/app/proguard-rules.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
27 changes: 27 additions & 0 deletions
27
...Day2 Task/app/src/androidTest/java/com/example/bmrcalculator/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.example.bmrcalculator; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.InstrumentationRegistry; | ||
import androidx.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.example.bmrcalculator", appContext.getPackageName()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
P02_HealthCalculator/Somyaguglani/Day2 Task/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.bmrcalculator"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".BMIActivity"></activity> | ||
<activity android:name=".ChoosingActivity" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".OtherActivity"/> | ||
<activity android:name=".MainActivity"></activity> | ||
</application> | ||
|
||
</manifest> |
Binary file added
BIN
+94 KB
P02_HealthCalculator/Somyaguglani/Day2 Task/app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 138 additions & 0 deletions
138
...lator/Somyaguglani/Day2 Task/app/src/main/java/com/example/bmrcalculator/BMIActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.example.bmrcalculator; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.RadioButton; | ||
import android.widget.RadioGroup; | ||
import android.widget.TextView; | ||
|
||
public class BMIActivity extends AppCompatActivity { | ||
EditText bmi_weight,bmi_height,bmi_age; | ||
TextView ans,bfp,bmi_gender; | ||
Button bmi_cal; | ||
int no = 0; | ||
double find_ans=0.0; | ||
double find_weight,find_height,find_bfp,find_age; | ||
RadioGroup bmi_radiogroup; | ||
RadioButton bmi_radiobutton; | ||
|
||
@Override | ||
public void onBackPressed() { | ||
finish(); | ||
} | ||
|
||
@Override | ||
|
||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_choosing); | ||
bmi_weight= findViewById(R.id.et_bmi_weight); | ||
bmi_height= findViewById(R.id.et_bmi_height); | ||
bmi_cal= findViewById(R.id.btn_bmi_cal); | ||
ans= findViewById(R.id.tv_bmi_ans); | ||
bfp = findViewById(R.id.tv_bmi_bodyfat); | ||
bmi_radiogroup= findViewById(R.id.rgroup_bmi_radiogroup); | ||
bmi_gender= findViewById(R.id.tv_bmi_gender); | ||
bmi_age= findViewById(R.id.et_bmi_age); | ||
|
||
|
||
|
||
|
||
|
||
bmi_cal.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
|
||
if (TextUtils.isEmpty(bmi_height.getText().toString())) { | ||
bmi_height.setError("Enter height"); | ||
return; | ||
}else if (TextUtils.isEmpty(bmi_age.getText().toString())) { | ||
bmi_age.setError("Enter weight"); | ||
return; | ||
} | ||
else if (TextUtils.isEmpty(bmi_weight.getText().toString())) { | ||
bmi_weight.setError("Enter weight"); | ||
return; | ||
}else if (bmi_radiogroup.getCheckedRadioButtonId() == -1) | ||
{ | ||
bmi_gender.setError("Choose gender"); | ||
return ; | ||
} | ||
else{ | ||
|
||
|
||
find_weight= Double.parseDouble(bmi_weight.getText().toString()); | ||
find_age= Double.parseDouble(bmi_age.getText().toString()); | ||
find_height= Double.parseDouble(bmi_height.getText().toString()); | ||
find_ans= find_weight/(find_height*find_height); | ||
|
||
//logic for bmi | ||
ans.setText(Double.toString((Double.parseDouble(String.format("0.2%f",find_ans))))+ " kg/m*m"); | ||
|
||
if(find_ans<16) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText(R.string.severe_underweighgt); | ||
else if(find_ans>=16 && find_ans<16.9) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText(R.string.moderate_weight); | ||
else if(find_ans>=17 && find_ans<18.4) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText("Underweight"); | ||
else if(find_ans>=18.5 && find_ans<24.9) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText("Normal"); | ||
else if(find_ans>=25 && find_ans<29.9) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText("Overweight"); | ||
else if(find_ans>=30 && find_ans<34.9) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText("Obese Class 1"); | ||
else if(find_ans>=35 && find_ans<39.9) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText("Obese Class 2"); | ||
else if(find_ans>=40) | ||
((TextView)(findViewById(R.id.tv_print_stuff))).setText("Obese Class 3"); | ||
|
||
//logic for bmi over | ||
|
||
|
||
//logic for bfp | ||
|
||
if(no==1){ | ||
|
||
if(find_age>= 0 && find_age<=17) | ||
find_bfp= 1.51*find_ans-0.70*find_age+1.4; | ||
else if(find_age>=18) | ||
find_bfp= 1.2*find_ans + 0.23*find_age -5.4; | ||
|
||
}else if(no==2){ | ||
|
||
if(find_age>= 0 && find_age<=17) | ||
find_bfp= 1.51*find_ans-0.70*find_age-2.2; | ||
else if(find_age>=18) | ||
find_bfp= 1.2*find_ans + 0.23*find_age -16.2; | ||
|
||
} | ||
|
||
bfp.setText(Double.toString((Double.parseDouble(String.format("0.2%f",find_bfp))))+ " %"); | ||
|
||
//logic for bfp over | ||
|
||
} | ||
} | ||
}); | ||
|
||
|
||
} | ||
public void Check_gender(View view) { | ||
switch(view.getId()){ | ||
|
||
case R.id.rbtn_bmi_male: | ||
no=2; | ||
break; | ||
case R.id.rbtn_bmi_female: | ||
no=1; | ||
break; | ||
|
||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
.../Somyaguglani/Day2 Task/app/src/main/java/com/example/bmrcalculator/ChoosingActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.example.bmrcalculator; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.app.AlertDialog; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ImageButton; | ||
|
||
public class ChoosingActivity extends AppCompatActivity { | ||
|
||
ImageButton bmi,bmr; | ||
|
||
|
||
@Override | ||
public void onBackPressed() { | ||
new AlertDialog.Builder(ChoosingActivity.this) | ||
.setMessage("Are you sure you want to exit?") | ||
.setCancelable(false) | ||
.setIcon(android.R.drawable.ic_dialog_alert) | ||
.setPositiveButton("Ok", new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialogInterface, int i) { | ||
finishAffinity(); | ||
} | ||
}) | ||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialogInterface, int i) { | ||
|
||
} | ||
}) | ||
.show(); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_choosing); | ||
|
||
bmi= findViewById(R.id.imbtn_bmi); | ||
bmr = findViewById(R.id.imbtn_bmr); | ||
|
||
bmi.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Intent i = new Intent(ChoosingActivity.this,BMIActivity.class); | ||
startActivity(i); | ||
} | ||
}); | ||
bmr.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Intent i = new Intent(ChoosingActivity.this,MainActivity.class); | ||
startActivity(i); | ||
} | ||
}); | ||
|
||
|
||
|
||
} | ||
} |
Oops, something went wrong.