Skip to content

Commit

Permalink
Added App logo, Splash Screen and Connected Firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
dhanushp committed Aug 15, 2021
1 parent f19300d commit c6a236c
Show file tree
Hide file tree
Showing 28 changed files with 134 additions and 274 deletions.
2 changes: 2 additions & 0 deletions .idea/misc.xml

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

6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionName "0.1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -34,6 +34,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-database:19.2.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand All @@ -49,7 +50,6 @@ dependencies {
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

implementation 'com.google.firebase:firebase-bom:28.3.0'
implementation 'com.google.firebase:firebase-analytics:19.0.0'
implementation platform('com.google.firebase:firebase-bom:28.3.1')

}
14 changes: 7 additions & 7 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"project_info": {
"project_number": "1015133424218",
"project_id": "coivid-19-tracker",
"storage_bucket": "coivid-19-tracker.appspot.com"
"project_number": "690019437051",
"project_id": "covid19-tracker-b8b56",
"storage_bucket": "covid19-tracker-b8b56.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1015133424218:android:f16c96969153d3fd7f6663",
"mobilesdk_app_id": "1:690019437051:android:e9cabc58792b3ddb2a235e",
"android_client_info": {
"package_name": "com.example.covid_19tracker"
}
},
"oauth_client": [
{
"client_id": "1015133424218-g31eq95kvdq1tjntaequ93hobr1aeshp.apps.googleusercontent.com",
"client_id": "690019437051-ehol6ondflj2tvipc137bddg7qd7fu91.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyC-ww3rwQS_phcI7QJ9uZG0kzeEonHH7xw"
"current_key": "AIzaSyC_OKYEmAie3v6RO8MFkaRQot2MwxDjJZU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1015133424218-g31eq95kvdq1tjntaequ93hobr1aeshp.apps.googleusercontent.com",
"client_id": "690019437051-ehol6ondflj2tvipc137bddg7qd7fu91.apps.googleusercontent.com",
"client_type": 3
}
]
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/ic_launcher_round-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions app/src/main/java/com/example/covid_19tracker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
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;
//import com.google.firebase.database.DataSnapshot;
//import com.google.firebase.database.DatabaseError;
//import com.google.firebase.database.DatabaseReference;
Expand All @@ -52,8 +57,8 @@
public class MainActivity extends AppCompatActivity {

private String version;
// private FirebaseDatabase firebaseDatabase;
// private DatabaseReference databaseReference;
private FirebaseDatabase firebaseDatabase;
private DatabaseReference databaseReference;
private String appUrl;
private TextView tv_confirmed, tv_confirmed_new, tv_active, tv_active_new, tv_recovered, tv_recovered_new, tv_death,
tv_death_new, tv_tests, tv_tests_new, tv_date, tv_time;
Expand All @@ -77,7 +82,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

//Check app update in Firebase
// CheckForUpdate();
// CheckForUpdate();

//setting up the titlebar text
getSupportActionBar().setTitle("Covid-19 Tracker (India)");
Expand Down Expand Up @@ -164,6 +169,8 @@ public void onClick(View v) {
//
// alertDialog.show();
// }
//
//
// }
//
// @Override
Expand Down
185 changes: 99 additions & 86 deletions app/src/main/java/com/example/covid_19tracker/SplashActivity.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
package com.example.covid_19tracker;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;

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 SplashActivity extends AppCompatActivity {

private static final long SPLASH_SCREEN_TIMEOUT = 5000;

private static final long SPLASH_SCREEN_TIMEOUT = 2000;
private String version;
// private FirebaseDatabase firebaseDatabase;
// private DatabaseReference databaseReference;
private FirebaseDatabase firebaseDatabase;
private DatabaseReference databaseReference;
private String appUrl;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
Expand All @@ -27,90 +38,92 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().hide();
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));

// CheckForUpdate();
CheckForUpdate();

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, SPLASH_SCREEN_TIMEOUT);
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// Intent intent = new Intent(SplashActivity.this, MainActivity.class);
// startActivity(intent);
// finish();
// }
// }, SPLASH_SCREEN_TIMEOUT);
}

// private void CheckForUpdate() {
// try{
// version = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
//
// firebaseDatabase = FirebaseDatabase.getInstance();
// databaseReference = firebaseDatabase.getReference("Version").child("versionNumber");
// databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
// @Override
// public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
// String versionName = (String) dataSnapshot.getValue();
//
// if(!versionName.equals(version)){
// //Toast.makeText(MainActivity.this, "Successful", Toast.LENGTH_SHORT).show();
//
// AlertDialog alertDialog = new AlertDialog.Builder(SplashActivity.this)
// .setTitle("New Version Available!")
// .setMessage("Please update our app to the latest version for continuous use.")
// .setPositiveButton("UPDATE", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// DatabaseReference myRef = FirebaseDatabase.getInstance().getReference("Version").child("appUrl");
// myRef.addListenerForSingleValueEvent(new ValueEventListener() {
// @Override
// public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
// appUrl = dataSnapshot.getValue().toString();
// startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(appUrl)));
// finish();
// }
//
// @Override
// public void onCancelled(@NonNull DatabaseError databaseError) {
//
// }
// });
// }
// })
// .setNegativeButton("EXIT", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// finish();
// }
// })
// .create();
//
// alertDialog.setCancelable(false);
// alertDialog.setCanceledOnTouchOutside(false);
//
// alertDialog.show();
// }
// else{
// int SPLASH_SCREEN_TIMEOUT = 2000;
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
//
// Intent intent = new Intent(SplashActivity.this, MainActivity.class);
// startActivity(intent);
// finish();
// }
// }, SPLASH_SCREEN_TIMEOUT);
// }
//
// }
//
// @Override
// public void onCancelled(@NonNull DatabaseError databaseError) {
//
// }
// });
//
// }catch (Exception e){
// e.printStackTrace();
// }
// }
private void CheckForUpdate() {
try{
version = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionName;

firebaseDatabase = FirebaseDatabase.getInstance();
databaseReference = firebaseDatabase.getReference("Version").child("versionNumber");
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String versionName = (String) dataSnapshot.getValue();


if(!versionName.equals(version)){
// Toast.makeText(MainActivity.this, "Successful", Toast.LENGTH_SHORT).show();

AlertDialog alertDialog = new AlertDialog.Builder(SplashActivity.this)
.setTitle("New Version Available!")
.setMessage("Please update our app to the latest version for continuous use.")
.setPositiveButton("UPDATE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
DatabaseReference myRef = FirebaseDatabase.getInstance().getReference("Version").child("appUrl");
myRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
appUrl = dataSnapshot.getValue().toString();
System.out.println(appUrl);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(appUrl)));
finish();
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});
}
})
.setNegativeButton("EXIT", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.create();

alertDialog.setCancelable(false);
alertDialog.setCanceledOnTouchOutside(false);

alertDialog.show();
}
else{
int SPLASH_SCREEN_TIMEOUT = 2000;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {

Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, SPLASH_SCREEN_TIMEOUT);
}

}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});

}catch (Exception e){
e.printStackTrace();
}
}
}
Loading

0 comments on commit c6a236c

Please sign in to comment.