diff --git a/.gitignore b/.gitignore index 39fb081..de927bb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /build /captures .externalNativeBuild +/app/src/main/java/com/example/dell/loot/Endpoints.java diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 0000000..5524c58 --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,47 @@ + + + + + + \ No newline at end of file diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..7898ada Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..ae78c11 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,113 @@ + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index cc72de3..64a67ca 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,45 +5,44 @@ - + - - - - - 1.8 - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 2e854e3..848244c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,21 +5,20 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 26 + compileSdkVersion 28 defaultConfig { - applicationId "com.example.dell.loot" - minSdkVersion 15 - targetSdkVersion 26 - versionCode 1 - versionName "1.0" + applicationId "com.hackncs.zealicon.loot" + minSdkVersion 18 + targetSdkVersion 28 + versionCode 7 + versionName "2.0" multiDexEnabled true - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true } buildTypes { release { minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } @@ -29,23 +28,26 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" //noinspection GradleCompatible - compile 'com.android.support:cardview-v7:26.1.0' - implementation 'com.android.support:appcompat-v7:26.1.0' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - implementation 'com.android.support:design:26.1.0' - implementation 'com.android.support:support-v4:26.1.0' - implementation 'com.google.firebase:firebase-auth:11.8.0' - implementation 'com.google.firebase:firebase-database:11.8.0' - compile 'com.google.android.gms:play-services-location:11.8.0' - compile 'com.google.firebase:firebase-messaging:11.8.0' - compile 'com.google.firebase:firebase-core:11.8.0' - compile 'com.android.volley:volley:1.0.0' - compile 'com.github.armcha:SpaceNavigationView:1.6.0' - compile 'com.android.support:multidex:1.0.3' - compile 'com.google.android.gms:play-services:11.8.0' - compile 'com.google.firebase:firebase-firestore:11.8.0' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.appcompat:appcompat:1.1.0-alpha02' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3' + implementation 'com.google.android.material:material:1.1.0-alpha03' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'com.google.firebase:firebase-auth:16.1.0' + implementation 'com.google.firebase:firebase-database:16.0.6' + implementation 'com.google.android.gms:play-services-location:16.0.0' + implementation 'com.google.firebase:firebase-messaging:17.3.4' + implementation 'com.google.firebase:firebase-core:16.0.7' + implementation 'com.android.volley:volley:1.1.0' + implementation 'com.github.armcha:SpaceNavigationView:1.6.0' + implementation 'androidx.multidex:multidex:2.0.1' + implementation 'com.google.firebase:firebase-firestore:18.0.1' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:0.5' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2' + implementation 'com.squareup.retrofit2:retrofit:2.3.0' + implementation 'com.google.code.gson:gson:2.8.2' + implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + androidTestImplementation 'androidx.test:runner:1.1.2-alpha01' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01' + implementation 'com.google.android.material:material:1.1.0-alpha03' } -apply plugin: 'com.google.gms.google-services' \ No newline at end of file +apply plugin: 'com.google.gms.google-services' diff --git a/app/google-services.json b/app/google-services.json index 8b1ee33..2f1795b 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -1,35 +1,35 @@ { "project_info": { - "project_number": "985079861117", - "firebase_url": "https://quizbox-ab539.firebaseio.com", - "project_id": "quizbox-ab539", - "storage_bucket": "quizbox-ab539.appspot.com" + "project_number": "755281348975", + "firebase_url": "https://loot-test-b6e21.firebaseio.com", + "project_id": "loot-test-b6e21", + "storage_bucket": "loot-test-b6e21.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:985079861117:android:bf074d82fd6a320d", + "mobilesdk_app_id": "1:755281348975:android:bf074d82fd6a320d", "android_client_info": { "package_name": "com.example.dell.loot" } }, "oauth_client": [ { - "client_id": "985079861117-c06j8qud16n49f5tep725apqjmqg0p1d.apps.googleusercontent.com", + "client_id": "755281348975-8nrak8q3p0l3b5mkshgnponr0bdjpk8v.apps.googleusercontent.com", "client_type": 1, "android_info": { "package_name": "com.example.dell.loot", - "certificate_hash": "cb7818da76a7f13658fba971657b4996734304a1" + "certificate_hash": "04d799a8e6900fb914f5fe90f31583a8dba9ddcf" } }, { - "client_id": "985079861117-0hpb7dc3tupjvgp8mk1oi73oo00f1q1k.apps.googleusercontent.com", + "client_id": "755281348975-s76ur0rd2gisemrm5ve8jo62lt16c8m6.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { - "current_key": "AIzaSyBGFJ1kxqrrIrSavnN9ipVBWtqGmh4W8Nk" + "current_key": "AIzaSyDBf_qhgAyQcy7IgbNhe5QV2yV2q1275iY" } ], "services": { @@ -40,7 +40,51 @@ "status": 2, "other_platform_oauth_client": [ { - "client_id": "985079861117-0hpb7dc3tupjvgp8mk1oi73oo00f1q1k.apps.googleusercontent.com", + "client_id": "755281348975-s76ur0rd2gisemrm5ve8jo62lt16c8m6.apps.googleusercontent.com", + "client_type": 3 + } + ] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:755281348975:android:135134922cfd2ce6", + "android_client_info": { + "package_name": "com.hackncs.zealicon.loot" + } + }, + "oauth_client": [ + { + "client_id": "755281348975-auehd1jchduik91t336hpd9sbga7saih.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.hackncs.zealicon.loot", + "certificate_hash": "04d799a8e6900fb914f5fe90f31583a8dba9ddcf" + } + }, + { + "client_id": "755281348975-s76ur0rd2gisemrm5ve8jo62lt16c8m6.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyDBf_qhgAyQcy7IgbNhe5QV2yV2q1275iY" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 2, + "other_platform_oauth_client": [ + { + "client_id": "755281348975-s76ur0rd2gisemrm5ve8jo62lt16c8m6.apps.googleusercontent.com", "client_type": 3 } ] diff --git a/app/release/app.aab b/app/release/app.aab new file mode 100644 index 0000000..3503202 Binary files /dev/null and b/app/release/app.aab differ diff --git a/app/src/androidTest/java/com/example/dell/loot/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/hackncs/zealicon/loot/ExampleInstrumentedTest.kt similarity index 94% rename from app/src/androidTest/java/com/example/dell/loot/ExampleInstrumentedTest.kt rename to app/src/androidTest/java/com/hackncs/zealicon/loot/ExampleInstrumentedTest.kt index 236e824..cbad7e7 100644 --- a/app/src/androidTest/java/com/example/dell/loot/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/hackncs/zealicon/loot/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.example.dell.loot +package com.hackncs.zealicon.loot import android.support.test.InstrumentationRegistry import android.support.test.runner.AndroidJUnit4 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 684192f..3d0dec8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,23 +1,25 @@ + package="com.hackncs.zealicon.loot"> - + + + + - + + android:name="com.hackncs.zealicon.loot.MyFirebaseMessagingService"> - - - - - + + + + + + + + - + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/CameraPreview.java b/app/src/main/java/com/example/dell/loot/CameraPreview.java deleted file mode 100644 index 157be3f..0000000 --- a/app/src/main/java/com/example/dell/loot/CameraPreview.java +++ /dev/null @@ -1,75 +0,0 @@ -//package com.example.dell.loot; -// -//import android.annotation.SuppressLint; -// -//import android.content.Context; -// -//import android.content.res.Configuration; -//import android.hardware.Camera; -// -//import android.util.Log; -//import android.view.SurfaceHolder; -//import android.view.SurfaceView; -// -// -//import java.io.IOException; -// -//import static android.content.ContentValues.TAG; -// -//@SuppressLint("ViewConstructor") -//public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback { -// -// private SurfaceHolder mHolder; -// private Camera mCamera; -// -// public CameraPreview(Context context, Camera camera) { -// super(context); -// mCamera = camera; -// mHolder = getHolder(); -// Log.i("holder",mHolder.getSurface().toString()); -// mHolder.addCallback(this); -// } -// -// public void surfaceCreated(SurfaceHolder holder) { -// try { -// if(mCamera!=null) { -// mCamera.setPreviewDisplay(holder); -// mCamera.startPreview(); -// } -// else { -// -// } -// } catch (IOException e) { -// Log.d(TAG, "Error setting camera preview: " + e.getMessage()); -// } -// } -// -// public void surfaceDestroyed(SurfaceHolder holder) { -// -// } -// -// public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { -// if (mHolder.getSurface() == null){ -// return; -// } -// try { -// mCamera.stopPreview(); -// } catch (Exception e){ -// -// } -// -// try { -// mCamera.setPreviewDisplay(mHolder); -// Camera.Parameters parameters = mCamera.getParameters(); -// if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { -// parameters.set("orientation", "portrait"); -// parameters.set("rotation",90); -// mCamera.setDisplayOrientation(90); -// } -// mCamera.setParameters(parameters); -// mCamera.startPreview(); -// } catch (Exception e){ -// Log.d(TAG, "Error starting camera preview: " + e.getMessage()); -// } -// } -//} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/ContactUs.java b/app/src/main/java/com/example/dell/loot/ContactUs.java deleted file mode 100644 index a01489f..0000000 --- a/app/src/main/java/com/example/dell/loot/ContactUs.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.dell.loot; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -public class ContactUs extends Fragment { - - public ContactUs() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_contact_us, container, false); - } - -} diff --git a/app/src/main/java/com/example/dell/loot/CurrentMission.java b/app/src/main/java/com/example/dell/loot/CurrentMission.java deleted file mode 100644 index 5c308df..0000000 --- a/app/src/main/java/com/example/dell/loot/CurrentMission.java +++ /dev/null @@ -1,392 +0,0 @@ -package com.example.dell.loot; - -import android.Manifest; -import android.app.AlertDialog; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.IntentSender; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.location.Location; -import android.os.Build; -import android.os.Bundle; -import android.os.VibrationEffect; -import android.os.Vibrator; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.ActivityCompat; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.Toast; - -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.google.android.gms.common.ConnectionResult; -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.ResultCallback; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.LocationListener; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.LocationServices; -import com.google.android.gms.location.LocationSettingsRequest; -import com.google.android.gms.location.LocationSettingsResult; -import com.google.android.gms.location.LocationSettingsStatusCodes; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; - -public class CurrentMission - extends - Fragment - implements - LocationListener, - GoogleApiClient.ConnectionCallbacks, - GoogleApiClient.OnConnectionFailedListener, ResultCallback { - - static final int LOCATION_REQUEST_CODE = 1; - static final int REQUEST_CHECK_SETTINGS = 100; - static final int STATE_LOCATE = 0, STATE_SOLVE = 1; - Button submit, drop_mission; - TextView story, question; - EditText answer; - AlertDialog alertDialog; - Mission mission; - int userStage, state; - Vibrator vibrator; - GoogleApiClient googleApiClient; - LocationRequest locationRequest; - FirebaseDatabase database; - DatabaseReference users, missions; - ProgressDialog progressDialog; - LootApplication app; - - public CurrentMission() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_current_mission, container, false); - story = view.findViewById(R.id.story); - question = view.findViewById(R.id.question); - answer = view.findViewById(R.id.answer); - submit = view.findViewById(R.id.submit); - drop_mission = view.findViewById(R.id.drop_mission); - vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); - SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); - userStage = sharedPreferences.getInt("com.hackncs.stage",0); - state = sharedPreferences.getInt("com.hackncs.state", 0); - checkPermission(); - StringRequest fetchMission = new StringRequest(Request.Method.GET, - Endpoints.fetchMission + userStage, - new Response.Listener() { - @Override - public void onResponse(String response) { -// mission.setMissionID(); -// mission.setMissionName(); -// mission.setStory(); -// mission.setDescription(); -// mission.setLat(); -// mission.setLng(); -// mission.setAnswer(); - progressDialog.dismiss(); - } - }, - new Response.ErrorListener() { - @Override - public void onErrorResponse(VolleyError error) { - progressDialog.dismiss(); - Toast.makeText(getContext(), "Error in fetching data!", Toast.LENGTH_SHORT).show(); - } - }); - RequestQueue requestQueue = Volley.newRequestQueue(getContext()); - requestQueue.add(fetchMission); - return view; - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - progressDialog = new ProgressDialog(getContext()); - progressDialog.setMessage("Loading..."); - progressDialog.show(); - drop_mission.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setTitle("Drop Mission"); - builder.setMessage((((int)Math.pow(2, (userStage-1)))*10)+" coins will be deducted!"); - builder.setPositiveButton("Drop", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - // TODO: update stage, state and score in SharedPrefs and Backend - getFragmentManager().beginTransaction().detach(CurrentMission.this).attach(CurrentMission.this).commit(); - } - }); - builder.setNegativeButton("Stay", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - alertDialog.dismiss(); - } - }); - alertDialog = builder.create(); - } - }); - switch (state) { - case STATE_LOCATE: - checkPermission(); - googleApiClient = new GoogleApiClient.Builder(getContext()) - .addApi(LocationServices.API) - .addConnectionCallbacks(this) - .addOnConnectionFailedListener(this) - .build(); - if (!googleApiClient.isConnected()) { - googleApiClient.connect(); - } - //TODO: update below - question.setText(/*mission.getStory()*/"Story"); - answer.setEnabled(false); - submit.setEnabled(false); - break; - case STATE_SOLVE: - if (googleApiClient.isConnected()) { - googleApiClient.disconnect(); - } - question.setText(mission.getDescription()); - answer.setEnabled(true); - submit.setEnabled(true); - submit.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (!answer.getText().toString().equals(mission.getAnswer())) { - answer.setText(""); - Toast.makeText(getContext(), "You might wanna try another one!", Toast.LENGTH_SHORT).show(); - } else { - // TODO: update stage, state and score in SharedPrefs and Backend - getFragmentManager().beginTransaction().detach(CurrentMission.this).attach(CurrentMission.this).commit(); - } - } - }); - break; - } -// database = FirebaseDatabase.getInstance(); -// users = database.getReference("Users"); -// missions = database.getReference("Missions"); -// progressDialog = new ProgressDialog(getContext()); -// app = (LootApplication)getActivity().getApplication(); -// if(app.user.active != null) { -// progressDialog.setMessage("Loading Mission..."); -// progressDialog.setTitle("Please Wait..."); -// progressDialog.show(); -// missions.child(app.user.active).addValueEventListener(new ValueEventListener() { -// @Override -// public void onDataChange(DataSnapshot dataSnapshot) { -// mission = dataSnapshot.getValue(Mission.class); -// story.setText(mission.getStory()); -// question.setText(mission.getDescription()); -// if(progressDialog.isShowing()) { -// progressDialog.dismiss(); -// } -// } -// -// @Override -// public void onCancelled(DatabaseError databaseError) { -// -// } -// }); -// } -// submit.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// if(answer.getText().toString().equalsIgnoreCase(mission.getAnswer())) { -// app.user.active = null; -// app.user.completed.add(mission.getMissionID()); -// app.user.score += 10; -// users.child(app.user.getUserID()).setValue(app.user); -// } -// } -// }); -// -// drop_mission.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// app.user.active = null; -// app.user.dropped.add(mission.getMissionID()); -// app.user.score -= 2; -// users.child(app.user.getUserID()).setValue(app.user); -// } -// }); { - } - - @Override - public void onConnected(@Nullable Bundle bundle) { - locationRequest = LocationRequest.create(); - locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); - locationRequest.setInterval(1000); - checkPermission(); - - LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() - .addLocationRequest(locationRequest); - builder.setAlwaysShow(true); - PendingResult result = LocationServices.SettingsApi. - checkLocationSettings(googleApiClient, builder.build()); - result.setResultCallback(this); - - LocationServices.FusedLocationApi. - requestLocationUpdates(googleApiClient, locationRequest, this); - } - - @Override - public void onConnectionSuspended(int i) { - Toast.makeText(getContext(), "Connection Suspended!", Toast.LENGTH_SHORT).show(); - checkPermission(); - } - - @Override - public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { - Toast.makeText(getContext(), "Connection Failed!", Toast.LENGTH_SHORT).show(); - checkPermission(); - } - - @Override - public void onLocationChanged(Location location) { - Location missionLocation = new Location(""); - //TODO: update below - missionLocation.setLatitude(/*mission.getLat()*/0.0); - missionLocation.setLongitude(/*mission.getLng()*/0.0); - Toast.makeText(getContext(), location.distanceTo(missionLocation)+"", Toast.LENGTH_SHORT).show(); - if (location.distanceTo(missionLocation) < 5) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - vibrator.vibrate(VibrationEffect.createWaveform( - new long[]{0, 250, 200, 250, 150, 150, 75, 150, 75, 150}, -1)); - } - // TODO: update state in SharedPrefs and Backend - getFragmentManager().beginTransaction().detach(this).attach(this).commit(); - } - } - - private void checkPermission() { - if (ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != - PackageManager.PERMISSION_GRANTED || - ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != - PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(getActivity(), - new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION}, - LOCATION_REQUEST_CODE); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, - String permissions[], int[] grantResults) { - if (requestCode == LOCATION_REQUEST_CODE) { - if (!(grantResults.length > 0 - && grantResults[0] == PackageManager.PERMISSION_GRANTED)) { - Toast.makeText(getContext(), "Permission not granted!", Toast.LENGTH_SHORT).show(); - } - else - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) { - new AlertDialog.Builder(getContext()) - .setMessage("The app needs to access device's location to function properly!") - .setPositiveButton("Ok", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - checkPermission(); - } - }) - .setNegativeButton("Cancel", null) - .create() - .show(); - } - } - } - } - - @Override - public void onResult(@NonNull LocationSettingsResult locationSettingsResult) { - Status status = locationSettingsResult.getStatus(); - switch (status.getStatusCode()) { - case LocationSettingsStatusCodes.SUCCESS: - // NO need to show the dialog; - break; - case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: - try { - status.startResolutionForResult(getActivity(), REQUEST_CHECK_SETTINGS); - } catch (IntentSender.SendIntentException e) { - e.printStackTrace(); - } - break; - case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: - // Location settings are unavailable so not possible to show any dialog now - break; - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - if (googleApiClient.isConnected()) { - googleApiClient.disconnect(); - } - } - - @Override - public void onStop() { - if (googleApiClient.isConnected()) { - googleApiClient.disconnect(); - } - super.onStop(); - } - // @Override -// public void onDestroyView() { -// Log.i("Current Mission","Destroy View"); -// if(progressDialog.isShowing()) { -// progressDialog.dismiss(); -// } -// super.onDestroyView(); -// } -// -// @Override -// public void onStart() { -// if(app.user.getActive()==null) { -// showDialog(); -// } -// super.onStart(); -// } -// -// @Override -// public void onStop() { -// Log.i("Current Mission","Stop"); -// super.onStop(); -// } -// -// private void showDialog() { -// AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); -// alertDialog.setTitle("Alert"); -// alertDialog.setMessage("No Active Mission"); -// alertDialog.setButton("OK", new DialogInterface.OnClickListener() { -// public void onClick(DialogInterface dialog, int which) { -// BottomNavigationView navigationView = getActivity().findViewById(R.id.navigation); -// navigationView.getMenu().getItem(0).setChecked(true); -// android.support.v4.app.Fragment fragment = new Locator(); -// FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); -// transaction.replace(R.id.frame_container, fragment,"locator"); -// transaction.addToBackStack(null); -// transaction.commit(); -// } -// }); -// alertDialog.show(); -// } -} diff --git a/app/src/main/java/com/example/dell/loot/CustomRecycleAdapter.java b/app/src/main/java/com/example/dell/loot/CustomRecycleAdapter.java deleted file mode 100644 index 62c048a..0000000 --- a/app/src/main/java/com/example/dell/loot/CustomRecycleAdapter.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.example.dell.loot; - -/** - * Created by shobhit on 3/9/2018. - */ -import android.content.Context; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import java.util.ArrayList; -import java.util.List; - -public class CustomRecycleAdapter extends RecyclerView.Adapter { - - private Context mContext; - private ArrayList users; - - public class MyViewHolder extends RecyclerView.ViewHolder { - public TextView name, coins; - public ImageView avatar; - - public MyViewHolder(View view) { - super(view); - name = (TextView) view.findViewById(R.id.user_name); - coins = (TextView) view.findViewById(R.id.user_coins); - avatar = (ImageView) view.findViewById(R.id.imageView); - } - } - - - public CustomRecycleAdapter(Context mContext, ArrayList users) { - this.mContext = mContext; - this.users = users; - } - - @Override - public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View itemView = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.recycle_cards, parent, false); - - return new MyViewHolder(itemView); - } - - @Override - public void onBindViewHolder(final MyViewHolder holder, int position) { - User user = users.get(position); - holder.name.setText(user.getName()); - holder.coins.setText("Coins $"+user.getScore()); - holder.avatar.setImageResource(R.drawable.avatar); - } - - @Override - public int getItemCount() { - return users.size(); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/Dashboard.java b/app/src/main/java/com/example/dell/loot/Dashboard.java deleted file mode 100644 index 46f237e..0000000 --- a/app/src/main/java/com/example/dell/loot/Dashboard.java +++ /dev/null @@ -1,178 +0,0 @@ -////package com.example.dell.loot; -//// -////import android.content.Context; -////import android.os.Bundle; -////import android.support.annotation.NonNull; -////import android.support.annotation.Nullable; -////import android.support.design.widget.BottomNavigationView; -////import android.support.v4.app.Fragment; -////import android.support.v4.app.FragmentTransaction; -////import android.support.v4.view.ViewPager; -////import android.view.LayoutInflater; -////import android.view.MenuItem; -////import android.view.View; -////import android.view.ViewGroup; -//// -////public class Dashboard extends Fragment { -//// -//// private ViewPager viewPager; -//// -//// @Override -//// public void onCreate(Bundle savedInstanceState) { -//// super.onCreate(savedInstanceState); -//// } -//// -//// @Override -//// public View onCreateView(LayoutInflater inflater, ViewGroup container, -//// Bundle savedInstanceState) { -//// return inflater.inflate(R.layout.fragment_dashboard, container, false); -//// } -//// -//// @Override -//// public void onActivityCreated(@Nullable Bundle savedInstanceState) { -//// super.onActivityCreated(savedInstanceState); -////// viewPager = getView().findViewById(R.id.viewpager); -//// LootApplication app = (LootApplication)getActivity().getApplication(); -//// -////// DashboardPagerAdapter dashboardPagerAdapter=new DashboardPagerAdapter(getActivity().getSupportFragmentManager()); -////// viewPager.setAdapter(dashboardPagerAdapter); -//// -////// TabLayout tabLayout = (TabLayout)getView().findViewById(R.id.tabs); -////// tabLayout.setSelected(true); -////// tabLayout.setSelectedTabIndicatorColor(Color.WHITE); -////// tabLayout.setupWithViewPager(viewPager); -////// tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); -////// if(app.user.getActive()==null||app.user.getActive().equalsIgnoreCase("")) { -////// switchTab(1); -////// } -//// -//// BottomNavigationView navigation = getView().findViewById(R.id.navigation); -//// navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); -//// -//// if(app.user.getActive() == null || app.user.getActive().equalsIgnoreCase("")) { -//// Fragment fragment = new Locator(); -//// navigation.getMenu().getItem(1).setChecked(true); -//// loadFragment(fragment,"locator"); -//// } -//<<<<<<< HEAD -//// else { -//// navigation.getMenu().getItem(0).setChecked(true); -//// Fragment fragment=new CurrentMission(); -//// loadFragment(fragment,"current_mission"); -//// } -//// } -//// -//// private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener -//// = new BottomNavigationView.OnNavigationItemSelectedListener() { -//// -//// @Override -//// public boolean onNavigationItemSelected(@NonNull MenuItem item) { -//// Fragment fragment; -//// switch (item.getItemId()) { -//// case R.id.navigation_current_mission: -//// fragment=new CurrentMission(); -//// loadFragment(fragment,"current_mission"); -//// return true; -//======= -// -// BottomNavigationView navigation = (BottomNavigationView)getView().findViewById(R.id.navigation); -// navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); -// -// if(app.user.getActive()==null||app.user.getActive().equalsIgnoreCase("")) -// { -// Fragment fragment=new Locator(); -// navigation.getMenu().getItem(1).setChecked(true); -// loadFragment(fragment,"locator"); -// } -// else -// { -// navigation.getMenu().getItem(0).setChecked(true); -// Fragment fragment=new Current_Mission(); -// loadFragment(fragment,"current_mission"); -// } -// -// -// } -// -// private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener -// = new BottomNavigationView.OnNavigationItemSelectedListener() { -// -// @Override -// public boolean onNavigationItemSelected(@NonNull MenuItem item) { -// Fragment fragment; -// switch (item.getItemId()) { -// case R.id.navigation_current_mission: -// fragment=new Current_Mission(); -// loadFragment(fragment,"current_mission"); -// return true; -//>>>>>>> d48ec20aa78b74743034f053fe1d0a93799096ae -//// case R.id.navigation_locator: -//// fragment=new Locator(); -//// loadFragment(fragment,"locator"); -//// return true; -//// case R.id.navigation_stats: -//// fragment=new Stats(); -//// loadFragment(fragment,"stats"); -//// return true; -//<<<<<<< HEAD -//// case R.id.navigation_leaderboard: -//// fragment=new LeaderBoard(); -//// loadFragment(fragment,"leaderboard"); -//// return true; -//// } -//// return false; -//// } -//// }; -//// -//// -//// private void loadFragment(Fragment fragment, String tag) { -//// FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); -//// transaction.replace(R.id.frame_container, fragment, tag); -//// transaction.addToBackStack(null); -//// transaction.commit(); -//// } -//// -//// @Override -//// public void onAttach(Context context) { -//// super.onAttach(context); -//// } -//// -//// @Override -//// public void onDetach() { -//// super.onDetach(); -//// } -//// -////} -//======= -// case R.id.navigation_leaderboard: -// fragment=new LeaderBoard(); -// loadFragment(fragment,"leaderboard"); -// return true; -// } -// return false; -// } -// }; -// -// -// private void loadFragment(Fragment fragment,String tag) { -// // load fragment -// FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); -// transaction.replace(R.id.frame_container, fragment,tag); -// transaction.addToBackStack(null); -// transaction.commit(); -// } -// @Override -// public void onAttach(Context context) { -// super.onAttach(context); -// -// } -// -// @Override -// public void onDetach() { -// super.onDetach(); -// -// } -// -// -//} -//>>>>>>> d48ec20aa78b74743034f053fe1d0a93799096ae diff --git a/app/src/main/java/com/example/dell/loot/DashboardLoot.java b/app/src/main/java/com/example/dell/loot/DashboardLoot.java deleted file mode 100644 index 79692b1..0000000 --- a/app/src/main/java/com/example/dell/loot/DashboardLoot.java +++ /dev/null @@ -1,269 +0,0 @@ -package com.example.dell.loot; - -import android.content.Intent; -import android.os.Build; -import android.support.annotation.NonNull; -import android.support.annotation.RequiresApi; -import android.support.design.widget.BottomNavigationView; -import android.support.design.widget.FloatingActionButton; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.support.v7.widget.Toolbar; -import android.util.Log; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.PopupMenu; -import android.widget.Toast; - -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.auth.FirebaseUser; -import com.google.firebase.firestore.FirebaseFirestore; -import com.luseen.spacenavigation.SpaceItem; -import com.luseen.spacenavigation.SpaceNavigationView; -import com.luseen.spacenavigation.SpaceOnClickListener; - -import java.util.HashMap; -import java.util.Map; - -public class DashboardLoot extends AppCompatActivity { - - SpaceNavigationView spaceNavigationView; - FloatingActionButton fab; - - FirebaseAuth mAuth; - FirebaseFirestore db; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_dashboard_loot); - Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar2); - fab = findViewById(R.id.fab); - db= FirebaseFirestore.getInstance(); - mAuth = FirebaseAuth.getInstance(); - setSupportActionBar(toolbar); - getSupportActionBar().setDisplayShowTitleEnabled(false); - - spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space); - spaceNavigationView.initWithSaveInstanceState(savedInstanceState); - spaceNavigationView.addSpaceItem(new SpaceItem("LeaderBoard", R.drawable.ic_menu_camera)); - spaceNavigationView.addSpaceItem(new SpaceItem("Duel", R.drawable.ic_menu_slideshow)); - spaceNavigationView.showIconOnly(); -// spaceNavigationView.changeCenterButtonIcon(R.drawable.avatar1); - spaceNavigationView.setSpaceOnClickListener(new SpaceOnClickListener() { - @Override - public void onCentreButtonClick() { - Toast.makeText(DashboardLoot.this,"onCentreButtonClick", Toast.LENGTH_SHORT).show(); - Fragment fragment=new Missions(); - loadFragment(fragment,"missions"); - } - - @Override - public void onItemClick(int itemIndex, String itemName) { - Toast.makeText(DashboardLoot.this, itemIndex + " " + itemName, Toast.LENGTH_SHORT).show(); - if(itemIndex==1) - { - - Fragment fragment=new Duel(); - loadFragment(fragment,"duel"); - } - else - { - Fragment fragment=new LeaderBoard(); - loadFragment(fragment,"leaderboard"); - } - } - - @Override - public void onItemReselected(int itemIndex, String itemName) { - Toast.makeText(DashboardLoot.this, itemIndex + " " + itemName, Toast.LENGTH_SHORT).show(); - } - }); - -// fab.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// PopupMenu popup = new PopupMenu(DashboardLoot.this, view); -// popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { -// @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) -// @Override -// public boolean onMenuItemClick(MenuItem menuItem) { -// switch (menuItem.getItemId()) { -// case R.id.item_stats: -// loadFragment(new Stats(),"stats"); -// return true; -// case R.id.item_howTo: -// loadFragment(new HowTo(),"how_to"); -// return true; -// case R.id.item_help: -// loadFragment(new Help(),"help"); -// return true; -// case R.id.pop_logout: -// mAuth.signOut(); -// Intent intent=new Intent(getApplicationContext(), Main3Activity.class); -// startActivity(intent); -// -// return true; -// default: -// return false; -// } -// } -// }); -// popup.inflate(R.menu.popup_menu); -// popup.show(); -// } -// }); - - Fragment fragment=new Missions(); - loadFragment(fragment,"missions"); - spaceNavigationView.setCentreButtonSelectable(true); - spaceNavigationView.setCentreButtonSelected(); - } - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - spaceNavigationView.onSaveInstanceState(outState); - } - - @Override - protected void onResume() { - super.onResume(); - updateFirebase(mAuth.getCurrentUser(),true); - } - - private void loadFragment(Fragment fragment, String tag) { - // load fragment - FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.replace(R.id.frame_container, fragment,tag); - transaction.addToBackStack(null); - transaction.commit(); - } - - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - @Override - public void onBackPressed() { -// - int size=getSupportFragmentManager().getFragments().size(); - - String fragmentTag=getSupportFragmentManager().getFragments().get(size-1).getTag(); - Log.i("Fragment",fragmentTag); - - - if(fragmentTag.equals("duel")||fragmentTag.equals("leaderboard")||fragmentTag.equals("current_mission")) { - - spaceNavigationView.setCentreButtonSelected(); - android.support.v4.app.Fragment fragment=new Missions(); - loadFragment(fragment,"missions"); - - } - else if(fragmentTag.equals("online_users")) - { - loadFragment(new Duel(),"duel"); - } - else if (fragmentTag.equals("missions")) - { - finishAffinity(); - } - else if(fragmentTag.equals("about")||fragmentTag.equals("how_to")||fragmentTag.equals("help")||fragmentTag.equals("contact_us")) - { -// navigationView.getMenu().getItem(0).setChecked(true); - android.support.v4.app.Fragment fragment=new Missions(); - loadFragment(fragment,"missions"); - } - - else { - super.onBackPressed(); - } - - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == CurrentMission.LOCATION_REQUEST_CODE) { - if (resultCode == RESULT_OK) { - Toast.makeText(this, "GPS enabled!", Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(this, "GPS disabled!", Toast.LENGTH_SHORT).show(); - finish(); - } - } - } - - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - @Override - protected void onStop() { - super.onStop(); - - } - - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - @Override - protected void onPause() { - super.onPause(); - if(mAuth.getCurrentUser()!=null) - updateFirebase(mAuth.getCurrentUser(),false); - else - finishAffinity(); - - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.popup_menu, menu); - return super.onCreateOptionsMenu(menu); - } - @Override - public boolean onOptionsItemSelected(MenuItem menuItem) { - switch (menuItem.getItemId()) { - case R.id.item_stats: - loadFragment(new Stats(),"stats"); - break; - - case R.id.item_howTo: - loadFragment(new HowTo(),"how_to"); - break; - case R.id.item_help: - loadFragment(new Help(),"help"); - break; - case R.id.pop_logout: - updateFirebase(mAuth.getCurrentUser(),false); - mAuth.signOut(); - Intent intent=new Intent(getApplicationContext(), Main3Activity.class); - startActivity(intent); - break; - default: - } - return super.onOptionsItemSelected(menuItem); - } - public void updateFirebase(FirebaseUser firebaseUser,boolean state) - { - Map user = new HashMap<>(); - user.put("userID", firebaseUser.getUid()); - user.put("online", state); - - db.collection("users").document(firebaseUser.getUid()) - .set(user).addOnCompleteListener(new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - - if(task.isSuccessful()) - { - Log.i("Added Succesfully",""); - } - else - { - Log.i("Error",task.getException().getMessage()); - } - } - }); - - } -} diff --git a/app/src/main/java/com/example/dell/loot/DashboardPagerAdapter.java b/app/src/main/java/com/example/dell/loot/DashboardPagerAdapter.java deleted file mode 100644 index e5e1eac..0000000 --- a/app/src/main/java/com/example/dell/loot/DashboardPagerAdapter.java +++ /dev/null @@ -1,42 +0,0 @@ -//package com.example.dell.loot; -// -//import android.support.v4.app.Fragment; -//import android.support.v4.app.FragmentManager; -//import android.support.v4.app.FragmentPagerAdapter; -//import android.support.v4.app.FragmentStatePagerAdapter; -// -//public class DashboardPagerAdapter extends FragmentStatePagerAdapter { -// -// private int NUM_ITEMS = 4; -// private String[] titles= new String[]{"Current Mission", "Locator", "Stats", "LeaderBoard"}; -// -// public DashboardPagerAdapter(FragmentManager fm) { -// super(fm); -// } -// -// @Override -// public int getCount() { -// return NUM_ITEMS ; -// } -// -// @Override -// public Fragment getItem(int position) { -// switch (position) { -// case 0: -// return new CurrentMission(); -// case 1: -// return new Locator(); -// case 2: -// return new Stats(); -// case 3: -// return new LeaderBoard(); -// default: -// return null; -// } -// } -// -// @Override -// public CharSequence getPageTitle(int position) { -// return titles[position]; -// } -//} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/Duel_Alert_Transparent_Activity.java b/app/src/main/java/com/example/dell/loot/Duel_Alert_Transparent_Activity.java deleted file mode 100644 index 20bbbac..0000000 --- a/app/src/main/java/com/example/dell/loot/Duel_Alert_Transparent_Activity.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.example.dell.loot; - -import android.content.DialogInterface; -import android.content.Intent; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.WindowManager; -import android.widget.TextView; - -public class Duel_Alert_Transparent_Activity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main22); - Intent intent=getIntent(); - String request_type=intent.getStringExtra("request_type"); - if(request_type.equals("duel_request")) { - String from_user = intent.getStringExtra("user"); - String stake = intent.getStringExtra("stake"); - showDialogRequest(from_user,stake); - - } - else if(request_type.equals("accept_request")) { - String from_user = intent.getStringExtra("user"); - String stake = intent.getStringExtra("stake"); - showDialogAccept(from_user,stake); - - } - else if(request_type.equals("reject_request")) - { - String from_user = intent.getStringExtra("user"); - showDialogReject(from_user); - } - - } - private void showDialogRequest(String user,String stake) - { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - LayoutInflater layoutInflater = getLayoutInflater(); - View view=layoutInflater.inflate(R.layout.duel_alert,null); - TextView from_user=view.findViewById(R.id.from_user); - TextView user_stake=view.findViewById(R.id.user_stake); - from_user.setText(user); - user_stake.setText(stake); - builder.setView(view) - // Add action buttons - .setPositiveButton("Accept", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - // sign in the user ... - //TODO:call duel activity - //TODO:send Duel Accept Request - } - }) - .setNegativeButton("Reject", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - - //TODO:finishActivity - //TODO:send Duel Reject Request - - } - }); - - AlertDialog dialog = builder.create(); - dialog.show(); - } - private void showDialogAccept(String user,String stake) - { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - - builder.setTitle("Accepted") - .setMessage(user+" has accepted your challenge for stake $"+stake) - // Add action buttons - .setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - // sign in the user ... - //TODO:call duel activity - } - }); - - AlertDialog dialog = builder.create(); - - dialog.show(); - } - private void showDialogReject(String user) - { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - - builder.setTitle("Accepted") - .setMessage(user+" has rejected your challenge") - // Add action buttons - .setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - // sign in the user ... - //TODO:finishActivity - } - }); - - AlertDialog dialog = builder.create(); - - dialog.show(); - } - -} diff --git a/app/src/main/java/com/example/dell/loot/Endpoints.java b/app/src/main/java/com/example/dell/loot/Endpoints.java deleted file mode 100644 index 192e824..0000000 --- a/app/src/main/java/com/example/dell/loot/Endpoints.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.dell.loot; - -public class Endpoints { - public static String syncRequest = ""; - public static String register = ""; - public static String leaders = ""; - public static String fetchMission = ""; -} diff --git a/app/src/main/java/com/example/dell/loot/Help.java b/app/src/main/java/com/example/dell/loot/Help.java deleted file mode 100644 index a3a38ee..0000000 --- a/app/src/main/java/com/example/dell/loot/Help.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.example.dell.loot; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -public class Help extends Fragment { - - public Help() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_help, container, false); - } - -} diff --git a/app/src/main/java/com/example/dell/loot/LeaderBoard.java b/app/src/main/java/com/example/dell/loot/LeaderBoard.java deleted file mode 100644 index 474a9c2..0000000 --- a/app/src/main/java/com/example/dell/loot/LeaderBoard.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.example.dell.loot; - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -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 java.lang.reflect.Method; -import java.util.ArrayList; - -public class LeaderBoard extends Fragment { - - ListView listView; - View view; - ArrayList usernames, coins; - - public LeaderBoard() { - // Required empty public constructor - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - view = inflater.inflate(R.layout.fragment_leader_board, container, false); - listView = view.findViewById(R.id.listView); - StringRequest leaders = new StringRequest(Request.Method.GET, Endpoints.leaders, - new Response.Listener() { - @Override - public void onResponse(String response) { - // TODO: parse response and inflate ArrayList objects - listView.setAdapter(new LeaderListAdapter(getContext(), usernames, coins)); - } - }, - new Response.ErrorListener() { - @Override - public void onErrorResponse(VolleyError error) { - - } - }); - RequestQueue requestQueue = Volley.newRequestQueue(getContext()); - requestQueue.add(leaders); - return view; - } -} diff --git a/app/src/main/java/com/example/dell/loot/LeaderListAdapter.java b/app/src/main/java/com/example/dell/loot/LeaderListAdapter.java deleted file mode 100644 index 97c637a..0000000 --- a/app/src/main/java/com/example/dell/loot/LeaderListAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.example.dell.loot; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import java.util.ArrayList; - -public class LeaderListAdapter extends BaseAdapter { - - ArrayList usernames, coins; - Context context; - LayoutInflater layoutInflater; - - public LeaderListAdapter(Context context, ArrayList usernames, ArrayList coins) { - this.context = context; - this.usernames = usernames; - this.coins = coins; - layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - - @Override - public int getCount() { - return usernames.size(); - } - - @Override - public Object getItem(int i) { - return null; - } - - @Override - public long getItemId(int i) { - return i; - } - - @Override - public View getView(int i, View view, ViewGroup viewGroup) { - View customView = layoutInflater.inflate(R.layout.leader_list, viewGroup); - ImageView icon = customView.findViewById(R.id.icon); - TextView username = customView.findViewById(R.id.usernameLine); - TextView coin = customView.findViewById(R.id.coinsLine); - icon.setImageResource(R.mipmap.ic_launcher_round); - username.setText(usernames.get(i)); - coin.setText(coins.get(i)); - customView.setBackgroundResource(R.drawable.list_shadow); - return customView; - } -} diff --git a/app/src/main/java/com/example/dell/loot/Locator.java b/app/src/main/java/com/example/dell/loot/Locator.java deleted file mode 100644 index 0d92bc9..0000000 --- a/app/src/main/java/com/example/dell/loot/Locator.java +++ /dev/null @@ -1,479 +0,0 @@ -//package com.example.dell.loot; -// -//import android.Manifest; -//import android.app.AlertDialog; -//import android.content.Context; -//import android.content.DialogInterface; -//import android.content.Intent; -//import android.content.pm.PackageManager; -//import android.hardware.Camera; -//import android.location.Location; -//import android.os.Build; -//import android.os.Bundle; -//import android.os.Vibrator; -//import android.support.annotation.NonNull; -//import android.support.annotation.Nullable; -//import android.support.design.widget.BottomNavigationView; -//import android.support.v4.app.ActivityCompat; -//import android.support.v4.app.Fragment; -//import android.support.v4.app.FragmentTransaction; -//import android.support.v4.content.ContextCompat; -//import android.util.Log; -//import android.view.LayoutInflater; -//import android.view.View; -//import android.view.ViewGroup; -//import android.widget.FrameLayout; -//import android.widget.ProgressBar; -//import android.widget.Toast; -// -//import com.google.android.gms.common.ConnectionResult; -//import com.google.android.gms.common.api.GoogleApiClient; -//import com.google.android.gms.location.FusedLocationProviderClient; -//import com.google.android.gms.location.LocationListener; -//import com.google.android.gms.location.LocationRequest; -//import com.google.android.gms.location.LocationServices; -//import com.google.firebase.database.DatabaseReference; -//import com.google.firebase.database.FirebaseDatabase; -// -//import java.util.ArrayList; -// -//public class Locator extends Fragment implements -// LocationListener, -// GoogleApiClient.ConnectionCallbacks, -// GoogleApiClient.OnConnectionFailedListener { -// -// final private int CAMERA_REQUEST_CODE = 1; -// final private int LOCATION_REQUEST_CODE = 2; -// Camera camera; -// private static final String TAG = "LocationActivity"; -// private static final long INTERVAL = 1000; -//// private static final long FASTEST_INTERVAL = 1000 * 5; -// private LootApplication app; -// private GoogleApiClient googleApiClient; -// private LocationRequest mLocationRequest; -// int minDistI; -// double maxDist; -// FirebaseDatabase database; -// DatabaseReference users; -// private FusedLocationProviderClient mFusedLocationClient; -// Vibrator vibrator; -// ProgressBar hot_cold; -// ArrayList geocodes; -// ArrayList missions_left; -// -// public Locator() { -// // Required empty public constructor -// } -// -// @Override -// public View onCreateView(LayoutInflater inflater, ViewGroup container, -// Bundle savedInstanceState) { -// Log.i("Locator","createView"); -// View view = inflater.inflate(R.layout.fragment_locator, container, false); -// checkPermission(); -// vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); -// hot_cold = view.findViewById(R.id.hot_cold); -// return view; -// } -// -// @Override -// public void onAttach(Context context) { -// Log.i("Locator","attach"); -// super.onAttach(context); -// } -// -// @Override -// public void onDetach() { -// Log.i("Locator","detach"); -// super.onDetach(); -// } -// -// @Override -// public void onActivityCreated(@Nullable Bundle savedInstanceState) { -// super.onActivityCreated(savedInstanceState); -// checkPermission(); -// app = (LootApplication) getActivity().getApplication(); -// googleApiClient = new GoogleApiClient.Builder(getContext()) -// .addApi(LocationServices.API) -// .addConnectionCallbacks(this) -// .addOnConnectionFailedListener(this) -// .build(); -// database = FirebaseDatabase.getInstance(); -// users = database.getReference("Users"); -// } -// -// @Override -// public void onResume() { -// Log.i("Locator","Resume"); -// super.onResume(); -// updateGeocode(); -// startCameraUpdates(); -// } -// -// protected void startCameraUpdates() { -// FrameLayout camera_frame = getActivity().findViewById(R.id.camera_frame); -// camera = getCameraInstance(); -// CameraPreview preview = new CameraPreview(getContext(), camera); -// camera_frame.addView(preview, 0); -// } -// -// public Camera getCameraInstance() { -// Camera c = null; -// try { -// c = Camera.open(); -// if (c == null) { -// checkPermission(); -// c = Camera.open(); -// } -// } catch (Exception e) { -// Toast.makeText(getContext(), "Unable to Open Camera", Toast.LENGTH_SHORT).show(); -// } -// return c; -// } -// -// @Override -// public void onPause() { -// Log.i("Locator","pause"); -// super.onPause(); -// stopCameraUpdates(); -//// stopLocationUpdates(); -// } -// -// private void stopCameraUpdates() { -// if (camera != null) { -// camera.stopPreview(); -// camera.release(); -// } -// } -// -// private void checkPermission() { -// if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.CAMERA) == -// PackageManager.PERMISSION_DENIED) { -// ActivityCompat.requestPermissions(getActivity(), -// new String[]{Manifest.permission.CAMERA}, -// CAMERA_REQUEST_CODE); -// } -// -// if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != -// PackageManager.PERMISSION_GRANTED && -// ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != -// PackageManager.PERMISSION_GRANTED) { -// ActivityCompat.requestPermissions(getActivity(), -// new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, -// LOCATION_REQUEST_CODE); -// } -// -// } -// -// @Override -// public void onRequestPermissionsResult(int requestCode, -// String permissions[], int[] grantResults) { -// if (requestCode == CAMERA_REQUEST_CODE) { -// if (grantResults.length > 0 -// && grantResults[0] == PackageManager.PERMISSION_GRANTED) { -// Toast.makeText(getContext(), "Permission Granted", Toast.LENGTH_SHORT).show(); -// } -// else { -// Toast.makeText(getContext(), "Please provide the required Permissions", Toast.LENGTH_SHORT).show(); -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { -// if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) { -// showMessageOKCancel("You need to allow access camera permissions", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { -// checkPermission(); -// } -// } -// }); -// } -// } -// } -// } -// if (requestCode == LOCATION_REQUEST_CODE) { -// if (grantResults.length > 0 -// && grantResults[0] == PackageManager.PERMISSION_GRANTED) { -// Toast.makeText(getContext(), "Permission Granted", Toast.LENGTH_SHORT).show(); -// } -// else -// Toast.makeText(getContext(), "Please provide the required Permissions", Toast.LENGTH_SHORT).show(); -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { -// if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) { -// showMessageOKCancel("You need to allow Location permissions", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { -// checkPermission(); -// } -// } -// }); -// } -// } -// } -// } -// -// private void showMessageOKCancel(String message, DialogInterface.OnClickListener okListener) { -// new AlertDialog.Builder(getContext()) -// .setMessage(message) -// .setPositiveButton("OK", okListener) -// .setNegativeButton("Cancel", null) -// .create() -// .show(); -// } -// -// @Override -// public void onActivityResult(int requestCode, int resultCode, Intent data) { -// super.onActivityResult(requestCode, resultCode, data); -// -// } -// -// -//// @SuppressLint("MissingPermission") -//// protected void startLocationUpdates() { -//// -//// // Create the location request to start receiving updates -//// mLocationRequest = new LocationRequest(); -//// mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); -//// mLocationRequest.setInterval(INTERVAL); -//// mLocationRequest.setFastestInterval(FASTEST_INTERVAL); -//// -//// // Create LocationSettingsRequest object using location request -//// LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); -//// builder.addLocationRequest(mLocationRequest); -//// LocationSettingsRequest locationSettingsRequest = builder.build(); -//// -//// // Check whether location settings are satisfied -//// // https://developers.google.com/android/reference/com/google/android/gms/location/SettingsClient -//// SettingsClient settingsClient = LocationServices.getSettingsClient(getActivity()); -//// settingsClient.checkLocationSettings(locationSettingsRequest); -//// -//// -//// Task task = settingsClient.checkLocationSettings(builder.build()); -//// -//// task.addOnSuccessListener(getActivity(), new OnSuccessListener() { -//// @Override -//// public void onSuccess(LocationSettingsResponse locationSettingsResponse) { -//// // All location settings are satisfied. The client can initialize -//// // location requests here. -//// // ... -//// -//// LocationServices.getFusedLocationProviderClient(getActivity()).requestLocationUpdates(mLocationRequest, new LocationCallback() { -//// @Override -//// public void onLocationResult(LocationResult locationResult) { -//// // do work here -//// onLocationChanged(locationResult.getLastLocation()); -//// } -//// }, -//// Looper.myLooper()); -//// } -//// }); -//// -//// task.addOnFailureListener(getActivity(), new OnFailureListener() { -//// @Override -//// public void onFailure(@NonNull Exception e) { -//// if (e instanceof ResolvableApiException) { -//// // Location settings are not satisfied, but this can be fixed -//// // by showing the user a dialog. -////// try { -////// // Show the dialog by calling startResolutionForResult(), -////// // and check the result in onActivityResult(). -////// ResolvableApiException resolvable = (ResolvableApiException) e; -////// resolvable.startResolutionForResult(getActivity(), -////// REQUEST_CHECK_SETTINGS); -////// } catch (IntentSender.SendIntentException sendEx) { -////// // Ignore the error. -////// } -//// } -//// } -//// }); -//// // new Google API SDK v11 uses getFusedLocationProviderClient(this) -//// -//// } -// -// -// -// protected void updateHot_Cold(Location location) { -//// Location location1=new Location(""); -//// location1.setLatitude(28.6148327d); -//// location1.setLongitude(77.3588033d); -// -// Mission mission = findNearest(location); -// Location location1 = new Location(""); -// location1.setLatitude(mission.getLat()); -// location1.setLongitude(mission.getLng()); -// -// -// if (location1 != null) { -// double dist = location.distanceTo(location1); -//// int progress = hot_cold.getMax()-(int)((dist/maxDist)*hot_cold.getMax()); -// int progress = hot_cold.getMax()-(int)dist; -// hot_cold.setProgress(progress>0?progress:0); -// if (dist <= 10) { -// vibrator.vibrate(7000); -// LootApplication app = (LootApplication) getActivity().getApplication(); -// app.user.active = mission.getMissionID(); -// if(app.user.found == null) { -// app.user.found = new ArrayList<>(); -// } -// if (!(app.user.found.contains(mission.getMissionID()))) { -// app.user.found.add(mission.getMissionID()); -// app.user.active = mission.getMissionID(); -// app.user.score += 2; -// users.child(app.user.getUserID()).setValue(app.user); -// } -// changeTab(); -// } -// Toast.makeText(getActivity(), "Distance Left :" + dist, -// Toast.LENGTH_SHORT).show(); -// } -// } -// -// private void changeTab() -// { -////// Dashboard fragment=(Dashboard)getParentFragment(); -////// fragment.switchTab(0); -//// ViewPager viewPager=getView().findViewById(R.id.viewpager); -//// viewPager.setCurrentItem(0,tr -// -// BottomNavigationView navigationView = getActivity().findViewById(R.id.navigation); -// navigationView.getMenu().getItem(0).setChecked(true); -// Fragment fragment = new CurrentMission(); -// loadFragment(fragment); -// } -// -// private void loadFragment(Fragment fragment) { -// FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); -// transaction.replace(R.id.frame_container, fragment); -// transaction.addToBackStack(null); -// transaction.commit(); -// } -// -// protected Mission findNearest(Location location) { -// double minDist = 0; -// int minI = -1; -// for (int i = 0; i < missions_left.size(); i++) { -// Location loc = new Location(""); -// loc.setLatitude(missions_left.get(i).getLat()); -// loc.setLongitude(missions_left.get(i).getLng()); -// -// double dist = location.distanceTo(loc); -// -// Log.i("LatM", location.getLatitude() + ""); -// Log.i("LngM", location.getLongitude() + ""); -// Log.i("Lat", loc.getLatitude() + ""); -// Log.i("Lng", loc.getLongitude() + ""); -// Log.i("Dist", dist + ""); -// if (i == 0 || minDist > dist) { -// minDist = dist; -// minI = i; -// } -// -// } -// if(minI != minDistI) { -// hot_cold.setMax((int)minDist); -// } -// return missions_left.get(minDistI); -// } -// -// private void updateGeocode() { -// missions_left = new ArrayList<>(); -// -// ArrayList completed = app.user.getCompleted(); -// ArrayList missions = app.missions; -// -// for (Mission mission : missions) { -// if (completed != null) { -// if (!(completed.contains(mission.getMissionID()))) { -// missions_left.add(mission); -//// Location loc=new Location(""); -//// loc.setLatitude(mission.getLat()); -//// loc.setLongitude(mission.getLng()); -//// geocodes.add(loc); -// Log.i("Mission Id", mission.getMissionID()); -// Log.i("Lat", mission.getLat() + ""); -// Log.i("Lng", mission.getLng() + ""); -// } -// } else { -// missions_left.add(mission); -//// Location loc=new Location(""); -//// loc.setLatitude(mission.getLat()); -//// loc.setLongitude(mission.getLng()); -//// geocodes.add(loc); -// Log.i("Mission Id", mission.getMissionID()); -// Log.i("Lat", mission.getLat() + ""); -// Log.i("Lng", mission.getLng() + ""); -// } -// } -// } -// -// @Override -// public void onConnected(@Nullable Bundle bundle) { -// mLocationRequest = LocationRequest.create(); -// mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); -// mLocationRequest.setInterval(INTERVAL); -// checkPermission(); -// LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, mLocationRequest, this); -// } -// -// @Override -// public void onConnectionSuspended(int i) { -// checkPermission(); -// Log.i("Connection","Suspended"); -// } -// -// @Override -// public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { -// Log.i("Connection","Failed"); -// checkPermission(); -// } -// -// @Override -// public void onStart() { -// Log.i("Locator","start"); -// if(app.user.getActive()!=null) { -// showDialog(); -// } -// else { -// googleApiClient.connect(); -// } -// super.onStart(); -// } -// -// @Override -// public void onStop() { -// Log.i("Locator","stop"); -// googleApiClient.disconnect(); -// super.onStop(); -// } -// -// @Override -// public void onLocationChanged(Location location) { -// String msg = "Updated Location: " + -// Double.toString(location.getLatitude()) + "," + -// Double.toString(location.getLongitude()); -// Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); -// // You can now create a LatLng Object for use with maps -//// LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); -// updateHot_Cold(location); -// } -// -// private void showDialog() { -// AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); -// alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialogInterface, int i) { -// BottomNavigationView navigationView = getActivity().findViewById(R.id.navigation); -// navigationView.getMenu().getItem(0).setChecked(true); -// android.support.v4.app.Fragment fragment = new CurrentMission(); -// FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); -// transaction.replace(R.id.frame_container, fragment,"current_mission"); -// transaction.addToBackStack(null); -// transaction.commit(); -// } -// }); -// alertDialog.setTitle("Alert"); -// alertDialog.setMessage("You already have a active Mission"); -// alertDialog.create().show(); -// } -//} diff --git a/app/src/main/java/com/example/dell/loot/Login.java b/app/src/main/java/com/example/dell/loot/Login.java deleted file mode 100644 index 097f73c..0000000 --- a/app/src/main/java/com/example/dell/loot/Login.java +++ /dev/null @@ -1,231 +0,0 @@ -package com.example.dell.loot; - -import android.app.ProgressDialog; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.Toast; - -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.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.auth.FirebaseUser; -import com.google.firebase.database.ChildEventListener; -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 java.util.ArrayList; -import java.util.HashSet; - -public class Login extends Fragment { - - private FirebaseAuth mAuth; - // private FirebaseDatabase database; -// DatabaseReference users, missions; -// ArrayList missionsList = new ArrayList<>(); - User user; - ProgressDialog dialog; - EditText email, password; - TextView register; - Button login; - - public Login() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_login, container, false); - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - initializeViews(); - mAuth = FirebaseAuth.getInstance(); -// database = FirebaseDatabase.getInstance(); -// users = database.getReference("Users"); -// missions = database.getReference("Missions"); - dialog = new ProgressDialog(getContext()); - dialog.setTitle("Please Wait"); - dialog.setCancelable(false); - dialog.setMessage("Signing in..."); - login.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.show(); - mAuth.signInWithEmailAndPassword(email.getText().toString(), password.getText().toString()) - .addOnCompleteListener(getActivity(), new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - if (task.isSuccessful()) { - Toast.makeText(getContext(),"Login Successful",Toast.LENGTH_SHORT).show(); - FirebaseUser firebaseUser = mAuth.getCurrentUser(); - syncUser(firebaseUser.getUid()); - } - else { - dialog.dismiss(); - Toast.makeText(getContext(), "Authentication failed."+ task.getException().getMessage(), - Toast.LENGTH_SHORT).show(); - } - } - }); - } - }); - register.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - register(); - } - }); - - } - - private void initializeViews() { - email = getView().findViewById(R.id.email); - password = getView().findViewById(R.id.password); - login = getView().findViewById(R.id.login); - register = getView().findViewById(R.id.goto_register); - } - - public void register() { - FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); - Register fragment = new Register(); - fragmentTransaction.replace(R.id.login_frame, fragment); - fragmentTransaction.commit(); - } - - public void syncSharedPrefs(User user) { - dialog.setMessage("Completing..."); - SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); - SharedPreferences.Editor editor = sharedPreferences.edit(); -// editor.putString("com.hackncs.userID", user.getUserID()); -// editor.putString("com.hackncs.username", user.getUsername()); -// editor.putString("com.hackncs.zealID", user.getZealID()); -// editor.putString("com.hackncs.name", user.getName()); -// editor.putString("com.hackncs.email", user.getEmail()); -// editor.putInt("com.hackncs.avatarID", user.getAvatarID()); -// editor.putInt("com.hackncs.score", user.getScore()); -// editor.putInt("com.hackncs.stage", user.getStage()); -// editor.putInt("com.hackncs.state", user.getState()); -// editor.putInt("com.hackncs.dropCount", user.getDropCount()); -// editor.putInt("com.hackncs.duelWon", user.getDuelWon()); -// editor.putInt("com.hackncs.duelLost", user.getDuelLost()); -// editor.putLong("com.hackncs.contactNumber", user.getContactNumber()); -// editor.putStringSet("com.hackncs.dropped", new HashSet<>(user.getDropped())); - editor.apply(); - -// LootApplication app = (LootApplication)getActivity().getApplication(); -// app.user = user; -// app.missions = missionsList; - dialog.dismiss(); - Intent i = new Intent(getContext(),DashboardLoot.class); - //TODO: update below - i.putExtra("UID", /*user.getUserID()*/ "x"); - startActivity(i); - } - - private void syncUser(final String userID) { - dialog.setMessage("Syncing Data..."); -// users.child(userId).addValueEventListener(new ValueEventListener() { -// @Override -// public void onDataChange(DataSnapshot dataSnapshot) { -// user = dataSnapshot.getValue(User.class); -// Log.i("User Email", "Value is: " + user.getEmail()); -// syncSharedPrefs(user); -// } -// -// @Override -// public void onCancelled(DatabaseError error) { -// Log.i("Error", error.toException().getMessage()); -// } -// }); -// -// missions.addChildEventListener(new ChildEventListener() { -// @Override -// public void onChildAdded(DataSnapshot dataSnapshot, String s) { -// Log.i("Missions",dataSnapshot.getKey()); -// missionsList.add(dataSnapshot.getValue(Mission.class)); -// LootApplication app = (LootApplication)getActivity().getApplication(); -// app.missions=missionsList; -// } -// -// @Override -// public void onChildChanged(DataSnapshot dataSnapshot, String s) { -// -// } -// -// @Override -// public void onChildRemoved(DataSnapshot dataSnapshot) { -// -// } -// -// @Override -// public void onChildMoved(DataSnapshot dataSnapshot, String s) { -// -// } -// -// @Override -// public void onCancelled(DatabaseError databaseError) { -// -// } -// }); - StringRequest syncRequest = new StringRequest(Request.Method.GET, Endpoints.syncRequest+userID, - new Response.Listener() { - @Override - public void onResponse(String response) { -// user.setUserID(); -// user.setUsername(); -// user.setZealID(); -// user.setName(); -// user.setEmail(); -// user.setAvatarID(); -// user.setScore(); -// user.setStage(); -// user.setState(); -// user.setDropCount(); -// user.setDuelWon(); -// user.setDuelLost(); -// user.setContactNumber(); -// user.setDropped(); - syncSharedPrefs(user); - } - }, - new Response.ErrorListener() { - @Override - public void onErrorResponse(VolleyError error) { - dialog.dismiss(); - Toast.makeText(getContext(), "Error while syncing data!", Toast.LENGTH_SHORT).show(); - //TODO: remove the statement below - syncSharedPrefs(user); - } - }); - RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); - requestQueue.add(syncRequest); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/Main2Activity.java b/app/src/main/java/com/example/dell/loot/Main2Activity.java deleted file mode 100644 index 5607b65..0000000 --- a/app/src/main/java/com/example/dell/loot/Main2Activity.java +++ /dev/null @@ -1,538 +0,0 @@ -// -//package com.example.dell.loot; -// -//import android.app.Fragment; -// -//import android.content.Context; -//import android.content.Intent; -//import android.content.SharedPreferences; -//import android.os.Build; -//import android.os.Bundle; -//import android.support.annotation.RequiresApi; -//import android.support.design.widget.BottomNavigationView; -//import android.support.v4.app.FragmentManager; -//import android.support.v4.app.FragmentTransaction; -//import android.util.Log; -//import android.view.View; -//import android.support.design.widget.NavigationView; -//import android.support.v4.view.GravityCompat; -//import android.support.v4.widget.DrawerLayout; -//import android.support.v7.app.ActionBarDrawerToggle; -//import android.support.v7.app.AppCompatActivity; -//import android.support.v7.widget.Toolbar; -//import android.view.Menu; -//import android.view.MenuItem; -//import com.google.firebase.auth.FirebaseAuth; -//import com.google.firebase.auth.FirebaseUser; -//import com.google.firebase.database.ChildEventListener; -//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 java.util.ArrayList; -// -//public class Main2Activity extends AppCompatActivity { -// -// FirebaseDatabase database; -// DatabaseReference users,missions; -// FirebaseAuth mAuth; -// User user; -// String userId; -// ArrayList missionsList=new ArrayList<>(); -// -//// private NavigationView navigationView; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_main2); -// Intent intent=getIntent(); -// userId=intent.getStringExtra("UID"); -// Log.i("UID",userId); -// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); -// setSupportActionBar(toolbar); -//// DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); -//// ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( -//// this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); -//// drawer.addDrawerListener(toggle); -//// toggle.syncState(); -// -//// navigationView = (NavigationView) findViewById(R.id.nav_view); -//// navigationView.setNavigationItemSelectedListener(this); -// mAuth=FirebaseAuth.getInstance(); -// database=FirebaseDatabase.getInstance(); -// users=database.getReference("Users"); -// missions=database.getReference("Missions"); -// // users.child(userId).child("online").setValue(true); -// -// FragmentManager fragmentManager = getSupportFragmentManager(); -// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); -// Dashboard fragment=new Dashboard(); -// fragmentTransaction.replace(R.id.frame, fragment,"dashboard"); -// fragmentTransaction.commit(); -//// navigationView.getMenu().getItem(0).setChecked(true); -//// MenuItem menuItem=(MenuItem)findViewById(R.id.nav_dashboard); -//// menuItem.setChecked(true); -// -// -// -// -// } -// -// @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) -// @Override -// public void onBackPressed() { -//// DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); -//// if (drawer.isDrawerOpen(GravityCompat.START)) { -//// drawer.closeDrawer(GravityCompat.START); -//// } else { -// int size=getSupportFragmentManager().getFragments().size(); -// -// String fragmentTag=getSupportFragmentManager().getFragments().get(size-1).getTag(); -// Log.i("Fragment",fragmentTag); -// -// -// if(fragmentTag.equals("locator")||fragmentTag.equals("stats")||fragmentTag.equals("leaderboard")) { -// -// BottomNavigationView navigationView=(BottomNavigationView)findViewById(R.id.navigation); -// navigationView.getMenu().getItem(0).setChecked(true); -// android.support.v4.app.Fragment fragment=new Current_Mission(); -// FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); -// transaction.replace(R.id.frame_container, fragment,"current_mission"); -// transaction.addToBackStack(null); -// transaction.commit(); -// -// } -// else if (fragmentTag.equals("current_mission")) -// { -// finishAffinity(); -// } -// else if(fragmentTag.equals("about")||fragmentTag.equals("how_to")||fragmentTag.equals("help")||fragmentTag.equals("contact_us")) -// { -//// navigationView.getMenu().getItem(0).setChecked(true); -// FragmentManager fragmentManager = getSupportFragmentManager(); -// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); -// Dashboard fragment=new Dashboard(); -// fragmentTransaction.replace(R.id.frame, fragment,"dashboard"); -// fragmentTransaction.commit(); -// } -// -// else { -// super.onBackPressed(); -// } -// -// } -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// // Inflate the menu; this adds items to the action bar if it is present. -// getMenuInflater().inflate(R.menu.main2, menu); -// return true; -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// // Handle action bar item clicks here. The action bar will -// // automatically handle clicks on the Home/Up button, so long -// // as you specify a parent activity in AndroidManifest.xml. -// int id = item.getItemId(); -// -// //noinspection SimplifiableIfStatement -// if (id == R.id.action_settings) { -// return true; -// } -// -// return super.onOptionsItemSelected(item); -// } -// -//// @SuppressWarnings("StatementWithEmptyBody") -//// @Override -//// public boolean onNavigationItemSelected(MenuItem item) { -//// // Handle navigation view item clicks here. -//// int id = item.getItemId(); -//// -//// FragmentManager fragmentManager = getSupportFragmentManager(); -//// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); -//// -//// android.support.v4.app.Fragment fragment=new android.support.v4.app.Fragment(); -//// String tag=""; -//// -//// if (id == R.id.nav_dashboard) { -//// // Handle the camera action -//// fragment=new Dashboard(); -//// tag="dashboard"; -//>>>>>>> d48ec20aa78b74743034f053fe1d0a93799096ae -//// -////import android.content.Context; -////import android.content.Intent; -////import android.content.SharedPreferences; -////import android.os.Build; -////import android.os.Bundle; -////import android.support.annotation.RequiresApi; -////import android.support.design.widget.BottomNavigationView; -////import android.support.design.widget.NavigationView; -////import android.support.v4.app.FragmentManager; -////import android.support.v4.app.FragmentTransaction; -////import android.support.v4.view.GravityCompat; -////import android.support.v4.widget.DrawerLayout; -////import android.support.v7.app.ActionBarDrawerToggle; -////import android.support.v7.app.AppCompatActivity; -////import android.support.v7.widget.Toolbar; -////import android.util.Log; -////import android.view.Menu; -////import android.view.MenuItem; -//// -////import com.google.firebase.auth.FirebaseAuth; -////import com.google.firebase.auth.FirebaseUser; -////import com.google.firebase.database.ChildEventListener; -////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 java.util.ArrayList; -//// -////public class Main2Activity extends AppCompatActivity -//// implements NavigationView.OnNavigationItemSelectedListener { -//// -//// FirebaseDatabase database; -//// DatabaseReference users, missions; -//// FirebaseAuth mAuth; -//// User user; -//// String userId; -//// ArrayList missionsList = new ArrayList<>(); -//// private NavigationView navigationView; -//// -//// @Override -//// protected void onCreate(Bundle savedInstanceState) { -//// super.onCreate(savedInstanceState); -//// setContentView(R.layout.activity_main2); -//// Intent intent = getIntent(); -//// userId = intent.getStringExtra("UID"); -//// Log.i("UID",userId); -//// Toolbar toolbar = findViewById(R.id.toolbar); -//// setSupportActionBar(toolbar); -//// -//// DrawerLayout drawer = findViewById(R.id.drawer_layout); -//// ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( -//// this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close); -//// drawer.addDrawerListener(toggle); -//// toggle.syncState(); -////// navigationView = findViewById(R.id.nav_view); -////// navigationView.setNavigationItemSelectedListener(this); -//// -//// mAuth = FirebaseAuth.getInstance(); -//// database = FirebaseDatabase.getInstance(); -//// users = database.getReference("Users"); -//// missions = database.getReference("Missions"); -////// users.child(userID).child("online").setValue(true); -//// -//// FragmentManager fragmentManager = getSupportFragmentManager(); -//// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); -//// Dashboard fragment = new Dashboard(); -//// fragmentTransaction.replace(R.id.frame, fragment,"dashboard"); -//// fragmentTransaction.commit(); -//// -//// navigationView.getMenu().getItem(0).setChecked(true); -//// } -//// -//// @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) -//// @Override -//// public void onBackPressed() { -//// DrawerLayout drawer = findViewById(R.id.drawer_layout); -//// if (drawer.isDrawerOpen(GravityCompat.START)) { -//// drawer.closeDrawer(GravityCompat.START); -//// } -//// else { -//// int size = getSupportFragmentManager().getFragments().size(); -//// String fragmentTag = getSupportFragmentManager().getFragments().get(size-1).getTag(); -//// Log.i("Fragment", fragmentTag); -//// if(fragmentTag.equals("locator") || -//// fragmentTag.equals("stats") || -//// fragmentTag.equals("leaderboard")) { -//// BottomNavigationView navigationView = findViewById(R.id.navigation); -//// navigationView.getMenu().getItem(0).setChecked(true); -//// android.support.v4.app.Fragment fragment = new CurrentMission(); -//// FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); -//// transaction.replace(R.id.frame_container, fragment,"current_mission"); -//// transaction.addToBackStack(null); -//// transaction.commit(); -//// } -//// else if (fragmentTag.equals("current_mission")) { -//// finishAffinity(); -//// } -//// else if(fragmentTag.equals("about") || -//// fragmentTag.equals("how_to") || -//// fragmentTag.equals("help") || -//// fragmentTag.equals("contact_us")) { -//// navigationView.getMenu().getItem(0).setChecked(true); -//// FragmentManager fragmentManager = getSupportFragmentManager(); -//// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); -//// Dashboard fragment = new Dashboard(); -//// fragmentTransaction.replace(R.id.frame, fragment,"dashboard"); -//// fragmentTransaction.commit(); -//// } -//// else { -//// super.onBackPressed(); -//// } -//// } -//// } -//// -//// @Override -//// public boolean onCreateOptionsMenu(Menu menu) { -//// // Inflate the menu; this adds items to the action bar if it is present. -//// getMenuInflater().inflate(R.menu.main2, menu); -//// return false; -//// } -//// -//// @Override -//// public boolean onOptionsItemSelected(MenuItem item) { -//// // Handle action bar item clicks here. The action bar will -//// // automatically handle clicks on the Home/Up button, so long -//// // as you specify a parent activity in AndroidManifest.xml. -//// int id = item.getItemId(); -//// -//// //noinspection SimplifiableIfStatement -//// if (id == R.id.action_settings) { -//// return true; -//// } -//// return super.onOptionsItemSelected(item); -//// } -//// -//// @SuppressWarnings("StatementWithEmptyBody") -//// @Override -//// public boolean onNavigationItemSelected(MenuItem item) { -//// // Handle navigation view item clicks here. -//// int id = item.getItemId(); -//// -//// FragmentManager fragmentManager = getSupportFragmentManager(); -//// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); -//// -//// if (id == R.id.nav_dashboard) { -//// Dashboard fragment = new Dashboard(); -//// fragmentTransaction.replace(R.id.frame, fragment,"dashboard"); -//// fragmentTransaction.commit(); -//// } -//<<<<<<< HEAD -//======= -//// else if (id == R.id.nav_about) { -//// fragment=new About(); -//// tag="about"; -//// -//// -//// } else if (id == R.id.nav_howTo) { -//// fragment=new HowTo(); -//// tag="how_to"; -//// -//// } else if (id == R.id.nav_help) { -//// fragment=new Help(); -//// tag="help"; -//// -//// } else if (id == R.id.nav_contact) { -//// fragment=new ContactUs(); -//// tag="contact_us"; -//// -//// -//// } -//>>>>>>> d48ec20aa78b74743034f053fe1d0a93799096ae -//// else if (id == R.id.nav_logout) { -//// mAuth.signOut(); -//// Intent intent=new Intent(this,Main3Activity.class); -//// startActivity(intent); -//<<<<<<< HEAD -//// } -//// DrawerLayout drawer = findViewById(R.id.drawer_layout); -//// drawer.closeDrawer(GravityCompat.START); -//// return true; -//// } -//// -//// @Override -//// protected void onStart() { -//// super.onStart(); -//// } -//// -//// @Override -//// protected void onResume() { -//// super.onResume(); -//// FirebaseUser currentUser = mAuth.getCurrentUser(); -//// LootApplication app = (LootApplication)getApplication(); -//// Log.i("Name",app.user.getEmail()); -//// Log.i("Mission",app.missions.get(0).missionID); -//// -////// attach(currentUser.getUid()); -//// } -//// -//// public void syncSharedPrefs(User user) { -//// SharedPreferences sharedPreferences=getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); -//// SharedPreferences.Editor editor=sharedPreferences.edit(); -//// editor.putString("Uid",user.getUserID()); -//// editor.putString("Username",user.getUsername()); -//// editor.putInt("Score",user.getScore()); -//// editor.putString("mActive",user.getActive()); -//// editor.apply(); -//// -//// LootApplication app = (LootApplication)getApplication(); -//// app.user = user; -//// app.missions = missionsList; -//// } -//// -//// private void attach(String userId) -//// { -//// users.child(userId).addValueEventListener(new ValueEventListener() { -//// @Override -//// public void onDataChange(DataSnapshot dataSnapshot) { -//// // This method is called once with the initial value and again -//// // whenever data at this location is updated. -//// user = dataSnapshot.getValue(User.class); -//// Log.i("User Email", "Value is: " + user.getEmail()); -//// LootApplication app = (LootApplication)getApplication(); -//// app.user = user; -//// syncSharedPrefs(user); -//// } -//// -//// @Override -//// public void onCancelled(DatabaseError error) { -//// // Failed to read value -//// Log.i("Error", error.toException().getMessage()); -//// } -//// }); -//// -//// missions.addChildEventListener(new ChildEventListener() { -//// @Override -//// public void onChildAdded(DataSnapshot dataSnapshot, String s) { -//// Log.i("Missions",dataSnapshot.getKey()); -//// missionsList.add(dataSnapshot.getValue(Mission.class)); -//// LootApplication app = (LootApplication)getApplication(); -//// app.missions = missionsList; -//// } -//// -//// @Override -//// public void onChildChanged(DataSnapshot dataSnapshot, String s) { -//// -//// } -//// -//// @Override -//// public void onChildRemoved(DataSnapshot dataSnapshot) { -//// -//// } -//// -//// @Override -//// public void onChildMoved(DataSnapshot dataSnapshot, String s) { -//// -//// } -//// -//// @Override -//// public void onCancelled(DatabaseError databaseError) { -//// -//// } -//// }); -//// -//// } -//// -////} -//======= -//// -//// } -//// fragmentTransaction.replace(R.id.frame, fragment,tag); -//// fragmentTransaction.commit(); -//// DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); -//// drawer.closeDrawer(GravityCompat.START); -//// return true; -//// } -// -// @Override -// protected void onStart() { -// super.onStart(); -// -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// FirebaseUser currentUser=mAuth.getCurrentUser(); -//// Loot_Application app=(Loot_Application)getApplication(); -//// Log.i("Name",app.user.getEmail()); -//// Log.i("Misison",app.missions.get(0).missionId); -// -// //attach(currentUser.getUid()); -// } -// -// public void syncSharedPrefs(User user) -// { -// SharedPreferences sharedPreferences=getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); -// SharedPreferences.Editor editor=sharedPreferences.edit(); -// editor.putString("Uid",user.getUserId()); -// editor.putString("Username",user.getUsername()); -// editor.putInt("Score",user.getScore()); -// editor.putString("mActive",user.getActive()); -// editor.apply(); -// -// Loot_Application app=(Loot_Application)getApplication(); -// app.user=user; -// app.missions=missionsList; -// -// } -// -// private void attach(String userId) -// { -// users.child(userId).addValueEventListener(new ValueEventListener() { -// @Override -// public void onDataChange(DataSnapshot dataSnapshot) { -// // This method is called once with the initial value and again -// // whenever data at this location is updated. -// user= dataSnapshot.getValue(User.class); -// Log.i("User Email", "Value is: " + user.getEmail()); -// Loot_Application app=(Loot_Application)getApplication(); -// app.user=user; -// -// -// syncSharedPrefs(user); -// -// -// } -// -// @Override -// public void onCancelled(DatabaseError error) { -// // Failed to read value -// Log.i("Error", error.toException().getMessage()); -// } -// }); -// -// missions.addChildEventListener(new ChildEventListener() { -// @Override -// public void onChildAdded(DataSnapshot dataSnapshot, String s) { -// -// Log.i("Missions",dataSnapshot.getKey()); -// missionsList.add(dataSnapshot.getValue(Mission.class)); -// Loot_Application app=(Loot_Application)getApplication(); -// app.missions=missionsList; -// -// } -// -// @Override -// public void onChildChanged(DataSnapshot dataSnapshot, String s) { -// -// } -// -// @Override -// public void onChildRemoved(DataSnapshot dataSnapshot) { -// -// } -// -// @Override -// public void onChildMoved(DataSnapshot dataSnapshot, String s) { -// -// } -// -// @Override -// public void onCancelled(DatabaseError databaseError) { -// -// } -// }); -// -// } -// -// -//} -//>>>>>>> d48ec20aa78b74743034f053fe1d0a93799096ae diff --git a/app/src/main/java/com/example/dell/loot/Main3Activity.java b/app/src/main/java/com/example/dell/loot/Main3Activity.java deleted file mode 100644 index bee45ec..0000000 --- a/app/src/main/java/com/example/dell/loot/Main3Activity.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.example.dell.loot; - -import android.os.Bundle; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; - -public class Main3Activity extends AppCompatActivity { - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main3); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); - Splash fragment = new Splash(); - fragmentTransaction.add(R.id.login_frame, fragment); - fragmentTransaction.commit(); - } - - @Override - public void onBackPressed() - { - if(getFragmentManager().getBackStackEntryCount() > 0) - getFragmentManager().popBackStack(); - else - super.onBackPressed(); - } -} diff --git a/app/src/main/java/com/example/dell/loot/MainActivity.java b/app/src/main/java/com/example/dell/loot/MainActivity.java deleted file mode 100644 index b490340..0000000 --- a/app/src/main/java/com/example/dell/loot/MainActivity.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.example.dell.loot; - -import android.content.Intent; -import android.support.annotation.NonNull; -import android.support.design.widget.BottomNavigationView; -import android.support.design.widget.FloatingActionButton; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.MenuItem; -import android.view.View; -import android.widget.PopupMenu; -import android.widget.Toast; - -import com.google.firebase.auth.FirebaseAuth; - -public class MainActivity extends AppCompatActivity { - - FloatingActionButton fab; - BottomNavigationView bottomNavigationView; - FirebaseAuth mAuth; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - fab = findViewById(R.id.fab); - bottomNavigationView = findViewById(R.id.bottom); - mAuth = FirebaseAuth.getInstance(); - bottomNavigationView.getMenu().getItem(1).setChecked(true); - loadFragment(new CurrentMission()); - bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { - @Override - public boolean onNavigationItemSelected(@NonNull MenuItem item) { - switch (item.getItemId()) { - case R.id.nav_leader_board: - bottomNavigationView.getMenu().getItem(0).setChecked(true); - loadFragment(new LeaderBoard()); - return true; - case R.id.nav_home: - bottomNavigationView.getMenu().getItem(1).setChecked(true); - loadFragment(new CurrentMission()); - return true; - case R.id.nav_duel: - bottomNavigationView.getMenu().getItem(2).setChecked(true); - Toast.makeText(MainActivity.this, "Coming Soon!", Toast.LENGTH_SHORT).show(); - // TODO Duel functionality - return true; - default: - return false; - } - } - }); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - PopupMenu popup = new PopupMenu(MainActivity.this, view); - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem menuItem) { - switch (menuItem.getItemId()) { - case R.id.item_stats: - loadFragment(new Stats()); - return true; - case R.id.item_howTo: - loadFragment(new HowTo()); - return true; - case R.id.item_help: - loadFragment(new Help()); - return true; - case R.id.pop_logout: - mAuth.signOut(); - Intent intent=new Intent(getApplicationContext(), Main3Activity.class); - startActivity(intent); - return true; - default: - return false; - } - } - }); - popup.inflate(R.menu.popup_menu); - popup.show(); - } - }); - } - - private void loadFragment(Fragment fragment) { - FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.replace(R.id.container, fragment); - transaction.addToBackStack(null); - transaction.commit(); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == CurrentMission.LOCATION_REQUEST_CODE) { - if (resultCode == RESULT_OK) { - Toast.makeText(this, "GPS enabled!", Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(this, "GPS disabled!", Toast.LENGTH_SHORT).show(); - finish(); - } - } - } -} diff --git a/app/src/main/java/com/example/dell/loot/Missions.java b/app/src/main/java/com/example/dell/loot/Missions.java deleted file mode 100644 index feb5f2e..0000000 --- a/app/src/main/java/com/example/dell/loot/Missions.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.example.dell.loot; - - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentTransaction; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - - -/** - * A simple {@link Fragment} subclass. - */ -public class Missions extends Fragment { - - - public Missions() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_missions, container, false); - - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - TextView mission_desc=(TextView)getView().findViewById(R.id.mission_desc); - mission_desc.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - Fragment fragment=new CurrentMission(); - loadFragment(fragment,"current_mission"); - - } - }); - } - private void loadFragment(Fragment fragment, String tag) { - // load fragment - FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); - transaction.replace(R.id.frame_container, fragment,tag); - transaction.addToBackStack(null); - transaction.commit(); - } -} diff --git a/app/src/main/java/com/example/dell/loot/MyFirebaseInstanceIDService.java b/app/src/main/java/com/example/dell/loot/MyFirebaseInstanceIDService.java deleted file mode 100644 index 5d968bd..0000000 --- a/app/src/main/java/com/example/dell/loot/MyFirebaseInstanceIDService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.example.dell.loot; - -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; -import android.util.Log; - -import com.google.firebase.iid.FirebaseInstanceId; -import com.google.firebase.iid.FirebaseInstanceIdService; -import com.google.firebase.messaging.FirebaseMessagingService; -import com.google.firebase.messaging.RemoteMessage; - -public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { - - private static final String TAG = "MyFirebaseIIDService"; - - @Override - public void onTokenRefresh() { - // Get updated InstanceID token. - String refreshedToken = FirebaseInstanceId.getInstance().getToken(); - Log.d(TAG, "Refreshed token: " + refreshedToken); - - // If you want to send messages to this application instance or - // manage this apps subscriptions on the server side, send the - // Instance ID token to your app server. - sendRegistrationToServer(refreshedToken); - } - private void sendRegistrationToServer(String token) { - // TODO: Implement this method to send token to your app server. - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/MyFirebaseMessagingService.java b/app/src/main/java/com/example/dell/loot/MyFirebaseMessagingService.java deleted file mode 100644 index 7b63253..0000000 --- a/app/src/main/java/com/example/dell/loot/MyFirebaseMessagingService.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.example.dell.loot; - -import android.app.Notification; -import android.app.PendingIntent; -import android.content.DialogInterface; -import android.content.Intent; -import android.os.Build; -import android.support.annotation.RequiresApi; -import android.support.v7.app.AlertDialog; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.WindowManager; -import android.widget.TextView; - -import com.google.firebase.messaging.FirebaseMessagingService; -import com.google.firebase.messaging.RemoteMessage; - -public class MyFirebaseMessagingService extends FirebaseMessagingService { - - private static final String TAG = "FirebaseMessageService"; - - @Override - public void onMessageReceived(RemoteMessage remoteMessage) { - // There are two types of messages data messages and notification messages. Data messages are handled - // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type - // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app - // is in the foreground. When the app is in the background an automatically generated notification is displayed. - // When the user taps on the notification they are returned to the app. Messages containing both notification - // and data payloads are treated as notification messages. The Firebase console always sends notification - // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options - // - Log.d(TAG, "From: " + remoteMessage.getFrom()); - - // Check if message contains a data payload. - if (remoteMessage.getData().size() > 0) { - Log.d(TAG, "Message data payload: " + remoteMessage.getData()); - String request_type=remoteMessage.getData().get("request_type"); - Intent intent=new Intent(this,Duel_Alert_Transparent_Activity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra("request_type",request_type); - if(request_type.equals("duel_request")) { - String from_user = remoteMessage.getData().get("user"); - String stake = remoteMessage.getData().get("stake"); - intent.putExtra("user",from_user); - intent.putExtra("stake",stake); - - } - else if(request_type.equals("accept_request")) { - String from_user = remoteMessage.getData().get("user"); - String stake = remoteMessage.getData().get("stake"); - intent.putExtra("user",from_user); - intent.putExtra("stake",stake); - } - else if(request_type.equals("reject_request")) - { - String from_user = remoteMessage.getData().get("user"); - intent.putExtra("user",from_user); - - } -// sendNotification(from_user,stake); - - startActivity(intent); - } - - // Check if message contains a notification payload. - if (remoteMessage.getNotification() != null) { - Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); - } - - //The message which i send will have keys named [message, image, AnotherActivity] and corresponding values. - //You can change as per the requirement. - -// //message will contain the Push Message -// String message = remoteMessage.getData().get("message"); -// -// String notiTitle=remoteMessage.getNotification().getTitle(); -// String notiMessgae=remoteMessage.getNotification().getBody(); -// //To get a Bitmap image from the URL received - - - - - } - - - /** - * Create and show a simple notification containing the received FCM message. - */ - - private void showDialog(String user,String stake) - { - AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext()); - LayoutInflater layoutInflater = LayoutInflater.from(getApplicationContext()); - View view=layoutInflater.inflate(R.layout.duel_alert,null); - TextView from_user=view.findViewById(R.id.from_user); - TextView user_stake=view.findViewById(R.id.user_stake); - from_user.setText(user); - user_stake.setText(stake); - builder.setView(view) - // Add action buttons - .setPositiveButton("Accept", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - // sign in the user ... - } - }) - .setNegativeButton("Reject", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - - } - }); - - AlertDialog dialog = builder.create(); - dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); - dialog.show(); - } - - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - private void sendNotification(String user, String stake) { -// Intent intent = new Intent(this, MainActivity.class); -// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); -// -// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, -// PendingIntent.FLAG_ONE_SHOT); - - -// RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.duel_alert); -// RemoteViews notificationLayoutExpanded = new RemoteViews(getPackageName(), R.layout.duel_alert); -// -//// Apply the layouts to the notification -// Notification customNotification = new NotificationCompat.Builder(this) -// .setSmallIcon(R.drawable.avatar1) -// .setStyle(new NotificationCompat.DecoratedCustomViewStyle()) -// .setCustomContentView(notificationLayout) -// .setCustomBigContentView(notificationLayoutExpanded) -// .build(); - -// Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); -// NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) -// .setLargeIcon(image)/*Notification icon image*/ -// .setSmallIcon(R.drawable.firebase_icon) -// .setContentTitle(messageBody) -// .setStyle(new NotificationCompat.BigPictureStyle() -// .bigPicture(image))/*Notification with Image*/ -// .setAutoCancel(true) -// .setSound(defaultSoundUri) -// .setContentIntent(pendingIntent); -// -// NotificationManager notificationManager = -// (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); -// -// notificationManager.notify(0 /* ID of notification*/, customNotification); -//// startForeground(0,customNotification); - - - Intent showTaskIntent = new Intent(getApplicationContext(), Duel_Alert_Transparent_Activity.class); - showTaskIntent.setAction(Intent.ACTION_MAIN); - showTaskIntent.addCategory(Intent.CATEGORY_LAUNCHER); - showTaskIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - PendingIntent contentIntent = PendingIntent.getActivity( - getApplicationContext(), - 0, - showTaskIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - - Notification notification = new Notification.Builder(getApplicationContext()) - .setContentTitle(getString(R.string.app_name)) - .setContentText("Hello") - .setSmallIcon(R.drawable.ic_audiotrack_dark) - .setWhen(System.currentTimeMillis()) - .setContentIntent(contentIntent) - .build(); - startForeground(0, notification); - } - -// /* -// *To get a Bitmap image from the URL received -// * */ -// public Bitmap getBitmapfromUrl(String imageUrl) { -// try { -// URL url = new URL(imageUrl); -// HttpURLConnection connection = (HttpURLConnection) url.openConnection(); -// connection.setDoInput(true); -// connection.connect(); -// InputStream input = connection.getInputStream(); -// Bitmap bitmap = BitmapFactory.decodeStream(input); -// return bitmap; -// -// } catch (Exception e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// return null; -// -// } -// } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/OnlineUsers.java b/app/src/main/java/com/example/dell/loot/OnlineUsers.java deleted file mode 100644 index e9c2b71..0000000 --- a/app/src/main/java/com/example/dell/loot/OnlineUsers.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.example.dell.loot; - - -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.firestore.DocumentSnapshot; -import com.google.firebase.firestore.FirebaseFirestore; -import com.google.firebase.firestore.QuerySnapshot; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * A simple {@link Fragment} subclass. - */ -public class OnlineUsers extends Fragment { - - - private RecyclerView mRecyclerView; - private RecyclerView.Adapter mAdapter; - private RecyclerView.LayoutManager mLayoutManager; - ArrayList onlineUsers; - FirebaseFirestore db; - - public OnlineUsers() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_online_users, container, false); - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - mRecyclerView = (RecyclerView) getView().findViewById(R.id.my_recycler_view); - - db=FirebaseFirestore.getInstance(); - onlineUsers=new ArrayList<>(); - // use a linear layout manager - mLayoutManager = new LinearLayoutManager(getContext()); - mRecyclerView.setLayoutManager(mLayoutManager); - - // specify an adapter (see also next example) - mAdapter = new CustomRecycleAdapter(getContext(),onlineUsers); - mRecyclerView.setAdapter(mAdapter); - - db.collection("users") - .whereEqualTo("online", true) - .get() - .addOnCompleteListener(new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - if (task.isSuccessful()) { - for (DocumentSnapshot document : task.getResult()) { - User user=new User(); - Map map=document.getData(); - user.setUserID(map.get("userID").toString()); - user.setName(map.get("userID").toString()); - user.setScore(100); - onlineUsers.add(user); - mAdapter.notifyDataSetChanged(); - } - } else { - Log.i("Error getting documents", task.getException().getMessage()); - } - } - }); - - - } -} diff --git a/app/src/main/java/com/example/dell/loot/Register.java b/app/src/main/java/com/example/dell/loot/Register.java deleted file mode 100644 index 4bc7e8d..0000000 --- a/app/src/main/java/com/example/dell/loot/Register.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.example.dell.loot; - -import android.app.ProgressDialog; -import android.content.Intent; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import com.android.volley.AuthFailureError; -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.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.OnFailureListener; -import com.google.android.gms.tasks.OnSuccessListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.auth.FirebaseUser; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.firestore.DocumentReference; -import com.google.firebase.firestore.FirebaseFirestore; - -import java.util.HashMap; -import java.util.Map; - -public class Register extends Fragment { - - private FirebaseAuth mAuth; -// private FirebaseDatabase database; -// DatabaseReference users; - View view; - EditText name, email, contact, zeal, username, password; - ProgressDialog dialog; - FirebaseFirestore db; - public Register() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - view = inflater.inflate(R.layout.fragment_register, container, false); - return view; - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - initializeViews(); - mAuth = FirebaseAuth.getInstance(); - db=FirebaseFirestore.getInstance(); -// database = FirebaseDatabase.getInstance(); -// users = database.getReference("Users"); - Button register = getView().findViewById(R.id.register); - TextView login = getView().findViewById(R.id.goto_login); - - login.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - login(); - } - }); - - dialog.setTitle("Please Wait"); - dialog.setCancelable(false); - dialog.setMessage("Signing in..."); - - register.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.show(); - mAuth.createUserWithEmailAndPassword(email.getText().toString(), password.getText().toString()) - .addOnCompleteListener(getActivity(), new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - if (task.isSuccessful()) { - dialog.dismiss(); - final FirebaseUser firebaseUser = mAuth.getCurrentUser(); - updateFirebase(firebaseUser); - Toast.makeText(getContext(),"You're registered successfully!",Toast.LENGTH_SHORT).show(); - Intent i=new Intent(getContext(),WelcomeSlider.class); - startActivity(i); -// StringRequest register = new StringRequest(Request.Method.POST, Endpoints.register, -// new Response.Listener() { -// @Override -// public void onResponse(String response) { -// Toast.makeText(getContext(),"You're registered successfully!",Toast.LENGTH_SHORT).show(); -// Intent i=new Intent(getContext(),WelcomeSlider.class); -// startActivity(i); -// } -// }, -// new Response.ErrorListener() { -// @Override -// public void onErrorResponse(VolleyError error) { -// -// } -// }){ -// @Override -// protected Map getParams() throws AuthFailureError { -// Map map = new HashMap(); -// map.put("", firebaseUser.getUid()); -// map.put("", email.getText().toString()); -// map.put("", name.getText().toString()); -// map.put("", username.getText().toString()); -// map.put("", zeal.getText().toString()); -// map.put("", contact.getText().toString()); -// return map; -// } -// }; -// RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); -// requestQueue.add(register); - } else { - dialog.dismiss(); - Toast.makeText(getContext(), "Registration failed."+ task.getException().getMessage(), - Toast.LENGTH_SHORT).show(); - } - } - }); - } - }); - } - - private void initializeViews() { - name = view.findViewById(R.id.name); - email = view.findViewById(R.id.email); - contact = view.findViewById(R.id.contactNumber); - zeal = view.findViewById(R.id.zealId); - username = view.findViewById(R.id.username); - password = view.findViewById(R.id.password); - dialog=new ProgressDialog(getContext()); - } - - @Override - public void onStart() { - super.onStart(); - } - -// private User getUser() { -// View view = getView(); -// EditText username = view.findViewById(R.id.username); -// EditText zealId = view.findViewById(R.id.zealId); -// EditText name = view.findViewById(R.id.name); -// EditText contact = view.findViewById(R.id.contact); -// EditText email = view.findViewById(R.id.email); -// EditText password = view.findViewById(R.id.password); -// ImageView avtar = view.findViewById(R.id.avatar); -// User user = new User(); -//// user.setAvatarID((int)avtar.getTag()); -// user.setContactNumber(Long.parseLong(contact.getText()+"")); -// user.setEmail(email.getText()+""); -// user.setName(name.getText()+""); -// user.setScore(0); -// user.setPassword(password.getText()+""); -// user.setZealID(zealId.getText()+""); -// user.setUsername(username.getText()+""); -// return user; -// } -// -// private void updateDB(User user) { -// users.child(user.getUserID()).setValue(user); -// Intent i=new Intent(getContext(),Main2Activity.class); -// i.putExtra("UID",user.getUserID()); -// startActivity(i); -// } - - public void login() { - - FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); - Login fragment = new Login(); - fragmentTransaction.replace(R.id.login_frame, fragment); - fragmentTransaction.commit(); - } - public void updateFirebase(FirebaseUser firebaseUser) - { - Map user = new HashMap<>(); - user.put("userID", firebaseUser.getUid()); - user.put("online", false); - - db.collection("users").document(firebaseUser.getUid()) - .set(user).addOnCompleteListener(new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - - if(task.isSuccessful()) - { - Log.i("Added Succesfully",""); - } - else - { - Log.i("Error",task.getException().getMessage()); - } - } - }); - - } -} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/APIService.java b/app/src/main/java/com/hackncs/zealicon/loot/APIService.java new file mode 100644 index 0000000..3ade4cc --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/APIService.java @@ -0,0 +1,15 @@ +package com.hackncs.zealicon.loot; +import org.json.JSONObject; + +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.Headers; +import retrofit2.http.POST; + +public interface APIService { + + + @Headers("x-auth: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicGFzc3dvcmQiOiJsb290MjAxOSIsImlhdCI6MTU0ODMxMzI2Mn0.VqN0AmH6URo8z_zPff68C81a8e5EUYPgOrwU18TvLMU") + @POST("/api/fcm/send/") + Call sendFCM(@Body FCMData data); +} \ No newline at end of file diff --git a/app/src/main/java/com/hackncs/zealicon/loot/APIUtils.java b/app/src/main/java/com/hackncs/zealicon/loot/APIUtils.java new file mode 100644 index 0000000..f04660b --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/APIUtils.java @@ -0,0 +1,15 @@ +package com.hackncs.zealicon.loot; + +/** + * Created by siddhartha on 14/3/18. + */ + +public class APIUtils { + + public static final String BASE_URL = Endpoints.send; + + public static APIService getAPIService() { + + return RetrofitClient.getClient(BASE_URL).create(APIService.class); + } +} diff --git a/app/src/main/java/com/example/dell/loot/Stats.java b/app/src/main/java/com/hackncs/zealicon/loot/AboutFragment.java similarity index 51% rename from app/src/main/java/com/example/dell/loot/Stats.java rename to app/src/main/java/com/hackncs/zealicon/loot/AboutFragment.java index 833a455..96f3292 100644 --- a/app/src/main/java/com/example/dell/loot/Stats.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/AboutFragment.java @@ -1,20 +1,31 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; + import android.os.Bundle; -import android.support.v4.app.Fragment; + +import androidx.fragment.app.Fragment; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -public class Stats extends Fragment { - public Stats() { +/** + * A simple {@link Fragment} subclass. + */ +public class AboutFragment extends Fragment { + + + public AboutFragment() { // Required empty public constructor } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_stats, container, false); + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_about, container, false); } + } diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Current_missions.java b/app/src/main/java/com/hackncs/zealicon/loot/Current_missions.java new file mode 100644 index 0000000..81a1f80 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Current_missions.java @@ -0,0 +1,276 @@ +package com.hackncs.zealicon.loot; + + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.os.Bundle; + +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.AuthFailureError; +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.google.firebase.database.DatabaseReference; + +import java.util.HashMap; +import java.util.Map; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; + + +/** + * A simple {@link Fragment} subclass. + */ +public class Current_missions extends Fragment { + + + Button submit, drop; + TextView story; + EditText answer; + AlertDialog alertDialog; + Mission mission; + int userStage, state, dropCount, score; + String userID; + DatabaseReference users, missions; + LootApplication app; + RequestQueue requestQueue; + SharedPreferences sharedPreferences; + + public Current_missions() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_current_mission, container, false); + story = view.findViewById(R.id.story); + answer = view.findViewById(R.id.answer); + submit = view.findViewById(R.id.submit); + drop = view.findViewById(R.id.drop_mission); + + Bundle bundle =this.getArguments(); + mission=new Mission(); + mission.setMissionID(bundle.getInt("misionID")); + mission.setStory(bundle.getString("story")); + mission.setDescription(bundle.getString("description")); + mission.setMissionName(bundle.getString("missionName")); + mission.setAnswer(bundle.getString("answer")); + +// Log.i("Mission Id",mission.getMissionName()); + + sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + userStage = sharedPreferences.getInt("com.hackncs.stage",1); + state = sharedPreferences.getInt("com.hackncs.state", 0); + dropCount = sharedPreferences.getInt("com.hackncs.dropCount", 0); + score = sharedPreferences.getInt("com.hackncs.score", 0); + userID = sharedPreferences.getString("com.hackncs.userID", null); + requestQueue = Volley.newRequestQueue(getContext()); + + return view; + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + + super.onActivityCreated(savedInstanceState); + displayMission(); + drop.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle("Drop Mission"); + if (score - (((int) Math.pow(2, dropCount)) * 10) >= 0) { + builder.setMessage((((int) Math.pow(2, dropCount)) * 10) + " coins will be deducted!"); + builder.setPositiveButton("Drop", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + userStage += 1; + state = 0; + score -= ((int) Math.pow(2, dropCount)) * 10; + dropCount += 1; + StringRequest updateUser = new StringRequest(Request.Method.POST, + Endpoints.updateUser + userID + "/edit/", + new Response.Listener() { + @Override + public void onResponse(String response) { +// Log.d("dropVolley", "response"); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putInt("com.hackncs.score", score); + editor.putInt("com.hackncs.stage", userStage); + editor.putInt("com.hackncs.state", state); + editor.putInt("com.hackncs.dropCount", dropCount); + editor.apply(); + + updateActionBarDetails(); + //TODO:load fragment + loadFragment(new Missions(),"missions"); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + Log.d("dropVolley", "error"); + } + }) { + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); + map.put("score", score+""); + map.put("stage", userStage+""); + map.put("mission_state", "false"); + map.put("drop_count", String.valueOf(dropCount)); + return map; + //TODO:Confirm + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + + }; + requestQueue.add(updateUser); + + } + }); + builder.setNegativeButton("Stay", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + alertDialog.dismiss(); + } + }); + } else { + builder.setMessage("You can't drop this mission! Not enough coins!"); + builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + alertDialog.dismiss(); + } + }); + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + alertDialog.dismiss(); + } + }); + } + alertDialog = builder.create(); + alertDialog.show(); + } + }); + + submit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + +// Log.i("Clicked","submit"); +// Log.i("Ans",answer.getText()+""); +// Log.i("AnsRight",mission.getAnswer()); + if (!answer.getText().toString().trim().equalsIgnoreCase(mission.getAnswer())) { + answer.setText(""); + Toast.makeText(getContext(), "You might wanna try another one!", Toast.LENGTH_SHORT).show(); + } else { + answer.setText(""); + Toast.makeText(getContext(), "Bravo you got it right!", Toast.LENGTH_SHORT).show(); + userStage += 1; + state = 0; + score += 100; + StringRequest updateUser = new StringRequest(Request.Method.POST, + Endpoints.updateUser + userID +"/edit/", + new Response.Listener() { + @Override + public void onResponse(String response) { +// Log.d("submitVolley", "response"); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putInt("com.hackncs.score", score); + editor.putInt("com.hackncs.stage", userStage); + editor.putInt("com.hackncs.state", state); + editor.apply(); + //TODO:load fragment + updateActionBarDetails(); + loadFragment(new Missions(),"missions"); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + Log.d("submitVolley", error.getMessage()); + } + }) { + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); + map.put("score", String.valueOf(score)); + map.put("stage", String.valueOf(userStage)); + map.put("mission_state", "false"); + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(updateUser); + } + } + }); + + + + } + + private void displayMission() { + + story.setText(mission.getDescription()); + answer.setEnabled(true); + submit.setEnabled(true); + drop.setEnabled(true); + + + } + @Override + public void onDestroy() { + super.onDestroy(); + + } + + @Override + public void onStop() { + + super.onStop(); + } + private void loadFragment(Fragment fragment,String tag) { + FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.frame_container, fragment,tag); + transaction.addToBackStack(null); + transaction.commit(); + } + + private void updateActionBarDetails() + { + TextView user_coins=getActivity().findViewById(R.id.user_coins); + user_coins.setText(score+""); + + } + +} + diff --git a/app/src/main/java/com/hackncs/zealicon/loot/CustomRecycleAdapter.java b/app/src/main/java/com/hackncs/zealicon/loot/CustomRecycleAdapter.java new file mode 100644 index 0000000..c8e5f4b --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/CustomRecycleAdapter.java @@ -0,0 +1,251 @@ +package com.hackncs.zealicon.loot; + +import android.app.Activity; +import android.content.Context; + +import android.content.SharedPreferences; + +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.AuthFailureError; +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 org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import androidx.appcompat.app.AlertDialog; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.RecyclerView; +import retrofit2.Call; +import retrofit2.Callback; + +public class CustomRecycleAdapter extends RecyclerView.Adapter { + private Context mContext; + private Activity mActivity; + private ArrayList users; + private String key; + Activity activity; + String fcm = ""; + APIService fcmService; + + public class MyViewHolder extends RecyclerView.ViewHolder { + public TextView name, coins; + public ImageView avatar; + public CardView cardView; + + public MyViewHolder(View view) { + super(view); + name = (TextView) view.findViewById(R.id.user_name); + coins = (TextView) view.findViewById(R.id.user_coins); + avatar = (ImageView) view.findViewById(R.id.avatar); + cardView=view.findViewById(R.id.card_view); + } + } + + + public CustomRecycleAdapter(Context mContext, Activity mActivity, ArrayList users, String key) { + this.mContext = mContext; + this.mActivity = mActivity; + this.users = users; + this.key=key; + fcmService=APIUtils.getAPIService(); + } + + @Override + public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View itemView = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.recycle_cards, parent, false); + return new MyViewHolder(itemView); + } + + @Override + public void onBindViewHolder(final MyViewHolder holder, int position) { + final RequestQueue requestQueue = Volley.newRequestQueue(mActivity); + final User user = users.get(position); +// Log.i("username",users.get(position).getUsername()); + holder.name.setText(user.getUsername()); + holder.coins.setText(""+user.getScore()); + holder.avatar.setImageResource(user.getAvatarID()); + if(key.equalsIgnoreCase("online_users")) + { + holder.cardView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); + LayoutInflater layoutInflater = mActivity.getLayoutInflater(); + View dialogView=layoutInflater.inflate(R.layout.challenge_dialog,null); + + TextView message=dialogView.findViewById(R.id.message); + final EditText my_stake=dialogView.findViewById(R.id.stake); + String chlng_msg="Are you sure you want to challenge "+user.getUsername()+" for a duel?"; + message.setText(chlng_msg); + final Button accept=dialogView.findViewById(R.id.positive); + Button reject=dialogView.findViewById(R.id.negative); + accept.setText("Send"); + reject.setText("Cancel"); + builder.setView(dialogView); + final AlertDialog dialog = builder.create(); + SharedPreferences sharedPreferences = mActivity.getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + final String senderUsername = sharedPreferences.getString("com.hackncs.username", ""); + final String senderUserID = sharedPreferences.getString("com.hackncs.userID", ""); + final int myScore = sharedPreferences.getInt("com.hackncs.score", 0); + + + accept.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(my_stake.getText()==null||my_stake.getText().length()==0) + { + Toast.makeText(mActivity,"Enter your stake",Toast.LENGTH_SHORT).show(); + } + else{ + + try + { + final int stake=Integer.valueOf(my_stake.getText().toString()); + + if (stake <= 0) { + Toast.makeText(mContext, "You entered an invalid value!", Toast.LENGTH_SHORT).show(); + + } + else if (stake > myScore) { + Toast.makeText(mContext, "You cannot put more coins than you have on stake!", Toast.LENGTH_SHORT).show(); + + } + else { + StringRequest getFCM = new StringRequest(Request.Method.GET, + Endpoints.syncRequest + user.getUserID(), + new Response.Listener() { + @Override + public void onResponse(String response) { + try { + JSONObject jsonObject = new JSONObject(response); + fcm = jsonObject.getString("fcm_token"); + //requestQueue.add(send); +// Log.i("senders fcm", fcm); + Data_Message message = new Data_Message(); + message.setRequest_type("duel_request"); + message.setUser(senderUsername); + message.setStake(stake + ""); + message.setReference_token(senderUserID); + FCMData fcmData = new FCMData(); + fcmData.setData_message(message); + fcmData.setMessage_body(""); + fcmData.setMessage_title(""); + fcmData.setRegistration_id(fcm); + dialog.dismiss(); + sendFCM(fcmData); + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(getFCM); + } + + + }catch (Exception e) + { + Toast.makeText(mActivity, "You entered an invalid value!", Toast.LENGTH_SHORT).show(); + } + + } + }}); + reject.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + } + }); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.show(); + } + }); + } + } + + @Override + public int getItemCount() { + return users.size(); + } + + + public void sendFCM(final FCMData fcmData) { + fcmService.sendFCM(fcmData).enqueue(new Callback() { + + + @Override + public void onResponse(Call call, retrofit2.Response response) { + + Log.i("Response Code",response.code()+""); + if(response.isSuccessful()) + { + JSONObject object=response.body(); + if(fcmData.getData_message().getRequest_type().equals("duel_request")) { + Toast.makeText(mActivity, "Challenge Sent", Toast.LENGTH_SHORT).show(); + } + + } + else + { + if(response.code()==504){ + JSONObject jsonObject = null; + try { + jsonObject = new JSONObject(response.errorBody().string()); + String userMessage = jsonObject.getString("message"); + Toast.makeText(mActivity,userMessage,Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + Toast.makeText(mActivity,"User is busy",Toast.LENGTH_SHORT).show(); + e.printStackTrace(); + } + + + + } + else{ + Toast.makeText(mActivity,"Response Failure "+response.message(),Toast.LENGTH_SHORT).show(); + } + } + } + + @Override + public void onFailure(Call call, Throwable t) { + Log.e("Error", "Unable to submit post to API."+ t.getMessage()); + } + }); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/hackncs/zealicon/loot/DashboardLoot.java b/app/src/main/java/com/hackncs/zealicon/loot/DashboardLoot.java new file mode 100644 index 0000000..d10b157 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/DashboardLoot.java @@ -0,0 +1,310 @@ +package com.hackncs.zealicon.loot; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.media.MediaPlayer; +import android.os.Build; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.AuthFailureError; +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.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; +import com.google.firebase.firestore.FirebaseFirestore; + +import java.util.HashMap; +import java.util.Map; + +import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; + +public class DashboardLoot extends AppCompatActivity { + + + BottomNavigationView bottomNavigationView; + FirebaseAuth mAuth; + FirebaseFirestore db; + MediaPlayer mediaPlayer; + TextView action_bar_usercoins; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_dashboard_loot); + Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar2); + + + db= FirebaseFirestore.getInstance(); + mAuth = FirebaseAuth.getInstance(); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowTitleEnabled(false); + + TextView action_bar_username=findViewById(R.id.user_name); + action_bar_usercoins=findViewById(R.id.user_coins); + ImageView action_bar_useravatar=findViewById(R.id.avatar); + + SharedPreferences sharedPreferences = getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + int score = sharedPreferences.getInt("com.hackncs.score", 0); + String username= sharedPreferences.getString("com.hackncs.username", null); + int avatarID = sharedPreferences.getInt("com.hackncs.avatarID", R.drawable.avatar_1); + action_bar_useravatar.setImageResource(avatarID); + action_bar_username.setText(username); + action_bar_usercoins.setText(score+""); + + + mediaPlayer = MediaPlayer.create(this, R.raw.backgroundloop); + mediaPlayer.setLooping(true); + if (mediaPlayer.isPlaying()) { + mediaPlayer.start(); + } + + bottomNavigationView=findViewById(R.id.bottom_nav); + bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + int id=item.getItemId(); + switch (id) + { + case R.id.navigation_duel: + + loadFragment(new Duel(),"duel"); +// + break; + case R.id.navigation_current_mission: + loadFragment(new Missions(),"missions"); + break; + case R.id.navigation_leaderboard: + + loadFragment(new LeaderBoard(),"leaderboard"); + break; + } + return true; + } + }); + + } + @Override + protected void onResume() { + super.onResume(); +// Log.i("Resume","Resume"); + if(mAuth.getCurrentUser().isEmailVerified()) { +// Log.i("Resume","Resume"+mediaPlayer.isPlaying()); + mediaPlayer.start(); +// Log.i("Resume","Resume1"+mediaPlayer.isPlaying()); + SharedPreferences sharedPreferences = getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + int score = sharedPreferences.getInt("com.hackncs.score", 0); + action_bar_usercoins.setText(score + ""); + userOnlineUpdate(mAuth.getCurrentUser().getUid(),false); + updateFirebase(mAuth.getCurrentUser(), true); + bottomNavigationView.getMenu().getItem(1).setChecked(true); + Fragment fragment = new Missions(); + loadFragment(fragment, "missions"); + } + else{ + Toast.makeText(this,"Please verify your email to continue",Toast.LENGTH_LONG).show(); + mAuth.signOut(); + Intent intent=new Intent(getApplicationContext(), Main3Activity.class); + startActivity(intent); + } + } + + private void loadFragment(Fragment fragment, String tag) { + // load fragment + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.frame_container, fragment,tag); + transaction.addToBackStack(null); + transaction.commit(); + } + + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + @Override + public void onBackPressed() { +// + int size=getSupportFragmentManager().getFragments().size(); + + String fragmentTag=getSupportFragmentManager().getFragments().get(size-1).getTag(); + Log.i("Fragment",fragmentTag); + + + if(fragmentTag.equals("duel")||fragmentTag.equals("leaderboard")||fragmentTag.equals("current_mission")) { + + + + bottomNavigationView.getMenu().getItem(1).setChecked(true); + Fragment fragment=new Missions(); + loadFragment(fragment,"missions"); + + } + else if(fragmentTag.equals("online_users")) + { + bottomNavigationView.getMenu().getItem(0).setChecked(true); + loadFragment(new Duel(),"duel"); + } + else if (fragmentTag.equals("missions")) + { + updateFirebase(mAuth.getCurrentUser(),false); + finishAffinity(); + } + else if(fragmentTag.equals("about")||fragmentTag.equals("how_to")||fragmentTag.equals("help")||fragmentTag.equals("contact_us")) + { + + bottomNavigationView.getMenu().getItem(1).setChecked(true); + Fragment fragment=new Missions(); + loadFragment(fragment,"missions"); + } + + else { + super.onBackPressed(); + } + + } + +// @Override +// protected void onActivityResult(int requestCode, int resultCode, Intent data) { +// super.onActivityResult(requestCode, resultCode, data); +// if (requestCode == Missions.LOCATION_REQUEST_CODE) { +// if (resultCode == RESULT_OK) { +// Toast.makeText(this, "GPS enabled!", Toast.LENGTH_SHORT).show(); +// } else { +// Toast.makeText(this, "GPS disabled!", Toast.LENGTH_SHORT).show(); +// finish(); +// } +// } +// } + + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + @Override + protected void onStop() { + super.onStop(); + + } + + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + @Override + protected void onPause() { + + + if(mAuth.getCurrentUser()!=null) + updateFirebase(mAuth.getCurrentUser(),false); + else{ + finishAffinity(); + } + mediaPlayer.pause(); + super.onPause(); + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.popup_menu, menu); + return super.onCreateOptionsMenu(menu); + } + @Override + public boolean onOptionsItemSelected(MenuItem menuItem) { + switch (menuItem.getItemId()) { + case R.id.item_howTo: + loadFragment(new HowTo(),"how_to"); +// Intent i1 = new Intent(this, MiniGame.class); +// i1.putExtra("duel_id","nknfknskfdsf" ); +// i1.putExtra("player_type", "challenger"); +// startActivity(i1); + break; + case R.id.item_about: + loadFragment(new AboutFragment(),"about"); + break; + case R.id.item_story: + Intent i = new Intent(this, WelcomeSlider.class); + startActivity(i); + break; + case R.id.item_help: + loadFragment(new Help(),"help"); + break; + case R.id.pop_logout: + updateFirebase(mAuth.getCurrentUser(),false); + mAuth.signOut(); + Intent intent=new Intent(getApplicationContext(), Main3Activity.class); + startActivity(intent); + break; + default: + } + return super.onOptionsItemSelected(menuItem); + } + public void updateFirebase(FirebaseUser firebaseUser,boolean state) + { + Map user = new HashMap<>(); + user.put("userID", firebaseUser.getUid()); + user.put("online", state); + + db.collection("users").document(firebaseUser.getUid()) + .set(user).addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + + if(task.isSuccessful()) + { +// Log.i("Added Succesfully",""); + } + else + { + Log.i("Error",task.getException().getMessage()); + } + } + }); + + + + + } + + public void userOnlineUpdate(String userID, final boolean state){ + RequestQueue requestQueue=requestQueue = Volley.newRequestQueue(this); + StringRequest updateUser = new StringRequest(Request.Method.POST, + Endpoints.updateUser + userID + "/edit/", + new Response.Listener() { + @Override + public void onResponse(String response) { + Log.d("updateVolley", response); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { +// Log.d("updateVolley", error.getMessage()); + } + }) { + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); + map.put("payment", state+""); + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(updateUser); + } +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Data_Message.java b/app/src/main/java/com/hackncs/zealicon/loot/Data_Message.java new file mode 100644 index 0000000..6368286 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Data_Message.java @@ -0,0 +1,51 @@ +package com.hackncs.zealicon.loot; + +/** + * Created by siddhartha on 14/3/18. + */ + +public class Data_Message { + + String request_type,reference_token,user,stake; + String id; + + public String getReference_token() { + return reference_token; + } + + public String getRequest_type() { + return request_type; + } + + public String getId() { + return id; + } + + public String getStake() { + return stake; + } + + public String getUser() { + return user; + } + + public void setId(String id) { + this.id = id; + } + + public void setReference_token(String reference_token) { + this.reference_token = reference_token; + } + + public void setRequest_type(String request_type) { + this.request_type = request_type; + } + + public void setStake(String stake) { + this.stake = stake; + } + + public void setUser(String user) { + this.user = user; + } +} diff --git a/app/src/main/java/com/example/dell/loot/Duel.java b/app/src/main/java/com/hackncs/zealicon/loot/Duel.java similarity index 59% rename from app/src/main/java/com/example/dell/loot/Duel.java rename to app/src/main/java/com/hackncs/zealicon/loot/Duel.java index 5179ff4..e0a9533 100644 --- a/app/src/main/java/com/example/dell/loot/Duel.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/Duel.java @@ -1,14 +1,20 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; +import android.content.Context; +import android.content.SharedPreferences; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.TextView; + +import com.google.android.material.bottomnavigation.BottomNavigationView; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; /** @@ -33,7 +39,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); View view=getView(); + TextView won=view.findViewById(R.id.won); + TextView lost=view.findViewById(R.id.lost); + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + int won_duels = sharedPreferences.getInt("com.hackncs.duelWon", 0); + int lost_duels = sharedPreferences.getInt("com.hackncs.duelLost",0); + won.setText(won_duels+""); + lost.setText(lost_duels+""); Button loot=view.findViewById(R.id.loot); + BottomNavigationView navigationView=getActivity().findViewById(R.id.bottom_nav); + navigationView.getMenu().getItem(0).setChecked(true); loot.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Duel_Alert_Transparent_Activity.java b/app/src/main/java/com/hackncs/zealicon/loot/Duel_Alert_Transparent_Activity.java new file mode 100644 index 0000000..10c0f0b --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Duel_Alert_Transparent_Activity.java @@ -0,0 +1,489 @@ +package com.hackncs.zealicon.loot; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.AuthFailureError; +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 org.json.JSONException; +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import retrofit2.Call; +import retrofit2.Callback; + +public class Duel_Alert_Transparent_Activity extends AppCompatActivity { + + APIService fcmService; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main22); + Intent intent=getIntent(); + fcmService=APIUtils.getAPIService(); + String request_type=intent.getStringExtra("request_type"); + if(request_type.equals("duel_request")) { + String from_user = intent.getStringExtra("user"); + String stake = intent.getStringExtra("stake"); + String reference_token = intent.getStringExtra("reference_token"); + showDialogRequest(from_user,stake,reference_token); + + } + else if(request_type.equals("accept_request")) { + String from_user = intent.getStringExtra("user"); + String stake = intent.getStringExtra("stake"); + String duel_id = intent.getStringExtra("duel_id"); + showDialogAccept(from_user,stake, duel_id); + + } + else if(request_type.equals("reject_request")) + { + String from_user = intent.getStringExtra("user"); + showDialogReject(from_user); + } + else if(request_type.equals("won_message")) + { + String from_user = intent.getStringExtra("user"); + String score=intent.getStringExtra("score"); + showDialogWon(from_user,score); + + } + else if(request_type.equals("lost_message")) + { + String from_user = intent.getStringExtra("user"); + String score=intent.getStringExtra("score"); + showDialogLost(from_user,score); + } + else if(request_type.equals("tie_message")) + { + String from_user = intent.getStringExtra("user"); +// String stake=intent.getStringExtra("stake"); + showDialogTie(from_user); + } + + } + + private void showDialogTie(String from_user) { + LayoutInflater layoutInflater = getLayoutInflater(); + View view=layoutInflater.inflate(R.layout.duel_alert,null); + + TextView title=view.findViewById(R.id.title); + final TextView message=view.findViewById(R.id.message); + Button ok=view.findViewById(R.id.positive); + title.setText("Result"); + message.setText("It was a tie!"); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + + builder.setView(view); + + final AlertDialog dialog = builder.create(); + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + finish(); + } + }); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.show(); + dialog.setCanceledOnTouchOutside(false); + dialog.setCancelable(false); + } + + private void showDialogLost(String from_user,String score) { + + LayoutInflater layoutInflater = getLayoutInflater(); + View view=layoutInflater.inflate(R.layout.duel_alert,null); + + TextView title=view.findViewById(R.id.title); + final TextView message=view.findViewById(R.id.message); + Button ok=view.findViewById(R.id.positive); + title.setText("Result"); + message.setText("You Lost!\n"+from_user+" Won!"); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + + builder.setView(view); + SharedPreferences sharedPreferences =getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + int wonCount=sharedPreferences.getInt("com.hackncs.duelLost",0)+1; + editor.putInt("com.hackncs.duelLost", wonCount); + editor.putInt("com.hackncs.score", Integer.parseInt(score)); + editor.apply(); + + + final AlertDialog dialog = builder.create(); + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + finish(); + } + }); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.setCanceledOnTouchOutside(false); + dialog.setCancelable(false); + dialog.show(); + } + + private void showDialogWon(String from_user, String score) { + LayoutInflater layoutInflater = getLayoutInflater(); + View view=layoutInflater.inflate(R.layout.duel_alert,null); + + TextView title=view.findViewById(R.id.title); + final TextView message=view.findViewById(R.id.message); + Button ok=view.findViewById(R.id.positive); + title.setText("Result"); + message.setText("You Won!\n"+from_user+" Lost!"); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + + builder.setView(view); + + final AlertDialog dialog = builder.create(); + + SharedPreferences sharedPreferences =getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + int wonCount=sharedPreferences.getInt("com.hackncs.duelWon",0)+1; + editor.putInt("com.hackncs.duelWon", wonCount); + editor.putInt("com.hackncs.score", Integer.parseInt(score)); + editor.apply(); + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + finish(); + } + }); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.show(); + } + + private void showDialogRequest(String user, final String stake, final String reference_token) + { + final RequestQueue requestQueue = Volley.newRequestQueue(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + LayoutInflater layoutInflater = getLayoutInflater(); + View view=layoutInflater.inflate(R.layout.challenge_dialog,null); + + TextView message=view.findViewById(R.id.message); + final EditText my_stake=view.findViewById(R.id.stake); + String chlng_msg=user+" has challenged you for a duel of stake "+ stake+"\nDo you want to accept it?"; + message.setText(chlng_msg); + Button accept=view.findViewById(R.id.positive); + Button reject=view.findViewById(R.id.negative); + accept.setText("Accept"); + reject.setText("Reject"); + SharedPreferences sharedPreferences = getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + final String userID = sharedPreferences.getString("com.hackncs.userID", ""); + final String username = sharedPreferences.getString("com.hackncs.username", ""); + builder.setView(view); + final AlertDialog dialog = builder.create(); + accept.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + final String finalStake; + final String[] duelID = new String[1]; + final String[] fcm = new String[1]; + int stakeEntered = 0; + dialog.dismiss(); + try { + + stakeEntered = Integer.valueOf(my_stake.getText().toString()); + if (stakeEntered <= 0) { + Toast.makeText(Duel_Alert_Transparent_Activity.this, "You entered an invalid value!", Toast.LENGTH_SHORT).show(); + + } else { + if (Integer.valueOf(stake) < Integer.valueOf(my_stake.getText().toString())) { + finalStake = stake; + } else { + finalStake = my_stake.getText().toString(); + } + final StringRequest getFCM = new StringRequest(Request.Method.GET, + Endpoints.syncRequest + reference_token, + new Response.Listener() { + @Override + public void onResponse(String response) { + try { + JSONObject jsonObject = new JSONObject(response); + fcm[0] = jsonObject.getString("fcm_token"); +// Log.i("senders fcm", fcm[0]); + Data_Message message = new Data_Message(); + message.setId(duelID[0]); + message.setRequest_type("accept_request"); + message.setUser(username); + message.setReference_token(userID); + message.setStake(finalStake); + FCMData fcmData = new FCMData(); + fcmData.setData_message(message); + fcmData.setMessage_body(""); + fcmData.setMessage_title(""); + fcmData.setRegistration_id(fcm[0]); + + sendFCM(fcmData); + + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + + Log.i("Error", error.getMessage()); + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + + + StringRequest createDuel = new StringRequest(Request.Method.POST, + Endpoints.duel, + new Response.Listener() { + @Override + public void onResponse(String response) { + try { + JSONObject jsonObject = new JSONObject(response); + duelID[0] = jsonObject.getString("id"); + String duelID1 = jsonObject.getString("id"); +// Log.i("duelId", duelID1); + requestQueue.add(getFCM); + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + + Log.i("Error", error.getMessage()); + } + }) { + @Override + protected Map getParams() throws AuthFailureError { + HashMap map = new HashMap<>(); + map.put("challenger_rt", reference_token); + map.put("opponent_rt", userID); + map.put("stake", String.valueOf(finalStake)); +// Log.i("stake", finalStake); + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(createDuel); + } +// + } catch (Exception e) { + Log.i("Exception", e.getMessage()); + } + }}); + + + reject.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { +// Toast.makeText(Duel_Alert_Transparent_Activity.this,"Reject",Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + final String fcm[] = new String[1]; + final StringRequest getFCM = new StringRequest(Request.Method.GET, + Endpoints.syncRequest + reference_token, + new Response.Listener() { + @Override + public void onResponse(String response) { + try { + JSONObject jsonObject = new JSONObject(response); + fcm[0] = jsonObject.getString("fcm_token"); + Data_Message message=new Data_Message(); + message.setRequest_type("reject_request"); + message.setUser(username); + message.setReference_token(userID); + FCMData fcmData=new FCMData(); + fcmData.setData_message(message); + fcmData.setMessage_body(""); + fcmData.setMessage_title(""); + fcmData.setRegistration_id(fcm[0]); + + sendFCM(fcmData); + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(getFCM); + + + } + }); + + dialog.setCanceledOnTouchOutside(false); + dialog.setCancelable(false); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.show(); + + } + private void showDialogAccept(String user, String stake, final String duel_id) + { + LayoutInflater layoutInflater = getLayoutInflater(); + View view=layoutInflater.inflate(R.layout.duel_alert,null); + + TextView title=view.findViewById(R.id.title); + final TextView message=view.findViewById(R.id.message); + Button ok=view.findViewById(R.id.positive); + title.setText("Accepted"); + message.setText(user+" has accepted your duel for "+stake+" coins"); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + + builder.setView(view); + + final AlertDialog dialog = builder.create(); + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + Intent i = new Intent(Duel_Alert_Transparent_Activity.this, MiniGame.class); + i.putExtra("duel_id",duel_id ); + i.putExtra("player_type", "challenger"); + startActivity(i); + } + }); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.setCanceledOnTouchOutside(false); + dialog.setCancelable(false); + dialog.show(); + } + private void showDialogReject(String user) + { + LayoutInflater layoutInflater = getLayoutInflater(); + View view=layoutInflater.inflate(R.layout.duel_alert,null); + + TextView title=view.findViewById(R.id.title); + final TextView message=view.findViewById(R.id.message); + Button ok=view.findViewById(R.id.positive); + title.setText("Rejected"); + message.setText(user+" has rejected your duel"); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + + builder.setView(view); + + final AlertDialog dialog = builder.create(); + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + finish(); + } + }); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.setCanceledOnTouchOutside(false); + dialog.setCancelable(false); + dialog.show(); + } + + + public void sendFCM(final FCMData fcmData) { + fcmService.sendFCM(fcmData).enqueue(new Callback() { + + @Override + public void onResponse(Call call, retrofit2.Response response) { + + Log.i("Response Code",response.code()+""); + + if(response.isSuccessful()) + { + JSONObject object=response.body(); + +// Toast.makeText(Duel_Alert_Transparent_Activity.this,"Success",Toast.LENGTH_SHORT).show(); + if(fcmData.getData_message().getRequest_type().equals("accept_request")) { + Intent i = new Intent(Duel_Alert_Transparent_Activity.this, MiniGame.class); + i.putExtra("duel_id",fcmData.getData_message().getId() ); + i.putExtra("player_type", "opponent"); + startActivity(i); + } + else + { +// Toast.makeText(Duel_Alert_Transparent_Activity.this,fcmData.getData_message().getRequest_type(),Toast.LENGTH_SHORT).show(); + finish(); + } + + } + else + { + if(response.code()==504){ + try { + Toast.makeText(Duel_Alert_Transparent_Activity.this,response.body().getString("message"),Toast.LENGTH_SHORT).show(); + } catch (JSONException e) { + e.printStackTrace(); + } + finish(); + } + else{ + Toast.makeText(Duel_Alert_Transparent_Activity.this,"Response Failure "+response.message(),Toast.LENGTH_SHORT).show(); + finish(); + } + + } + } + + @Override + public void onFailure(Call call, Throwable t) { + Log.e("Error", "Unable to submit post to API."+ t.getMessage()); + } + }); + } + + @Override + protected void onPause() { + super.onPause(); + finish(); + } +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Endpoints.java b/app/src/main/java/com/hackncs/zealicon/loot/Endpoints.java new file mode 100644 index 0000000..dab15c7 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Endpoints.java @@ -0,0 +1,12 @@ +package com.hackncs.zealicon.loot; + +public class Endpoints { + public static String syncRequest = "http://loot.shobhitagarwal.me/api/users/"; + public static String register = "http://loot.shobhitagarwal.me/api/users/register/"; + public static String leaders = "http://loot.shobhitagarwal.me/api/users/leaderboard/"; + public static String fetchMission = "http://loot.shobhitagarwal.me/api/missions/"; + public static String updateUser = "http://loot.shobhitagarwal.me/api/users/"; + public static String send = "http://loot.shobhitagarwal.me/"; + public static String duel = "http://loot.shobhitagarwal.me/api/duels/"; + public static String apikey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicGFzc3dvcmQiOiJsb290MjAxOSIsImlhdCI6MTU0ODMxMzI2Mn0.VqN0AmH6URo8z_zPff68C81a8e5EUYPgOrwU18TvLMU"; +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/FCMData.java b/app/src/main/java/com/hackncs/zealicon/loot/FCMData.java new file mode 100644 index 0000000..a552b0f --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/FCMData.java @@ -0,0 +1,45 @@ +package com.hackncs.zealicon.loot; + +/** + * Created by siddhartha on 14/3/18. + */ + +public class FCMData { + + String registration_id; + String message_body; + String message_title; + Data_Message data_message; + + public Data_Message getData_message() { + return data_message; + } + + public String getMessage_body() { + return message_body; + } + + public String getMessage_title() { + return message_title; + } + + public String getRegistration_id() { + return registration_id; + } + + public void setData_message(Data_Message data_message) { + this.data_message = data_message; + } + + public void setMessage_body(String message_body) { + this.message_body = message_body; + } + + public void setMessage_title(String message_title) { + this.message_title = message_title; + } + + public void setRegistration_id(String registration_id) { + this.registration_id = registration_id; + } +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/GridTap.java b/app/src/main/java/com/hackncs/zealicon/loot/GridTap.java new file mode 100644 index 0000000..f76834e --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/GridTap.java @@ -0,0 +1,242 @@ +package com.hackncs.zealicon.loot; + +import android.graphics.Color; +import android.media.MediaPlayer; +import android.os.Bundle; +import android.os.CountDownTimer; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.GridLayout; +import android.widget.TextView; +import android.widget.Toast; +import com.android.volley.AuthFailureError; +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 java.util.HashMap; +import java.util.Map; + +import androidx.fragment.app.Fragment; + + +public class GridTap extends Fragment implements View.OnClickListener { + + View view; + GridLayout gridLayout; + Button b[][]; + Bundle savedInstanceState; + ClockCountdown clockCountdown; + TileCountdown tileCountdown; + DelayCountdown delayCountdown; + MediaPlayer mediaPlayer; + TextView counterText, timerText; + Bundle args; + int avatarIds[]=new int[6]; + int random; + boolean finish; + + int buttonsID[][] = { + {R.id.b00, R.id.b01, R.id.b02, R.id.b03, R.id.b04}, + {R.id.b10, R.id.b11, R.id.b12, R.id.b13, R.id.b14}, + {R.id.b20, R.id.b21, R.id.b22, R.id.b23, R.id.b24}, + {R.id.b30, R.id.b31, R.id.b32, R.id.b33, R.id.b34}, + {R.id.b40, R.id.b41, R.id.b42, R.id.b43, R.id.b44} + }; + int redLocation, tappedLocation, counter = 0, seconds = 30, tileChangeInterval = 600, x, y; + + public GridTap() { + // Required empty public constructor + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.savedInstanceState = savedInstanceState; + b = new Button[5][5]; + + avatarIds[0]=R.drawable.avatar_1; + avatarIds[1]=R.drawable.avatar_2; + avatarIds[2]=R.drawable.avatar_3; + avatarIds[3]=R.drawable.avatar_4; + avatarIds[4]=R.drawable.avatar_5; + avatarIds[5]=R.drawable.avatar_6; + + + clockCountdown = new ClockCountdown(seconds * 1000, 1000); + tileCountdown = new TileCountdown(seconds * 1000, tileChangeInterval); + delayCountdown = new DelayCountdown(5000, 1000); + x = (int)(Math.random() * 5); + y = (int)(Math.random() * 5); + redLocation = (x*10) + (y+1); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + view = inflater.inflate(R.layout.fragment_grid_tap, container, false); + initializeViews(); + delayCountdown.start(); + Toast.makeText(getContext(), "Get ready to Loot", Toast.LENGTH_SHORT).show(); + mediaPlayer = MediaPlayer.create(getContext(), R.raw.minigame); + mediaPlayer.setLooping(true); + mediaPlayer.start(); + args=getArguments(); + return view; + } + + private void initializeViews() { + gridLayout = view.findViewById(R.id.gridLayout); + timerText = view.findViewById(R.id.timer); + counterText = view.findViewById(R.id.counter); + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + b[i][j] = view.findViewById(buttonsID[i][j]); + b[i][j].setTag(String.valueOf((i*10)+(j+1))); + b[i][j].setBackgroundColor(Color.TRANSPARENT); + b[i][j].setOnClickListener(this); + } + } + } + + @Override + public void onClick(View view) { + if(!finish) { + tappedLocation = Integer.valueOf(view.getTag().toString()); + updateCounter(); + } + else + { + Toast.makeText(getActivity(),"Please wait",Toast.LENGTH_SHORT).show(); + } + } + + private void updateCounter() { + if (tappedLocation == redLocation) { + counter++; + } else { + counter--; + } + counterText.setText(String.valueOf(counter)); + } + + private void updateRedTile() { + + b[x][y].setBackgroundColor(Color.TRANSPARENT); + x = (int)(Math.random() * 5); + y = (int)(Math.random() * 5); + redLocation = (x*10) + (y+1); + random=random%6+1; + + b[x][y].setBackgroundResource(avatarIds[random-1]); + + } + + class ClockCountdown extends CountDownTimer { + + public ClockCountdown(long millisInFuture, long countDownInterval) { + super(millisInFuture, countDownInterval); + } + + @Override + public void onTick(long l) { + timerText.setText("00:" + String.valueOf(--seconds)); + } + + @Override + public void onFinish() { + tileCountdown.cancel(); + finish=true; + b[x][y].setBackgroundColor(Color.TRANSPARENT); + StringRequest updateTapCount = new StringRequest(Request.Method.POST, + Endpoints.duel + args.get("duel_id") + "/edit/", + new Response.Listener() { + @Override + public void onResponse(String response) { + Toast.makeText(getContext(), "Stay tuned for the results!", Toast.LENGTH_SHORT).show(); + getActivity().finish(); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + Toast.makeText(getContext(), "Error"+ error.getMessage() , Toast.LENGTH_SHORT).show();; + } + }){ + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); +// if (args.get("player_type").equals("challenger")) { +// Log.i("Player_type",getActivity().getIntent().getStringExtra("player_type")); + if (getActivity().getIntent().getStringExtra("player_type").equals("challenger")) { + map.put("challenger_tap_count", String.valueOf(counter)); + } else { + map.put("opponent_tap_count", String.valueOf(counter)); + } + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + RequestQueue requestQueue = Volley.newRequestQueue(getContext()); + requestQueue.add(updateTapCount); + } + } + + class TileCountdown extends CountDownTimer { + + public TileCountdown(long millisInFuture, long countDownInterval) { + super(millisInFuture, countDownInterval); + } + + @Override + public void onTick(long l) { + updateRedTile(); + } + + @Override + public void onFinish() { + + mediaPlayer.stop(); + } + } + + class DelayCountdown extends CountDownTimer { + + public DelayCountdown(long millisInFuture, long countDownInterval) { + super(millisInFuture, countDownInterval); + } + + @Override + public void onTick(long l) { + //TODO: update text below +// Toast.makeText(getContext(), "Get ready to Loot", Toast.LENGTH_SHORT).show(); + } + + @Override + public void onFinish() { + + random=random%5+1; + b[x][y].setBackgroundResource(avatarIds[random-1]); + clockCountdown.start(); + tileCountdown.start(); + } + } + + @Override + public void onStop() { + super.onStop(); + if(mediaPlayer.isPlaying()) + { + mediaPlayer.stop(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Help.java b/app/src/main/java/com/hackncs/zealicon/loot/Help.java new file mode 100644 index 0000000..d67cbb4 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Help.java @@ -0,0 +1,105 @@ +package com.hackncs.zealicon.loot; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Bundle; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +public class Help extends Fragment { + + public Help() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_help, container, false); + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + Button shobhitContact=getView().findViewById(R.id.shobhitContact); + Button shubhamContact=getView().findViewById(R.id.shubhamContact); + final TextView facebook=getView().findViewById(R.id.textView6); + final TextView shobhit=getView().findViewById(R.id.textView2); + final TextView shubham=getView().findViewById(R.id.textView4); + shobhitContact.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialPhoneNumber("917291082627"); + } + }); + shubhamContact.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialPhoneNumber("917785037144"); + } + }); + shobhit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialPhoneNumber("917291082627"); + } + }); + shubham.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialPhoneNumber("917785037144"); + } + }); + facebook.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + Intent facebookIntent = new Intent(Intent.ACTION_VIEW); + String facebookUrl = getFacebookPageURL(getActivity()); + facebookIntent.setData(Uri.parse(facebookUrl)); + startActivity(facebookIntent); + } + catch (Exception e){ + String FACEBOOK_URL = "https://www.facebook.com/LootZealicon"; + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(FACEBOOK_URL)); + startActivity(i); + } + + } + }); + } + + public void dialPhoneNumber(String phoneNumber) { + Intent intent = new Intent(Intent.ACTION_DIAL); + intent.setData(Uri.parse("tel:" + phoneNumber)); + if (intent.resolveActivity(getActivity().getPackageManager()) != null) { + startActivity(intent); + } + } + public String getFacebookPageURL(Context context) { + String FACEBOOK_URL = "https://www.facebook.com/LootZealicon"; + String FACEBOOK_PAGE_ID = "LootZealicon"; + PackageManager packageManager = context.getPackageManager(); + try { + int versionCode = packageManager.getPackageInfo("com.facebook.katana", 0).versionCode; + if (versionCode >= 3002850) { //newer versions of fb app + return "fb://facewebmodal/f?href=" + FACEBOOK_URL; + } else { //older versions of fb app + return "fb://page/" + FACEBOOK_PAGE_ID; + } + } catch (PackageManager.NameNotFoundException e) { + return FACEBOOK_URL; //normal web url + } + } + +} diff --git a/app/src/main/java/com/example/dell/loot/HowTo.java b/app/src/main/java/com/hackncs/zealicon/loot/HowTo.java similarity index 86% rename from app/src/main/java/com/example/dell/loot/HowTo.java rename to app/src/main/java/com/hackncs/zealicon/loot/HowTo.java index 8e523da..bb774c9 100644 --- a/app/src/main/java/com/example/dell/loot/HowTo.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/HowTo.java @@ -1,11 +1,12 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.fragment.app.Fragment; + public class HowTo extends Fragment { public HowTo() { diff --git a/app/src/main/java/com/hackncs/zealicon/loot/LeaderBoard.java b/app/src/main/java/com/hackncs/zealicon/loot/LeaderBoard.java new file mode 100644 index 0000000..4bac7b2 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/LeaderBoard.java @@ -0,0 +1,122 @@ +package com.hackncs.zealicon.loot; + +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android.volley.AuthFailureError; +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.google.android.material.bottomnavigation.BottomNavigationView; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +public class LeaderBoard extends Fragment { + + private RecyclerView mRecyclerView; + private RecyclerView.Adapter mAdapter; + private RecyclerView.LayoutManager mLayoutManager; + ArrayList users; + ArrayList usernames, coins; + ArrayList avatarIDs; + View view; + RequestQueue requestQueue; + + public LeaderBoard() { + // Required empty public constructor + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + view = inflater.inflate(R.layout.fragment_leader_board, container, false); + mRecyclerView = view.findViewById(R.id.my_recycler_view); + + users = new ArrayList<>(); + mLayoutManager = new LinearLayoutManager(getContext()); + mRecyclerView.setLayoutManager(mLayoutManager); + + + mAdapter = new CustomRecycleAdapter(getContext(), getActivity(), users,"leaderBoard"); + + mRecyclerView.setAdapter(mAdapter); + BottomNavigationView navigationView=getActivity().findViewById(R.id.bottom_nav); + navigationView.getMenu().getItem(2).setChecked(true); + + return view; + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + usernames = new ArrayList<>(); + coins = new ArrayList<>(); + avatarIDs = new ArrayList<>(); + Log.i("times","times"); + StringRequest leaders = new StringRequest(Request.Method.GET, Endpoints.leaders, + new Response.Listener() { + @Override + public void onResponse(String response) { + JSONArray jsonArray; + try { + jsonArray= new JSONArray(response); + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + Log.d("JSON"+i, jsonObject.toString()); + User user=new User(); + user.setUsername(jsonObject.getString("username")); + user.setScore(Integer.valueOf(jsonObject.getString("score"))); + user.setAvatarID(jsonObject.getInt("avatar_id")); + users.add(user); + mAdapter.notifyDataSetChanged(); + usernames.add(i, jsonObject.getString("username")); + coins.add(i, jsonObject.getString("score")); + avatarIDs.add(i, jsonObject.getInt("avatar_id")); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + if(requestQueue==null) { + requestQueue = Volley.newRequestQueue(getActivity()); + } + requestQueue.add(leaders); + + } +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Login.java b/app/src/main/java/com/hackncs/zealicon/loot/Login.java new file mode 100644 index 0000000..ff4ec3d --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Login.java @@ -0,0 +1,265 @@ +package com.hackncs.zealicon.loot; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.AuthFailureError; +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.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.auth.AuthResult; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; +import com.google.firebase.iid.FirebaseInstanceId; +import com.google.firebase.iid.InstanceIdResult; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import static androidx.constraintlayout.motion.widget.MotionScene.TAG; + +public class Login extends Fragment { + + private FirebaseAuth mAuth; + + User user; + ProgressDialog dialog; + EditText email, password; + Button login; + TextView sendMail; + FirebaseUser firebaseUser; + + public Login() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_login, container, false); + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + initializeViews(); + mAuth = FirebaseAuth.getInstance(); + user = new User(); + dialog = new ProgressDialog(getContext()); + dialog.setTitle("Please Wait"); + dialog.setCancelable(false); + dialog.setMessage("Signing in..."); + login.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.show(); + mAuth.signInWithEmailAndPassword(email.getText().toString(), password.getText().toString()) + .addOnCompleteListener(getActivity(), new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()) { + Toast.makeText(getContext(),"Login Successful",Toast.LENGTH_SHORT).show(); + firebaseUser = mAuth.getCurrentUser(); + if(firebaseUser.isEmailVerified()) + syncUser(firebaseUser.getUid()); + else { + dialog.dismiss(); + sendMail.setVisibility(View.VISIBLE); + mAuth.signOut(); + Toast.makeText(getContext(), "Please Verify your email to continue", Toast.LENGTH_LONG).show(); + } + } + else { + dialog.dismiss(); + Toast.makeText(getContext(), "Authentication failed."+ task.getException().getMessage(), + Toast.LENGTH_SHORT).show(); + } + } + }); + } + }); + + } + + private void initializeViews() { + email = getView().findViewById(R.id.email); + password = getView().findViewById(R.id.password); + login = getView().findViewById(R.id.login); + sendMail=getView().findViewById(R.id.sendmail); + + sendMail.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + firebaseUser.sendEmailVerification().addOnCompleteListener(getActivity(), new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if(task.isSuccessful()){ + Toast.makeText(getActivity(), + "Verification Mail Sent. Please verify to continue", + Toast.LENGTH_SHORT).show(); + + } + else{ + Log.e(TAG, "sendEmailVerification", task.getException()); + Toast.makeText(getActivity(), + "Failed to send verification email.", + Toast.LENGTH_SHORT).show(); + + } + } + }); + } + }); + } + + + + public void syncSharedPrefs(User user) { + dialog.setMessage("Completing..."); + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("com.hackncs.userID", user.getUserID()); + editor.putString("com.hackncs.username", user.getUsername()); + editor.putString("com.hackncs.admissionNo", user.getAdmissionNo()); + editor.putString("com.hackncs.name", user.getName()); + editor.putString("com.hackncs.email", user.getEmail()); + editor.putInt("com.hackncs.avatarID", user.getAvatarID()); + editor.putInt("com.hackncs.score", user.getScore()); + editor.putInt("com.hackncs.stage", user.getStage()); + editor.putInt("com.hackncs.state", user.getState()); + editor.putInt("com.hackncs.dropCount", user.getDropCount()); + editor.putInt("com.hackncs.duelWon", user.getDuelWon()); + editor.putInt("com.hackncs.duelLost", user.getDuelLost()); + editor.putLong("com.hackncs.contactNumber", user.getContactNumber()); + editor.apply(); + dialog.dismiss(); + Intent i = new Intent(getContext(),DashboardLoot.class); + i.putExtra("UID", user.getUserID()); + startActivity(i); + } + + private void syncUser(final String userID) { + dialog.setMessage("Syncing Data..."); + StringRequest syncRequest = new StringRequest(Request.Method.GET, Endpoints.syncRequest+userID, + new Response.Listener() { + @Override + public void onResponse(String response) { + JSONObject jsonObject; + try { + Log.i("Response",response); + jsonObject = new JSONObject(response); + user.setUserID(jsonObject.getString("reference_token")); + user.setUsername(jsonObject.getString("username")); + user.setAdmissionNo(jsonObject.getString("admission_no")); + user.setName(jsonObject.getString("name")); + user.setEmail(jsonObject.getString("email")); + user.setAvatarID(Integer.valueOf(jsonObject.getString("avatar_id"))); + user.setScore(Integer.valueOf(jsonObject.getString("score"))); + user.setStage(Integer.valueOf(jsonObject.getString("stage"))); + user.setState(jsonObject.getString("mission_state").equals("false")?0:1); + user.setDropCount(Integer.valueOf(jsonObject.getString("drop_count"))); + user.setDuelWon(Integer.valueOf(jsonObject.getString("duel_won"))); + user.setDuelLost(Integer.valueOf(jsonObject.getString("duel_lost"))); + user.setContactNumber(Long.valueOf(jsonObject.getString("contact_number"))); +// user.setDropped(); + } catch (JSONException e) { + e.printStackTrace(); + } + syncSharedPrefs(user); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + dialog.dismiss(); + Toast.makeText(getContext(), "Error while syncing data!", Toast.LENGTH_SHORT).show(); + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); + requestQueue.add(syncRequest); + getFCMToken(); + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + final String fcmToken = sharedPreferences.getString("com.hackncs.FCMToken", ""); + if (!fcmToken.equals("")) { + Log.d("FCMToken", fcmToken); + StringRequest syncFCMToken = new StringRequest(Request.Method.POST, + Endpoints.updateUser + userID + "/edit/", + new Response.Listener() { + @Override + public void onResponse(String response) { + Log.d("FCMVolley", "response"); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + Log.d("FCMVolley", error.getMessage()); + } + }){ + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); + map.put("fcm_token", fcmToken); + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(syncFCMToken); + } + } + public void getFCMToken(){ + FirebaseInstanceId.getInstance().getInstanceId() + .addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (!task.isSuccessful()) { + Log.w(TAG, "getInstanceId failed", task.getException()); + return; + } + + // Get new Instance ID token + String token = task.getResult().getToken(); + Log.i("FCMTOKEN",token); + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("com.hackncs.FCMToken", token); + editor.commit(); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/LootApplication.java b/app/src/main/java/com/hackncs/zealicon/loot/LootApplication.java similarity index 82% rename from app/src/main/java/com/example/dell/loot/LootApplication.java rename to app/src/main/java/com/hackncs/zealicon/loot/LootApplication.java index 4266777..ff219b2 100644 --- a/app/src/main/java/com/example/dell/loot/LootApplication.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/LootApplication.java @@ -1,9 +1,10 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; import android.app.Application; import android.content.Context; -import android.support.multidex.MultiDex; import java.util.ArrayList; +import androidx.multidex.MultiDex; + public class LootApplication extends Application { User user; ArrayList missions; diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Main3Activity.java b/app/src/main/java/com/hackncs/zealicon/loot/Main3Activity.java new file mode 100644 index 0000000..5e8defa --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Main3Activity.java @@ -0,0 +1,61 @@ +package com.hackncs.zealicon.loot; + +import android.os.Build; +import android.os.Bundle; + +import android.util.Log; + +import androidx.annotation.RequiresApi; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; + +public class Main3Activity extends AppCompatActivity { + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main3); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); + Splash fragment = new Splash(); + loadFragment(fragment,"splash"); + } + + + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + @Override + public void onBackPressed() { +// + int size=getSupportFragmentManager().getFragments().size(); + + String fragmentTag=getSupportFragmentManager().getFragments().get(size-1).getTag(); + Log.i("Fragment",fragmentTag); + + + if(fragmentTag.equals("register")||fragmentTag.equals("login")) { + + Fragment fragment=new Splash(); + loadFragment(fragment,"splash"); + + } + else if (fragmentTag.equals("splash")) + { + finishAffinity(); + } + else { + super.onBackPressed(); + } + + } + + private void loadFragment(Fragment fragment, String tag) { + // load fragment + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.login_frame, fragment,tag); + transaction.addToBackStack(null); + transaction.commit(); + } +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/MiniGame.java b/app/src/main/java/com/hackncs/zealicon/loot/MiniGame.java new file mode 100644 index 0000000..56deef7 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/MiniGame.java @@ -0,0 +1,55 @@ +package com.hackncs.zealicon.loot; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; + +import android.os.Bundle; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; + + +public class MiniGame extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_mini_game); + Toolbar toolbar=findViewById(R.id.toolbar2); + setSupportActionBar(toolbar); + Intent intent =getIntent(); + String player_type=intent.getStringExtra("player_type"); + String duel_id=intent.getStringExtra("duel_id"); + Bundle args=new Bundle(); + args.putString("player_type",player_type); + args.putString("duel_id",duel_id); + + TextView action_bar_username=findViewById(R.id.user_name); + TextView action_bar_usercoins=findViewById(R.id.user_coins); + ImageView action_bar_useravatar=findViewById(R.id.avatar); + + SharedPreferences sharedPreferences = getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + int score = sharedPreferences.getInt("com.hackncs.score", 0); + String username= sharedPreferences.getString("com.hackncs.username", null); + int avatarID = sharedPreferences.getInt("com.hackncs.avatarID", R.drawable.avatar_1); + action_bar_useravatar.setImageResource(avatarID); + action_bar_username.setText(username); + action_bar_usercoins.setText(score+""); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); + GridTap fragment = new GridTap(); + fragment.setArguments(args); + fragmentTransaction.add(R.id.game_frame, fragment); + fragmentTransaction.commit(); + } + + @Override + public void onBackPressed() { + + } +} diff --git a/app/src/main/java/com/example/dell/loot/Mission.java b/app/src/main/java/com/hackncs/zealicon/loot/Mission.java similarity index 97% rename from app/src/main/java/com/example/dell/loot/Mission.java rename to app/src/main/java/com/hackncs/zealicon/loot/Mission.java index 20b2ce9..dbab55b 100644 --- a/app/src/main/java/com/example/dell/loot/Mission.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/Mission.java @@ -1,4 +1,4 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; public class Mission { diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Missions.java b/app/src/main/java/com/hackncs/zealicon/loot/Missions.java new file mode 100644 index 0000000..b807e28 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Missions.java @@ -0,0 +1,419 @@ +package com.hackncs.zealicon.loot; + +import android.Manifest; + +import android.app.Activity; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.IntentSender; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.location.Location; + +import android.os.Build; +import android.os.Bundle; +import android.os.VibrationEffect; +import android.os.Vibrator; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; +import androidx.core.app.ActivityCompat; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; + +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.AuthFailureError; +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.google.android.gms.common.api.ResolvableApiException; +import com.google.android.gms.location.FusedLocationProviderClient; +import com.google.android.gms.location.LocationCallback; +import com.google.android.gms.location.LocationRequest; +import com.google.android.gms.location.LocationResult; +import com.google.android.gms.location.LocationServices; +import com.google.android.gms.location.LocationSettingsRequest; +import com.google.android.gms.location.LocationSettingsResponse; +import com.google.android.gms.location.SettingsClient; +import com.google.android.gms.tasks.OnFailureListener; +import com.google.android.gms.tasks.OnSuccessListener; +import com.google.android.gms.tasks.Task; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.google.android.material.snackbar.Snackbar; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +public class Missions + extends + Fragment { + + private FusedLocationProviderClient fusedLocationClient; + private Location mCurrentLocation; + private LocationCallback locationCallback; + private LocationRequest locationRequest; + private boolean requestingLocationUpdates; + + static final int STATE_LOCATE = 0, STATE_SOLVE = 1; + TextView dan_msg; + Mission mission; + int userStage, state, dropCount, score; + String userID; + Vibrator vibrator; + + ProgressDialog progressDialog; + LootApplication app; + RequestQueue requestQueue; + SharedPreferences sharedPreferences; + int triedAttempts = 0; + + public Missions() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_missions, container, false); + dan_msg = view.findViewById(R.id.dan_msg); + BottomNavigationView navigationView = getActivity().findViewById(R.id.bottom_nav); + navigationView.getMenu().getItem(1).setChecked(true); + + sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + userStage = sharedPreferences.getInt("com.hackncs.stage", 1); + state = sharedPreferences.getInt("com.hackncs.state", 0); + dropCount = sharedPreferences.getInt("com.hackncs.dropCount", 0); + score = sharedPreferences.getInt("com.hackncs.score", 0); + userID = sharedPreferences.getString("com.hackncs.userID", null); + requestQueue = Volley.newRequestQueue(getContext()); + Log.i("State",state+""); + + return view; + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); + progressDialog = new ProgressDialog(getContext()); + progressDialog.setMessage("Loading..."); + progressDialog.show(); + requestingLocationUpdates = false; + fusedLocationClient = LocationServices.getFusedLocationProviderClient(getActivity()); + getMissions(); + createLocationRequest(); + locationCallback = new LocationCallback() { + @Override + public void onLocationResult(LocationResult locationResult) { + if (locationResult == null) { + return; + } + for (Location location : locationResult.getLocations()) { + // Update UI with location data + // ... + if(mission!=null) + checkDistance(location); +// Toast.makeText(getActivity(), location.getLatitude() + " " + location.getLongitude(), Toast.LENGTH_LONG).show(); + } + } + + ; + }; + } + @Override + public void onRequestPermissionsResult(int requestCode, + String permissions[], int[] grantResults) { + switch (requestCode) { + case 1: { + // If request is cancelled, the result arrays are empty. + if (grantResults.length > 0 + && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + // permission was granted, yay! Do the + // contacts-related task you need to do. + startLocationUpdates(); + } else { + // permission denied, boo! Disable the + // functionality that depends on this permission. + getActivity().finish(); + } + return; + } + + // other 'case' lines to check for other + // permissions this app might request. + } + } + + + + protected void createLocationRequest() { + locationRequest = LocationRequest.create(); + locationRequest.setInterval(1000); + locationRequest.setFastestInterval(500); + locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); + LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() + .addLocationRequest(locationRequest); + +// ... + + SettingsClient client = LocationServices.getSettingsClient(getActivity()); + Task task = client.checkLocationSettings(builder.build()); + task.addOnSuccessListener(getActivity(), new OnSuccessListener() { + @Override + public void onSuccess(LocationSettingsResponse locationSettingsResponse) { + // All location settings are satisfied. The client can initialize + // location requests here. + // ... + requestingLocationUpdates = true; + startLocationUpdates(); + } + }); + + task.addOnFailureListener(getActivity(), new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + if (e instanceof ResolvableApiException) { + // Location settings are not satisfied, but this can be fixed + // by showing the user a dialog. + try { + // Show the dialog by calling startResolutionForResult(), + // and check the result in onActivityResult(). + ResolvableApiException resolvable = (ResolvableApiException) e; + resolvable.startResolutionForResult(getActivity(), + 2); + } catch (IntentSender.SendIntentException sendEx) { + // Ignore the error. + } + } + } + }); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 2) { + switch (resultCode) { + case Activity.RESULT_OK: + + startLocationUpdates(); + Log.i("Missions", "User agreed to make required location settings changes."); + // Nothing to do. startLocationupdates() gets called in onResume again. + break; + case Activity.RESULT_CANCELED: + Log.i("Missions", "User chose not to make required location settings changes."); + requestingLocationUpdates = false; + break; + } + } + } + + @Override + public void onResume() { + super.onResume(); + if (requestingLocationUpdates) { + startLocationUpdates(); + } + } + + private void startLocationUpdates() { + if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), + Manifest.permission.ACCESS_FINE_LOCATION)) { + // Show an explanation to the user *asynchronously* -- don't block + // this thread waiting for the user's response! After the user + // sees the explanation, try again to request the permission. + Toast.makeText(getActivity(), "Provide Location Permissions to Continue", Toast.LENGTH_SHORT).show(); + ActivityCompat.requestPermissions(getActivity(), + new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, + 1); + } else { + // No explanation needed; request the permission + ActivityCompat.requestPermissions(getActivity(), + new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, + 1); + + // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an + // app-defined int constant. The callback method gets the + // result of the request. + } + } else { + fusedLocationClient.requestLocationUpdates(locationRequest, + locationCallback, + null /* Looper */); + } + } + private void getMissions() + { Log.i("Stage",String.valueOf(userStage)); + StringRequest fetchMission = new StringRequest(Request.Method.GET, + Endpoints.fetchMission + userStage, + new Response.Listener() { + @Override + public void onResponse(String response) { + JSONObject jsonObject; + mission = new Mission(); + try { + jsonObject = new JSONObject(response); + mission.setMissionID(jsonObject.getInt("id")); + mission.setMissionName(jsonObject.getString("mission_name")); + mission.setStory(jsonObject.getString("story")); + mission.setDescription(jsonObject.getString("description")); + String g = jsonObject.getString("geocode"); + mission.setLat(Double.valueOf(g.substring(0, g.indexOf(" ")))); + mission.setLng(Double.valueOf(g.substring(g.indexOf(" ")))); + mission.setAnswer(jsonObject.getString("answer")); + displayMission(); + } catch (JSONException e) { + e.printStackTrace(); + } + progressDialog.dismiss(); + } + }, + new Response.ErrorListener() { + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + @Override + public void onErrorResponse(VolleyError error) { + progressDialog.dismiss(); +// Log.i("error",error.getMessage()); + Toast.makeText(getContext(), "Slow Network...Error in fetching data!", Toast.LENGTH_SHORT).show(); + if(triedAttempts<5) { + getFragmentManager().beginTransaction().detach(Missions.this).attach(Missions.this).commit(); + triedAttempts++; + } + else + { + Toast.makeText(getContext(), "Slow Network Connectivity.. Restart the App when connected", Toast.LENGTH_SHORT).show(); + Intent i = new Intent(getActivity(), WelcomeSlider.class); + startActivity(i); + } + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(fetchMission); + + + } + + private void displayMission() { + switch (state) { + case STATE_LOCATE: + dan_msg.setText(mission.getStory()); + break; + case STATE_SOLVE: + stopLocationUpdates(); + loadFragment(new Current_missions(), "current_mission"); + break; + } + } + private void loadFragment(Fragment fragment, String tag) { + Bundle bundle = new Bundle(); + bundle.putInt("missionID", mission.getMissionID()); + bundle.putString("story", mission.getStory()); + bundle.putString("description", mission.getDescription()); + bundle.putString("missionName", mission.getMissionName()); + bundle.putString("answer", mission.getAnswer()); + bundle.putDouble("lat", mission.getLat()); + bundle.putDouble("lng", mission.getLng()); + fragment.setArguments(bundle); + FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.frame_container, fragment, tag); + transaction.addToBackStack(null); + transaction.commit(); + } + + private void checkDistance(Location location) { + Location missionLocation = new Location(""); + missionLocation.setLatitude(mission.getLat()); + missionLocation.setLongitude(mission.getLng()); + Log.i("Lat",String.valueOf(location.getLatitude())); + Log.i("Lon",String.valueOf(location.getLongitude())); + Log.i("MLat",String.valueOf(mission.getLat())); + Log.i("MLon",String.valueOf(mission.getLng())); +// Toast.makeText(getContext(), location.distanceTo(missionLocation)+"", Toast.LENGTH_SHORT).show(); + if (location.distanceTo(missionLocation) < 5) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + + stopLocationUpdates(); + + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + vibrator.vibrate(VibrationEffect.createWaveform(new long[]{0, 250, 200, 250, 150, 150, 75, 150, 75, 150}, -1)); + } else { + vibrator.vibrate(3000); + } + Log.i("Distance",location.distanceTo(missionLocation)+""); + + state = 1; + StringRequest updateUser = new StringRequest(Request.Method.POST, + Endpoints.updateUser + userID + "/edit/", + new Response.Listener() { + @Override + public void onResponse(String response) { + Log.d("updateVolley", "response"); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putInt("com.hackncs.state", state); + editor.apply(); +// getFragmentManager().beginTransaction().detach(Missions.this).attach(Missions.this).commit(); + loadFragment(new Current_missions(), "current_mission"); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + Log.d("updateVolley", error.getMessage()); + } + }) { + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); + map.put("mission_state", "true"); + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + requestQueue.add(updateUser); + } + } + private void showSnackbar(String mainTextStringId, String actionStringId, + View.OnClickListener listener) { + Snackbar.make( + getActivity().findViewById(android.R.id.content), + mainTextStringId, + Snackbar.LENGTH_INDEFINITE) + .setAction(actionStringId, listener).show(); + } + @Override + public void onPause() { + super.onPause(); + stopLocationUpdates(); + } + + private void stopLocationUpdates() { + fusedLocationClient.removeLocationUpdates(locationCallback); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hackncs/zealicon/loot/MyFirebaseInstanceIDService.java b/app/src/main/java/com/hackncs/zealicon/loot/MyFirebaseInstanceIDService.java new file mode 100644 index 0000000..88e9e5f --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/MyFirebaseInstanceIDService.java @@ -0,0 +1,72 @@ +//package com.example.dell.loot; +// +//import android.app.Activity; +//import android.app.Service; +//import android.content.Context; +//import android.content.Intent; +//import android.content.SharedPreferences; +//import android.os.IBinder; +//import android.util.Log; +// +//import com.android.volley.AuthFailureError; +//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.google.firebase.auth.FirebaseAuth; +//import com.google.firebase.auth.FirebaseUser; +//import com.google.firebase.iid.FirebaseInstanceId; +//import com.google.firebase.iid.FirebaseInstanceIdService; +//import com.google.firebase.messaging.FirebaseMessagingService; +//import com.google.firebase.messaging.RemoteMessage; +// +//import java.util.HashMap; +//import java.util.Map; +// +//public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { +// +// private static final String TAG = "MyFirebaseIIDService"; +// +// @Override +// public void onTokenRefresh() { +// // Get updated InstanceID token. +// String refreshedToken = FirebaseInstanceId.getInstance().getToken(); +// Log.d(TAG, "Refreshed token: " + refreshedToken); +// +// // If you want to send messages to this application instance or +// // manage this apps subscriptions on the server side, send the +// // Instance ID token to your app server. +// sendRegistrationToServer(refreshedToken); +// } +// private void sendRegistrationToServer(final String token) { +// FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser(); +// if (firebaseUser != null) { +// String userID = firebaseUser.getUid(); +// StringRequest updateFCMToken = new StringRequest(Request.Method.POST, +// Endpoints.updateUser + userID + "/edit/", +// null, +// null) { +// @Override +// protected Map getParams() throws AuthFailureError { +// Map map = new HashMap(); +// map.put("fcm_token", token); +// return map; +// } +// @Override +// public Map getHeaders() throws AuthFailureError { +// Map params = new HashMap<>(); +// params.put("x-auth",Endpoints.apikey); +// return params; +// } +// }; +// RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext()); +// requestQueue.add(updateFCMToken); +// } +// SharedPreferences sharedPreferences = getApplication().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); +// SharedPreferences.Editor editor = sharedPreferences.edit(); +// editor.putString("com.hackncs.FCMToken", token); +// editor.commit(); +// } +//} \ No newline at end of file diff --git a/app/src/main/java/com/hackncs/zealicon/loot/MyFirebaseMessagingService.java b/app/src/main/java/com/hackncs/zealicon/loot/MyFirebaseMessagingService.java new file mode 100644 index 0000000..0eea5ad --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/MyFirebaseMessagingService.java @@ -0,0 +1,129 @@ +package com.hackncs.zealicon.loot; + + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.util.Log; + +import com.android.volley.AuthFailureError; +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.StringRequest; +import com.android.volley.toolbox.Volley; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; +import com.google.firebase.messaging.FirebaseMessagingService; +import com.google.firebase.messaging.RemoteMessage; + +import java.util.HashMap; +import java.util.Map; + +public class MyFirebaseMessagingService extends FirebaseMessagingService { + + private static final String TAG = "FirebaseMessageService"; + + @Override + public void onMessageReceived(RemoteMessage remoteMessage) { + // There are two types of messages data messages and notification messages. Data messages are handled + // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type + // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app + // is in the foreground. When the app is in the background an automatically generated notification is displayed. + // When the user taps on the notification they are returned to the app. Messages containing both notification + // and data payloads are treated as notification messages. The Firebase console always sends notification + // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options + // + Log.d(TAG, "From: " + remoteMessage.getFrom()); + + // Check if message contains a data payload. + if (remoteMessage.getData() != null) { + Log.d(TAG, "Message data payload: " + remoteMessage.getData()); + String request_type = remoteMessage.getData().get("request_type"); + Intent intent = new Intent(this, Duel_Alert_Transparent_Activity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra("request_type", request_type); + if (request_type.equals("duel_request")) { + String from_user = remoteMessage.getData().get("user"); + String stake = remoteMessage.getData().get("stake"); + String reference_token = remoteMessage.getData().get("reference_token"); + intent.putExtra("user", from_user); + intent.putExtra("stake", stake); + intent.putExtra("reference_token", reference_token); + } else if (request_type.equals("accept_request")) { + String from_user = remoteMessage.getData().get("user"); + String stake = remoteMessage.getData().get("stake"); + String duel_id = remoteMessage.getData().get("id"); + intent.putExtra("duel_id", duel_id); + intent.putExtra("user", from_user); + intent.putExtra("stake", stake); + } else if (request_type.equals("reject_request")) { + String from_user = remoteMessage.getData().get("user"); + intent.putExtra("user", from_user); + + } else if (request_type.equals("won_message")) { + String from_user = remoteMessage.getData().get("user"); + String score = remoteMessage.getData().get("score"); + intent.putExtra("user", from_user); + intent.putExtra("score", score); + } else if (request_type.equals("lost_message")) { + String from_user = remoteMessage.getData().get("user"); + String score = remoteMessage.getData().get("score"); + intent.putExtra("user", from_user); + intent.putExtra("score", score); + } else if (request_type.equals("tie_message")) { + String from_user = remoteMessage.getData().get("user"); +// String stake = remoteMessage.getData().get("stake"); + intent.putExtra("user", from_user); +// intent.putExtra("stake", stake); + } +// sendNotification(from_user,stake); + + startActivity(intent); + } + + // Check if message contains a notification payload. + if (remoteMessage.getNotification() != null) { + Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); + } + + } + @Override + public void onNewToken(String token) { + Log.d(TAG, "Refreshed token: " + token); + + // If you want to send messages to this application instance or + // manage this apps subscriptions on the server side, send the + // Instance ID token to your app server. + sendRegistrationToServer(token); + } + private void sendRegistrationToServer(final String token) { + FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser(); + if (firebaseUser != null) { + String userID = firebaseUser.getUid(); + StringRequest updateFCMToken = new StringRequest(Request.Method.POST, + Endpoints.updateUser + userID + "/edit/", + null, + null) { + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); + map.put("fcm_token", token); + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext()); + requestQueue.add(updateFCMToken); + } + SharedPreferences sharedPreferences = getApplication().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + Log.i("FCMTOKEN",token); + editor.putString("com.hackncs.FCMToken", token); + editor.commit(); + } +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/OnlineUsers.java b/app/src/main/java/com/hackncs/zealicon/loot/OnlineUsers.java new file mode 100644 index 0000000..90416af --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/OnlineUsers.java @@ -0,0 +1,184 @@ +package com.hackncs.zealicon.loot; + + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android.volley.AuthFailureError; +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.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.firestore.DocumentSnapshot; +import com.google.firebase.firestore.EventListener; +import com.google.firebase.firestore.FirebaseFirestore; +import com.google.firebase.firestore.FirebaseFirestoreException; +import com.google.firebase.firestore.QueryDocumentSnapshot; +import com.google.firebase.firestore.QuerySnapshot; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + + +/** + * A simple {@link Fragment} subclass. + */ +public class OnlineUsers extends Fragment { + + + private RecyclerView mRecyclerView; + private RecyclerView.Adapter mAdapter; + private RecyclerView.LayoutManager mLayoutManager; + ArrayList onlineUsers; + FirebaseFirestore db; + + public OnlineUsers() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_online_users, container, false); + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + mRecyclerView = (RecyclerView) getView().findViewById(R.id.my_recycler_view); + + db = FirebaseFirestore.getInstance(); + onlineUsers = new ArrayList<>(); + // use a linear layout manager + mLayoutManager = new LinearLayoutManager(getContext()); + mRecyclerView.setLayoutManager(mLayoutManager); + + + mAdapter = new CustomRecycleAdapter(getContext(), getActivity(), onlineUsers,"online_users"); + SharedPreferences sharedPreferences =getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + final String userId = sharedPreferences.getString("com.hackncs.userID",""); + mRecyclerView.setAdapter(mAdapter); +// db.collection("users") +// .whereEqualTo("online", true) +// .get() +// .addOnCompleteListener(new OnCompleteListener() { +// @Override +// public void onComplete(@NonNull Task task) { +// if (task.isSuccessful()) { +// for (DocumentSnapshot document : task.getResult()) { +// Map map = document.getData(); +// if(!map.get("userID").toString().equals(userId)) +// getUser(map.get("userID").toString()); +// } +// } else { +// Log.i("Error getting documents", task.getException().getMessage()); +// } +// } +// }); + db.collection("users") + .whereEqualTo("online", true) + .addSnapshotListener(new EventListener() { + @Override + public void onEvent(@javax.annotation.Nullable QuerySnapshot queryDocumentSnapshots, @javax.annotation.Nullable FirebaseFirestoreException e) { + if (e != null) { + Log.w("Online Error", "Listen failed.", e); + return; + } + onlineUsers.clear(); + for (QueryDocumentSnapshot doc : queryDocumentSnapshots) { + Log.i("Data",doc.getString("userID")); + if(!doc.get("userID").toString().equals(userId)) + getUser(doc.get("userID").toString()); + } + } + }); +// .get() +// .addOnCompleteListener(new OnCompleteListener() { +// @Override +// public void onComplete(@NonNull Task task) { +// if (task.isSuccessful()) { +// for (DocumentSnapshot document : task.getResult()) { +// Map map = document.getData(); +// if(!map.get("userID").toString().equals(userId)) +// getUser(map.get("userID").toString()); +// } +// } else { +// Log.i("Error getting documents", task.getException().getMessage()); +// } +// } +// }); + } + + + private void getUser(String userID) { + final User user = new User(); + StringRequest syncRequest = new StringRequest(Request.Method.GET, + Endpoints.syncRequest + userID, + new Response.Listener() { + @Override + public void onResponse(String response) { + JSONObject jsonObject; + try { + jsonObject = new JSONObject(response); + Log.i("response",response); + user.setUserID(jsonObject.getString("reference_token")); + user.setUsername(jsonObject.getString("username")); + user.setAdmissionNo(jsonObject.getString("admission_no")); + user.setName(jsonObject.getString("name")); + user.setEmail(jsonObject.getString("email")); + user.setAvatarID(Integer.valueOf(jsonObject.getString("avatar_id"))); + user.setScore(Integer.valueOf(jsonObject.getString("score"))); + user.setStage(Integer.valueOf(jsonObject.getString("stage"))); + user.setState(jsonObject.getString("mission_state").equals("0")?0:1); + user.setDropCount(Integer.valueOf(jsonObject.getString("drop_count"))); + user.setDuelWon(Integer.valueOf(jsonObject.getString("duel_won"))); + user.setDuelLost(Integer.valueOf(jsonObject.getString("duel_lost"))); + user.setContactNumber(Long.valueOf(jsonObject.getString("contact_number"))); +// user.setDropped(); + + } catch (JSONException e) { + e.printStackTrace(); + } + onlineUsers.add(user); + mAdapter.notifyDataSetChanged(); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { +// Log.i("Error",error.getMessage()); + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); + requestQueue.add(syncRequest); + } + +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Register.java b/app/src/main/java/com/hackncs/zealicon/loot/Register.java new file mode 100644 index 0000000..5201a4b --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Register.java @@ -0,0 +1,355 @@ +package com.hackncs.zealicon.loot; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.Toast; + +import com.android.volley.AuthFailureError; +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.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.auth.AuthResult; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; +import com.google.firebase.firestore.FirebaseFirestore; +import com.google.firebase.iid.FirebaseInstanceId; +import com.google.firebase.iid.InstanceIdResult; + +import java.util.HashMap; +import java.util.Map; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import static androidx.constraintlayout.motion.widget.MotionScene.TAG; + +public class Register extends Fragment implements View.OnClickListener{ + + private FirebaseAuth mAuth; + View view; + EditText name, email, contact, zeal, username, password; + ImageView avatars[]=new ImageView[6]; + ImageView tick[]=new ImageView[6]; + int avatarIds[]=new int[6]; + ProgressDialog dialog; + FirebaseFirestore db; + int selectedAvatar; + FirebaseUser firebaseUser; + User user; + public Register() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + view = inflater.inflate(R.layout.fragment_register, container, false); + initializeViews(); + return view; + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + mAuth = FirebaseAuth.getInstance(); + db = FirebaseFirestore.getInstance(); + Button register = getView().findViewById(R.id.submit); + + dialog.setTitle("Please Wait"); + dialog.setCancelable(false); + dialog.setMessage("Signing in..."); + + register.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!validation()) { + Toast.makeText(getActivity(), "Please fill in all the field", Toast.LENGTH_SHORT).show(); + } else { + dialog.show(); + mAuth.createUserWithEmailAndPassword(email.getText().toString(), password.getText().toString()) + .addOnCompleteListener(getActivity(), new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()) { + dialog.dismiss(); + firebaseUser = mAuth.getCurrentUser(); + firebaseUser.sendEmailVerification().addOnCompleteListener(getActivity(), new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if(task.isSuccessful()){ + Toast.makeText(getActivity(), + "Verification Mail Sent. Please verify to continue", + Toast.LENGTH_SHORT).show(); + createUser(); + } + else{ + firebaseUser.delete(); + Log.e(TAG, "sendEmailVerification", task.getException()); + Toast.makeText(getActivity(), + "Failed to send verification email.Invalid Email. Try Again", + Toast.LENGTH_SHORT).show(); + } + } + }); + + } else { + dialog.dismiss(); + Toast.makeText(getContext(), "Registration failed." + task.getException().getMessage(), + Toast.LENGTH_SHORT).show(); + + } + } + }); + + } + } + }); + } + private void createUser(){ + updateFirebase(firebaseUser); + StringRequest register = new StringRequest(Request.Method.POST, + Endpoints.register, + new Response.Listener() { + @Override + public void onResponse(String response) { + Log.d("volley request", "response"); + syncSharedPrefs(); + Toast.makeText(getContext(), "You're registered successfully!", Toast.LENGTH_SHORT).show(); + Intent i = new Intent(getContext(), WelcomeSlider.class); + startActivity(i); + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + firebaseUser.delete(); + Log.d("volley request", "error"); + Toast.makeText(getContext(), "Error Occurred!", Toast.LENGTH_SHORT).show(); + } + }) { + @Override + protected Map getParams() throws AuthFailureError { + Map map = new HashMap(); + map.put("reference_token", firebaseUser.getUid()); + map.put("email", email.getText().toString()); + map.put("name", name.getText().toString()); + map.put("username", username.getText().toString()); + map.put("admission_no", zeal.getText().toString()); + map.put("contact_number", contact.getText().toString()); + map.put("score", "0"); + map.put("stage", "1"); + map.put("mission_state", "false"); + map.put("drop_count", "0"); + map.put("duel_won", "0"); + map.put("duel_lost", "0"); + map.put("avatar_id", String.valueOf(avatarIds[selectedAvatar])); + getFCMToken(); + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + final String fcmToken = sharedPreferences.getString("com.hackncs.FCMToken", ""); + if (!fcmToken.equals("")) { + map.put("fcm_token", fcmToken); + } + return map; + } + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); + requestQueue.add(register); + } + + private void initializeViews() { + name = view.findViewById(R.id.name); + email = view.findViewById(R.id.email); + contact = view.findViewById(R.id.contactNumber); + zeal = view.findViewById(R.id.zealId); + username = view.findViewById(R.id.username); + password = view.findViewById(R.id.password); + avatars[0]=view.findViewById(R.id.avatar_1); + avatars[1]=view.findViewById(R.id.avatar_2); + avatars[2]=view.findViewById(R.id.avatar_3); + avatars[3]=view.findViewById(R.id.avatar_4); + avatars[4]=view.findViewById(R.id.avatar_5); + avatars[5]=view.findViewById(R.id.avatar_6); + + + for (int x=0;x<6;x++) + { + avatars[x].setOnClickListener(this); + } + + tick[0]=view.findViewById(R.id.tick_1); + tick[1]=view.findViewById(R.id.tick_2); + tick[2]=view.findViewById(R.id.tick_3); + tick[3]=view.findViewById(R.id.tick_4); + tick[4]=view.findViewById(R.id.tick_5); + tick[5]=view.findViewById(R.id.tick_6); + + + avatarIds[0]=R.drawable.avatar_1; + avatarIds[1]=R.drawable.avatar_2; + avatarIds[2]=R.drawable.avatar_3; + avatarIds[3]=R.drawable.avatar_4; + avatarIds[4]=R.drawable.avatar_5; + avatarIds[5]=R.drawable.avatar_6; + + dialog=new ProgressDialog(getContext()); + } + + @Override + public void onStart() { + super.onStart(); + } + + private User getUser() { + user = new User(); + user.setUserID(firebaseUser.getUid()); + user.setUsername(username.getText().toString()); + user.setAdmissionNo(zeal.getText().toString()); + user.setName(name.getText().toString()); + user.setEmail(email.getText().toString()); + user.setAvatarID(avatarIds[selectedAvatar]); + user.setScore(0); + user.setStage(1); + user.setState(0); + user.setDropCount(0); + user.setDuelWon(0); + user.setDuelLost(0); + user.setContactNumber(Long.valueOf(contact.getText().toString())); + return user; + } + + public void syncSharedPrefs() { + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("com.hackncs.userID", firebaseUser.getUid()); + editor.putString("com.hackncs.username", username.getText().toString()); + editor.putString("com.hackncs.admissionNo", zeal.getText().toString()); + editor.putString("com.hackncs.name", name.getText().toString()); + editor.putString("com.hackncs.email", email.getText().toString()); + editor.putInt("com.hackncs.avatarID", avatarIds[selectedAvatar]); + editor.putInt("com.hackncs.score", 0); + editor.putInt("com.hackncs.stage", 1); + editor.putInt("com.hackncs.state", 0); + editor.putInt("com.hackncs.dropCount", 0); + editor.putInt("com.hackncs.duelWon", 0); + editor.putInt("com.hackncs.duelLost", 0); + editor.putLong("com.hackncs.contactNumber", Long.valueOf(contact.getText().toString())); + editor.apply(); + } + + public void updateFirebase(FirebaseUser firebaseUser) + { + Map user = new HashMap<>(); + user.put("userID", firebaseUser.getUid()); + user.put("online", false); + + db.collection("users").document(firebaseUser.getUid()) + .set(user).addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + + if(task.isSuccessful()) + { + Log.i("Added Succesfully",""); + } + else + { + Log.i("Error",task.getException().getMessage()); + } + } + }); + + } + + @Override + public void onClick(View view) { + + + int id=view.getId(); + Log.i("Clicked",id+""); + for(int i=0;i<6;i++) + { + if(avatars[i].getId()==id) + { + tick[selectedAvatar].setVisibility(View.GONE); + tick[i].setVisibility(View.VISIBLE); + //TODO:Update avatarId + selectedAvatar=i; + Log.i("Selected",selectedAvatar+""); + } + } + + } + + private boolean validation() + { + boolean validate=true; + if(name.getText()==null||name.getText().toString().trim().length()==0) + { + validate=false; + } + else if(email.getText()==null||email.getText().toString().trim().length()==0) + { + validate=false; + } + else if(zeal.getText()==null||zeal.getText().toString().trim().length()==0) + { + validate=false; + } + else if(contact.getText()==null||contact.getText().toString().trim().length()==0) + { + validate=false; + } + else if(password.getText()==null||password.getText().toString().trim().length()==0) + { + validate=false; + } + else if(username.getText()==null||username.getText().toString().trim().length()==0) + { + validate=false; + } + return validate; + + } + public void getFCMToken(){ + FirebaseInstanceId.getInstance().getInstanceId() + .addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (!task.isSuccessful()) { + Log.w(TAG, "getInstanceId failed", task.getException()); + return; + } + + // Get new Instance ID token + String token = task.getResult().getToken(); + Log.i("FCMTOKEN",token); + SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("com.hackncs.FCMToken", token); + editor.commit(); + } + }); + } +} diff --git a/app/src/main/java/com/hackncs/zealicon/loot/RetrofitClient.java b/app/src/main/java/com/hackncs/zealicon/loot/RetrofitClient.java new file mode 100644 index 0000000..b72dd58 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/RetrofitClient.java @@ -0,0 +1,19 @@ +package com.hackncs.zealicon.loot; + +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class RetrofitClient { + + private static Retrofit retrofit = null; + + public static Retrofit getClient(String baseUrl) { + if (retrofit==null) { + retrofit = new Retrofit.Builder() + .baseUrl(baseUrl) + .addConverterFactory(GsonConverterFactory.create()) + .build(); + } + return retrofit; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/Splash.java b/app/src/main/java/com/hackncs/zealicon/loot/Splash.java similarity index 56% rename from app/src/main/java/com/example/dell/loot/Splash.java rename to app/src/main/java/com/hackncs/zealicon/loot/Splash.java index 25597f3..94f4bdb 100644 --- a/app/src/main/java/com/example/dell/loot/Splash.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/Splash.java @@ -1,4 +1,4 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; import android.content.Context; import android.content.Intent; @@ -7,11 +7,9 @@ import android.net.NetworkInfo; import android.os.AsyncTask; import android.os.Bundle; +import android.os.CountDownTimer; import android.os.Handler; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -20,6 +18,7 @@ import android.widget.RelativeLayout; import android.widget.Toast; +import com.android.volley.AuthFailureError; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; @@ -31,11 +30,18 @@ import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; +import org.json.JSONException; +import org.json.JSONObject; + import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; +import java.util.HashMap; +import java.util.Map; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; -import static com.google.android.gms.internal.zzahn.runOnUiThread; public class Splash extends Fragment { @@ -44,8 +50,9 @@ public class Splash extends Fragment { DatabaseReference users,missions; FirebaseUser fbuser; User user; + ProgressBar loader; ArrayList missionsList = new ArrayList<>(); - boolean isConnected, logged_in, synced_user, synced_missions; + boolean isConnected, logged_in, synced_user, synced_missions, isVerified; public Splash() { // Required empty public constructor @@ -59,6 +66,7 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + user = new User(); return inflater.inflate(R.layout.fragment_splash, container, false); } @@ -79,7 +87,23 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { mAuth = FirebaseAuth.getInstance(); database = FirebaseDatabase.getInstance(); users = database.getReference("Users"); - missions = database.getReference("Missions"); + missions = database.getReference("Current_missions"); + loader=(ProgressBar)getView().findViewById(R.id.loader); + + loader.setMax(5000); + new CountDownTimer(5100, 1) { + @Override + public void onTick(long l) { + int progress=(int)((5000-l)/50); + loader.setProgress(5000-(int)l); + } + + @Override + public void onFinish() { + + } + }.start(); + new BackgroundTasks().execute(); new Handler().postDelayed(new Runnable() { @Override @@ -106,113 +130,71 @@ public void onStart() { } private void syncUser(String userID) { -// users.child(userId).addValueEventListener(new ValueEventListener() { -// @Override -// public void onDataChange(DataSnapshot dataSnapshot) { -// user = dataSnapshot.getValue(User.class); -// Log.i("User Email", "Value is: " + user.getEmail()); -// synced_user = true; -// } -// -// @Override -// public void onCancelled(DatabaseError error) { -// Log.i("Error", error.toException().getMessage()); -// } -// }); -// missions.addListenerForSingleValueEvent(new ValueEventListener() { -// public void onDataChange(DataSnapshot dataSnapshot) { -// synced_missions = true; -// } -// -// @Override -// public void onCancelled(DatabaseError databaseError) { -// -// } -// -// }); -// missions.addChildEventListener(new ChildEventListener() { -// @Override -// public void onChildAdded(DataSnapshot dataSnapshot, String s) { -// missionsList.add(dataSnapshot.getValue(Mission.class)); -// LootApplication app = (LootApplication)getActivity().getApplication(); -// app.missions = missionsList; -// } -// -// @Override -// public void onChildChanged(DataSnapshot dataSnapshot, String s) { -// -// } -// -// @Override -// public void onChildRemoved(DataSnapshot dataSnapshot) { -// -// } -// -// @Override -// public void onChildMoved(DataSnapshot dataSnapshot, String s) { -// -// } -// -// @Override -// public void onCancelled(DatabaseError databaseError) { -// -// } -// }); - - - -// StringRequest syncRequest = new StringRequest(Request.Method.GET, Endpoints.syncRequest+userID, -// new Response.Listener() { -// @Override -// public void onResponse(String response) { -//// user.setUserID(); -//// user.setUsername(); -//// user.setZealID(); -//// user.setName(); -//// user.setEmail(); -//// user.setAvatarID(); -//// user.setScore(); -//// user.setStage(); -//// user.setState(); -//// user.setDropCount(); -//// user.setDuelWon(); -//// user.setDuelLost(); -//// user.setContactNumber(); -//// user.setDropped(); -// } -// }, -// new Response.ErrorListener() { -// @Override -// public void onErrorResponse(VolleyError error) { -// -// } -// }); -// RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); -// requestQueue.add(syncRequest); + + StringRequest syncRequest = new StringRequest(Request.Method.GET, + Endpoints.syncRequest+userID, + new Response.Listener() { + @Override + public void onResponse(String response) { + JSONObject jsonObject; + try { + jsonObject = new JSONObject(response); + user.setUserID(jsonObject.getString("reference_token")); + user.setUsername(jsonObject.getString("username")); + user.setAdmissionNo(jsonObject.getString("admission_no")); + user.setName(jsonObject.getString("name")); + user.setEmail(jsonObject.getString("email")); + user.setAvatarID(Integer.valueOf(jsonObject.getString("avatar_id"))); + user.setScore(Integer.valueOf(jsonObject.getString("score"))); + user.setStage(Integer.valueOf(jsonObject.getString("stage"))); + Log.i("Stage1",jsonObject.getString("stage")); + Log.i("Stage2",String.valueOf(user.getStage())); + user.setState(jsonObject.getString("mission_state").equals("false")?0:1); + user.setDropCount(Integer.valueOf(jsonObject.getString("drop_count"))); + user.setDuelWon(Integer.valueOf(jsonObject.getString("duel_won"))); + user.setDuelLost(Integer.valueOf(jsonObject.getString("duel_lost"))); + user.setContactNumber(Long.valueOf(jsonObject.getString("contact_number"))); +// user.setDropped(); + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, + new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + + } + }){ + @Override + public Map getHeaders() throws AuthFailureError { + Map params = new HashMap<>(); + params.put("x-auth",Endpoints.apikey); + return params; + } + }; + RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); + requestQueue.add(syncRequest); } public void syncSharedPrefs(User user) { SharedPreferences sharedPreferences = getActivity().getSharedPreferences("LootPrefs", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); -// editor.putString("com.hackncs.userID", user.getUserID()); -// editor.putString("com.hackncs.username", user.getUsername()); -// editor.putString("com.hackncs.zealID", user.getZealID()); -// editor.putString("com.hackncs.name", user.getName()); -// editor.putString("com.hackncs.email", user.getEmail()); -// editor.putInt("com.hackncs.avatarID", user.getAvatarID()); -// editor.putInt("com.hackncs.score", user.getScore()); -// editor.putInt("com.hackncs.stage", user.getStage()); -// editor.putInt("com.hackncs.state", user.getState()); -// editor.putInt("com.hackncs.dropCount", user.getDropCount()); -// editor.putInt("com.hackncs.duelWon", user.getDuelWon()); -// editor.putInt("com.hackncs.duelLost", user.getDuelLost()); -// editor.putLong("com.hackncs.contactNumber", user.getContactNumber()); + editor.putString("com.hackncs.userID", user.getUserID()); + editor.putString("com.hackncs.username", user.getUsername()); + editor.putString("com.hackncs.admissionNo", user.getAdmissionNo()); + editor.putString("com.hackncs.name", user.getName()); + editor.putString("com.hackncs.email", user.getEmail()); + editor.putInt("com.hackncs.avatarID", user.getAvatarID()); + editor.putInt("com.hackncs.score", user.getScore()); + editor.putInt("com.hackncs.stage", user.getStage()); + editor.putInt("com.hackncs.state", user.getState()); + editor.putInt("com.hackncs.dropCount", user.getDropCount()); + editor.putInt("com.hackncs.duelWon", user.getDuelWon()); + editor.putInt("com.hackncs.duelLost", user.getDuelLost()); + editor.putLong("com.hackncs.contactNumber", user.getContactNumber()); // editor.putStringSet("com.hackncs.dropped", new HashSet<>(user.getDropped())); editor.apply(); - -// LootApplication app = (LootApplication)getActivity().getApplication(); -// app.user = user; -// app.missions = missionsList; Intent i = new Intent(getContext(), DashboardLoot.class); i.putExtra("UID", fbuser.getUid()); startActivity(i); @@ -224,16 +206,16 @@ public boolean isOnline() { NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { - runOnUiThread(new Runnable() { + getActivity().runOnUiThread(new Runnable() { @Override public void run() { - Toast.makeText(getActivity(), "Connected!", Toast.LENGTH_SHORT).show(); +// Toast.makeText(getActivity(), "Connected!", Toast.LENGTH_SHORT).show(); } }); return true; } else { - runOnUiThread(new Runnable() { + getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), "Disconnected!", Toast.LENGTH_SHORT).show(); @@ -247,7 +229,10 @@ private void backgroundTasks() { isConnected = isOnline(); logged_in = mAuth.getCurrentUser() != null; fbuser = mAuth.getCurrentUser(); + if(logged_in) { + isVerified=fbuser.isEmailVerified(); + if(isVerified) syncUser(fbuser.getUid()); } } @@ -279,7 +264,7 @@ public void onClick(View v) { FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Login fragment = new Login(); - fragmentTransaction.replace(R.id.login_frame, fragment); + fragmentTransaction.replace(R.id.login_frame, fragment,"login"); fragmentTransaction.commit(); } }); @@ -289,7 +274,7 @@ public void onClick(View v) { FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Register fragment = new Register(); - fragmentTransaction.replace(R.id.login_frame, fragment); + fragmentTransaction.replace(R.id.login_frame, fragment,"register"); fragmentTransaction.commit(); } }); diff --git a/app/src/main/java/com/hackncs/zealicon/loot/Stats.java b/app/src/main/java/com/hackncs/zealicon/loot/Stats.java new file mode 100644 index 0000000..b3fbc28 --- /dev/null +++ b/app/src/main/java/com/hackncs/zealicon/loot/Stats.java @@ -0,0 +1,20 @@ +//package com.example.dell.loot; +// +//import android.os.Bundle; +//import android.support.v4.app.Fragment; +//import android.view.LayoutInflater; +//import android.view.View; +//import android.view.ViewGroup; +// +//public class Stats extends Fragment { +// +// public Stats() { +// // Required empty public constructor +// } +// +// @Override +// public View onCreateView(LayoutInflater inflater, ViewGroup container, +// Bundle savedInstanceState) { +// return inflater.inflate(R.layout.fragment_stats, container, false); +// } +//} diff --git a/app/src/main/java/com/example/dell/loot/User.java b/app/src/main/java/com/hackncs/zealicon/loot/User.java similarity index 89% rename from app/src/main/java/com/example/dell/loot/User.java rename to app/src/main/java/com/hackncs/zealicon/loot/User.java index 39517a0..baf36ef 100644 --- a/app/src/main/java/com/example/dell/loot/User.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/User.java @@ -1,4 +1,4 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; import java.util.ArrayList; @@ -6,14 +6,14 @@ public class User { int avatarID, score, stage, state, dropCount, duelWon, duelLost; long contactNumber; - String userID, username, zealID, name, email; + String userID, username, admissionNo, name, email; ArrayList dropped; public User() { } public User(int avatarID, int score, int stage, int state, int dropCount, int duelWon, - int duelLost, long contactNumber, String userID, String username, String zealID, + int duelLost, long contactNumber, String userID, String username, String admissionNo, String name, String email, ArrayList dropped) { this.avatarID = avatarID; this.score = score; @@ -25,7 +25,7 @@ public User(int avatarID, int score, int stage, int state, int dropCount, int du this.contactNumber = contactNumber; this.userID = userID; this.username = username; - this.zealID = zealID; + this.admissionNo = admissionNo; this.name = name; this.email = email; this.dropped = dropped; @@ -111,12 +111,12 @@ public void setUsername(String username) { this.username = username; } - public String getZealID() { - return zealID; + public String getAdmissionNo() { + return admissionNo; } - public void setZealID(String zealID) { - this.zealID = zealID; + public void setAdmissionNo(String admissionNo) { + this.admissionNo = admissionNo; } public String getName() { @@ -142,4 +142,5 @@ public ArrayList getDropped() { public void setDropped(ArrayList dropped) { this.dropped = dropped; } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/dell/loot/WelcomeSlider.java b/app/src/main/java/com/hackncs/zealicon/loot/WelcomeSlider.java similarity index 93% rename from app/src/main/java/com/example/dell/loot/WelcomeSlider.java rename to app/src/main/java/com/hackncs/zealicon/loot/WelcomeSlider.java index 5b7e229..4ec483a 100644 --- a/app/src/main/java/com/example/dell/loot/WelcomeSlider.java +++ b/app/src/main/java/com/hackncs/zealicon/loot/WelcomeSlider.java @@ -1,12 +1,9 @@ -package com.example.dell.loot; +package com.hackncs.zealicon.loot; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.os.Build; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Html; import android.view.LayoutInflater; @@ -18,6 +15,12 @@ import android.widget.LinearLayout; import android.widget.TextView; +import com.google.firebase.auth.FirebaseAuth; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; + public class WelcomeSlider extends AppCompatActivity { private ViewPager viewPager; @@ -51,8 +54,7 @@ protected void onCreate(Bundle savedInstanceState) { layouts = new int[]{ R.layout.welcome_slide1, R.layout.welcome_slide2, - R.layout.welcome_slide3, - R.layout.welcome_slide4}; + R.layout.welcome_slide3}; // adding bottom dots addBottomDots(0); @@ -113,8 +115,8 @@ private int getItem(int i) { private void launchHomeScreen() { Intent i=new Intent(this,DashboardLoot.class); - LootApplication app=(LootApplication)getApplication(); - i.putExtra("UID",app.user.getUserID()); + String uid = FirebaseAuth.getInstance().getCurrentUser().getUid(); + i.putExtra("UID", uid); startActivity(i); finish(); } diff --git a/app/src/main/res/color/item_selector.xml b/app/src/main/res/color/item_selector.xml new file mode 100644 index 0000000..49fbedc --- /dev/null +++ b/app/src/main/res/color/item_selector.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable-hdpi/avatar_1.webp b/app/src/main/res/drawable-hdpi/avatar_1.webp new file mode 100644 index 0000000..1a6081c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/avatar_1.webp differ diff --git a/app/src/main/res/drawable-hdpi/avatar_2.webp b/app/src/main/res/drawable-hdpi/avatar_2.webp new file mode 100644 index 0000000..a7c3510 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/avatar_2.webp differ diff --git a/app/src/main/res/drawable-hdpi/avatar_3.webp b/app/src/main/res/drawable-hdpi/avatar_3.webp new file mode 100644 index 0000000..ba1d120 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/avatar_3.webp differ diff --git a/app/src/main/res/drawable-hdpi/avatar_4.webp b/app/src/main/res/drawable-hdpi/avatar_4.webp new file mode 100644 index 0000000..e6a1042 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/avatar_4.webp differ diff --git a/app/src/main/res/drawable-hdpi/avatar_5.webp b/app/src/main/res/drawable-hdpi/avatar_5.webp new file mode 100644 index 0000000..1aa9390 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/avatar_5.webp differ diff --git a/app/src/main/res/drawable-hdpi/avatar_6.webp b/app/src/main/res/drawable-hdpi/avatar_6.webp new file mode 100644 index 0000000..45c8759 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/avatar_6.webp differ diff --git a/app/src/main/res/drawable-hdpi/bg_1.webp b/app/src/main/res/drawable-hdpi/bg_1.webp new file mode 100644 index 0000000..31876e5 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/bg_1.webp differ diff --git a/app/src/main/res/drawable-hdpi/duel_2.webp b/app/src/main/res/drawable-hdpi/duel_2.webp new file mode 100644 index 0000000..28d1d4b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/duel_2.webp differ diff --git a/app/src/main/res/drawable-hdpi/gaitonde.webp b/app/src/main/res/drawable-hdpi/gaitonde.webp new file mode 100644 index 0000000..1dd5b24 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/gaitonde.webp differ diff --git a/app/src/main/res/drawable-hdpi/gaitonde_5.webp b/app/src/main/res/drawable-hdpi/gaitonde_5.webp new file mode 100644 index 0000000..a3f3af5 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/gaitonde_5.webp differ diff --git a/app/src/main/res/drawable-hdpi/leader.webp b/app/src/main/res/drawable-hdpi/leader.webp new file mode 100644 index 0000000..de39ee7 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/leader.webp differ diff --git a/app/src/main/res/drawable-hdpi/logo_2.webp b/app/src/main/res/drawable-hdpi/logo_2.webp new file mode 100644 index 0000000..416dae0 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/logo_2.webp differ diff --git a/app/src/main/res/drawable-hdpi/map_2.png b/app/src/main/res/drawable-hdpi/map_2.png new file mode 100644 index 0000000..924b8f1 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/map_2.png differ diff --git a/app/src/main/res/drawable-hdpi/noun_ellipsis_799828.webp b/app/src/main/res/drawable-hdpi/noun_ellipsis_799828.webp new file mode 100644 index 0000000..3ade9d9 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/noun_ellipsis_799828.webp differ diff --git a/app/src/main/res/drawable-hdpi/noun_pin_682494.webp b/app/src/main/res/drawable-hdpi/noun_pin_682494.webp new file mode 100644 index 0000000..6b55c3f Binary files /dev/null and b/app/src/main/res/drawable-hdpi/noun_pin_682494.webp differ diff --git a/app/src/main/res/drawable-hdpi/shape_1.webp b/app/src/main/res/drawable-hdpi/shape_1.webp new file mode 100644 index 0000000..c0b4cf5 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/shape_1.webp differ diff --git a/app/src/main/res/drawable-hdpi/symbol_1.webp b/app/src/main/res/drawable-hdpi/symbol_1.webp new file mode 100644 index 0000000..b59b790 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/symbol_1.webp differ diff --git a/app/src/main/res/drawable-hdpi/welcome_3.webp b/app/src/main/res/drawable-hdpi/welcome_3.webp new file mode 100644 index 0000000..d7bf29b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/welcome_3.webp differ diff --git a/app/src/main/res/drawable-ldpi/avatar_1.webp b/app/src/main/res/drawable-ldpi/avatar_1.webp new file mode 100644 index 0000000..8395cf5 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/avatar_1.webp differ diff --git a/app/src/main/res/drawable-ldpi/avatar_2.webp b/app/src/main/res/drawable-ldpi/avatar_2.webp new file mode 100644 index 0000000..0aff4a4 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/avatar_2.webp differ diff --git a/app/src/main/res/drawable-ldpi/avatar_3.webp b/app/src/main/res/drawable-ldpi/avatar_3.webp new file mode 100644 index 0000000..70a94c8 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/avatar_3.webp differ diff --git a/app/src/main/res/drawable-ldpi/avatar_4.webp b/app/src/main/res/drawable-ldpi/avatar_4.webp new file mode 100644 index 0000000..05553ab Binary files /dev/null and b/app/src/main/res/drawable-ldpi/avatar_4.webp differ diff --git a/app/src/main/res/drawable-ldpi/avatar_5.webp b/app/src/main/res/drawable-ldpi/avatar_5.webp new file mode 100644 index 0000000..de6ae10 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/avatar_5.webp differ diff --git a/app/src/main/res/drawable-ldpi/avatar_6.webp b/app/src/main/res/drawable-ldpi/avatar_6.webp new file mode 100644 index 0000000..4a28170 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/avatar_6.webp differ diff --git a/app/src/main/res/drawable-ldpi/bg_1.webp b/app/src/main/res/drawable-ldpi/bg_1.webp new file mode 100644 index 0000000..e0272c5 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/bg_1.webp differ diff --git a/app/src/main/res/drawable-ldpi/duel_2.webp b/app/src/main/res/drawable-ldpi/duel_2.webp new file mode 100644 index 0000000..20b39b5 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/duel_2.webp differ diff --git a/app/src/main/res/drawable-ldpi/gaitonde.webp b/app/src/main/res/drawable-ldpi/gaitonde.webp new file mode 100644 index 0000000..a4117c1 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/gaitonde.webp differ diff --git a/app/src/main/res/drawable-ldpi/gaitonde_5.webp b/app/src/main/res/drawable-ldpi/gaitonde_5.webp new file mode 100644 index 0000000..4d3ea92 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/gaitonde_5.webp differ diff --git a/app/src/main/res/drawable-ldpi/leader.webp b/app/src/main/res/drawable-ldpi/leader.webp new file mode 100644 index 0000000..637ecb7 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/leader.webp differ diff --git a/app/src/main/res/drawable-ldpi/logo_2.webp b/app/src/main/res/drawable-ldpi/logo_2.webp new file mode 100644 index 0000000..62e6c16 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/logo_2.webp differ diff --git a/app/src/main/res/drawable-ldpi/map_2.png b/app/src/main/res/drawable-ldpi/map_2.png new file mode 100644 index 0000000..ff60bcd Binary files /dev/null and b/app/src/main/res/drawable-ldpi/map_2.png differ diff --git a/app/src/main/res/drawable-ldpi/noun_ellipsis_799828.webp b/app/src/main/res/drawable-ldpi/noun_ellipsis_799828.webp new file mode 100644 index 0000000..ab402c2 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/noun_ellipsis_799828.webp differ diff --git a/app/src/main/res/drawable-ldpi/noun_pin_682494.webp b/app/src/main/res/drawable-ldpi/noun_pin_682494.webp new file mode 100644 index 0000000..c7e3a84 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/noun_pin_682494.webp differ diff --git a/app/src/main/res/drawable-ldpi/symbol_1.webp b/app/src/main/res/drawable-ldpi/symbol_1.webp new file mode 100644 index 0000000..d505fbb Binary files /dev/null and b/app/src/main/res/drawable-ldpi/symbol_1.webp differ diff --git a/app/src/main/res/drawable-mdpi/avatar_1.webp b/app/src/main/res/drawable-mdpi/avatar_1.webp new file mode 100644 index 0000000..72a125e Binary files /dev/null and b/app/src/main/res/drawable-mdpi/avatar_1.webp differ diff --git a/app/src/main/res/drawable-mdpi/avatar_2.webp b/app/src/main/res/drawable-mdpi/avatar_2.webp new file mode 100644 index 0000000..636f252 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/avatar_2.webp differ diff --git a/app/src/main/res/drawable-mdpi/avatar_3.webp b/app/src/main/res/drawable-mdpi/avatar_3.webp new file mode 100644 index 0000000..f6b742b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/avatar_3.webp differ diff --git a/app/src/main/res/drawable-mdpi/avatar_4.webp b/app/src/main/res/drawable-mdpi/avatar_4.webp new file mode 100644 index 0000000..cdcee30 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/avatar_4.webp differ diff --git a/app/src/main/res/drawable-mdpi/avatar_5.webp b/app/src/main/res/drawable-mdpi/avatar_5.webp new file mode 100644 index 0000000..a1e5e13 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/avatar_5.webp differ diff --git a/app/src/main/res/drawable-mdpi/avatar_6.webp b/app/src/main/res/drawable-mdpi/avatar_6.webp new file mode 100644 index 0000000..91df710 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/avatar_6.webp differ diff --git a/app/src/main/res/drawable-mdpi/bg_1.webp b/app/src/main/res/drawable-mdpi/bg_1.webp new file mode 100644 index 0000000..902e0a6 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/bg_1.webp differ diff --git a/app/src/main/res/drawable-mdpi/duel_2.webp b/app/src/main/res/drawable-mdpi/duel_2.webp new file mode 100644 index 0000000..e0c0cdd Binary files /dev/null and b/app/src/main/res/drawable-mdpi/duel_2.webp differ diff --git a/app/src/main/res/drawable-mdpi/gaitonde.webp b/app/src/main/res/drawable-mdpi/gaitonde.webp new file mode 100644 index 0000000..ef9160a Binary files /dev/null and b/app/src/main/res/drawable-mdpi/gaitonde.webp differ diff --git a/app/src/main/res/drawable-mdpi/gaitonde_5.webp b/app/src/main/res/drawable-mdpi/gaitonde_5.webp new file mode 100644 index 0000000..f79caab Binary files /dev/null and b/app/src/main/res/drawable-mdpi/gaitonde_5.webp differ diff --git a/app/src/main/res/drawable-mdpi/leader.webp b/app/src/main/res/drawable-mdpi/leader.webp new file mode 100644 index 0000000..892ff51 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/leader.webp differ diff --git a/app/src/main/res/drawable-mdpi/logo_2.webp b/app/src/main/res/drawable-mdpi/logo_2.webp new file mode 100644 index 0000000..8f12179 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/logo_2.webp differ diff --git a/app/src/main/res/drawable-mdpi/map_2.png b/app/src/main/res/drawable-mdpi/map_2.png new file mode 100644 index 0000000..20ff3cc Binary files /dev/null and b/app/src/main/res/drawable-mdpi/map_2.png differ diff --git a/app/src/main/res/drawable-mdpi/noun_ellipsis_799828.webp b/app/src/main/res/drawable-mdpi/noun_ellipsis_799828.webp new file mode 100644 index 0000000..ccb4be9 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/noun_ellipsis_799828.webp differ diff --git a/app/src/main/res/drawable-mdpi/noun_pin_682494.webp b/app/src/main/res/drawable-mdpi/noun_pin_682494.webp new file mode 100644 index 0000000..a9b5af7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/noun_pin_682494.webp differ diff --git a/app/src/main/res/drawable-mdpi/shape_1.webp b/app/src/main/res/drawable-mdpi/shape_1.webp new file mode 100644 index 0000000..06bd8e9 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/shape_1.webp differ diff --git a/app/src/main/res/drawable-mdpi/symbol_1.webp b/app/src/main/res/drawable-mdpi/symbol_1.webp new file mode 100644 index 0000000..01d5264 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/symbol_1.webp differ diff --git a/app/src/main/res/drawable-mdpi/welcome_3.webp b/app/src/main/res/drawable-mdpi/welcome_3.webp new file mode 100644 index 0000000..d1e4cdb Binary files /dev/null and b/app/src/main/res/drawable-mdpi/welcome_3.webp differ diff --git a/app/src/main/res/drawable-v21/ic_menu_camera.xml b/app/src/main/res/drawable-v21/ic_menu_camera.xml deleted file mode 100644 index 0d9ea10..0000000 --- a/app/src/main/res/drawable-v21/ic_menu_camera.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable-v21/ic_menu_gallery.xml b/app/src/main/res/drawable-v21/ic_menu_gallery.xml deleted file mode 100644 index f6872c4..0000000 --- a/app/src/main/res/drawable-v21/ic_menu_gallery.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable-v21/ic_menu_manage.xml b/app/src/main/res/drawable-v21/ic_menu_manage.xml deleted file mode 100644 index c1be60b..0000000 --- a/app/src/main/res/drawable-v21/ic_menu_manage.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - \ No newline at end of file diff --git a/app/src/main/res/drawable-v21/ic_menu_send.xml b/app/src/main/res/drawable-v21/ic_menu_send.xml deleted file mode 100644 index 00c668c..0000000 --- a/app/src/main/res/drawable-v21/ic_menu_send.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable-v21/ic_menu_share.xml b/app/src/main/res/drawable-v21/ic_menu_share.xml deleted file mode 100644 index a28fb9e..0000000 --- a/app/src/main/res/drawable-v21/ic_menu_share.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable-v21/ic_menu_slideshow.xml b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml deleted file mode 100644 index 209aa64..0000000 --- a/app/src/main/res/drawable-v21/ic_menu_slideshow.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index c7bd21d..0000000 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - diff --git a/app/src/main/res/drawable-xhdpi/avatar_1.webp b/app/src/main/res/drawable-xhdpi/avatar_1.webp new file mode 100644 index 0000000..dd7b417 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/avatar_1.webp differ diff --git a/app/src/main/res/drawable-xhdpi/avatar_2.webp b/app/src/main/res/drawable-xhdpi/avatar_2.webp new file mode 100644 index 0000000..e02ca60 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/avatar_2.webp differ diff --git a/app/src/main/res/drawable-xhdpi/avatar_3.webp b/app/src/main/res/drawable-xhdpi/avatar_3.webp new file mode 100644 index 0000000..2e17f8f Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/avatar_3.webp differ diff --git a/app/src/main/res/drawable-xhdpi/avatar_4.webp b/app/src/main/res/drawable-xhdpi/avatar_4.webp new file mode 100644 index 0000000..f051634 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/avatar_4.webp differ diff --git a/app/src/main/res/drawable-xhdpi/avatar_5.webp b/app/src/main/res/drawable-xhdpi/avatar_5.webp new file mode 100644 index 0000000..ddfa5b3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/avatar_5.webp differ diff --git a/app/src/main/res/drawable-xhdpi/avatar_6.webp b/app/src/main/res/drawable-xhdpi/avatar_6.webp new file mode 100644 index 0000000..37dad29 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/avatar_6.webp differ diff --git a/app/src/main/res/drawable-xhdpi/bg_1.webp b/app/src/main/res/drawable-xhdpi/bg_1.webp new file mode 100644 index 0000000..12f25d9 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/bg_1.webp differ diff --git a/app/src/main/res/drawable-xhdpi/duel_2.webp b/app/src/main/res/drawable-xhdpi/duel_2.webp new file mode 100644 index 0000000..2a00090 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/duel_2.webp differ diff --git a/app/src/main/res/drawable-xhdpi/gaitonde.webp b/app/src/main/res/drawable-xhdpi/gaitonde.webp new file mode 100644 index 0000000..13dfcdd Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/gaitonde.webp differ diff --git a/app/src/main/res/drawable-xhdpi/gaitonde_5.webp b/app/src/main/res/drawable-xhdpi/gaitonde_5.webp new file mode 100644 index 0000000..79fd66c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/gaitonde_5.webp differ diff --git a/app/src/main/res/drawable-xhdpi/leader.webp b/app/src/main/res/drawable-xhdpi/leader.webp new file mode 100644 index 0000000..2a4894c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/leader.webp differ diff --git a/app/src/main/res/drawable-xhdpi/logo_2.webp b/app/src/main/res/drawable-xhdpi/logo_2.webp new file mode 100644 index 0000000..16d98c9 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/logo_2.webp differ diff --git a/app/src/main/res/drawable-xhdpi/map_2.png b/app/src/main/res/drawable-xhdpi/map_2.png new file mode 100644 index 0000000..e298387 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/map_2.png differ diff --git a/app/src/main/res/drawable-xhdpi/noun_ellipsis_799828.webp b/app/src/main/res/drawable-xhdpi/noun_ellipsis_799828.webp new file mode 100644 index 0000000..23053b9 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/noun_ellipsis_799828.webp differ diff --git a/app/src/main/res/drawable-xhdpi/noun_pin_682494.webp b/app/src/main/res/drawable-xhdpi/noun_pin_682494.webp new file mode 100644 index 0000000..18f13c7 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/noun_pin_682494.webp differ diff --git a/app/src/main/res/drawable-xhdpi/shape_1.webp b/app/src/main/res/drawable-xhdpi/shape_1.webp new file mode 100644 index 0000000..5db5aec Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/shape_1.webp differ diff --git a/app/src/main/res/drawable-xhdpi/symbol_1.webp b/app/src/main/res/drawable-xhdpi/symbol_1.webp new file mode 100644 index 0000000..29a014d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/symbol_1.webp differ diff --git a/app/src/main/res/drawable-xhdpi/welcome_3.webp b/app/src/main/res/drawable-xhdpi/welcome_3.webp new file mode 100644 index 0000000..766ff22 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/welcome_3.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/avatar_1.webp b/app/src/main/res/drawable-xxhdpi/avatar_1.webp new file mode 100644 index 0000000..cedb642 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/avatar_1.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/avatar_2.webp b/app/src/main/res/drawable-xxhdpi/avatar_2.webp new file mode 100644 index 0000000..51e4178 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/avatar_2.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/avatar_3.webp b/app/src/main/res/drawable-xxhdpi/avatar_3.webp new file mode 100644 index 0000000..31f4179 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/avatar_3.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/avatar_4.webp b/app/src/main/res/drawable-xxhdpi/avatar_4.webp new file mode 100644 index 0000000..6762313 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/avatar_4.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/avatar_5.webp b/app/src/main/res/drawable-xxhdpi/avatar_5.webp new file mode 100644 index 0000000..12c3fcf Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/avatar_5.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/avatar_6.webp b/app/src/main/res/drawable-xxhdpi/avatar_6.webp new file mode 100644 index 0000000..703eac1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/avatar_6.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/bg_1.webp b/app/src/main/res/drawable-xxhdpi/bg_1.webp new file mode 100644 index 0000000..a79e7d9 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/bg_1.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/duel_2.webp b/app/src/main/res/drawable-xxhdpi/duel_2.webp new file mode 100644 index 0000000..f805487 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/duel_2.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/gaitonde.webp b/app/src/main/res/drawable-xxhdpi/gaitonde.webp new file mode 100644 index 0000000..9c06832 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/gaitonde.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/gaitonde_5.webp b/app/src/main/res/drawable-xxhdpi/gaitonde_5.webp new file mode 100644 index 0000000..c9907d1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/gaitonde_5.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/leader.webp b/app/src/main/res/drawable-xxhdpi/leader.webp new file mode 100644 index 0000000..c852951 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/leader.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/logo_2.webp b/app/src/main/res/drawable-xxhdpi/logo_2.webp new file mode 100644 index 0000000..f07b1d8 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/logo_2.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/map_2.png b/app/src/main/res/drawable-xxhdpi/map_2.png new file mode 100644 index 0000000..c075663 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/map_2.png differ diff --git a/app/src/main/res/drawable-xxhdpi/noun_ellipsis_799828.webp b/app/src/main/res/drawable-xxhdpi/noun_ellipsis_799828.webp new file mode 100644 index 0000000..f43f22f Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/noun_ellipsis_799828.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/noun_pin_682494.webp b/app/src/main/res/drawable-xxhdpi/noun_pin_682494.webp new file mode 100644 index 0000000..7e6c709 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/noun_pin_682494.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/shape_1.webp b/app/src/main/res/drawable-xxhdpi/shape_1.webp new file mode 100644 index 0000000..4e5e9a0 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/shape_1.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/symbol_1.webp b/app/src/main/res/drawable-xxhdpi/symbol_1.webp new file mode 100644 index 0000000..9139518 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/symbol_1.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/welcome_3.webp b/app/src/main/res/drawable-xxhdpi/welcome_3.webp new file mode 100644 index 0000000..8924cb7 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/welcome_3.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/avatar_1.webp b/app/src/main/res/drawable-xxxhdpi/avatar_1.webp new file mode 100644 index 0000000..444c51f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/avatar_1.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/avatar_2.webp b/app/src/main/res/drawable-xxxhdpi/avatar_2.webp new file mode 100644 index 0000000..a9685b2 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/avatar_2.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/avatar_3.webp b/app/src/main/res/drawable-xxxhdpi/avatar_3.webp new file mode 100644 index 0000000..cc8d52e Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/avatar_3.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/avatar_4.webp b/app/src/main/res/drawable-xxxhdpi/avatar_4.webp new file mode 100644 index 0000000..00867a0 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/avatar_4.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/avatar_5.webp b/app/src/main/res/drawable-xxxhdpi/avatar_5.webp new file mode 100644 index 0000000..83dcae8 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/avatar_5.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/avatar_6.webp b/app/src/main/res/drawable-xxxhdpi/avatar_6.webp new file mode 100644 index 0000000..42dc92e Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/avatar_6.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/bg_1.webp b/app/src/main/res/drawable-xxxhdpi/bg_1.webp new file mode 100644 index 0000000..b2e7d93 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/bg_1.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/duel_2.webp b/app/src/main/res/drawable-xxxhdpi/duel_2.webp new file mode 100644 index 0000000..7593b9b Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/duel_2.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/gaitonde.webp b/app/src/main/res/drawable-xxxhdpi/gaitonde.webp new file mode 100644 index 0000000..bf00f08 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/gaitonde.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/gaitonde_5.webp b/app/src/main/res/drawable-xxxhdpi/gaitonde_5.webp new file mode 100644 index 0000000..e148dfd Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/gaitonde_5.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/leader.webp b/app/src/main/res/drawable-xxxhdpi/leader.webp new file mode 100644 index 0000000..f887f0c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/leader.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/logo_2.webp b/app/src/main/res/drawable-xxxhdpi/logo_2.webp new file mode 100644 index 0000000..99dc353 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/logo_2.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/map_2.png b/app/src/main/res/drawable-xxxhdpi/map_2.png new file mode 100644 index 0000000..5ec395d Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/map_2.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/noun_ellipsis_799828.webp b/app/src/main/res/drawable-xxxhdpi/noun_ellipsis_799828.webp new file mode 100644 index 0000000..a0a57fe Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/noun_ellipsis_799828.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/noun_pin_682494.webp b/app/src/main/res/drawable-xxxhdpi/noun_pin_682494.webp new file mode 100644 index 0000000..4ebf48b Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/noun_pin_682494.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/shape_1.webp b/app/src/main/res/drawable-xxxhdpi/shape_1.webp new file mode 100644 index 0000000..a511aee Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/shape_1.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/symbol_1.webp b/app/src/main/res/drawable-xxxhdpi/symbol_1.webp new file mode 100644 index 0000000..3647c22 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/symbol_1.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/welcome_3.webp b/app/src/main/res/drawable-xxxhdpi/welcome_3.webp new file mode 100644 index 0000000..d0cb5ea Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/welcome_3.webp differ diff --git a/app/src/main/res/drawable/action_bar.xml b/app/src/main/res/drawable/action_bar.xml index 3f1467f..4c21f36 100644 --- a/app/src/main/res/drawable/action_bar.xml +++ b/app/src/main/res/drawable/action_bar.xml @@ -1,10 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/app/src/main/res/drawable/avatar.jpg b/app/src/main/res/drawable/avatar.jpg deleted file mode 100644 index cff4393..0000000 Binary files a/app/src/main/res/drawable/avatar.jpg and /dev/null differ diff --git a/app/src/main/res/drawable/avatar1.png b/app/src/main/res/drawable/avatar1.png deleted file mode 100644 index 4be38f9..0000000 Binary files a/app/src/main/res/drawable/avatar1.png and /dev/null differ diff --git a/app/src/main/res/drawable/background.jpg b/app/src/main/res/drawable/background.jpg deleted file mode 100644 index 0328b26..0000000 Binary files a/app/src/main/res/drawable/background.jpg and /dev/null differ diff --git a/app/src/main/res/drawable/name_score.xml b/app/src/main/res/drawable/card_background_red.xml similarity index 67% rename from app/src/main/res/drawable/name_score.xml rename to app/src/main/res/drawable/card_background_red.xml index 15a12c6..3dea70b 100644 --- a/app/src/main/res/drawable/name_score.xml +++ b/app/src/main/res/drawable/card_background_red.xml @@ -3,8 +3,8 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/drawable/card_background_white.xml b/app/src/main/res/drawable/card_background_white.xml new file mode 100644 index 0000000..bb492ef --- /dev/null +++ b/app/src/main/res/drawable/card_background_white.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/card_background_yellow.xml b/app/src/main/res/drawable/card_background_yellow.xml new file mode 100644 index 0000000..94ac903 --- /dev/null +++ b/app/src/main/res/drawable/card_background_yellow.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/edittext_layout_black.xml b/app/src/main/res/drawable/edittext_layout_black.xml new file mode 100644 index 0000000..9752c6c --- /dev/null +++ b/app/src/main/res/drawable/edittext_layout_black.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/edittext_layout_resource.xml b/app/src/main/res/drawable/edittext_layout_resource.xml new file mode 100644 index 0000000..a26693d --- /dev/null +++ b/app/src/main/res/drawable/edittext_layout_resource.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/edittext_layout_white.xml b/app/src/main/res/drawable/edittext_layout_white.xml new file mode 100644 index 0000000..a26693d --- /dev/null +++ b/app/src/main/res/drawable/edittext_layout_white.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/edittext_underline_black.xml b/app/src/main/res/drawable/edittext_underline_black.xml new file mode 100644 index 0000000..cde7128 --- /dev/null +++ b/app/src/main/res/drawable/edittext_underline_black.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/edittext_underline_color.xml b/app/src/main/res/drawable/edittext_underline_color.xml new file mode 100644 index 0000000..f894b78 --- /dev/null +++ b/app/src/main/res/drawable/edittext_underline_color.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gangsta.png b/app/src/main/res/drawable/gangsta.png deleted file mode 100644 index 53ede25..0000000 Binary files a/app/src/main/res/drawable/gangsta.png and /dev/null differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index d5fccc5..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/ic_phone_black_24dp.xml b/app/src/main/res/drawable/ic_phone_black_24dp.xml new file mode 100644 index 0000000..7e6f97c --- /dev/null +++ b/app/src/main/res/drawable/ic_phone_black_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/list_shadow.xml b/app/src/main/res/drawable/list_shadow.xml deleted file mode 100644 index 4d37b3f..0000000 --- a/app/src/main/res/drawable/list_shadow.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/screen_1.jpg b/app/src/main/res/drawable/screen_1.jpg new file mode 100644 index 0000000..d98ff67 Binary files /dev/null and b/app/src/main/res/drawable/screen_1.jpg differ diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml deleted file mode 100644 index 6d81870..0000000 --- a/app/src/main/res/drawable/side_nav_bar.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vertical_progress.xml b/app/src/main/res/drawable/vertical_progress.xml index 962603a..d956ee9 100644 --- a/app/src/main/res/drawable/vertical_progress.xml +++ b/app/src/main/res/drawable/vertical_progress.xml @@ -3,8 +3,9 @@ - - + + + @@ -12,14 +13,11 @@ + > - - + + + diff --git a/app/src/main/res/drawable/white15_rectangle.xml b/app/src/main/res/drawable/white15_rectangle.xml new file mode 100644 index 0000000..e37a811 --- /dev/null +++ b/app/src/main/res/drawable/white15_rectangle.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/white_background70.xml b/app/src/main/res/drawable/white_background70.xml new file mode 100644 index 0000000..d6056a6 --- /dev/null +++ b/app/src/main/res/drawable/white_background70.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/white_rectangle.xml b/app/src/main/res/drawable/white_rectangle.xml new file mode 100644 index 0000000..2860130 --- /dev/null +++ b/app/src/main/res/drawable/white_rectangle.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/avenir_next_lt_pro_bold.otf b/app/src/main/res/font/avenir_next_lt_pro_bold.otf new file mode 100644 index 0000000..9799f30 Binary files /dev/null and b/app/src/main/res/font/avenir_next_lt_pro_bold.otf differ diff --git a/app/src/main/res/font/avenir_next_lt_pro_demi.otf b/app/src/main/res/font/avenir_next_lt_pro_demi.otf new file mode 100644 index 0000000..0edab0f Binary files /dev/null and b/app/src/main/res/font/avenir_next_lt_pro_demi.otf differ diff --git a/app/src/main/res/font/bahnschrift_reg.ttf b/app/src/main/res/font/bahnschrift_reg.ttf new file mode 100644 index 0000000..ca925fa Binary files /dev/null and b/app/src/main/res/font/bahnschrift_reg.ttf differ diff --git a/app/src/main/res/layout/active_mission_layout.xml b/app/src/main/res/layout/active_mission_layout.xml deleted file mode 100644 index 786aa2d..0000000 --- a/app/src/main/res/layout/active_mission_layout.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_dashboard_loot.xml b/app/src/main/res/layout/activity_dashboard_loot.xml index d90aabd..4e17675 100644 --- a/app/src/main/res/layout/activity_dashboard_loot.xml +++ b/app/src/main/res/layout/activity_dashboard_loot.xml @@ -1,91 +1,124 @@ - + android:background="@color/black" + tools:context="com.hackncs.zealicon.loot.DashboardLoot"> - - - - + android:layout_height="match_parent" + android:scaleType="center" + android:src="@drawable/bg_1"/> - - - - - - - - - - - - - - - + android:layout_height="67dp" + app:popupTheme="@style/ThemeOverlay.MyTheme" + android:background="@drawable/action_bar" + android:elevation="4dp"> + + + + + + + + + + + + + + + + + + + + + - + android:background="@color/colorPrimary" + android:theme="@style/BottomNavTheme" + app:itemIconSize="23dp" + app:itemIconTint="@color/item_selector" + app:itemTextColor="@color/item_selector" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:menu="@menu/bottom_navigation_item" /> - + diff --git a/app/src/main/res/layout/activity_fullscreen.xml b/app/src/main/res/layout/activity_fullscreen.xml deleted file mode 100644 index 3651558..0000000 --- a/app/src/main/res/layout/activity_fullscreen.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 876dc8d..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main22.xml b/app/src/main/res/layout/activity_main22.xml index 7225dc9..b6cf092 100644 --- a/app/src/main/res/layout/activity_main22.xml +++ b/app/src/main/res/layout/activity_main22.xml @@ -1,9 +1,9 @@ - + tools:context="com.hackncs.zealicon.loot.Duel_Alert_Transparent_Activity"> - + diff --git a/app/src/main/res/layout/activity_main3.xml b/app/src/main/res/layout/activity_main3.xml index 422d03f..5c1494d 100644 --- a/app/src/main/res/layout/activity_main3.xml +++ b/app/src/main/res/layout/activity_main3.xml @@ -1,10 +1,10 @@ - + tools:context="com.hackncs.zealicon.loot.Main3Activity"> - + diff --git a/app/src/main/res/layout/activity_mini_game.xml b/app/src/main/res/layout/activity_mini_game.xml new file mode 100644 index 0000000..c30380a --- /dev/null +++ b/app/src/main/res/layout/activity_mini_game.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_welcome_slider.xml b/app/src/main/res/layout/activity_welcome_slider.xml index c6d0dee..f3c1373 100644 --- a/app/src/main/res/layout/activity_welcome_slider.xml +++ b/app/src/main/res/layout/activity_welcome_slider.xml @@ -4,10 +4,10 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="com.example.dell.loot.WelcomeSlider"> + tools:context="com.hackncs.zealicon.loot.WelcomeSlider"> - @@ -26,7 +26,7 @@ android:layout_height="1dp" android:alpha=".5" android:layout_above="@id/layoutDots" - android:background="@android:color/white" /> + android:background="@color/white" />