Commit f084e7d9 authored by PiyumaliHulangamwa's avatar PiyumaliHulangamwa

Add Rewarding system code

parent a6ffb88c
# Default ignored files
/shelf/
/workspace.xml
The Trek
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -142,6 +142,13 @@
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".PredictReward"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".HomeActivity"
android:exported="false">
......@@ -190,6 +197,13 @@
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".screens.locationsHandler.MapVedioActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivityRecognition"
android:exported="false">
......@@ -202,11 +216,11 @@
android:value="required" />
<meta-data
android:name="com.google.android.ar.API_KEY"
android:value="AIzaSyAynx5iCqfkqmUyUp3b2FNzf3OCm1dOrbU"
android:value="AIzaSyAN5kiFNbLfInKmkge47ycTB01mcMG48IY"
/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyAynx5iCqfkqmUyUp3b2FNzf3OCm1dOrbU" />
android:value="AIzaSyAN5kiFNbLfInKmkge47ycTB01mcMG48IY" />
</application>
</manifest>
\ No newline at end of file
package com.example.thetrek;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class PredictReward extends AppCompatActivity {
EditText Latitude, Longitude, Elevation;
Button predict;
TextView Reward;
String url = "https://trek-7f4725930ac3.herokuapp.com/predict";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.predict_reward);
Latitude = findViewById(R.id.latitude);
Longitude = findViewById(R.id.longitude);
Elevation = findViewById(R.id.elevation);
predict = findViewById(R.id.predict);
Reward = findViewById(R.id.reward);
predict.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// hit the API -> Volley
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
String data = jsonObject.getString("placement");
switch (data) {
case "0":
Reward.setText("\uD83C\uDF1F \"Reward level 0 recieved!\" \uD83C\uDF1F");
break;
case "1":
Reward.setText("\uD83C\uDF1F \"Reward level 1 recieved!\" \uD83C\uDF1F");
break;
case "2":
Reward.setText("\uD83C\uDF1F \"Reward level 2 recieved!\" \uD83C\uDF1F");
break;
case "3":
Reward.setText("\uD83C\uDF1F \"Reward level 3 recieved!\" \uD83C\uDF1F");
break;
case "4":
Reward.setText("\uD83C\uDF1F \"Reward level 4 recieved!\" \uD83C\uDF1F");
break;
case "5":
Reward.setText("\uD83C\uDF1F \"Reward level 5 recieved!\" \uD83C\uDF1F");
break;
default:
Reward.setText("\uD83C\uDF1F \"No any reward recieved!\" \uD83C\uDF1F");
break;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(PredictReward.this, error.getMessage(), Toast.LENGTH_SHORT).show();
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String,String>();
params.put("Latitude",Latitude.getText().toString());
params.put("Longitude",Longitude.getText().toString());
params.put("Elevation",Elevation.getText().toString());
return params;
}
};
RequestQueue queue = Volley.newRequestQueue(PredictReward.this);
queue.add(stringRequest);
}
});
}
}
......@@ -9,6 +9,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.thetrek.PredictReward;
import com.example.thetrek.R;
import com.example.thetrek.db.LocationDAO;
......@@ -60,8 +61,26 @@ public class AddLocations extends AppCompatActivity {
v.getContext().startActivity(intent);
}
});
Button userGuideButton = (Button) findViewById(R.id.btn_MapVedioActivity_userGuide);
userGuideButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), MapVedioActivity.class);
v.getContext().startActivity(intent);
}
});
Button rewardPredictor = (Button) findViewById(R.id.btn_predictor);
rewardPredictor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), PredictReward.class);
v.getContext().startActivity(intent);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
......
package com.example.thetrek.screens.locationsHandler;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import com.example.thetrek.R;
public class MapVedioActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapvedio);
WebView webView = findViewById(R.id.webView);
String video = "<iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/vkrg4rqKfVU?si=YmgwAsVkGZ2_HG9w\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>";
webView.loadData(video, "text/html","utf-8");
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
WebView webView2 = findViewById(R.id.webView2);
String video2 = "<iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/XZJcS9wU9Ec?si=XfSWIvA1UhFzKY6X\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>";
webView2.loadData(video2, "text/html", "utf-8");
webView2.getSettings().setJavaScriptEnabled(true);
webView2.setWebChromeClient(new WebChromeClient());
}
}
\ No newline at end of file
......@@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".screens.locationsHandler.AddLocations">
tools:context=".screens.locationsHandler.AddLocations"
android:background="@drawable/background">
<LinearLayout
android:layout_width="375dp"
......@@ -63,6 +64,22 @@
android:id="@+id/btn_addLocationActivity_addLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Location" />
android:text="Add Location"
android:backgroundTint="#5D71C9"/>
<Button
android:id="@+id/btn_MapVedioActivity_userGuide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Guide"
android:backgroundTint="#5D71C9"/>
<Button
android:id="@+id/btn_predictor"
android:layout_width="match_parent"
android:layout_height="65dp"
android:backgroundTint="#5D71C9"
android:text="Rewards Predictor" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".screens.getPhysical.GetPhysicalActivity">
tools:context=".screens.getPhysical.GetPhysicalActivity"
android:background="@drawable/background">
<TextView
android:id="@+id/textView7"
......
......@@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".screens.locationsHandler.LocationsCrud">
tools:context=".screens.locationsHandler.LocationsCrud"
android:background="@drawable/background">
<LinearLayout
android:layout_width="380dp"
......@@ -43,6 +44,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Locations"
app:icon="@drawable/ic_baseline_playlist_add_24" />
app:icon="@drawable/ic_baseline_playlist_add_24"
android:backgroundTint="#5D71C9"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".screens.locationsHandler.MapVedioActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Embark on a Geospatial Odyssey 🌐🔍 Explore the Universe of Latitude, Longitude, and Elevation!"
android:textSize="20dp"
android:textAlignment="center"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:textColor="@color/cardview_dark_background"></TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Check Latitude longitude on Google map"
android:textSize="18dp"
android:textAlignment="center"
android:layout_marginTop="120dp"
android:textStyle="bold"
android:textColor="@color/cardview_dark_background"></TextView>
<WebView
android:layout_width="match_parent"
android:layout_height="250sp"
android:id="@+id/webView"
android:layout_marginTop="160dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Check elevation on Google map"
android:textSize="18dp"
android:textAlignment="center"
android:layout_marginTop="430dp"
android:textStyle="bold"
android:textColor="@color/cardview_dark_background"></TextView>
<WebView
android:id="@+id/webView2"
android:layout_width="match_parent"
android:layout_height="250sp"
android:layout_marginTop="470dp"/>
</RelativeLayout>
\ No newline at end of file
......@@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".geospatial.RewardingScreenActivity">
tools:context=".geospatial.RewardingScreenActivity"
android:background="@drawable/background">
<LinearLayout
android:layout_width="371dp"
......@@ -45,6 +46,7 @@
android:id="@+id/btn_claim_reward"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Claim Reward" />
android:text="Claim Reward"
android:backgroundTint="#5D71C9"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".screens.rewards.RewardsActivity">
tools:context=".screens.rewards.RewardsActivity"
android:background="@drawable/background">
<LinearLayout
android:layout_width="367dp"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PredictReward"
android:orientation="vertical"
android:background="@drawable/background">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Rewards Predictor"
android:textSize="24dp"
android:textAlignment="center"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:textColor="@color/cardview_dark_background"></TextView>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Latitude"
android:id="@+id/latitude"
android:textStyle="bold"
android:layout_marginTop="10dp"
></EditText>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Longitude"
android:id="@+id/longitude"
android:textStyle="bold"
android:layout_marginTop="10dp"
></EditText>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Elevation (0 – (177.3 to 179.9), 1 – (180 to 189.9), 2 - (190 to 200), 3 - (201 to 229.9), 4 - (230 to 290), 5 - (291 to 460.6)
)"
android:id="@+id/elevation"
android:textStyle="bold"
android:layout_marginTop="10dp"
></EditText>
<Button
android:layout_width="match_parent"
android:layout_height="65dp"
android:text="Click for Prediction"
android:layout_marginTop="20dp"
android:textStyle="bold"
android:id="@+id/predict"
android:backgroundTint="#5D71C9"></Button>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="20dp"
android:textAlignment="center"
android:layout_marginTop="25dp"
android:textStyle="bold"
android:id="@+id/reward"
android:textColor="@color/cardview_dark_background"></TextView>
</LinearLayout>
......@@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="@drawable/background">
<LinearLayout
android:layout_width="376dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment