From db8c2174bf712cb5b98a794f7176ac818ecc8142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Sat, 27 Apr 2019 18:09:34 +0300 Subject: [PATCH] added photo, fixes cor error --- MyCity/app/build.gradle | 5 +- MyCity/app/src/main/AndroidManifest.xml | 16 +- .../gq/yigit/mycity/DenunciationFragment.java | 66 +- .../java/gq/yigit/mycity/MainActivity.java | 5 + .../main/java/gq/yigit/mycity/QRFragment.java | 5 +- .../main/java/gq/yigit/mycity/TakePhoto.java | 67 + .../yigit/mycity/tools/QRCodeGenerator.java | 51 +- .../mycity/utility/UtilityElectricity.java | 58 + .../gq/yigit/mycity/utility/UtilityWater.java | 58 + .../main/res/layout/activity_take_photo.xml | 29 + .../src/main/res/layout/fragment_utility.xml | 2 +- .../layout/fragment_utility_electricity.xml | 12 +- .../res/layout/fragment_utility_water.xml | 12 +- MyCity/build.gradle | 1 + .../interface/UserData/denunciation_map.html | 4 +- client_side/interface/UserData/qr_info.html | 14 +- client_side/interface/UserData/ratings.html | 6 +- .../interface/UserData/voting_results.html | 7 +- client_side/modules/qr/user_data.py | 12 +- server_side/api/modules/SpotSelector.py | 56 + .../__pycache__/denunciation.cpython-37.pyc | Bin 2350 -> 2870 bytes .../__pycache__/navigation.cpython-37.pyc | Bin 9865 -> 9932 bytes .../__pycache__/rating_system.cpython-37.pyc | Bin 3161 -> 3361 bytes .../__pycache__/utility.cpython-37.pyc | Bin 1221 -> 1927 bytes .../__pycache__/voting_system.cpython-37.pyc | Bin 3445 -> 3643 bytes server_side/api/modules/createData.py | 1 + server_side/api/modules/databases/bus.json | 33960 ++++++++++------ .../api/modules/databases/locations.json | 1 + .../api/modules/databases/park_data.json | 3 + server_side/api/modules/databases/users.json | 28 +- server_side/api/modules/denunciation.py | 20 +- .../{alternateSolution1.py => detectSpots.py} | 54 +- server_side/api/modules/navigation.py | 12 +- server_side/api/modules/parking_images/1.jpg | Bin 0 -> 253975 bytes server_side/api/modules/parking_images/2.jpg | Bin 0 -> 247250 bytes server_side/api/modules/parking_images/3.jpg | Bin 0 -> 230357 bytes server_side/api/modules/parking_images/4.jpg | Bin 0 -> 230805 bytes server_side/api/modules/parking_images/5.jpg | Bin 0 -> 258950 bytes server_side/api/modules/parking_images/6.jpg | Bin 0 -> 241459 bytes server_side/api/modules/parking_images/7.jpg | Bin 0 -> 309364 bytes server_side/api/modules/parking_images/8.jpg | Bin 0 -> 282688 bytes .../api/modules/parking_images/main.jpg | Bin 0 -> 254119 bytes server_side/api/modules/rating_system.py | 16 +- server_side/api/modules/utility.py | 6 +- server_side/api/modules/voting_system.py | 13 +- 45 files changed, 23025 insertions(+), 11575 deletions(-) create mode 100644 MyCity/app/src/main/java/gq/yigit/mycity/TakePhoto.java create mode 100644 MyCity/app/src/main/res/layout/activity_take_photo.xml create mode 100644 server_side/api/modules/SpotSelector.py create mode 100644 server_side/api/modules/createData.py create mode 100644 server_side/api/modules/databases/locations.json create mode 100644 server_side/api/modules/databases/park_data.json rename server_side/api/modules/{alternateSolution1.py => detectSpots.py} (80%) create mode 100644 server_side/api/modules/parking_images/1.jpg create mode 100644 server_side/api/modules/parking_images/2.jpg create mode 100644 server_side/api/modules/parking_images/3.jpg create mode 100644 server_side/api/modules/parking_images/4.jpg create mode 100644 server_side/api/modules/parking_images/5.jpg create mode 100644 server_side/api/modules/parking_images/6.jpg create mode 100644 server_side/api/modules/parking_images/7.jpg create mode 100644 server_side/api/modules/parking_images/8.jpg create mode 100644 server_side/api/modules/parking_images/main.jpg diff --git a/MyCity/app/build.gradle b/MyCity/app/build.gradle index 305382f..f10314f 100644 --- a/MyCity/app/build.gradle +++ b/MyCity/app/build.gradle @@ -10,6 +10,7 @@ android { versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" android.defaultConfig.vectorDrawables.useSupportLibrary = true + multiDexEnabled true } buildTypes { release { @@ -20,9 +21,11 @@ android { } dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') api 'cz.msebera.android:httpclient:4.4.1.2' - implementation 'com.google.zxing:core:3.2.0' + implementation 'com.github.chathuralakmal:AndroidImagePopup:1.2.1' + implementation 'com.journeyapps:zxing-android-embedded:3.6.0' implementation 'com.jjoe64:graphview:4.2.2' implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:appcompat-v7:27.0.0' diff --git a/MyCity/app/src/main/AndroidManifest.xml b/MyCity/app/src/main/AndroidManifest.xml index 49ce08d..100719a 100644 --- a/MyCity/app/src/main/AndroidManifest.xml +++ b/MyCity/app/src/main/AndroidManifest.xml @@ -1,8 +1,14 @@ - - + + + + + + + + + + + android:screenOrientation="portrait" + android:theme="@style/AppTheme.NoActionBar"> diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/DenunciationFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/DenunciationFragment.java index 6044b01..1830869 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/DenunciationFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/DenunciationFragment.java @@ -2,6 +2,7 @@ package gq.yigit.mycity; import android.Manifest; import android.app.Dialog; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -28,6 +29,7 @@ import org.json.JSONObject; import java.io.ByteArrayOutputStream; import java.io.File; +import java.net.URI; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -49,7 +51,9 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons private EditText note; private Bitmap img; private ImageButton img_button; - private static final int CAMERA_REQUEST = 1888; + private static final int CAMERA_REQUEST = 100; + + private Uri mImageUri; public DenunciationFragment() { } @@ -72,23 +76,25 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons + + View rootView = inflater.inflate(R.layout.fragment_denunciation, container, false); FileActions file_manager = new FileActions(); url = file_manager.readFromFile(getContext(),"server.config").trim(); activity=this; - - submit = rootView.findViewById(R.id.denunciation_submit); note = (EditText) rootView.findViewById(R.id.denunciation_text); img_button= rootView.findViewById(R.id.denunciation_photo); spinner = rootView.findViewById(R.id.denunciation_spinner); if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { - img_button.setEnabled(false); ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); } + + + submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -117,14 +123,27 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons request.execute(); } }); - img_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - - Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); - startActivityForResult(cameraIntent, CAMERA_REQUEST); - + File photo; + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + + try + { + // place where to store camera taken picture + photo = createTemporaryFile("picture", ".jpg"); + photo.delete(); + Uri mImageUri = Uri.fromFile(photo); + } + catch(Exception e) + { + Log.v("[ERROR]", "Can't create file to take picture!"); + Toast.makeText(getContext(), "Please check SD card! Image shot is impossible!", Toast.LENGTH_LONG); + } + intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); + //start camera intent + activity.startActivityForResult(intent, CAMERA_REQUEST); } }); @@ -158,6 +177,17 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons } } + private File createTemporaryFile(String part, String ext) throws Exception + { + File tempDir= Environment.getExternalStorageDirectory(); + tempDir=new File(tempDir.getAbsolutePath()+"/.temp/"); + if(!tempDir.exists()) + { + tempDir.mkdirs(); + } + return File.createTempFile(part, ext, tempDir); + } + @Override public void onAttach(Context context) { super.onAttach(context); @@ -232,6 +262,20 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons } + //called after camera intent finished + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) + { + //MenuShootImage is user defined menu option to shoot image + if(requestCode==CAMERA_REQUEST && resultCode==RESULT_OK) + { + Bitmap photo = (Bitmap) data.getExtras().get("data"); + img = photo; + } + super.onActivityResult(requestCode, resultCode, data); + } + + @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == 0) { @@ -242,8 +286,4 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons } } - - - - } diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java index bec9a85..cb6c4d0 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java @@ -4,10 +4,12 @@ import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.design.widget.NavigationView.OnNavigationItemSelectedListener; import android.support.v4.app.ActivityCompat; import android.support.v4.app.FragmentManager; @@ -102,6 +104,7 @@ public class MainActivity extends AppCompatActivity transaction.replace(R.id.app_bar_main, fragment); transaction.addToBackStack(null); transaction.commit(); + Log.d("[BOOKMARK]","Done with main"); } @@ -247,4 +250,6 @@ public class MainActivity extends AppCompatActivity Log.e("[ERROR]","Cannot set avatar!"); } } + + } diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/QRFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/QRFragment.java index 55e58a1..afd6d0f 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/QRFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/QRFragment.java @@ -12,8 +12,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import com.google.zxing.WriterException; +import com.google.zxing.WriterException; import org.json.JSONException; import gq.yigit.mycity.tools.QRCodeGenerator; @@ -46,8 +46,9 @@ public class QRFragment extends Fragment { Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_qr, container, false); qr_view = rootView.findViewById(R.id.qr_image); + try { - qr_img = QRCodeGenerator.Generate(MainActivity.userData.getString("id"),429,429); + qr_img = QRCodeGenerator.Generate(MainActivity.userData.getString("id"),1080,1080); qr_view.setImageBitmap(qr_img); }catch(JSONException e){ Log.e("[ERROR]","JSON error occured while generating qr code!"); diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/TakePhoto.java b/MyCity/app/src/main/java/gq/yigit/mycity/TakePhoto.java new file mode 100644 index 0000000..766b739 --- /dev/null +++ b/MyCity/app/src/main/java/gq/yigit/mycity/TakePhoto.java @@ -0,0 +1,67 @@ +package gq.yigit.mycity; + +import android.Manifest; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.provider.MediaStore; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; + +public class TakePhoto extends AppCompatActivity { + + + private Button takePictureButton; + private ImageView imageView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_take_photo); + + takePictureButton = (Button) findViewById(R.id.button_image); + imageView = (ImageView) findViewById(R.id.imageview); + + if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { + takePictureButton.setEnabled(false); + ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + if (requestCode == 0) { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED + && grantResults[1] == PackageManager.PERMISSION_GRANTED) { + takePictureButton.setEnabled(true); + } + } + } + + public void takePicture(View view) { + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + + startActivityForResult(intent, 100); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == 100) { + Log.d("[BOOKMARK]","Actvitity resulted"); + if (resultCode == RESULT_OK) { + if (data == null) { + Log.d("[BOOKMARK]","Received image"); + // TODO Do something with the full image stored + // in outputFileUri. Perhaps copying it to the app folder + } + } + } + } + +} diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/tools/QRCodeGenerator.java b/MyCity/app/src/main/java/gq/yigit/mycity/tools/QRCodeGenerator.java index f78c034..44bc4fa 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/tools/QRCodeGenerator.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/tools/QRCodeGenerator.java @@ -3,7 +3,6 @@ package gq.yigit.mycity.tools; import android.graphics.Bitmap; import android.graphics.Color; import android.net.Uri; - import com.google.zxing.BarcodeFormat; import com.google.zxing.MultiFormatWriter; import com.google.zxing.WriterException; @@ -16,30 +15,30 @@ import static android.graphics.Color.BLACK; import static android.graphics.Color.WHITE; public class QRCodeGenerator { - public static Bitmap Generate(String data, int height,int width) throws WriterException { - - BitMatrix result; - try { - result = new MultiFormatWriter().encode(data, - BarcodeFormat.QR_CODE, width, height, null); - } catch (IllegalArgumentException iae) { - // Unsupported format - return null; - } - - int w = result.getWidth(); - int h = result.getHeight(); - int[] pixels = new int[w * h]; - for (int y = 0; y < h; y++) { - int offset = y * w; - for (int x = 0; x < w; x++) { - pixels[offset + x] = result.get(x, y) ? BLACK : WHITE; - } - } - - Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); - bitmap.setPixels(pixels, 0, w, 0, 0, w, h); - return bitmap; - } + public static Bitmap Generate(String data, int height,int width) throws WriterException { + + BitMatrix result; + try { + result = new MultiFormatWriter().encode(data, + BarcodeFormat.QR_CODE, width, height, null); + } catch (IllegalArgumentException iae) { + // Unsupported format + return null; + } + + int w = result.getWidth(); + int h = result.getHeight(); + int[] pixels = new int[w * h]; + for (int y = 0; y < h; y++) { + int offset = y * w; + for (int x = 0; x < w; x++) { + pixels[offset + x] = result.get(x, y) ? BLACK : WHITE; + } + } + + Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); + bitmap.setPixels(pixels, 0, w, 0, 0, w, h); + return bitmap; + } } diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityElectricity.java b/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityElectricity.java index 32f7ca9..df47478 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityElectricity.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityElectricity.java @@ -1,7 +1,9 @@ package gq.yigit.mycity.utility; import android.content.Context; +import android.graphics.Bitmap; import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -10,6 +12,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; +import com.ceylonlabs.imageviewpopup.ImagePopup; +import com.google.zxing.WriterException; import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.helper.StaticLabelsFormatter; import com.jjoe64.graphview.series.DataPoint; @@ -17,6 +24,7 @@ import com.jjoe64.graphview.series.LineGraphSeries; import gq.yigit.mycity.MainActivity; import gq.yigit.mycity.R; import gq.yigit.mycity.tools.FileActions; +import gq.yigit.mycity.tools.QRCodeGenerator; import gq.yigit.mycity.tools.WebRequest; import org.json.JSONException; import org.json.JSONObject; @@ -29,6 +37,14 @@ public class UtilityElectricity extends Fragment implements WebRequest.responseL private JSONObject electricityUsage; private GraphView graph; + private TextView bill; + private TextView points; + private TextView efficiency; + + private Button qr_view; + private Button pay_bill; + + private OnFragmentInteractionListener mListener; public UtilityElectricity() { @@ -54,6 +70,44 @@ public class UtilityElectricity extends Fragment implements WebRequest.responseL View rootView = inflater.inflate(R.layout.fragment_utility_electricity, container, false);; graph = (GraphView) rootView.findViewById(R.id.utility_graph); + points = rootView.findViewById(R.id.points_utility_electricity); + bill = rootView.findViewById(R.id.bill_utility_electricity); + efficiency = rootView.findViewById(R.id.efficiency_utility_electricity); + + pay_bill = rootView.findViewById(R.id.pay_bill_electricity); + qr_view = rootView.findViewById(R.id.use_point_electricity); + + pay_bill.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(getContext(),"Bills paid successfully!",Toast.LENGTH_LONG).show(); + } + }); + + + + final ImagePopup imagePopup = new ImagePopup(getContext()); + imagePopup.setWindowHeight(712); // Optional + imagePopup.setWindowWidth(712); // Optional + imagePopup.setBackgroundColor(Color.WHITE); // Optional + imagePopup.setFullScreen(true); // Optional + imagePopup.setImageOnClickClose(true); // Optional + try { + imagePopup.initiatePopup(new BitmapDrawable(QRCodeGenerator.Generate(MainActivity.userData.getString("id"), 712, 712))); + }catch (JSONException e){ + Log.e("[ERROR]","Cannot get user id"); + }catch (WriterException e){ + Log.e("[ERROR]","Writer exception occured"); + } + + qr_view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + imagePopup.viewPopup(); + + } + }); + StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph); staticLabelsFormatter.setHorizontalLabels(new String[] {"0", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24"}); @@ -130,6 +184,10 @@ public class UtilityElectricity extends Fragment implements WebRequest.responseL graph.addSeries(series); graph.addSeries(series2); + points.setText(String.valueOf(((Double)electricityUsage.get("points")).intValue())); + bill.setText(String.valueOf(((Double)electricityUsage.get("bill")).intValue())); + efficiency.setText(String.valueOf(((Double)electricityUsage.get("efficiency")).intValue())); + }catch (JSONException e){ Log.e("[ERROR]","Cannot interpret response from electric service"); } diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityWater.java b/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityWater.java index 8258f15..a6ed684 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityWater.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityWater.java @@ -1,7 +1,9 @@ package gq.yigit.mycity.utility; import android.content.Context; +import android.graphics.Bitmap; import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -10,6 +12,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; +import com.ceylonlabs.imageviewpopup.ImagePopup; +import com.google.zxing.WriterException; import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.helper.StaticLabelsFormatter; import com.jjoe64.graphview.series.DataPoint; @@ -17,6 +24,7 @@ import com.jjoe64.graphview.series.LineGraphSeries; import gq.yigit.mycity.MainActivity; import gq.yigit.mycity.R; import gq.yigit.mycity.tools.FileActions; +import gq.yigit.mycity.tools.QRCodeGenerator; import gq.yigit.mycity.tools.WebRequest; import org.json.JSONException; import org.json.JSONObject; @@ -29,6 +37,14 @@ public class UtilityWater extends Fragment implements WebRequest.responseListene private JSONObject waterUsage; private GraphView graph; + private TextView bill; + private TextView points; + private TextView efficiency; + + private Button qr_view; + private Button pay_bill; + + private OnFragmentInteractionListener mListener; public UtilityWater() { @@ -54,6 +70,43 @@ public class UtilityWater extends Fragment implements WebRequest.responseListene View rootView = inflater.inflate(R.layout.fragment_utility_water, container, false);; graph = (GraphView) rootView.findViewById(R.id.utility_graph); + points = rootView.findViewById(R.id.points_utility_water); + bill = rootView.findViewById(R.id.bill_utility_water); + efficiency = rootView.findViewById(R.id.efficiency_utility_water); + + pay_bill = rootView.findViewById(R.id.pay_bill_water); + qr_view = rootView.findViewById(R.id.use_point_water); + + pay_bill.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(getContext(),"Bills paid successfully!",Toast.LENGTH_LONG).show(); + } + }); + + final ImagePopup imagePopup = new ImagePopup(getContext()); + imagePopup.setWindowHeight(712); // Optional + imagePopup.setWindowWidth(712); // Optional + imagePopup.setBackgroundColor(Color.WHITE); // Optional + imagePopup.setFullScreen(true); // Optional + imagePopup.setImageOnClickClose(true); // Optional + try { + imagePopup.initiatePopup(new BitmapDrawable(QRCodeGenerator.Generate(MainActivity.userData.getString("id"), 712, 712))); + }catch (JSONException e){ + Log.e("[ERROR]","Cannot get user id"); + }catch (WriterException e){ + Log.e("[ERROR]","Writer exception occured"); + } + + qr_view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + imagePopup.viewPopup(); + + } + }); + + StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph); staticLabelsFormatter.setHorizontalLabels(new String[] {"0", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24"}); @@ -123,6 +176,7 @@ public class UtilityWater extends Fragment implements WebRequest.responseListene true, 100); } + series.setTitle("ideal"); series.setColor(Color.BLUE); series2.setTitle("usage"); @@ -130,6 +184,10 @@ public class UtilityWater extends Fragment implements WebRequest.responseListene graph.addSeries(series); graph.addSeries(series2); + points.setText(String.valueOf(((Double)waterUsage.get("points")).intValue())); + bill.setText(String.valueOf(((Double)waterUsage.get("bill")).intValue())); + efficiency.setText(String.valueOf(((Double)waterUsage.get("efficiency")).intValue())); + }catch (JSONException e){ Log.e("[ERROR]","Cannot interpret response from water service"); } diff --git a/MyCity/app/src/main/res/layout/activity_take_photo.xml b/MyCity/app/src/main/res/layout/activity_take_photo.xml new file mode 100644 index 0000000..6ca7d93 --- /dev/null +++ b/MyCity/app/src/main/res/layout/activity_take_photo.xml @@ -0,0 +1,29 @@ + + + + + + +