Initial commit

parent 1b37443b
......@@ -84,4 +84,6 @@ dependencies {
implementation 'com.google.android.gms:play-services-safetynet:17.0.1'
implementation 'com.google.firebase:firebase-dynamic-links'
implementation 'com.google.firebase:firebase-analytics'
implementation 'org.tensorflow:tensorflow-android:1.2.0-preview'
}
\ No newline at end of file
......@@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.jachdev.consumerprotection">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
......@@ -26,7 +25,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.ConsumerProtection"
android:usesCleartextTraffic="true">
<activity android:name=".ui.calories.ExercisesSuggeserActivity"></activity>
<activity android:name=".ui.calories.CaloriesActivity" />
<activity android:name=".ui.classifier.ClassifierActivity" />
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
......@@ -41,8 +42,7 @@
<activity
android:name=".ui.map.MapsActivity"
android:label="@string/title_activity_maps"></activity>
<activity android:name=".ui.prediction.PredictionActivity" />
android:label="@string/title_activity_maps" />
<activity android:name=".ui.vendor.VendorActivity" />
<activity
android:name=".ui.MainActivity"
......@@ -61,15 +61,17 @@
<intent-filter
android:autoVerify="true"
tools:targetApi="23">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="consumerprotection.page.link"
android:scheme="http"/>
android:scheme="http" />
<data
android:host="consumerprotection.page.link"
android:scheme="https"/>
android:scheme="https" />
</intent-filter>
</activity>
<activity
......
notstudynotes
studynotes
phone
selfie
\ No newline at end of file
......@@ -5,7 +5,7 @@ import android.app.Application;
import com.jachdev.consumerprotection.network.AppService;
/**
* Created by Asanka on 9/20/2021.
* Created by Tharushaa on 9/20/2021.
*/
public class AppApplication extends Application {
......
package com.jachdev.consumerprotection;
/**
* Created by Asanka on 9/20/2021.
* Created by Tharushaa on 9/20/2021.
*/
public class AppConstant {
public static final String BASE_URL = "http://192.168.1.4:5000/";
......
package com.jachdev.consumerprotection.data;
import com.google.gson.annotations.SerializedName;
import com.jachdev.consumerprotection.AppConstant;
import java.io.File;
/**
* Created by Asanka on 9/28/2021.
*/
public class AddOrgRequest extends BaseRequest{
@SerializedName("user_id")
private long userId;
private String logo;
@SerializedName("shop_type_id")
private long shopTypeId;
private String name;
private String description;
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
setImageParts(AppConstant.ORG_LOGO_KEY, new File(logo));
}
public long getShopTypeId() {
return shopTypeId;
}
public void setShopTypeId(long shopTypeId) {
this.shopTypeId = shopTypeId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void createDataPart(){
setTextParts("user_id", String.valueOf(userId));
setTextParts("shop_type_id", String.valueOf(shopTypeId));
setTextParts("name", name);
setTextParts("description", description);
}
}
package com.jachdev.consumerprotection.data;
import android.os.Parcel;
import android.os.Parcelable;
public class Address implements Parcelable {
private String line1;
private String line2;
private String line3;
private String postalCode;
private String country;
private double latitude;
private double longitude;
public Address() {
}
public String getLine1() {
return line1 != null? line1 : "";
}
public void setLine1(String line1) {
this.line1 = line1;
}
public String getLine2() {
return line2 != null? line2 : "";
}
public void setLine2(String line2) {
this.line2 = line2;
}
public String getLine3() {
return line3 != null? line3 : "";
}
public void setLine3(String line3) {
this.line3 = line3;
}
public String getPostalCode() {
return postalCode != null? postalCode : "";
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getCountry() {
return country != null? country : "";
}
public void setCountry(String country) {
this.country = country;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
@Override
public String toString() {
return "Address{" +
"line1='" + line1 + '\'' +
", line2='" + line2 + '\'' +
", line3='" + line3 + '\'' +
", postalCode='" + postalCode + '\'' +
", country='" + country + '\'' +
", latitude=" + latitude +
", longitude=" + longitude +
'}';
}
public boolean compareTo(Address address){
return (address != null &&
!(getCountry().equals(address.getCountry())
&& getPostalCode().equals(address.getPostalCode())
&& getLine1().equals(address.getLine1())
&& getLine2().equals(address.getLine2())
&& getLine3().equals(address.getLine3())));
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.line1);
dest.writeString(this.line2);
dest.writeString(this.line3);
dest.writeString(this.postalCode);
dest.writeString(this.country);
dest.writeDouble(this.latitude);
dest.writeDouble(this.longitude);
}
protected Address(Parcel in) {
this.line1 = in.readString();
this.line2 = in.readString();
this.line3 = in.readString();
this.postalCode = in.readString();
this.country = in.readString();
this.latitude = in.readDouble();
this.longitude = in.readDouble();
}
public static final Creator<Address> CREATOR = new Creator<Address>() {
@Override
public Address createFromParcel(Parcel source) {
return new Address(source);
}
@Override
public Address[] newArray(int size) {
return new Address[size];
}
};
public String getLongAddress() {
return (getLine1().isEmpty() ? "" : line1 + ", ") + (getLine2().isEmpty() ? "" : line2 + ", ")
+ (getLine3().isEmpty() ? "" : line3 + ", ") + (getCountry().isEmpty() ? "" : country + ".")
+ (getPostalCode().isEmpty() ? "" : "[" + postalCode + "]");
}
}
package com.jachdev.consumerprotection.data;
import com.google.gson.annotations.SerializedName;
import com.jachdev.consumerprotection.AppConstant;
/**
* Created by Asanka on 10/4/2021.
*/
public class AllShopResponse extends Shop{
@SerializedName("org_name")
private String orgName;
@SerializedName("logo")
private String logo;
@SerializedName("description")
private String description;
private String distance;
public String getOrgName() {
return orgName;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public String getLogo() {
return AppConstant.BASE_URL + AppConstant.IMAGE_PATH + logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDistance() {
return distance;
}
public void setDistance(String distance) {
this.distance = distance;
}
}
......@@ -3,7 +3,7 @@ package com.jachdev.consumerprotection.data;
import com.google.gson.Gson;
/**
* Created by Asanka on 9/20/2021.
* Created by Tharushaa on 9/20/2021.
*/
public class AppResponse {
......
......@@ -9,7 +9,7 @@ import okhttp3.MultipartBody;
import okhttp3.RequestBody;
/**
* Created by Asanka on 9/28/2021.
* Created by Tharushaa on 9/28/2021.
*/
public class BaseRequest {
......
package com.jachdev.consumerprotection.data;
/**
* Created by Asanka on 9/26/2021.
* Created by Tharushaa on 9/26/2021.
*/
public class Category {
......
package com.jachdev.consumerprotection.data;
/**
* Created by Asanka on 10/13/2021.
* Created by Tharushaa on 10/13/2021.
*/
public class FirebasePredictionData {
......
package com.jachdev.consumerprotection.data;
/**
* Created by Asanka on 9/29/2021.
*/
public class LatLong {
private double lat;
private double lon;
public LatLong(double lat, double lon) {
this.lat = lat;
this.lon = lon;
}
public double getLat() {
return lat;
}
public double getLon() {
return lon;
}
}
package com.jachdev.consumerprotection.data;
import com.google.gson.annotations.SerializedName;
import com.jachdev.consumerprotection.AppConstant;
/**
* Created by Asanka on 9/28/2021.
*/
public class Organization {
private long id;
@SerializedName("user_id")
private long userId;
private String logo;
@SerializedName("shop_type_id")
private long shopTypeId;
private String name;
private String description;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public String getLogo() {
return AppConstant.BASE_URL + AppConstant.IMAGE_PATH + logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public long getShopTypeId() {
return shopTypeId;
}
public void setShopTypeId(long shopTypeId) {
this.shopTypeId = shopTypeId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
package com.jachdev.consumerprotection.data;
import com.jachdev.consumerprotection.data.enums.PredictionType;
import java.util.List;
/**
* Created by Asanka on 10/11/2021.
*/
public class PredictionCategory {
private String name;
private List<SubCategory> subs;
public PredictionCategory() {
}
public PredictionCategory(String name, List<SubCategory> subs) {
this.name = name;
this.subs = subs;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<SubCategory> getSubCategory() {
return subs;
}
public void setSubCategory(List<SubCategory> subs) {
this.subs = subs;
}
public boolean hasSubCategory() {
return subs != null && !subs.isEmpty();
}
public static class SubCategory {
public SubCategory(String name) {
this.name = name;
}
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
package com.jachdev.consumerprotection.data;
import com.jachdev.consumerprotection.util.Helper;
import java.util.Calendar;
/**
* Created by Asanka on 10/3/2021.
*/
public class PredictionData {
private String date;
private String importValue;
private String priceValue;
private String salesValue;
public String getDate() {
return date;
}
public int getMonth() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(getUnix());
return calendar.get(Calendar.MONTH);
}
public long getUnix() {
return Helper.dateTimeToUnix(date);
}
public void setDate(String date) {
this.date = date;
}
public String getImportValue() {
return importValue;
}
public Integer getValue() {
if(importValue != null){
return (int)Double.parseDouble(importValue);
}else if(priceValue != null){
return (int)Double.parseDouble(priceValue);
}else if(salesValue != null){
return (int)Double.parseDouble(salesValue);
}
return 0;
}
public void setImportValue(String importValue) {
this.importValue = importValue;
}
@Override
public String toString() {
return "PredictionData{" +
"date='" + date + '\'' +
", importValue='" + importValue + '\'' +
'}';
}
}
package com.jachdev.consumerprotection.data;
import com.google.gson.annotations.SerializedName;
/**
* Created by Asanka on 10/3/2021.
*/
public class PredictionRequest {
private String path = "import_dataset";
private String category = "";
@SerializedName("sub_category")
private String subCategory = "";
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getSubCategory() {
return subCategory;
}
public void setSubCategory(String subCategory) {
this.subCategory = subCategory;
}
@Override
public String toString() {
return "PredictionRequest{" +
"path='" + path + '\'' +
", category='" + category + '\'' +
", subCategory='" + subCategory + '\'' +
'}';
}
}
package com.jachdev.consumerprotection.data;
/**
* Created by Asanka on 10/4/2021.
* Created by Tharushaa on 10/4/2021.
*/
public class Report {
......
package com.jachdev.consumerprotection.data;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
/**
* Created by Asanka on 9/29/2021.
*/
public class Shop {
private long id;
private String name;
private String address;
@SerializedName("phonenumber")
private String phoneNumber;
@SerializedName("organization_id")
private long organizationId;
private String location;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(long organizationId) {
this.organizationId = organizationId;
}
public String getLocation() {
return location;
}
public LatLong getLatLong() {
return new Gson().fromJson(location, LatLong.class);
}
public void setLocation(String location) {
this.location = location;
}
public void setLocation(double lat, double lon) {
this.location = new Gson().toJson(new LatLong(lat, lon));
}
}
......@@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName;
import com.jachdev.consumerprotection.data.enums.UserType;
/**
* Created by Asanka on 9/20/2021.
* Created by Tharushaa on 9/20/2021.
*/
public class User {
......
package com.jachdev.consumerprotection.data.enums;
/**
* Created by Asanka on 9/26/2021.
*/
public enum PickerType {
GALLERY, CAMERA
}
package com.jachdev.consumerprotection.data.enums;
import com.jachdev.consumerprotection.R;
/**
* Created by Asanka on 6/5/2021.
*/
public enum PredictionType {
IMPORT(0), PRICE(1), QUANTITY(2), SALES(3);
PredictionType(int value) {
this.id = value;
switch (value){
case 0:
name = "import";
title = R.string.import_prediction;
break;
case 1:
name = "price";
title = R.string.price_prediction;
break;
case 2:
name = "quantity";
title = R.string.price_prediction;
break;
case 3:
name = "sales";
title = R.string.sales_prediction;
break;
}
}
public int id;
public String name;
public int title;
public static PredictionType getPredictionType(int value) {
PredictionType[] types = PredictionType.values();
for (PredictionType type : types) {
if(type.getId() == value)
return type;
}
return IMPORT;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getTitle() {
return title;
}
public void setTitle(int title) {
this.title = title;
}
}
package com.jachdev.consumerprotection.data.enums;
/**
* Created by Asanka on 6/5/2021.
* Created by Tharushaa on 6/5/2021.
*/
public enum UserType {
CONSUMER(0), VENDOR(1), ADMIN(2);
......@@ -11,10 +11,10 @@ public enum UserType {
switch (value){
case 0:
name = "Consumer";
name = "Patient";
break;
case 1:
name = "Vendor";
name = "Doctor";
break;
case 2:
name = "Admin";
......
......@@ -2,18 +2,14 @@ package com.jachdev.consumerprotection.network;
import com.jachdev.consumerprotection.AppConstant;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.PredictionRequest;
import com.jachdev.consumerprotection.data.Report;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.data.User;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Single;
import okhttp3.MultipartBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
......@@ -21,7 +17,7 @@ import retrofit2.http.Part;
import retrofit2.http.Query;
/**
* Created by Asanka on 9/20/2021.
* Created by Tharushaa on 9/20/2021.
*/
public interface ApiInterface {
......@@ -34,28 +30,9 @@ public interface ApiInterface {
@GET(AppConstant.PATH_GET_CATEGORIES)
Single<AppResponse> getCategories();
@Multipart
@POST(AppConstant.PATH_ADD_ORGANIZATION)
Single<AppResponse> addOrganization(@Part List<MultipartBody.Part> file);
@GET(AppConstant.PATH_GET_ORGANIZATION)
Single<AppResponse> getOrganization(@Query("user_id") long user_id);
@POST(AppConstant.PATH_ADD_SHOP)
Single<AppResponse> addShop(@Body Shop shop);
@GET(AppConstant.PATH_GET_SHOP)
Single<AppResponse> getShops(@Query("organization_id") long organization_id);
@POST(AppConstant.PATH_GET_ESSENTIALS)
Single<AppResponse> getEssentials(@Body PredictionRequest request);
@POST(AppConstant.PATH_COMPLAINTS)
Single<AppResponse> complaints(@Body Report report);
@GET(AppConstant.PATH_GET_ALL_SHOPS)
Single<AppResponse> getAllShops();
@GET(AppConstant.PATH_GET_NOTIFICATIONS)
Single<AppResponse> getNotifications(@Query("uid") long uid);
}
......@@ -18,7 +18,7 @@ import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by Asanka on 9/20/2021.
* Created by Tharushaa on 9/20/2021.
*/
public class AppService {
......
......@@ -9,15 +9,13 @@ import android.view.View;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.jachdev.commonlibs.base.BaseActivity;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.enums.PredictionType;
import com.jachdev.consumerprotection.ui.calories.CaloriesActivity;
import com.jachdev.consumerprotection.ui.classifier.ClassifierActivity;
import com.jachdev.consumerprotection.ui.dashboard.DashboardFragment;
import com.jachdev.consumerprotection.ui.home.HomeFragment;
import com.jachdev.consumerprotection.ui.map.MapsActivity;
import com.jachdev.consumerprotection.ui.prediction.ComplaintsFragment;
import com.jachdev.consumerprotection.ui.prediction.ContactUsFragment;
import com.jachdev.consumerprotection.ui.prediction.PredictionActivity;
import com.jachdev.consumerprotection.ui.prediction.PredictionFragment;
import com.jachdev.consumerprotection.ui.vendor.VendorActivity;
import com.jachdev.consumerprotection.util.SessionManager;
import org.jetbrains.annotations.NotNull;
......@@ -83,18 +81,6 @@ public class HomeActivity extends BaseActivity implements HomeFragment.FragmentE
return super.onOptionsItemSelected(item);
}
@Override
public void onAddOrganizationClick() {
activityToActivity(VendorActivity.class);
}
@Override
public void onViewOrganizationClick() {
activityToActivity(VendorActivity.class);
}
private NavController.OnDestinationChangedListener mOnDestinationChangedListener = new NavController.OnDestinationChangedListener() {
@Override
public void onDestinationChanged(@NonNull @NotNull NavController controller, @NonNull @NotNull NavDestination destination, @Nullable @org.jetbrains.annotations.Nullable Bundle arguments) {
......@@ -157,4 +143,23 @@ public class HomeActivity extends BaseActivity implements HomeFragment.FragmentE
intent.setAction(ContactUsFragment.ACTION);
activityToActivity(intent, 0);
}
@Override
public void onImageRecognitionClick() {
Intent intent = new Intent(HomeActivity.this, ClassifierActivity.class);
intent.setAction(ContactUsFragment.ACTION);
activityToActivity(intent, 0);
}
@Override
public void onCalorieCounterClick() {
Intent intent = new Intent(HomeActivity.this, CaloriesActivity.class);
intent.setAction(ContactUsFragment.ACTION);
activityToActivity(intent, 0);
}
@Override
public void onMealPlanClick() {
}
}
\ No newline at end of file
......@@ -151,7 +151,10 @@ public class LoginActivity extends BaseActivity {
mUser.setNumber(etPhone.getTextString());
SessionManager.getInstance().setUser(mUser);
signInWithEmailAuthCredential(etEmail.getTrimText());
activityToActivity(HomeActivity.class);
LoginActivity.this.finish();
// signInWithEmailAuthCredential(etEmail.getTrimText());
break;
default:
......
......@@ -4,15 +4,12 @@ import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.jachdev.commonlibs.widget.CustomImageView;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.AllShopResponse;
import com.jachdev.consumerprotection.data.FirebasePredictionData;
import com.jachdev.consumerprotection.data.Notification;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.util.Helper;
import org.jetbrains.annotations.NotNull;
......@@ -20,14 +17,13 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by Asanka on 7/30/2021.
* Created by Tharushaa on 7/30/2021.
*/
public class CommonAdaptor<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
......
package com.jachdev.consumerprotection.ui.calories;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.jachdev.commonlibs.widget.CustomEditText;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.util.StepDetector;
import com.jachdev.consumerprotection.util.StepListener;
public class CaloriesActivity extends AppCompatActivity implements SensorEventListener, StepListener {
private CustomTextView TvSteps, tvCount;
private CustomEditText etWeight, etHeight;
private Button BtnStart, BtnStop;
private StepDetector simpleStepDetector;
private SensorManager sensorManager;
private Sensor accel;
private static final String TEXT_NUM_STEPS = "Number of Steps: ";
private int numSteps;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calories);
// Get an instance of the SensorManager
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
accel = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
simpleStepDetector = new StepDetector();
simpleStepDetector.registerListener(this);
TvSteps = (CustomTextView) findViewById(R.id.tv_steps);
tvCount = (CustomTextView) findViewById(R.id.tv_count);
BtnStart = (Button) findViewById(R.id.btn_start);
BtnStop = (Button) findViewById(R.id.btn_stop);
etWeight = (CustomEditText) findViewById(R.id.et_weight);
etHeight = (CustomEditText) findViewById(R.id.et_height);
BtnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
numSteps = 0;
sensorManager.registerListener(CaloriesActivity.this, accel, SensorManager.SENSOR_DELAY_FASTEST);
}
});
BtnStop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
sensorManager.unregisterListener(CaloriesActivity.this);
startActivity(new Intent(CaloriesActivity.this, ExercisesSuggeserActivity.class));
}
});
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
simpleStepDetector.updateAccel(
event.timestamp, event.values[0], event.values[1], event.values[2]);
}
}
@Override
public void step(long timeNs) {
numSteps++;
TvSteps.setText(TEXT_NUM_STEPS + numSteps);
double weightSum = etWeight.getTextDouble() * 0.035;
double velocity = (1.4 * numSteps) * (1.4 * numSteps);
double velocityDevide = velocity/etHeight.getTextDouble();
double addFstSec = velocityDevide + weightSum;
double muly = addFstSec * 0.029;
double res = muly * etWeight.getTextDouble();
tvCount.setAnyText(res + "");
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.ui.calories;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.jachdev.consumerprotection.R;
public class ExercisesSuggeserActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exercises_suggeser);
MyListData[] myListData = new MyListData[] {
new MyListData("First Day", android.R.drawable.ic_dialog_email),
new MyListData("Second Day", android.R.drawable.ic_dialog_info),
new MyListData("Third Day", android.R.drawable.ic_delete),
new MyListData("Forth Day", android.R.drawable.ic_dialog_dialer),
new MyListData("Fifth Day", android.R.drawable.ic_dialog_alert),
new MyListData("Sixth Day", android.R.drawable.ic_dialog_map),
new MyListData("Seventh Day", android.R.drawable.ic_dialog_email),
new MyListData("Ninth Day", android.R.drawable.ic_dialog_info),
new MyListData("10 Day", android.R.drawable.ic_delete),
new MyListData("11 Day", android.R.drawable.ic_dialog_dialer),
new MyListData("12 Day", android.R.drawable.ic_dialog_alert),
new MyListData("13 Day", android.R.drawable.ic_dialog_map),
};
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
MyListAdapter adapter = new MyListAdapter(myListData);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
}
public class MyListAdapter extends RecyclerView.Adapter<MyListAdapter.ViewHolder>{
private MyListData[] listdata;
// RecyclerView recyclerView;
public MyListAdapter(MyListData[] listdata) {
this.listdata = listdata;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View listItem= layoutInflater.inflate(R.layout.list_item, parent, false);
ViewHolder viewHolder = new ViewHolder(listItem);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final MyListData myListData = listdata[position];
holder.textView.setText(listdata[position].getDescription());
// holder.imageView.setImageResource(listdata[position].getImgId());
holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(view.getContext(),"click on item: "+myListData.getDescription(),Toast.LENGTH_LONG).show();
}
});
}
@Override
public int getItemCount() {
return listdata.length;
}
public class ViewHolder extends RecyclerView.ViewHolder {
public ImageView imageView;
public TextView textView;
public RelativeLayout relativeLayout;
public ViewHolder(View itemView) {
super(itemView);
this.imageView = (ImageView) itemView.findViewById(R.id.imageView);
this.textView = (TextView) itemView.findViewById(R.id.textView);
relativeLayout = (RelativeLayout)itemView.findViewById(R.id.relativeLayout);
}
}
}
public class MyListData{
private String description;
private int imgId;
public MyListData(String description, int imgId) {
this.description = description;
this.imgId = imgId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getImgId() {
return imgId;
}
public void setImgId(int imgId) {
this.imgId = imgId;
}
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.ui.classifier;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.util.Classifier;
import com.jachdev.consumerprotection.util.TensorFlowImageClassifier;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public class ClassifierActivity extends AppCompatActivity {//for CameraIntent
private int PICK_IMAGE_REQUEST = 1;
//setUp for tensorflow
public static final int INPUT_SIZE = 224;
public static final int IMAGE_MEAN = 128;
public static final float IMAGE_STD = 128.0f;
public static final String INPUT_NAME = "input";
public static final String OUTPUT_NAME = "final_result";
public static final String MODEL_FILE = "file:///android_asset/rounded_graph.pb";
public static final String LABEL_FILE = "file:///android_asset/retrained_labels.txt";
public Classifier classifier;
public Executor executor = Executors.newSingleThreadExecutor();
public TextView TV1;
public ImageView iV1;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_classifier);
TV1 = (TextView) findViewById(R.id.textView1);
iV1 = (ImageView) findViewById(R.id.imageView1);
initTensorFlowAndLoadModel();
}
private void initTensorFlowAndLoadModel() {
executor.execute(new Runnable() {
@Override
public void run() {
try {
classifier = TensorFlowImageClassifier.create(
getAssets(),
MODEL_FILE,
LABEL_FILE,
INPUT_SIZE,
IMAGE_MEAN,
IMAGE_STD,
INPUT_NAME,
OUTPUT_NAME);
} catch (final Exception e) {
throw new RuntimeException("Error initializing TensorFlow!", e);
}
}
});
}
public List<Classifier.Recognition> analyse(Bitmap bitmap)
{
bitmap = Bitmap.createScaledBitmap(bitmap, INPUT_SIZE, INPUT_SIZE, false);
final List<Classifier.Recognition> results = classifier.recognizeImage(bitmap);
return results;
}
public void selectPhoto(View v)
{
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, PICK_IMAGE_REQUEST);
}
@Override
protected void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
if (resultCode == RESULT_OK) {
try
{
final Uri imageUri = data.getData();
final InputStream imageStream = getContentResolver().openInputStream(imageUri);
final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
List<Classifier.Recognition> results = analyse(selectedImage);
TV1.setText(results.get(0).toString());
setPicture(selectedImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
//set Picture in the ImageView (iV1)
public void setPicture(Bitmap bp)
{
Bitmap scaledBp = Bitmap.createScaledBitmap(bp, iV1.getWidth(), iV1.getHeight(), false);
iV1.setImageBitmap(scaledBp);
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.ui.dashboard;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.enums.PickerType;
import com.jachdev.consumerprotection.ui.vendor.AddOrgFragment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import butterknife.OnClick;
public class DashboardFragment extends BaseFragment {
......
......@@ -3,33 +3,20 @@ package com.jachdev.consumerprotection.ui.home;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.commonlibs.widget.CircleImageView;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.FirebasePredictionData;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.User;
import com.jachdev.consumerprotection.data.enums.UserType;
import com.jachdev.consumerprotection.ui.adapter.CommonAdaptor;
import com.jachdev.consumerprotection.util.Helper;
import com.jachdev.consumerprotection.util.SessionManager;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
......@@ -37,31 +24,6 @@ public class HomeFragment extends BaseFragment {
@BindView(R.id.tv_header)
CustomTextView tvHeader;
@BindView(R.id.btn_add_org)
FrameLayout btnAddOrg;
@BindView(R.id.view_org)
LinearLayoutCompat layoutOrg;
@BindView(R.id.iv_logo)
CircleImageView ivLogo;
@BindView(R.id.tv_org_name)
CustomTextView tvOrgName;
@BindView(R.id.tv_org_description)
CustomTextView tvOrgDesc;
@BindView(R.id.recyclerViewSales)
RecyclerView recyclerViewSales;
private CommonAdaptor<FirebasePredictionData> salesAdapter;
private List<FirebasePredictionData> sales = new ArrayList<>();
@BindView(R.id.recyclerViewPrice)
RecyclerView recyclerViewPrice;
private CommonAdaptor<FirebasePredictionData> priceAdapter;
private List<FirebasePredictionData> price = new ArrayList<>();
@BindView(R.id.recyclerViewImport)
RecyclerView recyclerViewImport;
private CommonAdaptor<FirebasePredictionData> importAdapter;
private List<FirebasePredictionData> imp = new ArrayList<>();
private HomeViewModel homeViewModel;
private FragmentEventListener listener;
......@@ -81,63 +43,10 @@ public class HomeFragment extends BaseFragment {
init();
homeViewModel.getUser().observe(getViewLifecycleOwner(), mUserObserver);
homeViewModel.getSalesPredictionData().observe(getViewLifecycleOwner(), mSalesPredictionObserver);
homeViewModel.getPricePredictionData().observe(getViewLifecycleOwner(), mPricePredictionObserver);
homeViewModel.getImportPredictionData().observe(getViewLifecycleOwner(), mImportPredictionObserver);
}
private void init() {
UserType userType = SessionManager.getInstance().getUser().getUserType();
switch (userType){
case CONSUMER:
btnAddOrg.setVisibility(View.GONE);
layoutOrg.setVisibility(View.GONE);
break;
case ADMIN:
case VENDOR:
showWaiting();
homeViewModel.getOrganization().observe(getViewLifecycleOwner(), mOrgObserver);
btnAddOrg.setVisibility(View.VISIBLE);
layoutOrg.setVisibility(View.VISIBLE);
break;
}
//sales
salesAdapter = new CommonAdaptor<>(getBaseActivity(), sales, new CommonAdaptor.CommonAdaptorCallback() {
@Override
public void onView(int viewType, int position) {
}
});
salesAdapter.setViewType(CommonAdaptor.VIEW_TYPE_FIREBASE_PREDICTION);
recyclerViewSales.setLayoutManager(new GridLayoutManager(getBaseActivity(), 2));
recyclerViewSales.setAdapter(salesAdapter);
//price
priceAdapter = new CommonAdaptor<>(getBaseActivity(), price, new CommonAdaptor.CommonAdaptorCallback() {
@Override
public void onView(int viewType, int position) {
}
});
priceAdapter.setViewType(CommonAdaptor.VIEW_TYPE_FIREBASE_PREDICTION);
recyclerViewPrice.setLayoutManager(new GridLayoutManager(getBaseActivity(), 2));
recyclerViewPrice.setAdapter(priceAdapter);
//imports
importAdapter = new CommonAdaptor<>(getBaseActivity(), imp, new CommonAdaptor.CommonAdaptorCallback() {
@Override
public void onView(int viewType, int position) {
}
});
importAdapter.setViewType(CommonAdaptor.VIEW_TYPE_FIREBASE_PREDICTION);
recyclerViewImport.setLayoutManager(new GridLayoutManager(getBaseActivity(), 2));
recyclerViewImport.setAdapter(importAdapter);
}
@Override
......@@ -160,98 +69,27 @@ public class HomeFragment extends BaseFragment {
}
};
private Observer<? super Organization> mOrgObserver = new Observer<Organization>() {
@Override
public void onChanged(Organization organization) {
dismissWaiting();
if(organization == null){
btnAddOrg.setVisibility(View.VISIBLE);
layoutOrg.setVisibility(View.GONE);
}else{
layoutOrg.setVisibility(View.VISIBLE);
btnAddOrg.setVisibility(View.GONE);
Helper.loadImageByUrl(ivLogo, organization.getLogo());
tvOrgName.setAnyText(organization.getName());
tvOrgDesc.setAnyText(organization.getDescription());
}
}
};
private Observer<? super HashMap<String, FirebasePredictionData>> mSalesPredictionObserver = new Observer<HashMap<String, FirebasePredictionData>>() {
@Override
public void onChanged(HashMap<String, FirebasePredictionData> map) {
List<FirebasePredictionData> sales = new ArrayList<>();
if(map == null)
return;
for (String key : map.keySet()) {
FirebasePredictionData data = map.get(key);
data.setName(key);
sales.add(data);
}
salesAdapter.setItems(sales);
}
};
private Observer<? super HashMap<String, FirebasePredictionData>> mPricePredictionObserver = new Observer<HashMap<String, FirebasePredictionData>>() {
@Override
public void onChanged(HashMap<String, FirebasePredictionData> map) {
List<FirebasePredictionData> price = new ArrayList<>();
if(map == null)
return;
for (String key : map.keySet()) {
FirebasePredictionData data = map.get(key);
data.setName(key);
price.add(data);
}
priceAdapter.setItems(price);
}
};
private Observer<? super HashMap<String, FirebasePredictionData>> mImportPredictionObserver = new Observer<HashMap<String, FirebasePredictionData>>() {
@Override
public void onChanged(HashMap<String, FirebasePredictionData> map) {
List<FirebasePredictionData> imp = new ArrayList<>();
if(map == null)
return;
for (String key : map.keySet()) {
FirebasePredictionData data = map.get(key);
data.setName(key);
imp.add(data);
}
importAdapter.setItems(imp);
}
};
@OnClick(R.id.btn_image_rec)
public void onImageRecognitionClick(){
if(listener != null)
listener.onImageRecognitionClick();
}
@OnClick(R.id.btn_add_org)
public void onAddOrganizationClick(){
@OnClick(R.id.btn_calorie_count)
public void onCalorieCounterClick(){
if(listener != null)
listener.onAddOrganizationClick();
listener.onCalorieCounterClick();
}
@OnClick(R.id.view_org)
public void onViewOrganizationClick(){
@OnClick(R.id.btn_meal_plan)
public void onMealPlanClick(){
if(listener != null)
listener.onViewOrganizationClick();
listener.onMealPlanClick();
}
public interface FragmentEventListener{
void onAddOrganizationClick();
void onViewOrganizationClick();
void onImageRecognitionClick();
void onCalorieCounterClick();
void onMealPlanClick();
}
}
\ No newline at end of file
......@@ -12,7 +12,6 @@ import com.google.gson.reflect.TypeToken;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.FirebasePredictionData;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.User;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.util.SessionManager;
......@@ -21,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
......
......@@ -23,8 +23,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.google.android.gms.common.api.ResolvableApiException;
......@@ -50,14 +48,10 @@ import com.google.android.gms.tasks.Task;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.AllShopResponse;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.ui.adapter.CommonAdaptor;
import com.jachdev.consumerprotection.util.Helper;
import com.jachdev.consumerprotection.util.SessionManager;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionDeniedResponse;
......
package com.jachdev.consumerprotection.ui.notifications;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.Notification;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.ui.adapter.CommonAdaptor;
import org.jetbrains.annotations.NotNull;
......@@ -21,7 +16,6 @@ import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
......
......@@ -5,7 +5,6 @@ import android.util.Log;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.Notification;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.data.User;
import com.jachdev.consumerprotection.data.enums.UserType;
import com.jachdev.consumerprotection.network.AppService;
......
package com.jachdev.consumerprotection.ui.prediction;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.formatter.IndexAxisValueFormatter;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.commonlibs.validator.Validator;
import com.jachdev.commonlibs.widget.CustomEditText;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.PredictionData;
import com.jachdev.consumerprotection.data.PredictionRequest;
import com.jachdev.consumerprotection.data.Report;
import com.jachdev.consumerprotection.data.enums.PredictionType;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.util.Helper;
import com.jachdev.consumerprotection.util.SessionManager;
import com.pd.chocobar.ChocoBar;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.OnClick;
......
package com.jachdev.consumerprotection.ui.prediction;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.formatter.IndexAxisValueFormatter;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.PredictionData;
import com.jachdev.consumerprotection.data.PredictionRequest;
import com.jachdev.consumerprotection.data.enums.PredictionType;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.util.Helper;
import com.pd.chocobar.ChocoBar;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class ContactUsFragment extends BaseFragment {
public static final String ACTION = "ACTION_CONTACT_US";
......
package com.jachdev.consumerprotection.ui.prediction;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.jachdev.commonlibs.base.BaseActivity;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.enums.PredictionType;
public class PredictionActivity extends BaseActivity implements PredictionFragment.FragmentEventListener, ComplaintsFragment.FragmentEventListener {
public static final String KEY_PREDICTION_TYPE = "KEY_PREDICTION_TYPE";
private static final String TAG = PredictionActivity.class.getSimpleName();
@Override
protected int layoutRes() {
return R.layout.activity_prediction;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
onNewIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
String action = intent.getAction();
Log.d(TAG, "Action: " + action);
if(action.equalsIgnoreCase(PredictionFragment.ACTION)){
startPredictionFragment(intent);
} else if(action.equalsIgnoreCase(ComplaintsFragment.ACTION)){
startFragment(R.id.nav_host_fragment, ComplaintsFragment.newInstance(), false);
setTitle(R.string.complaints);
} else if(action.equalsIgnoreCase(ContactUsFragment.ACTION)){
startFragment(R.id.nav_host_fragment, ContactUsFragment.newInstance(), false);
setTitle(R.string.contact_us);
}
}
private void startPredictionFragment(Intent intent) {
PredictionType type = PredictionType.getPredictionType(intent.getIntExtra(KEY_PREDICTION_TYPE, 0));
switch (type){
case IMPORT:
startFragment(R.id.nav_host_fragment, PredictionFragment.newInstance(PredictionType.IMPORT), false);
setTitle(R.string.import_prediction);
break;
case PRICE:
startFragment(R.id.nav_host_fragment, PredictionFragment.newInstance(PredictionType.PRICE), false);
setTitle(R.string.price_prediction);
break;
case SALES:
startFragment(R.id.nav_host_fragment, PredictionFragment.newInstance(PredictionType.SALES), false);
setTitle(R.string.sales_prediction);
break;
}
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.ui.vendor;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.commonlibs.widget.CircleImageView;
import com.jachdev.commonlibs.widget.CustomEditText;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.AddOrgRequest;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.Category;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.enums.PickerType;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.util.Helper;
import com.jachdev.consumerprotection.util.SessionManager;
import com.pd.chocobar.ChocoBar;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class AddOrgFragment extends BaseFragment {
private static final String TAG = AddOrgFragment.class.getSimpleName();
@BindView(R.id.et_organization_name)
CustomEditText etOrgName;
@BindView(R.id.et_description)
CustomEditText etOrgDescription;
@BindView(R.id.et_organization_type)
CustomTextView etOrgType;
@BindView(R.id.iv_logo)
CircleImageView ivLogo;
private FragmentEventListener listener;
private Category currentCategory;
private String logo;
private AppService service;
private List<Category> categories = new ArrayList<>();
public static Fragment newInstance() {
return new AddOrgFragment();
}
@Override
protected int layoutRes() {
return R.layout.fragment_add_org;
}
@Override
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
service = AppApplication.getInstance().getAppService();
getCategories();
}
@Override
public void onAttach(Context context) {
listener = (FragmentEventListener) context;
super.onAttach(context);
}
@OnClick(R.id.et_organization_type)
public void onCategoryClick(){
String[] cats = new String[categories.size()];
for (int x = 0; x < categories.size(); x++) {
Category c = categories.get(x);
cats[x] = c.getType();
}
// setup the alert builder
AlertDialog.Builder builder = new AlertDialog.Builder(getBaseActivity());
builder.setTitle("Choose a category");
builder.setItems(cats, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
etOrgType.setAnyText(categories.get(which).getType());
currentCategory = categories.get(which);
}
});
// create and show the alert dialog
AlertDialog dialog = builder.create();
dialog.show();
}
@OnClick(R.id.btn_add_logo)
public void onAddLogoClick(){
String[] cats = new String[]{getString(R.string.from_gallery), getString(R.string.from_camera)};
// setup the alert builder
AlertDialog.Builder builder = new AlertDialog.Builder(getBaseActivity());
builder.setTitle("Add logo");
builder.setItems(cats, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(listener != null)
listener.onImagePicker(which == 0 ? PickerType.GALLERY : PickerType.CAMERA);
}
});
// create and show the alert dialog
AlertDialog dialog = builder.create();
dialog.show();
}
@OnClick(R.id.btn_submit)
public void onSubmitClick(){
showWaiting();
AddOrgRequest request = new AddOrgRequest();
request.setName(etOrgName.getTrimText());
request.setDescription(etOrgDescription.getTrimText());
request.setShopTypeId(currentCategory.getId());
request.setLogo(logo);
request.setUserId(SessionManager.getInstance().getUser().getId());
request.createDataPart();
service.getServer().addOrganization(request.getMultiParts())
.subscribeOn(Schedulers.io())
.subscribe(new SingleObserver<AppResponse>() {
@Override
public void onSubscribe(@NotNull Disposable d) {
Log.d(TAG, "onSubscribe: ");
}
@Override
public void onSuccess(@NotNull AppResponse response) {
dismissWaiting();
switch (response.getCode()){
case 0:
Organization organization = response.getObjectToType(Organization.class);
SessionManager.getInstance().setOrganization(organization);
getBaseActivity().finish();
break;
default:
showError(response.getMessage());
break;
}
}
@Override
public void onError(@NotNull Throwable e) {
dismissWaiting();
showError(e.getMessage());
Log.d(TAG, "onError: " + e.getMessage());
}
});
}
private void getCategories() {
showWaiting();
service.getServer().getCategories()
.subscribeOn(Schedulers.io())
.subscribe(new SingleObserver<AppResponse>() {
@Override
public void onSubscribe(@NotNull Disposable d) {
Log.d(TAG, "onSubscribe: ");
}
@Override
public void onSuccess(@NotNull AppResponse response) {
dismissWaiting();
switch (response.getCode()){
case 0:
categories = Arrays.asList(response.getObjectToType(Category[].class).clone());
break;
default:
showError(response.getMessage());
break;
}
}
@Override
public void onError(@NotNull Throwable e) {
dismissWaiting();
showError(e.getMessage());
Log.d(TAG, "onError: " + e.getMessage());
}
});
}
private void showError(String message){
ChocoBar.builder().setBackgroundColor(Color.parseColor("#FFA61B1B"))
.setTextSize(18)
.setTextColor(Color.parseColor("#FFFFFF"))
.setTextTypefaceStyle(Typeface.ITALIC)
.setText(message)
.setMaxLines(4)
.centerText()
.setActionText(getString(R.string.ok))
.setActivity(getBaseActivity())
.build()
.show();
}
public void setLogo(String path) {
this.logo = path;
Helper.loadImageByFilePath(ivLogo, path);
}
public interface FragmentEventListener{
void onImagePicker(PickerType type);
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.ui.vendor;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.commonlibs.validator.Validator;
import com.jachdev.commonlibs.widget.CircleImageView;
import com.jachdev.commonlibs.widget.CustomEditText;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.Address;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.Category;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.util.Helper;
import com.jachdev.consumerprotection.util.SessionManager;
import com.pd.chocobar.ChocoBar;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class AddShopFragment extends BaseFragment {
private static final String TAG = AddShopFragment.class.getSimpleName();
@BindView(R.id.et_name)
CustomEditText et_name;
@BindView(R.id.et_phone)
CustomEditText et_phone;
@BindView(R.id.et_address)
CustomTextView et_address;
private Address address;
private AppService service;
private FragmentEventListener listener;
public static Fragment newInstance() {
return new AddShopFragment();
}
@Override
protected int layoutRes() {
return R.layout.fragment_add_shop;
}
@Override
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
service = AppApplication.getInstance().getAppService();
}
@Override
public void onAttach(Context context) {
listener = (FragmentEventListener) context;
super.onAttach(context);
}
@OnClick(R.id.et_address)
public void onAddressClick(){
if(listener != null)
listener.onAddressClick();
}
@OnClick(R.id.btn_submit)
public void onSubmitClick(){
if(!Validator.isValidField(et_name) || !Validator.isValidPhoneNumber(et_phone)){
return;
}
if(et_address.getText().length() == 0){
showMessage(getString(R.string.error_add_a_location));
}
Shop shop = new Shop();
shop.setName(et_name.getTrimText());
shop.setAddress(et_address.getTrimText());
shop.setPhoneNumber(et_phone.getTrimText());
shop.setOrganizationId(SessionManager.getInstance().getOrganization().getId());
if(address != null)
shop.setLocation(address.getLatitude(), address.getLongitude());
showWaiting();
service.getServer().addShop(shop)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SingleObserver<AppResponse>() {
@Override
public void onSubscribe(@NotNull Disposable d) {
Log.d(TAG, "onSubscribe: ");
}
@Override
public void onSuccess(@NotNull AppResponse response) {
dismissWaiting();
switch (response.getCode()){
case 0:
List<Shop> shops = Arrays.asList(response.getObjectToType(Shop[].class).clone());
if(listener != null)
listener.onShopAdded(shops);
showMessage(getString(R.string.successfully_added));
break;
default:
showError(response.getMessage());
break;
}
}
@Override
public void onError(@NotNull Throwable e) {
dismissWaiting();
showError(e.getMessage());
Log.d(TAG, "onError: " + e.getMessage());
}
});
}
public void setShopAddress(Address address) {
this.address = address;
String loc = address.getLongAddress();
et_address.setAnyText(loc);
}
private void showError(String message){
ChocoBar.builder().setBackgroundColor(Color.parseColor("#FFA61B1B"))
.setTextSize(18)
.setTextColor(Color.parseColor("#FFFFFF"))
.setTextTypefaceStyle(Typeface.ITALIC)
.setText(message)
.setMaxLines(4)
.centerText()
.setActionText(getString(R.string.ok))
.setActivity(getBaseActivity())
.build()
.show();
}
public interface FragmentEventListener{
void onAddressClick();
void onShopAdded(List<Shop> shops);
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.ui.vendor;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import android.Manifest;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import com.esafirm.imagepicker.features.ImagePicker;
import com.esafirm.imagepicker.model.Image;
import com.jachdev.commonlibs.base.BaseActivity;
import com.jachdev.consumerprotection.AppConstant;
import com.jachdev.consumerprotection.BuildConfig;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.Address;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.data.enums.PickerType;
import com.jachdev.consumerprotection.ui.HomeActivity;
import com.jachdev.consumerprotection.ui.map.SearchLocationActivity;
import com.jachdev.consumerprotection.util.Helper;
import com.jachdev.consumerprotection.util.SessionManager;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.MultiplePermissionsReport;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
import java.io.File;
import java.util.List;
public class VendorActivity extends BaseActivity implements AddOrgFragment.FragmentEventListener,
ViewOrgFragment.FragmentEventListener, AddShopFragment.FragmentEventListener {
private static final int MAP_ACTIVITY_REQUEST = 101;
@Override
protected int layoutRes() {
return R.layout.activity_vendor;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Organization organization = SessionManager.getInstance().getOrganization();
if(organization == null){
setTitle(R.string.add_organization);
startFragment(R.id.nav_host_fragment, AddOrgFragment.newInstance(), false);
}else{
setTitle(R.string.view_organization);
startFragment(R.id.nav_host_fragment, ViewOrgFragment.newInstance(), false);
}
}
@Override
protected void onResume() {
super.onResume();
checkCameraPermissions();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (ImagePicker.shouldHandle(requestCode, resultCode, data)) {
List<Image> images = ImagePicker.getImages(data);
for (int x = 0; x < images.size(); x++) {
Image image = images.get(x);
try {
File file = Helper.compressToFile(VendorActivity.this, new File(image.getPath()));
if(getFragment() instanceof AddOrgFragment){
AddOrgFragment addOrgFragment = (AddOrgFragment) getFragment();
addOrgFragment.setLogo(file.getPath());
}
} catch (Exception e) {
showMessage(getString(R.string.error_please_insert_a_valid_image));
}
}
}
if (requestCode == MAP_ACTIVITY_REQUEST && resultCode == RESULT_OK) {
if (data != null && data.getParcelableExtra(SearchLocationActivity.MY_LOCATION_DATA) != null) {
Address address = (Address) data.getParcelableExtra(SearchLocationActivity.MY_LOCATION_DATA);
if (getFragment() instanceof AddShopFragment) {
((AddShopFragment) getFragment()).setShopAddress(address);
}
}
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onImagePicker(PickerType type) {
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" +
BuildConfig.APPLICATION_ID + "/.photo");
switch (type){
case GALLERY:
ImagePicker.create(VendorActivity.this)
.imageFullDirectory(file.getPath())
.includeVideo(false)
.limit(AppConstant.IMAGE_LIMIT)
.showCamera(false)
.folderMode(true)
.start();
break;
case CAMERA:
ImagePicker.cameraOnly()
.imageFullDirectory(file.getPath())
.start(VendorActivity.this);
break;
}
}
private void checkCameraPermissions() {
Dexter.withActivity(this)
.withPermissions(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
// check if all permissions are granted
if (report.areAllPermissionsGranted()) {
// do you work now
}
// check for permanent denial of any permission
if (report.isAnyPermissionPermanentlyDenied()) {
// permission is denied permenantly, navigate user to app settings
showSettingsDialog();
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
token.continuePermissionRequest();
}
})
.onSameThread()
.check();
}
private void showSettingsDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(VendorActivity.this);
builder.setTitle(getString(R.string.need_permissions));
builder.setMessage(getString(R.string.need_permissions_to_use_this_feature));
builder.setPositiveButton(getString(R.string.goto_settings), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
openSettings();
}
});
builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
@Override
public void onAddShopClick() {
setTitle(R.string.add_shop);
startFragment(R.id.nav_host_fragment, AddShopFragment.newInstance(), true);
}
@Override
public void onAddressClick() {
activityToActivity(new Intent(VendorActivity.this,
SearchLocationActivity.class), MAP_ACTIVITY_REQUEST);
}
@Override
public void onShopAdded(List<Shop> shops) {
onBackPressed();
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.ui.vendor;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.jachdev.commonlibs.base.BaseFragment;
import com.jachdev.commonlibs.widget.CircleImageView;
import com.jachdev.commonlibs.widget.CustomEditText;
import com.jachdev.commonlibs.widget.CustomImageView;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.AddOrgRequest;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.Category;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.Shop;
import com.jachdev.consumerprotection.data.enums.PickerType;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.ui.adapter.CommonAdaptor;
import com.jachdev.consumerprotection.util.Helper;
import com.jachdev.consumerprotection.util.SessionManager;
import com.pd.chocobar.ChocoBar;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class ViewOrgFragment extends BaseFragment {
private static final String TAG = ViewOrgFragment.class.getSimpleName();
@BindView(R.id.iv_logo)
CustomImageView ivLogo;
@BindView(R.id.tv_org_name)
CustomTextView tvOrgName;
@BindView(R.id.recyclerView)
RecyclerView mRecyclerView;
private FragmentEventListener listener;
private AppService service;
private CommonAdaptor<Shop> adaptor;
private List<Shop> shops = new ArrayList<>();
public static Fragment newInstance() {
return new ViewOrgFragment();
}
@Override
protected int layoutRes() {
return R.layout.fragment_view_org;
}
@Override
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
service = AppApplication.getInstance().getAppService();
adaptor = new CommonAdaptor<>(getBaseActivity(), shops, new CommonAdaptor.CommonAdaptorCallback() {
@Override
public void onView(int viewType, int position) {
}
});
mRecyclerView.setLayoutManager(new LinearLayoutManager(getBaseActivity(), LinearLayoutManager.VERTICAL,false));
mRecyclerView.setAdapter(adaptor);
Organization organization = SessionManager.getInstance().getOrganization();
Helper.loadImageByUrl(ivLogo, organization.getLogo());
tvOrgName.setAnyText(organization.getName());
getShops(organization.getId());
}
private void getShops(long id) {
showWaiting();
service.getServer().getShops(id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SingleObserver<AppResponse>() {
@Override
public void onSubscribe(@NotNull Disposable d) {
Log.d(TAG, "onSubscribe: ");
}
@Override
public void onSuccess(@NotNull AppResponse response) {
dismissWaiting();
switch (response.getCode()){
case 0:
List<Shop> shops = Arrays.asList(response.getObjectToType(Shop[].class).clone());
setShops(shops);
break;
default:
showMessage(response.getMessage());
break;
}
}
@Override
public void onError(@NotNull Throwable e) {
showMessage(e.getMessage());
}
});
}
@Override
public void onAttach(Context context) {
listener = (FragmentEventListener) context;
super.onAttach(context);
}
@OnClick(R.id.btnAddShop)
public void onAddShopClick(){
if(listener != null)
listener.onAddShopClick();
}
public void setShops(List<Shop> shops) {
try{
this.shops = shops;
adaptor.setItems(shops);
}catch (Exception e){}
}
public interface FragmentEventListener{
void onAddShopClick();
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ import com.jachdev.consumerprotection.R;
import androidx.annotation.Nullable;
/**
* Created by Asanka on 6/5/2021.
* Created by Tharushaa on 6/5/2021.
*/
public class HeaderView extends FrameLayout {
private CustomTextView tvHeader;
......
package com.jachdev.consumerprotection.util;
import android.graphics.Bitmap;
import android.graphics.RectF;
import java.util.List;
/**
* Generic interface for interacting with different recognition engines.
*/
public interface Classifier {
/**
* An immutable result returned by a Classifier describing what was recognized.
*/
public class Recognition {
/**
* A unique identifier for what has been recognized. Specific to the class, not the instance of
* the object.
*/
private final String id;
/**
* Display name for the recognition.
*/
private final String title;
/**
* A sortable score for how good the recognition is relative to others. Higher should be better.
*/
private final Float confidence;
/** Optional location within the source image for the location of the recognized object. */
private RectF location;
public Recognition(
final String id, final String title, final Float confidence, final RectF location) {
this.id = id;
this.title = title;
this.confidence = confidence;
this.location = location;
}
public String getId() {
return id;
}
public String getTitle() {
return title;
}
public Float getConfidence() {
return confidence;
}
public RectF getLocation() {
return new RectF(location);
}
public void setLocation(RectF location) {
this.location = location;
}
@Override
public String toString() {
String resultString = "";
if (id != null) {
resultString += "[" + id + "] ";
}
if (title != null) {
resultString += title + " ";
}
if (confidence != null) {
resultString += String.format("(%.1f%%) ", confidence * 100.0f);
}
if (location != null) {
resultString += location + " ";
}
return resultString.trim();
}
}
List<Recognition> recognizeImage(Bitmap bitmap);
void enableStatLogging(final boolean debug);
String getStatString();
void close();
}
......@@ -24,7 +24,7 @@ import java.util.Locale;
import id.zelory.compressor.Compressor;
/**
* Created by Asanka on 9/20/2021.
* Created by Tharushaa on 9/20/2021.
*/
public class Helper {
......
package com.jachdev.consumerprotection.util;
/**
*/
public class SensorFilter {
private SensorFilter() {
}
public static float sum(float[] array) {
float retval = 0;
for (int i = 0; i < array.length; i++) {
retval += array[i];
}
return retval;
}
public static float[] cross(float[] arrayA, float[] arrayB) {
float[] retArray = new float[3];
retArray[0] = arrayA[1] * arrayB[2] - arrayA[2] * arrayB[1];
retArray[1] = arrayA[2] * arrayB[0] - arrayA[0] * arrayB[2];
retArray[2] = arrayA[0] * arrayB[1] - arrayA[1] * arrayB[0];
return retArray;
}
public static float norm(float[] array) {
float retval = 0;
for (int i = 0; i < array.length; i++) {
retval += array[i] * array[i];
}
return (float) Math.sqrt(retval);
}
public static float dot(float[] a, float[] b) {
float retval = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
return retval;
}
public static float[] normalize(float[] a) {
float[] retval = new float[a.length];
float norm = norm(a);
for (int i = 0; i < a.length; i++) {
retval[i] = a[i] / norm;
}
return retval;
}
}
......@@ -4,7 +4,6 @@ import android.util.Log;
import com.jachdev.commonlibs.utils.ContextManager;
import com.jachdev.commonlibs.utils.TinyDb;
import com.jachdev.consumerprotection.data.Organization;
import com.jachdev.consumerprotection.data.User;
......
package com.jachdev.consumerprotection.util;
/**
*/
public class StepDetector {
private static final int ACCEL_RING_SIZE = 50;
private static final int VEL_RING_SIZE = 10;
// change this threshold according to your sensitivity preferences
private static final float STEP_THRESHOLD = 50f;
private static final int STEP_DELAY_NS = 250000000;
private int accelRingCounter = 0;
private float[] accelRingX = new float[ACCEL_RING_SIZE];
private float[] accelRingY = new float[ACCEL_RING_SIZE];
private float[] accelRingZ = new float[ACCEL_RING_SIZE];
private int velRingCounter = 0;
private float[] velRing = new float[VEL_RING_SIZE];
private long lastStepTimeNs = 0;
private float oldVelocityEstimate = 0;
private StepListener listener;
public void registerListener(StepListener listener) {
this.listener = listener;
}
public void updateAccel(long timeNs, float x, float y, float z) {
float[] currentAccel = new float[3];
currentAccel[0] = x;
currentAccel[1] = y;
currentAccel[2] = z;
// First step is to update our guess of where the global z vector is.
accelRingCounter++;
accelRingX[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[0];
accelRingY[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[1];
accelRingZ[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[2];
float[] worldZ = new float[3];
worldZ[0] = SensorFilter.sum(accelRingX) / Math.min(accelRingCounter, ACCEL_RING_SIZE);
worldZ[1] = SensorFilter.sum(accelRingY) / Math.min(accelRingCounter, ACCEL_RING_SIZE);
worldZ[2] = SensorFilter.sum(accelRingZ) / Math.min(accelRingCounter, ACCEL_RING_SIZE);
float normalization_factor = SensorFilter.norm(worldZ);
worldZ[0] = worldZ[0] / normalization_factor;
worldZ[1] = worldZ[1] / normalization_factor;
worldZ[2] = worldZ[2] / normalization_factor;
float currentZ = SensorFilter.dot(worldZ, currentAccel) - normalization_factor;
velRingCounter++;
velRing[velRingCounter % VEL_RING_SIZE] = currentZ;
float velocityEstimate = SensorFilter.sum(velRing);
if (velocityEstimate > STEP_THRESHOLD && oldVelocityEstimate <= STEP_THRESHOLD
&& (timeNs - lastStepTimeNs > STEP_DELAY_NS)) {
listener.step(timeNs);
lastStepTimeNs = timeNs;
}
oldVelocityEstimate = velocityEstimate;
}
}
package com.jachdev.consumerprotection.util;
/**
* // Will listen to step alerts
*/
public interface StepListener {
public void step(long timeNs);
}
package com.jachdev.consumerprotection.util;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.os.Trace;
import android.util.Log;
import org.tensorflow.Operation;
import org.tensorflow.contrib.android.TensorFlowInferenceInterface;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Vector;
/** A classifier specialized to label images using TensorFlow. */
public class TensorFlowImageClassifier implements Classifier {
private static final String TAG = TensorFlowImageClassifier.class.getSimpleName();
// Only return this many results with at least this confidence.
private static final int MAX_RESULTS = 3;
private static final float THRESHOLD = 0.1f;
// Config values.
private String inputName;
private String outputName;
private int inputSize;
private int imageMean;
private float imageStd;
// Pre-allocated buffers.
private Vector<String> labels = new Vector<String>();
private int[] intValues;
private float[] floatValues;
private float[] outputs;
private String[] outputNames;
private boolean logStats = false;
private TensorFlowInferenceInterface inferenceInterface;
private TensorFlowImageClassifier() {}
/**
* Initializes a native TensorFlow session for classifying images.
*
* @param assetManager The asset manager to be used to load assets.
* @param modelFilename The filepath of the model GraphDef protocol buffer.
* @param labelFilename The filepath of label file for classes.
* @param inputSize The input size. A square image of inputSize x inputSize is assumed.
* @param imageMean The assumed mean of the image values.
* @param imageStd The assumed std of the image values.
* @param inputName The label of the image input node.
* @param outputName The label of the output node.
* @throws IOException
*/
public static Classifier create(
AssetManager assetManager,
String modelFilename,
String labelFilename,
int inputSize,
int imageMean,
float imageStd,
String inputName,
String outputName) {
TensorFlowImageClassifier c = new TensorFlowImageClassifier();
c.inputName = inputName;
c.outputName = outputName;
// Read the label names into memory.
// TODO(andrewharp): make this handle non-assets.
String actualFilename = labelFilename.split("file:///android_asset/")[1];
Log.i(TAG, "Reading labels from: " + actualFilename);
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(assetManager.open(actualFilename)));
String line;
while ((line = br.readLine()) != null) {
c.labels.add(line);
}
br.close();
} catch (IOException e) {
throw new RuntimeException("Problem reading label file!" , e);
}
c.inferenceInterface = new TensorFlowInferenceInterface(assetManager, modelFilename);
// The shape of the output is [N, NUM_CLASSES], where N is the batch size.
final Operation operation = c.inferenceInterface.graphOperation(outputName);
final int numClasses = (int) operation.output(0).shape().size(1);
Log.i(TAG, "Read " + c.labels.size() + " labels, output layer size is " + numClasses);
// Ideally, inputSize could have been retrieved from the shape of the input operation. Alas,
// the placeholder node for input in the graphdef typically used does not specify a shape, so it
// must be passed in as a parameter.
c.inputSize = inputSize;
c.imageMean = imageMean;
c.imageStd = imageStd;
// Pre-allocate buffers.
c.outputNames = new String[] {outputName};
c.intValues = new int[inputSize * inputSize];
c.floatValues = new float[inputSize * inputSize * 3];
c.outputs = new float[numClasses];
return c;
}
@Override
public List<Recognition> recognizeImage(final Bitmap bitmap) {
// Log this method so that it can be analyzed with systrace.
Trace.beginSection("recognizeImage");
Trace.beginSection("preprocessBitmap");
// Preprocess the image data from 0-255 int to normalized float based
// on the provided parameters.
bitmap.getPixels(intValues, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
for (int i = 0; i < intValues.length; ++i) {
final int val = intValues[i];
floatValues[i * 3 + 0] = (((val >> 16) & 0xFF) - imageMean) / imageStd;
floatValues[i * 3 + 1] = (((val >> 8) & 0xFF) - imageMean) / imageStd;
floatValues[i * 3 + 2] = ((val & 0xFF) - imageMean) / imageStd;
}
Trace.endSection();
// Copy the input data into TensorFlow.
Trace.beginSection("feed");
inferenceInterface.feed(inputName, floatValues, 1, inputSize, inputSize, 3);
Trace.endSection();
// Run the inference call.
Trace.beginSection("run");
inferenceInterface.run(outputNames, logStats);
Trace.endSection();
// Copy the output Tensor back into the output array.
Trace.beginSection("fetch");
inferenceInterface.fetch(outputName, outputs);
Trace.endSection();
// Find the best classifications.
PriorityQueue<Recognition> pq =
new PriorityQueue<Recognition>(
3,
new Comparator<Recognition>() {
@Override
public int compare(Recognition lhs, Recognition rhs) {
// Intentionally reversed to put high confidence at the head of the queue.
return Float.compare(rhs.getConfidence(), lhs.getConfidence());
}
});
for (int i = 0; i < outputs.length; ++i) {
if (outputs[i] > THRESHOLD) {
pq.add(
new Recognition(
"" + i, labels.size() > i ? labels.get(i) : "unknown", outputs[i], null));
}
}
final ArrayList<Recognition> recognitions = new ArrayList<Recognition>();
int recognitionsSize = Math.min(pq.size(), MAX_RESULTS);
for (int i = 0; i < recognitionsSize; ++i) {
recognitions.add(pq.poll());
}
Trace.endSection(); // "recognizeImage"
return recognitions;
}
@Override
public void enableStatLogging(boolean logStats) {
this.logStats = logStats;
}
@Override
public String getStatString() {
return inferenceInterface.getStatString();
}
@Override
public void close() {
inferenceInterface.close();
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checkable="true" android:drawable="@drawable/ic_admin_selected" /> <!-- pressed -->
<item android:state_checked="true" android:drawable="@drawable/ic_admin_selected" /> <!-- focused -->
<item android:state_checkable="true" android:drawable="@drawable/ic_admin" /> <!-- pressed -->
<item android:state_checked="true" android:drawable="@drawable/ic_admin" /> <!-- focused -->
<item android:drawable="@drawable/ic_admin" /> <!-- default -->
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checkable="true" android:drawable="@drawable/ic_consumer_selected" /> <!-- pressed -->
<item android:state_checked="true" android:drawable="@drawable/ic_consumer_selected" /> <!-- focused -->
<item android:drawable="@drawable/ic_consumer" /> <!-- default -->
<item android:state_checkable="true" android:drawable="@drawable/ic_patient" /> <!-- pressed -->
<item android:state_checked="true" android:drawable="@drawable/ic_patient" /> <!-- focused -->
<item android:drawable="@drawable/ic_patient" /> <!-- default -->
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/colorPrimary"/>
<corners android:bottomLeftRadius="100dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checkable="true" android:drawable="@drawable/ic_basket_selected" /> <!-- pressed -->
<item android:state_checked="true" android:drawable="@drawable/ic_basket_selected" /> <!-- focused -->
<item android:drawable="@drawable/ic_basket" /> <!-- default -->
<item android:state_checkable="true" android:drawable="@drawable/ic_doctor" /> <!-- pressed -->
<item android:state_checked="true" android:drawable="@drawable/ic_doctor" /> <!-- focused -->
<item android:drawable="@drawable/ic_doctor" /> <!-- default -->
</selector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="80dp"
android:height="80dp"
android:viewportWidth="474.565"
android:viewportHeight="474.565">
<path
android:fillColor="#ff6601"
android:pathData="M255.204,102.3c-0.606,-11.321 -12.176,-9.395 -23.465,-9.395C240.078,95.126 247.967,98.216 255.204,102.3z"/>
<path
android:fillColor="#ff6601"
android:pathData="M134.524,73.928c-43.825,0 -63.997,55.471 -28.963,83.37c11.943,-31.89 35.718,-54.788 66.886,-63.826C163.921,81.685 150.146,73.928 134.524,73.928z"/>
<path
android:fillColor="#ff6601"
android:pathData="M43.987,148.617c1.786,5.731 4.1,11.229 6.849,16.438L36.44,179.459c-3.866,3.866 -3.866,10.141 0,14.015l25.375,25.383c1.848,1.848 4.38,2.888 7.019,2.888c2.61,0 5.125,-1.04 7.005,-2.888l14.38,-14.404c2.158,1.142 4.55,1.842 6.785,2.827c0,-0.164 -0.016,-0.334 -0.016,-0.498c0,-11.771 1.352,-22.875 3.759,-33.302c-17.362,-11.174 -28.947,-30.57 -28.947,-52.715c0,-34.592 28.139,-62.739 62.723,-62.739c23.418,0 43.637,13.037 54.43,32.084c11.523,-1.429 22.347,-1.429 35.376,1.033c-1.676,-5.07 -3.648,-10.032 -6.118,-14.683l14.396,-14.411c1.878,-1.856 2.918,-4.38 2.918,-7.004c0,-2.625 -1.04,-5.148 -2.918,-7.004l-25.361,-25.367c-1.94,-1.941 -4.472,-2.904 -7.003,-2.904c-2.532,0 -5.063,0.963 -6.989,2.904l-14.442,14.411c-5.217,-2.764 -10.699,-5.078 -16.444,-6.825V9.9c0,-5.466 -4.411,-9.9 -9.893,-9.9h-35.888c-5.451,0 -9.909,4.434 -9.909,9.9v20.359c-5.73,1.747 -11.213,4.061 -16.446,6.825L75.839,22.689c-1.942,-1.941 -4.473,-2.904 -7.005,-2.904c-2.531,0 -5.077,0.963 -7.003,2.896L36.44,48.048c-1.848,1.864 -2.888,4.379 -2.888,7.012c0,2.632 1.04,5.148 2.888,7.004l14.396,14.403c-2.75,5.218 -5.063,10.708 -6.817,16.438H23.675c-5.482,0 -9.909,4.441 -9.909,9.915v35.889c0,5.458 4.427,9.908 9.909,9.908H43.987z"/>
<path
android:fillColor="#ff6601"
android:pathData="M354.871,340.654c15.872,-8.705 26.773,-25.367 26.773,-44.703c0,-28.217 -22.967,-51.168 -51.184,-51.168c-9.923,0 -19.118,2.966 -26.975,7.873c-4.705,18.728 -12.113,36.642 -21.803,52.202C309.152,310.022 334.357,322.531 354.871,340.654z"/>
<path
android:fillColor="#ff6601"
android:pathData="M460.782,276.588c0,-5.909 -4.799,-10.693 -10.685,-10.693H428.14c-1.896,-6.189 -4.411,-12.121 -7.393,-17.75l15.544,-15.544c2.02,-2.004 3.137,-4.721 3.137,-7.555c0,-2.835 -1.118,-5.553 -3.137,-7.563l-27.363,-27.371c-2.08,-2.09 -4.829,-3.138 -7.561,-3.138c-2.734,0 -5.467,1.048 -7.547,3.138l-15.576,15.552c-5.623,-2.982 -11.539,-5.481 -17.751,-7.369v-21.958c0,-5.901 -4.768,-10.685 -10.669,-10.685H311.11c-2.594,0 -4.877,1.04 -6.739,2.578c3.26,11.895 5.046,24.793 5.046,38.552c0,8.735 -0.682,17.604 -1.956,26.423c7.205,-2.656 14.876,-4.324 22.999,-4.324c36.99,0 67.086,30.089 67.086,67.07c0,23.637 -12.345,44.353 -30.872,56.303c13.48,14.784 24.195,32.324 31.168,51.976c1.148,0.396 2.344,0.684 3.54,0.684c2.733,0 5.467,-1.04 7.563,-3.13l27.379,-27.371c2.004,-2.004 3.106,-4.721 3.106,-7.555s-1.102,-5.551 -3.106,-7.563l-15.576,-15.552c2.982,-5.621 5.497,-11.555 7.393,-17.75h21.957c2.826,0 5.575,-1.118 7.563,-3.138c2.004,-1.996 3.138,-4.72 3.138,-7.555L460.782,276.588z"/>
<path
android:fillColor="#ff6601"
android:pathData="M376.038,413.906c-16.602,-48.848 -60.471,-82.445 -111.113,-87.018c-16.958,17.958 -37.954,29.351 -61.731,29.351c-23.759,0 -44.771,-11.392 -61.713,-29.351c-50.672,4.573 -94.543,38.17 -111.145,87.026l-9.177,27.013c-2.625,7.773 -1.368,16.338 3.416,23.007c4.783,6.671 12.486,10.631 20.685,10.631h315.853c8.215,0 15.918,-3.96 20.702,-10.631c4.767,-6.669 6.041,-15.234 3.4,-23.007L376.038,413.906z"/>
<path
android:fillColor="#ff6601"
android:pathData="M120.842,206.782c0,60.589 36.883,125.603 82.352,125.603c45.487,0 82.368,-65.014 82.368,-125.603C285.563,81.188 120.842,80.939 120.842,206.782z"/>
</vector>
<?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"
android:orientation="vertical"
android:gravity="center"
android:layout_margin="@dimen/medium"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.jachdev.commonlibs.widget.CustomEditText
android:id="@+id/et_weight"
android:layout_marginTop="@dimen/medium"
style="@style/EditText"
android:hint="@string/weight"
android:inputType="numberDecimal"
app:fontType="@string/font_para"
app:layout_constraintTop_toBottomOf="@+id/headerView" />
<com.jachdev.commonlibs.widget.CustomEditText
android:id="@+id/et_height"
android:layout_marginTop="@dimen/medium"
style="@style/EditText"
android:hint="@string/height"
android:inputType="numberDecimal"
app:fontType="@string/font_para"
app:layout_constraintTop_toBottomOf="@+id/headerView" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tv_steps"
android:textSize="32sp"
android:layout_margin="@dimen/medium"
style="@style/TextView" />
<Button
android:id="@+id/btn_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start Pedometer"
/>
<Button
android:id="@+id/btn_stop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Stop Pedometer"
/>
<com.jachdev.commonlibs.widget.CustomTextView
android:textSize="16sp"
android:text="Calories burned per minute: "
android:layout_margin="@dimen/medium"
style="@style/TextView" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tv_count"
android:textSize="32sp"
android:layout_margin="@dimen/medium"
style="@style/TextView" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e0e0e0"
tools:context="com.samuel.smartgallery.smartgallery.ClassifierActivity">
<ImageView
android:id="@+id/imageView1"
android:layout_width="220dip"
android:layout_marginTop="30dip"
android:layout_height="320dip"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/textView1"
android:layout_below="@id/imageView1"
android:layout_width="wrap_content"
android:layout_marginTop="5dip"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
android:text="Choose a picture from your gallery to analyse it"/>
<Button
android:id="@+id/selectPhoto"
android:layout_below="@id/imageView1"
android:layout_marginTop="50dip"
android:layout_width="160dip"
android:layout_height="50dip"
android:layout_gravity="bottom|center"
android:text="select Photo"
android:onClick="selectPhoto"
android:textAllCaps="false"
android:layout_alignParentTop="false"
android:layout_centerHorizontal="true"
android:theme="@style/Button"
android:textColor="#ffffff"/>
</RelativeLayout>
\ No newline at end of file
......@@ -4,15 +4,12 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.vendor.VendorActivity">
tools:context=".ui.calories.ExercisesSuggeserActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:scrollbars="vertical"
android:id="@+id/recyclerView" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".ui.vendor.VendorActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".ui.home.HomeFragment">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/medium"
android:orientation="vertical">
<FrameLayout
android:id="@+id/btn_add_logo"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:layout_margin="@dimen/medium">
<com.jachdev.commonlibs.widget.CircleImageView
android:id="@+id/iv_logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_circle" />
<com.jachdev.commonlibs.widget.CustomTextView
style="@style/TextView"
android:layout_gravity="center"
android:layout_marginTop="@dimen/medium"
android:text="@string/add_logo"
android:textSize="12sp"
app:fontType="@string/font_para_light" />
</FrameLayout>
<com.jachdev.commonlibs.widget.CustomEditText
android:id="@+id/et_organization_name"
style="@style/EditText"
android:hint="@string/organization_name"
android:inputType="textPersonName|textCapWords"
app:fontType="@string/font_para"
app:layout_constraintTop_toBottomOf="@+id/headerView" />
<com.jachdev.commonlibs.widget.CustomEditText
android:id="@+id/et_description"
style="@style/EditTextMultiline"
android:hint="@string/description"
app:fontType="@string/font_para"
app:layout_constraintTop_toBottomOf="@+id/headerView" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/et_organization_type"
style="@style/EditText"
android:layout_marginTop="@dimen/low"
android:focusable="true"
android:clickable="true"
android:gravity="center|start"
android:hint="@string/organization_type"
android:inputType="textPersonName|textCapWords"
app:fontType="@string/font_para"
app:layout_constraintTop_toBottomOf="@+id/headerView" />
<com.jachdev.commonlibs.widget.CustomButton
android:id="@+id/btn_submit"
android:layout_marginTop="@dimen/medium"
app:fontType="@string/font_para"
android:text="@string/submit"
style="@style/Button"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/customTextView"
style="@style/TextView"
android:layout_margin="@dimen/medium"
android:text="@string/please_add_shop_details"
app:fontType="@string/font_para"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.jachdev.commonlibs.widget.CustomEditText
android:id="@+id/et_name"
style="@style/EditText"
android:layout_marginStart="@dimen/medium"
android:layout_marginTop="@dimen/medium"
android:layout_marginEnd="@dimen/medium"
android:hint="@string/shop_name"
android:inputType="textPersonName|textCapWords"
app:fontType="@string/font_para"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customTextView" />
<com.jachdev.commonlibs.widget.CustomEditText
android:id="@+id/et_phone"
style="@style/EditText"
android:layout_marginStart="@dimen/medium"
android:layout_marginTop="@dimen/medium"
android:layout_marginEnd="@dimen/medium"
android:hint="@string/phone_number"
android:inputType="phone"
app:fontType="@string/font_para"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_name" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/et_address"
style="@style/EditText"
android:layout_marginStart="@dimen/medium"
android:layout_marginTop="@dimen/medium"
android:layout_marginEnd="@dimen/medium"
android:clickable="true"
android:focusable="true"
android:gravity="center|start"
android:lines="4"
android:maxLines="4"
android:hint="@string/shop_address"
android:inputType="textMultiLine"
app:fontType="@string/font_para"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_phone" />
<com.jachdev.commonlibs.widget.CustomButton
android:id="@+id/btn_submit"
style="@style/Button"
android:layout_margin="@dimen/medium"
android:text="@string/submit"
app:fontType="@string/font_para"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -30,7 +30,7 @@
style="@style/TextView"
android:layout_margin="@dimen/medium"
android:layout_weight="1"
android:text="@string/asanka_sandaruwan"
android:text="@string/Tharushaa_sandaruwan"
app:fontType="@string/font_para_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customTextView3" />
......@@ -109,7 +109,7 @@
android:layout_weight="1"
android:autoLink="email"
android:clickable="true"
android:text="asanka@gmail.com \n uditha@gmail.com \n nelush@gmail.com"
android:text="Tharushaa@gmail.com \n uditha@gmail.com \n nelush@gmail.com"
app:fontType="@string/font_para_light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customTextView7" />
......
......@@ -30,148 +30,40 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/btn_add_org"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="@dimen/medium"
android:elevation="@dimen/default_radius"
android:background="@drawable/bg_side_curve_layout"
app:layout_constraintTop_toBottomOf="@+id/tv_header">
<com.jachdev.commonlibs.widget.CustomTextView
app:fontType="@string/font_para"
android:text="@string/add_organization"
android:textSize="24sp"
android:layout_margin="@dimen/medium"
style="@style/TextView" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/medium"
android:src="@drawable/ic_corporation"/>
</FrameLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_add_org">
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_header">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="50dp"
android:orientation="vertical"
android:visibility="visible">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/view_org"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="@dimen/medium"
android:background="@drawable/bg_side_curve_layout"
android:elevation="@dimen/default_radius"
android:orientation="horizontal">
<com.jachdev.commonlibs.widget.CircleImageView
android:id="@+id/iv_logo"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="start|top"
android:layout_margin="@dimen/low"
android:src="@drawable/ic_corporation" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tv_org_name"
style="@style/TextView"
android:layout_marginTop="@dimen/low"
android:layout_marginBottom="@dimen/low"
android:maxLines="2"
android:textSize="24sp"
app:fontType="@string/font_para" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tv_org_description"
style="@style/TextView"
android:layout_marginEnd="@dimen/low"
android:layout_marginBottom="@dimen/low"
android:maxLines="4"
app:fontType="@string/font_para_light" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.jachdev.commonlibs.widget.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/low"
android:textColor="@color/colorPrimaryText"
android:textSize="@dimen/font_size_medium"
android:text="@string/sales_prediction"
app:fontType="@string/font_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewSales"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/low"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:spanCount="2"
tools:listitem="@layout/item_prediction" />
<com.jachdev.commonlibs.widget.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/low"
android:textColor="@color/colorPrimaryText"
android:textSize="@dimen/font_size_medium"
android:text="@string/price_prediction"
app:fontType="@string/font_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewPrice"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/low"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:spanCount="2"
tools:listitem="@layout/item_prediction" />
<com.jachdev.commonlibs.widget.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/low"
android:textColor="@color/colorPrimaryText"
android:textSize="@dimen/font_size_medium"
android:text="@string/import_prediction"
app:fontType="@string/font_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewImport"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/low"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:spanCount="2"
tools:listitem="@layout/item_prediction" />
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium"
android:orientation="vertical">
<com.jachdev.commonlibs.widget.CustomButton
android:id="@+id/btn_image_rec"
android:layout_marginTop="@dimen/medium"
app:fontType="@string/font_para"
android:text="Image Recognition"
style="@style/Button"/>
<com.jachdev.commonlibs.widget.CustomButton
android:id="@+id/btn_calorie_count"
android:layout_marginTop="@dimen/medium"
app:fontType="@string/font_para"
android:text="Calorie Counter"
style="@style/Button"/>
<com.jachdev.commonlibs.widget.CustomButton
android:id="@+id/btn_meal_plan"
android:layout_marginTop="@dimen/medium"
app:fontType="@string/font_para"
android:text="Meal Plan"
style="@style/Button"/>
</androidx.appcompat.widget.LinearLayoutCompat>
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/medium">
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/et_category_type"
style="@style/EditText"
android:layout_margin="@dimen/medium"
android:clickable="true"
android:focusable="true"
android:gravity="center|start"
android:hint="@string/category_type"
android:inputType="textPersonName|textCapWords"
app:fontType="@string/font_para"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/et_sub_category"
style="@style/EditText"
android:layout_margin="@dimen/medium"
android:clickable="true"
android:focusable="true"
android:gravity="center|start"
android:hint="@string/sub_category_type"
android:inputType="textPersonName|textCapWords"
android:visibility="gone"
app:fontType="@string/font_para"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_category_type" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvYAxisLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium"
android:layout_marginStart="@dimen/medium"
app:fontType="@string/font_para_extra_light"
android:text="YAxis"
app:layout_constraintBottom_toTopOf="@+id/chart"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_sub_category" />
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginStart="@dimen/medium"
android:layout_marginEnd="@dimen/medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvYAxisLabel" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvXAxisLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/medium"
android:text="XAxis"
app:fontType="@string/font_para_extra_light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chart" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvSV"
style="@style/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium"
android:gravity="center"
android:text="@string/seasonal_variation"
android:textSize="24sp"
app:fontType="@string/font_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chart" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvYAxisLabel2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium"
android:layout_marginStart="@dimen/medium"
app:fontType="@string/font_para_extra_light"
android:text="YAxis"
app:layout_constraintBottom_toTopOf="@+id/pieChart"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvSV" />
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/pieChart"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginStart="@dimen/medium"
android:layout_marginEnd="@dimen/medium"
app:layout_constraintTop_toBottomOf="@+id/tvYAxisLabel2" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvXAxisLabel2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:text="XAxis"
app:fontType="@string/font_para_extra_light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pieChart" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/low"
android:padding="@dimen/low"
android:background="@drawable/bg_prediction_card"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Milk"
android:textColor="@color/white"
android:textSize="@dimen/font_size_medium"
app:fontType="@string/font_header"
app:layout_constraintEnd_toStartOf="@+id/customTextView10"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/customTextView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Current prediction rate: "
android:textColor="@color/white"
android:textSize="8sp"
app:fontType="@string/font_para"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/low"
android:text="Rs 150"
android:textColor="@color/white"
android:textSize="24sp"
app:fontType="@string/font_header"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customTextView10" />
<com.jachdev.commonlibs.widget.CustomTextView
android:id="@+id/tvMinMax"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/min_max_ratio_10_100"
android:padding="@dimen/low"
android:textColor="@color/white"
android:textSize="12sp"
app:fontType="@string/font_para"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvValue" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -21,12 +21,13 @@
android:maxLines="2"
android:padding="@dimen/medium"
android:text="@string/app_name"
android:textAlignment="textEnd"
android:textAlignment="center"
android:textColor="@color/colorAccent"
android:textSize="35sp"
app:fontType="@string/font_header"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/iv_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/iv_header" />
</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"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightLarge"
android:layout_margin="@dimen/low"
android:background="@drawable/bg_top_header">
<ImageView
android:id="@+id/imageView"
android:src="@color/cl_white"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:contentDescription="Icon" />
<TextView
android:id="@+id/textView"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toEndOf="@id/imageView"
android:layout_toRightOf="@id/imageView"
android:gravity="center_vertical"
android:textSize="16sp"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#ff6601</color>
<color name="colorPrimary">#0288D1</color>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="purple_200">#40C4FF</color>
<color name="purple_500">#00B0FF</color>
<color name="purple_700">#0091EA</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="colorPrimaryDark">#c43300</color>
<color name="colorPrimaryDark">#00507C</color>
<color name="colorAccent">#FFFFFF</color>
<color name="colorAccentVariant">#B88476</color>
<color name="colorAccentVariant">#00B8D4</color>
<color name="whiteTwo">#FFFFFF</color>
<color name="colorPrimaryText">@color/colorPrimary</color>
<color name="colorPrimaryTextAccent">@color/colorAccent</color>
......
<resources>
<string name="app_name">Consumer Protection</string>
<string name="app_name">Mobile Health Monitor</string>
<string name="font_header">fonts/Montserrat-Bold.ttf</string>
<string name="font_Sub_header">fonts/Montserrat-Medium.ttf</string>
......@@ -63,7 +63,7 @@
<string name="category_type">Category - %s</string>
<string name="sub_category_type">Sub Category - %s</string>
<string name="title">Title</string>
<string name="asanka_sandaruwan">Asanka Sandaruwan</string>
<string name="Tharushaa_sandaruwan">Tharushaa Sandaruwan</string>
<string name="uditha_kariyawasam">Uditha Kariyawasam</string>
<string name="nelushi_nitara">Nelushi Nitara</string>
<string name="email_us">Email Us</string>
......@@ -74,4 +74,6 @@
<string name="min_max_ratio_10_100">Min/Max Ratio: %s ~ %s</string>
<string name="_947">+947########</string>
<string name="enter_6_digit_pin">Enter 6 digit pin</string>
<string name="weight">Weight (kg)</string>
<string name="height">Height (m)</string>
</resources>
\ No newline at end of file
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