Smart Lab App
This commit is contained in:
22
app/src/main/java/com/smi/smartlab/About.java
Normal file
22
app/src/main/java/com/smi/smartlab/About.java
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
app/src/main/java/com/smi/smartlab/FontAwesome.java
Normal file
35
app/src/main/java/com/smi/smartlab/FontAwesome.java
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
218
app/src/main/java/com/smi/smartlab/GPS_Location.java
Normal file
218
app/src/main/java/com/smi/smartlab/GPS_Location.java
Normal file
@@ -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<String>() {
|
||||
@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));
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
38
app/src/main/java/com/smi/smartlab/Home.java
Normal file
38
app/src/main/java/com/smi/smartlab/Home.java
Normal file
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
93
app/src/main/java/com/smi/smartlab/Lab_Metrics.java
Normal file
93
app/src/main/java/com/smi/smartlab/Lab_Metrics.java
Normal file
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
271
app/src/main/java/com/smi/smartlab/LoginScreen.java
Normal file
271
app/src/main/java/com/smi/smartlab/LoginScreen.java
Normal file
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
129
app/src/main/java/com/smi/smartlab/NavigationTop.java
Normal file
129
app/src/main/java/com/smi/smartlab/NavigationTop.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
44
app/src/main/java/com/smi/smartlab/SplashScreen.java
Normal file
44
app/src/main/java/com/smi/smartlab/SplashScreen.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user