commit d9df4e5dd1dd57c4dfbcb6f11e4cfcda214548a9 Author: Ramandeep Date: Sat Jan 29 02:26:38 2022 +0530 Smart Lab App diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.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 +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..440480e --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..2942dba --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6199cc2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..5ec37a1 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,91 @@ +apply plugin: 'com.android.application' +apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.google.firebase.crashlytics' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + + defaultConfig { + applicationId "com.smi.smartlab" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + multiDexEnabled true + + versionName "1.0" + multiDexEnabled true + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + aaptOptions { + noCompress "tflite" + noCompress "lite" + } +} + +dependencies { + + implementation 'com.chaos.view:pinview:1.4.3' + implementation 'com.github.bumptech.glide:glide:4.11.0' + implementation 'com.firebaseui:firebase-ui-database:7.1.1' + + + + implementation 'androidx.browser:browser:1.2.0' + + implementation 'de.hdodenhof:circleimageview:3.1.0' + implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+' + + implementation 'com.google.android.material:material:1.0.0' + implementation 'com.hbb20:ccp:2.4.0' + + + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'com.google.firebase:firebase-config:20.0.0' + implementation 'com.google.firebase:firebase-auth:20.0.1' + + + implementation 'com.google.firebase:firebase-database:19.5.1' + implementation 'com.google.firebase:firebase-storage:19.2.0' + testImplementation 'junit:junit:4.12' + implementation 'com.google.android.gms:play-services-location:17.0.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + + implementation 'com.google.firebase:firebase-crashlytics:17.1.1' + implementation 'com.google.firebase:firebase-perf:19.0.11' + implementation 'com.android.support:multidex:1.0.3' + implementation 'com.karumi:dexter:6.2.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0' + implementation 'com.android.volley:volley:1.1.0' + implementation 'com.squareup.retrofit2:converter-gson:2.9.0' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + + implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.0'){ + exclude group: 'group_name', module: 'module_name' + } + implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0' + implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0' + + + + +} diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..0656b98 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "1042792090548", + "firebase_url": "https://smartlab-9b83e-default-rtdb.firebaseio.com", + "project_id": "smartlab-9b83e", + "storage_bucket": "smartlab-9b83e.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:1042792090548:android:4f095c661cb392df4480e1", + "android_client_info": { + "package_name": "com.smi.smartlab" + } + }, + "oauth_client": [ + { + "client_id": "1042792090548-682fmspc4hchou6thilamja1of4aqsd6.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCiO5owTmUgosDyjL0_SqpxRoAwgKtn5-o" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "1042792090548-682fmspc4hchou6thilamja1of4aqsd6.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/app/src/androidTest/java/in/testright/smartlab_app23/ExampleInstrumentedTest.java b/app/src/androidTest/java/in/testright/smartlab_app23/ExampleInstrumentedTest.java new file mode 100644 index 0000000..d4e3fe1 --- /dev/null +++ b/app/src/androidTest/java/in/testright/smartlab_app23/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package in.testright.smartlab_app23; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.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 Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("in.testright.smartlab_app23", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/google-services.json b/app/src/google-services.json new file mode 100644 index 0000000..0656b98 --- /dev/null +++ b/app/src/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "1042792090548", + "firebase_url": "https://smartlab-9b83e-default-rtdb.firebaseio.com", + "project_id": "smartlab-9b83e", + "storage_bucket": "smartlab-9b83e.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:1042792090548:android:4f095c661cb392df4480e1", + "android_client_info": { + "package_name": "com.smi.smartlab" + } + }, + "oauth_client": [ + { + "client_id": "1042792090548-682fmspc4hchou6thilamja1of4aqsd6.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCiO5owTmUgosDyjL0_SqpxRoAwgKtn5-o" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "1042792090548-682fmspc4hchou6thilamja1of4aqsd6.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2d6cc85 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/fa-solid-900.ttf b/app/src/main/assets/fa-solid-900.ttf new file mode 100644 index 0000000..7c59512 Binary files /dev/null and b/app/src/main/assets/fa-solid-900.ttf differ diff --git a/app/src/main/java/com/smi/smartlab/About.java b/app/src/main/java/com/smi/smartlab/About.java new file mode 100644 index 0000000..4ce67da --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/About.java @@ -0,0 +1,22 @@ +package com.smi.smartlab; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + + +public class About extends NavigationTop { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + LayoutInflater inflater = (LayoutInflater) this + .getSystemService(LAYOUT_INFLATER_SERVICE); + View contentView = inflater.inflate(R.layout.activity_about, null, false); + draw.addView(contentView, 0); + + //setContentView(R.layout.activity_about); + } + + +} diff --git a/app/src/main/java/com/smi/smartlab/FontAwesome.java b/app/src/main/java/com/smi/smartlab/FontAwesome.java new file mode 100644 index 0000000..407cebf --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/FontAwesome.java @@ -0,0 +1,35 @@ +package com.smi.smartlab; + + +import android.content.Context; +import android.graphics.Typeface; +import android.util.AttributeSet; + +import androidx.appcompat.widget.AppCompatTextView; + +public class FontAwesome extends AppCompatTextView { + + + public FontAwesome(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(); + } + + public FontAwesome(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public FontAwesome(Context context) { + super(context); + init(); + } + + private void init() { + + Typeface tf = Typeface.createFromAsset(getContext().getAssets(), + "fa-solid-900.ttf"); + setTypeface(tf); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/smi/smartlab/GPS_Location.java b/app/src/main/java/com/smi/smartlab/GPS_Location.java new file mode 100644 index 0000000..eb0c9e0 --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/GPS_Location.java @@ -0,0 +1,218 @@ +package com.smi.smartlab; + +import android.annotation.SuppressLint; +import android.os.Bundle; +import android.util.Log; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.StringRequest; +import com.android.volley.toolbox.Volley; +import com.mapbox.mapboxsdk.Mapbox; +import com.mapbox.mapboxsdk.annotations.Icon; +import com.mapbox.mapboxsdk.annotations.IconFactory; +import com.mapbox.mapboxsdk.annotations.MarkerOptions; +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.maps.Style; +import com.mapbox.mapboxsdk.plugins.markerview.MarkerView; + +import org.json.JSONArray; +import org.json.JSONObject; + +public class GPS_Location extends AppCompatActivity { + private MapView mapView; + RequestQueue queue; + TextView text1, text2; + String lat, lag; + String URL = "http://13.127.144.213/webservice?token=getLiveData&user=shanmukha&pass=123456&format=json"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Mapbox.getInstance(this, getString(R.string.mapbox_access_token)); + + setContentView(R.layout.activity_gps_location); + queue = Volley.newRequestQueue(this); + text1 = findViewById(R.id.text1); + text2 = findViewById(R.id.text2); + + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + + Thread t = new Thread() { + + + @Override + public void run() { + + while (!isInterrupted()) { + + try { + Thread.sleep(10); //1000ms = 1 sec + + runOnUiThread(new Runnable() { + + @Override + public void run() { + loc(); + } + }); + + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + } + }; + + t.start(); + + + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + public void loc() { + + StringRequest request = new StringRequest(Request.Method.GET, URL, new Response.Listener() { + @Override + public void onResponse(String response) { + // textView.setText(response.toString()); + try { + + + JSONObject jObject = new JSONObject(response).getJSONObject("root"); + + + JSONArray jsonarray = jObject.getJSONArray("VehicleData"); + + + for (int i = 0; i < jsonarray.length(); i++) { + JSONObject jsonobject = jsonarray.getJSONObject(i); + String lat = jsonobject.getString("Latitude"); + String lag = jsonobject.getString("Longitude"); + String tex = jsonobject.getString("Location"); + String speed = jsonobject.getString("Speed"); + + text1.setText(tex); + text2.setText("Speed :" + speed + "Km/h"); + + Log.e("lat,long", lat); + Log.e("long", lag); + mapx(lat, lag); + + + } + + + } catch (Exception e) { + e.printStackTrace(); + } + } + }, new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + Log.d("error", error.toString()); + } + }); + queue.add(request); + + } + + public void mapx(String lat, String lag) { + + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(@NonNull MapboxMap mapboxMap) { + mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() { + @Override + public void onStyleLoaded(@NonNull Style style) { + + mapboxMap.clear(); + + + IconFactory iconFactory = IconFactory.getInstance(GPS_Location.this); + + Icon icons = iconFactory.fromResource(R.drawable.mapbox_marker_icon_default); + @SuppressLint("Range") CameraPosition position = new CameraPosition.Builder() + .target(new LatLng(Double.parseDouble(lat), Double.parseDouble(lag))) + .zoom(12) + .tilt(15) + .build(); +// Add the marker to the map + MarkerView marker_inter; + mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 500); + + mapboxMap.addMarker(new MarkerOptions() + .getThis() + + + .position(new LatLng(Double.parseDouble(lat), Double.parseDouble(lag))) + + + .icon(icons)); + + + } + }); + + } + }); + + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/smi/smartlab/Home.java b/app/src/main/java/com/smi/smartlab/Home.java new file mode 100644 index 0000000..c4f15cb --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/Home.java @@ -0,0 +1,38 @@ +package com.smi.smartlab; + +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.Button; + + +public class Home extends NavigationTop { +private Button add_gps,add_sensors; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + LayoutInflater inflater = (LayoutInflater) this + .getSystemService(LAYOUT_INFLATER_SERVICE); + View contentView = inflater.inflate(R.layout.activity_home, null, false); + draw.addView(contentView, 0); + add_gps=findViewById(R.id.add_gps); + add_sensors=findViewById(R.id.add_sensors); + add_gps.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent=new Intent (Home.this, GPS_Location.class); + startActivity(intent); + } + }); + add_sensors.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent=new Intent (Home.this, Lab_Metrics.class); + startActivity(intent); + } + }); + + + } +} diff --git a/app/src/main/java/com/smi/smartlab/Lab_Metrics.java b/app/src/main/java/com/smi/smartlab/Lab_Metrics.java new file mode 100644 index 0000000..2e2b4fc --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/Lab_Metrics.java @@ -0,0 +1,93 @@ +package com.smi.smartlab; + +import android.os.Bundle; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.google.firebase.database.ValueEventListener; + +public class Lab_Metrics extends AppCompatActivity { + + + FirebaseDatabase firebaseDatabase; + + DatabaseReference databaseReference; + DatabaseReference databaseReference2; + + private TextView retrieveTemp; + private TextView retrieveHum; + private TextView adc; + private TextView retrieveTemp2; + private TextView retrieveHum2; + private TextView adc2; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_lab); + + + firebaseDatabase = FirebaseDatabase.getInstance(); + + + databaseReference = firebaseDatabase.getReference("Data").child("smi").child("van1").child("compartment_1").child("sensor_data"); + databaseReference2 = firebaseDatabase.getReference("Data").child("smi").child("van1").child("compartment_2").child("sensor_data"); + + // initializing our object class variable. + retrieveTemp = findViewById(R.id.temp1); + retrieveHum = findViewById(R.id.humidity1); + adc = findViewById(R.id.gas1); + + retrieveTemp2 = findViewById(R.id.temp2); + retrieveHum2 = findViewById(R.id.humidity2); + adc2 = findViewById(R.id.gas2); + + + // calling method + // for getting data. + getdata(databaseReference, retrieveTemp, retrieveHum, adc, "Zone 1 : "); + getdata(databaseReference2, retrieveTemp2, retrieveHum2, adc2, "Zone 2: "); + + } + + private void getdata(DatabaseReference d, TextView t1, TextView t2, TextView t3, String zone) { + + // calling add value event listener method + // for getting the values from database. + d.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot snapshot) { + + + Double temp1 = snapshot.child("temperature").getValue(Double.class); + + Double ppm1 = snapshot.child("ppm").getValue(Double.class); + Double humidity1 = snapshot.child("humidity").getValue(Double.class); + String d1 = String.format("%.2f", temp1); + String d2 = String.format("%.2f", ppm1); + String d3 = String.format("%.2f", humidity1); + + + t1.setText(zone + d1 + "°C"); + t2.setText(zone + d3 + "%"); + t3.setText(zone + d2); + + + } + + @Override + public void onCancelled(@NonNull DatabaseError error) { + + Toast.makeText(Lab_Metrics.this, "Fail to get data.", Toast.LENGTH_SHORT).show(); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/smi/smartlab/LoginScreen.java b/app/src/main/java/com/smi/smartlab/LoginScreen.java new file mode 100644 index 0000000..fb38573 --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/LoginScreen.java @@ -0,0 +1,271 @@ +package com.smi.smartlab; + +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.os.Bundle; +import android.text.method.HideReturnsTransformationMethod; +import android.text.method.PasswordTransformationMethod; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.AppCompatCheckBox; + +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.google.firebase.database.Query; +import com.google.firebase.database.ValueEventListener; + + +public class LoginScreen extends AppCompatActivity { + + private TextView createaccount, forgetpassword; + private Button login; + private DatabaseReference databaseReference; + private EditText phonenumber, password; + String passworddata, phonenum, phonenumbers, name; + private ProgressDialog loadingBar; + public static final String Name = "nameKey"; + public static final String Phone = "phoneKey"; + private ImageButton close; + private AppCompatCheckBox checkbox; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login__screen); + createaccount = findViewById(R.id.createaccount); + phonenumber = findViewById(R.id.contactnumber); + checkbox = (AppCompatCheckBox) findViewById(R.id.showpassword); + + password = findViewById(R.id.password); + checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { + if (isChecked) { + // show password + password.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); + } else { + // hide password + password.setTransformationMethod(PasswordTransformationMethod.getInstance()); + } + } + }); + + // Paper.init(this); + loadingBar = new ProgressDialog(this); + // Paper.init(this); + + login = findViewById(R.id.login); + forgetpassword = findViewById(R.id.forgetpassword); + forgetpassword.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + open(); + + } + }); + login.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!isOnline()) { + //Create an alertdialog + AlertDialog.Builder Checkbuilder = new AlertDialog.Builder(LoginScreen.this); + Checkbuilder.setTitle("No Internet Connection !"); + Checkbuilder.setMessage("Check Your Internet Connection."); + //Builder Retry Button + + Checkbuilder.setPositiveButton("Retry", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + + dialog.cancel(); + } + }); + + Checkbuilder.setNegativeButton("Exit", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + + AlertDialog alert = Checkbuilder.create(); + alert.show(); + + } else { + String mobile = phonenumber.getText().toString().trim(); + phonenum = mobile; + final String passwordj = password.getText().toString().trim(); + + + if (mobile.equals("") || passwordj.equals("")) { + Toast.makeText(LoginScreen.this, "Please enter all the required fields", Toast.LENGTH_SHORT).show(); + + } else { + loadingBar.setTitle("Login Account"); + loadingBar.setMessage("Please wait, while we are checking the credentials."); + loadingBar.setCanceledOnTouchOutside(false); + loadingBar.show(); + + Query chekuser = FirebaseDatabase.getInstance().getReference("Companies").orderByChild("company_id").equalTo(phonenum); + chekuser.addListenerForSingleValueEvent(new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot dataSnapshot) { + if (dataSnapshot.exists()) { + String systempassword = dataSnapshot.child(phonenum).child("passkay").getValue(String.class); + + if (systempassword.equals(passwordj)) { + + Toast.makeText(LoginScreen.this, "logged in Successfully...", Toast.LENGTH_SHORT).show(); + loadingBar.dismiss(); + + String name = dataSnapshot.child(phonenum).child("company_name").getValue(String.class); + String nid = dataSnapshot.child(phonenum).child("company_name").getValue(String.class); + + Log.e("name", name); + + + SharedPreferences preferences = getSharedPreferences("PhoneBook_number", MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + + // editor.putString(Name, phonenum); + editor.putString("Phone", phonenum); + + editor.commit(); + + + Intent intent = new Intent(LoginScreen.this, Home.class); + + + intent.putExtra("mobile", phonenum); + + startActivity(intent); + + } else { + loadingBar.dismiss(); + + Toast.makeText(LoginScreen.this, "Wrong Password", Toast.LENGTH_SHORT).show(); + } + } else { + loadingBar.dismiss(); + + Toast.makeText(LoginScreen.this, "No such user exists", Toast.LENGTH_SHORT).show(); + } + + } + + @Override + public void onCancelled(@NonNull DatabaseError databaseError) { + Toast.makeText(LoginScreen.this, databaseError.getMessage(), Toast.LENGTH_SHORT).show(); + + } + }); + + + } + } + } + }); + createaccount.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + open(); + + } + }); + } + + private void net_check() { + if (!isOnline()) { + + AlertDialog.Builder Checkbuilder = new AlertDialog.Builder(LoginScreen.this); + Checkbuilder.setTitle("Error!"); + Checkbuilder.setMessage("Enable your internet connection and Retry "); + + Checkbuilder.setPositiveButton("Retry", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + + dialog.cancel(); + + } + }); + + Checkbuilder.setNegativeButton("Exit", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + } + ); + + AlertDialog alert = Checkbuilder.create(); + alert.show(); + + } + } + + @Override + public void onBackPressed() { + + finishAffinity(); + finish(); + } + + public boolean isOnline() { + ConnectivityManager connMgr = (ConnectivityManager) + getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); + return (networkInfo != null && networkInfo.isConnected()); + + } + + + public void open() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Contact Us :ShanMukha Innovations Pvt Ltd\n" + + "No. 25, 2nd floor, Ram Thulasi Chambers\n" + + "MS Ramaiah Road , Mathikere\n" + + "Bangalore, Karnataka 560054.\n" + + "\n" + + "Tel: +91 9742255674\n" + + "Email : info@sminnovations.in"); + alertDialogBuilder.setPositiveButton("Okay", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + + } + }); + + alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Intent intent = new Intent(LoginScreen.this, LoginScreen.class); + startActivity(intent); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + + +} diff --git a/app/src/main/java/com/smi/smartlab/NavigationTop.java b/app/src/main/java/com/smi/smartlab/NavigationTop.java new file mode 100644 index 0000000..e704ae7 --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/NavigationTop.java @@ -0,0 +1,129 @@ +package com.smi.smartlab; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.MenuItem; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.drawerlayout.widget.DrawerLayout; + +import com.google.android.material.navigation.NavigationView; + +public class NavigationTop extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { + + protected DrawerLayout draw; + private LinearLayout line; + private Toolbar tool; + + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { + switch (menuItem.getItemId()) + { + + case R.id.nav_contact_us: + Intent intent3=new Intent(this, About.class); + startActivity(intent3); + break; + // open(); + case R.id.nav_home: + Intent intent2=new Intent(this, Home.class); + startActivity(intent2); + break; + + case R.id.nav_logout: + Intent intent8=new Intent(this, LoginScreen.class); + SharedPreferences preferences = getSharedPreferences("PhoneBook_number", MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + + // editor.putString(Name, phonenum); + editor.putString("Phone", null); + editor.putString("Name",null); + + + editor.commit(); + + startActivity(intent8); + break; + + } + return true; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + + setContentView(R.layout.activity_navigation__top); + + + draw = findViewById(R.id.Drawer); + line = findViewById(R.id.line); + tool = findViewById(R.id.tollbar); + NavigationView navigationView = findViewById(R.id.navigation); + navigationView.setNavigationItemSelectedListener(this); + + setSupportActionBar(tool); + + Window window = getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + + + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, draw, tool, R.string.open_navigation_drawer, R.string.close_navigation_drawer) { + @Override + public void onDrawerSlide(View drawerView, float slideOffset) { + super.onDrawerSlide(drawerView, slideOffset); + float sidebar = drawerView.getWidth() * slideOffset; + line.setTranslationX(sidebar); + } + }; + + draw.addDrawerListener(toggle); + toggle.syncState(); + View headerView = navigationView.getHeaderView(0); + TextView textView=headerView.findViewById(R.id.text); + TextView textView1=headerView.findViewById(R.id.not_sign_in); + + SharedPreferences preferences=getSharedPreferences("PhoneBook_number",MODE_PRIVATE); + + String string1 = preferences.getString("Phone", null); + String string2 = preferences.getString("Name", null); + textView.setText(string2); + textView1.setText(string1); + + } + public void open(){ + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Contact Us :ShanMukha Innovations Pvt Ltd\n" + + "No. 25, 2nd floor, Ram Thulasi Chambers\n" + + "MS Ramaiah Road , Mathikere\n" + + "Bangalore, Karnataka 560054.\n" + + "\n" + + "Tel: +91 9742255674\n" + + "Email : info@sminnovations.in"); + alertDialogBuilder.setPositiveButton("Okay", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + Intent intent = new Intent(NavigationTop.this, Home.class); + startActivity(intent); + } + }); + + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } +} + diff --git a/app/src/main/java/com/smi/smartlab/SplashScreen.java b/app/src/main/java/com/smi/smartlab/SplashScreen.java new file mode 100644 index 0000000..0f8c2d9 --- /dev/null +++ b/app/src/main/java/com/smi/smartlab/SplashScreen.java @@ -0,0 +1,44 @@ +package com.smi.smartlab; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.Handler; + +import androidx.appcompat.app.AppCompatActivity; + + +public class SplashScreen extends AppCompatActivity { + + private static int SPLASH_TIME_OUT=3000; + String number; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_splash_screen); + SharedPreferences preferences6 = getSharedPreferences("PhoneBook_number", MODE_PRIVATE); + + number = preferences6.getString("Phone", null); + + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (number == null ) { + + + Intent home = new Intent(SplashScreen.this, LoginScreen.class); + startActivity(home); + finish(); + } + else + { + Intent home1 = new Intent(SplashScreen.this, Home.class); + startActivity(home1); + finish(); + } + + } + }, SPLASH_TIME_OUT); + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_list_row.xml b/app/src/main/res/drawable/bg_list_row.xml new file mode 100644 index 0000000..e817f66 --- /dev/null +++ b/app/src/main/res/drawable/bg_list_row.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/buttonshape.xml b/app/src/main/res/drawable/buttonshape.xml new file mode 100644 index 0000000..85525c7 --- /dev/null +++ b/app/src/main/res/drawable/buttonshape.xml @@ -0,0 +1,20 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_add_24.xml b/app/src/main/res/drawable/ic_baseline_add_24.xml new file mode 100644 index 0000000..ad75d50 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_add_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_search_24.xml b/app/src/main/res/drawable/ic_baseline_search_24.xml new file mode 100644 index 0000000..21be354 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_search_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_share_24.xml b/app/src/main/res/drawable/ic_baseline_share_24.xml new file mode 100644 index 0000000..ba7e732 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_share_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/logo_app.png b/app/src/main/res/drawable/logo_app.png new file mode 100644 index 0000000..0215f9a Binary files /dev/null and b/app/src/main/res/drawable/logo_app.png differ diff --git a/app/src/main/res/drawable/round_background.xml b/app/src/main/res/drawable/round_background.xml new file mode 100644 index 0000000..e427e9b --- /dev/null +++ b/app/src/main/res/drawable/round_background.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shanmukha_logo_small.png b/app/src/main/res/drawable/shanmukha_logo_small.png new file mode 100644 index 0000000..ba5bdf7 Binary files /dev/null and b/app/src/main/res/drawable/shanmukha_logo_small.png differ diff --git a/app/src/main/res/drawable/text_back.xml b/app/src/main/res/drawable/text_back.xml new file mode 100644 index 0000000..b155c77 --- /dev/null +++ b/app/src/main/res/drawable/text_back.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/fontstyle.ttf b/app/src/main/res/font/fontstyle.ttf new file mode 100644 index 0000000..0ac5e51 Binary files /dev/null and b/app/src/main/res/font/fontstyle.ttf differ diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..1d93388 --- /dev/null +++ b/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_gps_location.xml b/app/src/main/res/layout/activity_gps_location.xml new file mode 100644 index 0000000..82fdc57 --- /dev/null +++ b/app/src/main/res/layout/activity_gps_location.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml new file mode 100644 index 0000000..a0e0c49 --- /dev/null +++ b/app/src/main/res/layout/activity_home.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + //second linear + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_lab.xml b/app/src/main/res/layout/activity_lab.xml new file mode 100644 index 0000000..68ccf1c --- /dev/null +++ b/app/src/main/res/layout/activity_lab.xml @@ -0,0 +1,423 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //second linear + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login__screen.xml b/app/src/main/res/layout/activity_login__screen.xml new file mode 100644 index 0000000..ff04568 --- /dev/null +++ b/app/src/main/res/layout/activity_login__screen.xml @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + /> + + + + +