diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 3b79f8dfd6c7e0b365408fc6302383ae507d17cb..1a142b2cc4de6a6e20b2401ed6792e8c6d044015 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -3,6 +3,7 @@ <option name="myName" value="Project Default" /> <inspection_tool class="AndroidLintExtraText" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="AndroidLintGradleCompatible" enabled="false" level="ERROR" enabled_by_default="false" /> + <inspection_tool class="AndroidLintNotSibling" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" /> diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 9dcbf9ed32e2816a1b59e0ba015f4b6dcc13ed8f..1b0a0f237b0b9e0022f87165caf90cc6885c45a8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,5 +30,4 @@ dependencies { compile 'com.android.support:design:23.1.1' compile 'com.android.support:recyclerview-v7:23.1.1' compile 'com.android.support:cardview-v7:23.1.1' - } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 46be82659ed4acbba3480b9582916af5a75312f3..b596947a21b9226532b1cb2caf83b0d23e75ae81 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,6 +5,9 @@ <uses-permission android:name="android.hardware.camera" android:required="true" /> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" @@ -49,7 +52,7 @@ <activity android:name=".ScrollingActivity" android:label="@string/title_activity_scrolling" - android:theme="@style/AppTheme.NoActionBar"></activity> + android:theme="@style/AppTheme.NoActionBar" /> </application> </manifest> \ No newline at end of file diff --git a/app/src/main/java/com/example/srinivasan/database2/LocationAdress.java b/app/src/main/java/com/example/srinivasan/database2/LocationAdress.java new file mode 100644 index 0000000000000000000000000000000000000000..36d8d1b8910679dc9569bdd1b48a05f909b7fe0f --- /dev/null +++ b/app/src/main/java/com/example/srinivasan/database2/LocationAdress.java @@ -0,0 +1,65 @@ +package com.example.srinivasan.database2; + +import android.content.Context; +import android.location.Address; +import android.location.Geocoder; +import android.os.Bundle; +import android.os.Message; +import android.util.Log; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; +import java.util.logging.Handler; + +/** + * Created by SRINIVASAN on 4/22/2017. + */ + +public class LocationAdress { + private static final String TAG = "LocationAddress"; + + public static String getAddressFromLocation(final double latitude, final double longitude, + final Context context) + { + Geocoder geocoder = new Geocoder(context, Locale.getDefault()); + String result = null; + try { + List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 1); + if (addressList != null && addressList.size() > 0) { + Address address = addressList.get(0); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < address.getMaxAddressLineIndex(); i++) { + sb.append(address.getAddressLine(i)).append("\n"); + } + sb.append(address.getLocality()).append("\n"); + sb.append(address.getPostalCode()).append("\n"); + sb.append(address.getCountryName()); + result = sb.toString(); + return result; + } + } catch (IOException e) { + Log.e(TAG, "Unable connect to Geocoder", e); + }/* finally { + Message message = Message.obtain(); + message.setTarget(handler); + if (result != null) { + message.what = 1; + Bundle bundle = new Bundle(); + result = "Latitude: " + latitude + " Longitude: " + longitude + + "\n\nAddress:\n" + result; + bundle.putString("address", result); + message.setData(bundle); + } else { + message.what = 1; + Bundle bundle = new Bundle(); + result = "Latitude: " + latitude + " Longitude: " + longitude + + "\n Unable to get address for this lat-long."; + bundle.putString("address", result); + message.setData(bundle); + } + message.sendToTarget(); + }*/ + return result; + } +} diff --git a/app/src/main/java/com/example/srinivasan/database2/Loggedin.java b/app/src/main/java/com/example/srinivasan/database2/Loggedin.java index 8ade97e94534ea107af01f727c3bba7ca5856f99..c5eb362db9e6c847aa318535a4ec8a2476d7a4e9 100644 --- a/app/src/main/java/com/example/srinivasan/database2/Loggedin.java +++ b/app/src/main/java/com/example/srinivasan/database2/Loggedin.java @@ -1,97 +1,340 @@ package com.example.srinivasan.database2; +import android.Manifest; import android.annotation.TargetApi; import android.app.DialogFragment; +import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; import android.os.Build; import android.os.Bundle; +import android.os.Handler; +import android.os.Message; import android.provider.MediaStore; +import android.provider.Settings; +import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; +import android.widget.TextView; import android.widget.Toast; +import org.json.JSONObject; + import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; +import java.util.Locale; +import java.util.logging.LogRecord; + +import static java.util.Locale.*; public class Loggedin extends AppCompatActivity { DatabaseHelperTwo myDb; public static final int REQUEST_CAPTURE =1; ImageView resultPhoto; EditText date,time,query; - Button add; + TextView textloc,address1; + LocationManager locationManager; + LocationListener listener; + TrackGPS gps; + Button add,loc; + List<Address> addresses; + private static final int MY_PERMISSION_REQUEST_LOCATION =1 ; byte[] a; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_loggedin); - myDb=new DatabaseHelperTwo(this); - Button click = (Button)findViewById(R.id.take); - resultPhoto = (ImageView)findViewById(R.id.photo); - date = (EditText)findViewById(R.id.date); - time = (EditText)findViewById(R.id.time); - query = (EditText)findViewById(R.id.query); - if(!hasCamera()){ - click.setEnabled(false); - } - AddData(); - } - public boolean hasCamera(){ - return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY); - } - public void launchCamera(View view){ - Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - startActivityForResult(i,REQUEST_CAPTURE); - } - protected void onActivityResult(int requestCode,int resultCode,Intent data){ - if(requestCode == REQUEST_CAPTURE && resultCode == RESULT_OK){ - Bundle extras= data.getExtras(); - Bitmap photo = (Bitmap)extras.get("data"); - a=getBytes(photo); - resultPhoto.setImageBitmap(photo); - } - } + myDb = new DatabaseHelperTwo(this); + final Button click = (Button) findViewById(R.id.take); + resultPhoto = (ImageView) findViewById(R.id.photo); + date = (EditText) findViewById(R.id.date); + time = (EditText) findViewById(R.id.time); + query = (EditText) findViewById(R.id.query); + textloc = (TextView) findViewById(R.id.textloc); + address1 =(TextView)findViewById(R.id.address); + loc = (Button)findViewById(R.id.loc); - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public void showDatePickerDialog(View v){ - DialogFragment newFragment = new DatePickerFragment(); - newFragment.show(getFragmentManager(),"datePicker"); - } - public void showTimePickerDialog(View v){ - DialogFragment newFragment = new TimePickerFragment(); - newFragment.show(getFragmentManager(),"datePicker"); - } - public void AddData(){ - add =(Button)findViewById(R.id.add); - add.setOnClickListener(new View.OnClickListener() { + locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); + listener = new LocationListener() { + @Override + public void onLocationChanged(Location location) { + //textloc.setText(location.getLongitude() + " " + location.getLatitude()); + Double latitude = location.getLatitude(); + Double longitude = location.getLongitude(); + Geocoder geocoder; + geocoder = new Geocoder(Loggedin.this, getDefault()); + try{ + addresses = geocoder.getFromLocation(latitude,longitude,1); + String address = addresses.get(0).getAddressLine(0); + String area= addresses.get(0).getLocality(); + String city = addresses.get(0).getAdminArea(); + String country = addresses.get(0).getCountryName(); + String postalcode = addresses.get(0).getPostalCode(); + String fulladress = address +","+area+","+city+","+country+","+postalcode; + address1.setText(fulladress); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + @Override + public void onStatusChanged(String s, int i, Bundle bundle) { + + } + + @Override + public void onProviderEnabled(String s) { + + } + + @Override + public void onProviderDisabled(String s) { + + Intent i = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + startActivity(i); + } + }; + configure_button(); + + /*loc.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - boolean inserted= myDb.addEntry(date.getText().toString(),time.getText().toString(),query.getText().toString(),a); - if(inserted == true){ - Intent intent=new Intent(Loggedin.this,Float.class); - startActivity(intent); - Toast.makeText(getApplicationContext(),"Your feedback has been sent ",Toast.LENGTH_SHORT).show(); - } - else { - Toast.makeText(getApplicationContext(),"Data not inserted",Toast.LENGTH_SHORT).show(); - } + Double latitude = 18.944620; + Double longitude = 72.822278; + Geocoder geocoder; + geocoder = new Geocoder(Loggedin.this, getDefault()); + try{ + addresses = geocoder.getFromLocation(latitude,longitude,1); + String address = addresses.get(0).getAddressLine(0); + String area= addresses.get(0).getLocality(); + String city = addresses.get(0).getAdminArea(); + String country = addresses.get(0).getCountryName(); + String postalcode = addresses.get(0).getPostalCode(); + String fulladress = address +","+area+","+city+","+country+","+postalcode; + address.setText(fulladress); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + + /* if (ContextCompat.checkSelfPermission(Loggedin.this, + android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.shouldShowRequestPermissionRationale(Loggedin.this, android.Manifest.permission.ACCESS_COARSE_LOCATION + )) { + ActivityCompat.requestPermissions(Loggedin.this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION}, + MY_PERMISSION_REQUEST_LOCATION); + } else { + ActivityCompat.requestPermissions(Loggedin.this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION}, + MY_PERMISSION_REQUEST_LOCATION); + } + } else { + LocationManager locationmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + Location location = locationmanager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + try { + textloc.setText(location(location.getLatitude(), location.getLongitude())); + } catch (Exception e) { + e.printStackTrace(); + Toast.makeText(Loggedin.this, "Not found", Toast.LENGTH_SHORT).show(); + } + } } }); } - public static byte[] getBytes(Bitmap bitmap) { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream); - return stream.toByteArray(); - } - public static Bitmap getImage(byte[] image) { - return BitmapFactory.decodeByteArray(image, 0, image.length); - } + public void onRequestPermissionsResult(int requestCode,String[] permissions , int[] grantResults) { + switch (requestCode) { + case MY_PERMISSION_REQUEST_LOCATION: { + // If request is cancelled, the result arrays are empty. + if (grantResults.length > 0 + && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + + if(ContextCompat.checkSelfPermission(Loggedin.this, android.Manifest.permission.ACCESS_COARSE_LOCATION)== + PackageManager.PERMISSION_GRANTED){ + LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); + Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + try{ + textloc.setText(location(location.getLatitude(),location.getLongitude())); + }catch (Exception e){ + e.printStackTrace(); + Toast.makeText(Loggedin.this,"Not found",Toast.LENGTH_SHORT).show(); + } + } + + } else { + + // permission denied, boo! Disable the + // functionality that depends on this permission. + Toast.makeText(Loggedin.this,"No permission found",Toast.LENGTH_SHORT).show(); + + } + + } + + // other 'case' lines to check for other + // permissions this app might request + } + } + */ + + if (!hasCamera()) { + click.setEnabled(false); + } + AddData(); + + } + protected void onDestroy() { + super.onDestroy(); + gps.stopUsingGPS(); + } +@Override +public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, +@NonNull int[] grantResults) { + switch (requestCode) { + case 10: + configure_button(); + break; +default: + break; + } } + + void configure_button() { + // first check for permissions + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != + PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, + Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.INTERNET} + , 10); + } + return; + } + // this code won'textView execute IF permissions are not allowed, because in the line above there is return statement. + loc.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //noinspection MissingPermission + locationManager.requestLocationUpdates("gps", 5000, 0, listener); + + + } + }); + } + + private void getLocation() { + loc = (Button) findViewById(R.id.loc); + loc.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String curcity = ""; + double lat = 0, log = 0; + Geocoder geocoder = new Geocoder(Loggedin.this, getDefault()); + List<Address> addressList; + try { + addressList = geocoder.getFromLocation(lat, log, 1); + if (addressList.size() > 0) { + curcity = addressList.get(0).getLocality(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + } + + public String location(double lat, double log) { + + String curcity = ""; + Geocoder geocoder = new Geocoder(Loggedin.this, getDefault()); + List<Address> addressList; + try { + addressList = geocoder.getFromLocation(lat, log, 1); + if (addressList.size() > 0) { + curcity = addressList.get(0).getLocality(); + } + } catch (IOException e) { + e.printStackTrace(); + } + return curcity; + } + + public boolean hasCamera() { + return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY); + } + + public void launchCamera(View view) { + Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + startActivityForResult(i, REQUEST_CAPTURE); + } + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == REQUEST_CAPTURE && resultCode == RESULT_OK) { + Bundle extras = data.getExtras(); + Bitmap photo = (Bitmap) extras.get("data"); + a = getBytes(photo); + resultPhoto.setImageBitmap(photo); + } + } + + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public void showDatePickerDialog(View v) { + DialogFragment newFragment = new DatePickerFragment(); + newFragment.show(getFragmentManager(), "datePicker"); + } + + public void showTimePickerDialog(View v) { + DialogFragment newFragment = new TimePickerFragment(); + newFragment.show(getFragmentManager(), "datePicker"); + } + + public void AddData() { + add = (Button) findViewById(R.id.add); + add.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean inserted = myDb.addEntry(date.getText().toString(), time.getText().toString(), query.getText().toString(), a); + if (inserted == true) { + Intent intent = new Intent(Loggedin.this, Float.class); + startActivity(intent); + Toast.makeText(getApplicationContext(), "Your feedback has been sent ", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(getApplicationContext(), "Data not inserted", Toast.LENGTH_SHORT).show(); + } + } + }); + + } + + public static byte[] getBytes(Bitmap bitmap) { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream); + return stream.toByteArray(); + } + + public static Bitmap getImage(byte[] image) { + return BitmapFactory.decodeByteArray(image, 0, image.length); + } + +} + diff --git a/app/src/main/java/com/example/srinivasan/database2/ScrollingActivity.java b/app/src/main/java/com/example/srinivasan/database2/ScrollingActivity.java index 1ecbf3a3c90502e22e7382851d22155aa5168a15..0731ef081b95cf290441a49ebb9d9f646bc3c6ee 100644 --- a/app/src/main/java/com/example/srinivasan/database2/ScrollingActivity.java +++ b/app/src/main/java/com/example/srinivasan/database2/ScrollingActivity.java @@ -1,11 +1,18 @@ package com.example.srinivasan.database2; +import android.location.Address; +import android.location.Geocoder; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; +import android.widget.Button; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; public class ScrollingActivity extends AppCompatActivity { @@ -15,4 +22,5 @@ public class ScrollingActivity extends AppCompatActivity { setContentView(R.layout.activity_scrolling); } + } diff --git a/app/src/main/java/com/example/srinivasan/database2/SingleView.java b/app/src/main/java/com/example/srinivasan/database2/SingleView.java index a7cda6a053d219048c2e6e7429a6a0d303e7c63e..30a96af8b1e68efee4c0b4d6438d0a11b0cdc6e1 100644 --- a/app/src/main/java/com/example/srinivasan/database2/SingleView.java +++ b/app/src/main/java/com/example/srinivasan/database2/SingleView.java @@ -10,6 +10,7 @@ import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.EditText; import android.widget.ImageView; +import android.widget.ProgressBar; import android.widget.TextView; import java.util.ArrayList; @@ -18,6 +19,7 @@ public class SingleView extends AppCompatActivity { DatabaseHelperTwo db2; String[] date,time,query; TextView date1,time1,com1; + ProgressBar progressBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -36,10 +38,16 @@ public class SingleView extends AppCompatActivity { date = db2.dat(); time = db2.tim(); query = db2.com(); - +progressBar=(ProgressBar)findViewById(R.id.progressBar2); + progressBar.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + progressBar.setProgress(50); + } + }); ImageView imageView = (ImageView) findViewById(R.id.SingleView); - // imageView.setImageResource(imageAdapter.mThumbIds[position]); + //imageView.setImageResource(imageAdapter.mThumbIds[position]); imageView.setImageBitmap(bitmapArray.get(position)); date1.setText(date[position]); time1.setText(time[position]); diff --git a/app/src/main/java/com/example/srinivasan/database2/TrackGps.java b/app/src/main/java/com/example/srinivasan/database2/TrackGps.java new file mode 100644 index 0000000000000000000000000000000000000000..532fe494624e8f3914051c55cf00bc5f2abb056e --- /dev/null +++ b/app/src/main/java/com/example/srinivasan/database2/TrackGps.java @@ -0,0 +1,134 @@ +package com.example.srinivasan.database2; + +import android.Manifest; +import android.app.AlertDialog; +import android.app.Service; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; +import android.os.IBinder; +import android.provider.Settings; +import android.support.annotation.Nullable; +import android.support.v4.app.ActivityCompat; +import android.util.Log; +import android.widget.Toast; + +/** + * Created by SRINIVASAN on 4/22/2017. + */ + +class TrackGPS extends Service implements LocationListener { + + private final Context mContext; + boolean checkGPS = false; + boolean checkNetwork = false; + boolean canGetLocation = false; + Location loc; + double latitude; + double longitude; + private static final long MIN_DISTANCE_FOR_UPDATE = 10; + private static final long MIN_TIME_FOR_UPDATE = 1000 * 60 * 2; + protected LocationManager locationManager; + + public TrackGPS(Context mContext) { + this.mContext = mContext; + //getLocation(); + locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE); + } + + Location getLocation(String provider) { + Toast.makeText(getApplicationContext(),"fsdfdsf",Toast.LENGTH_SHORT).show(); + if (locationManager.isProviderEnabled(provider)) { + + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + // TODO: Consider calling + // ActivityCompat#requestPermissions + // here to request the missing permissions, and then overriding + // public void onRequestPermissionsResult(int requestCode, String[] permissions, + // int[] grantResults) + // to handle the case where the user grants the permission. See the documentation + // for ActivityCompat#requestPermissions for more details. + + } + locationManager.requestLocationUpdates(provider, MIN_TIME_FOR_UPDATE, MIN_DISTANCE_FOR_UPDATE, this); + if (locationManager != null) { + loc = locationManager.getLastKnownLocation(provider); + return loc; + } + } + return null; + } + + public double getLongitude() { + if (loc != null) { + longitude = loc.getLongitude(); + } + return longitude; + } + + public double getLatitude() { + if (loc != null) { + latitude = loc.getLatitude(); + } + return latitude; + } + + public boolean canGetLocation() { + return this.canGetLocation; + } + + public void showSettingsAlert() { + AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext); + alertDialog.setTitle("GPS Not Enabled"); + alertDialog.setMessage("Do you wants to turn On GPS"); + alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + mContext.startActivity(intent); + } + }); + alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + } + }); + alertDialog.show(); + } + + + public void stopUsingGPS() { + if (locationManager != null) { + locationManager.removeUpdates(TrackGPS.this); + } + } + @Nullable + @Override + public IBinder onBind(Intent intent) { + return null; + } + + @Override + public void onLocationChanged(Location location) { + + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_loggedin.xml b/app/src/main/res/layout/activity_loggedin.xml index 51fa60b86d0fa83e6473053d05708154b3c0d441..a62f1715d5c0202c015031881b3de73a7f798604 100644 --- a/app/src/main/res/layout/activity_loggedin.xml +++ b/app/src/main/res/layout/activity_loggedin.xml @@ -22,12 +22,4 @@ <include layout="@layout/content_loggedin" /> - <android.support.design.widget.FloatingActionButton - android:id="@+id/fab" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="bottom|end" - android:layout_margin="@dimen/fab_margin" - app:srcCompat="@android:drawable/ic_dialog_email" /> - </android.support.design.widget.CoordinatorLayout> diff --git a/app/src/main/res/layout/content_loggedin.xml b/app/src/main/res/layout/content_loggedin.xml index 35216927e9515626057ae166b5821ff627015845..3427e6758c15561c907de511d7bc579885fa366f 100644 --- a/app/src/main/res/layout/content_loggedin.xml +++ b/app/src/main/res/layout/content_loggedin.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> - -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<android.support.v4.widget.NestedScrollView + 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" @@ -8,68 +8,173 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.srinivasan.database2.Loggedin" tools:showIn="@layout/activity_loggedin"> - - <Button - android:id="@+id/take" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="61dp" - android:onClick="launchCamera" - android:text="Capture" - android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" /> - - <ImageView - android:id="@+id/photo" - android:layout_width="300dp" - android:layout_height="300dp" - app:srcCompat="@android:drawable/alert_light_frame" - android:layout_below="@+id/date" - android:layout_centerHorizontal="true" - android:layout_marginTop="23dp" /> - - <EditText - android:id="@+id/date" - android:layout_width="180dp" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:layout_alignParentTop="true" - android:ems="10" - android:inputType="textPersonName" - android:onClick="showDatePickerDialog" - android:text="Date" /> - - <EditText - android:id="@+id/query" + <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/reel" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="29dp" - android:ems="10" - android:hint="Queries" - android:inputType="textPersonName" - android:layout_above="@+id/take" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" /> - - <EditText - android:id="@+id/time" - android:layout_width="180dp" - android:layout_height="wrap_content" - android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:ems="10" - android:inputType="textPersonName" - android:onClick="showTimePickerDialog" - android:text="Time" /> - - <Button - android:id="@+id/add" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:layout_below="@+id/query" - android:text="Send" /> -</RelativeLayout> + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + tools:context="com.example.srinivasan.database2.Loggedin" + tools:showIn="@layout/activity_loggedin"> + + <LinearLayout + android:id="@+id/LinearLayout01" + android:layout_width="match_parent" + android:layout_height="fill_parent" + android:orientation="horizontal" + android:layout_alignParentTop="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + ><![CDATA[>]]> + + <EditText + android:id="@+id/date" + android:layout_width="180dp" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_toLeftOf="@+id/textloc" + android:layout_toStartOf="@+id/textloc" + android:layout_weight="0.79" + android:ems="10" + android:inputType="textPersonName" + android:onClick="showDatePickerDialog" + android:text="Date" /> + + <EditText + android:id="@+id/time" + android:layout_width="180dp" + android:layout_height="wrap_content" + android:layout_below="@+id/LinearLayout01" + android:layout_marginLeft="44dp" + android:layout_marginStart="44dp" + android:layout_toEndOf="@+id/date" + android:layout_toRightOf="@+id/date" + android:layout_weight="0.71" + android:ems="10" + android:inputType="textPersonName" + android:onClick="showTimePickerDialog" + android:text="Time" /> + + </LinearLayout> + <LinearLayout + android:id="@+id/LinearLayout02" + android:layout_width="match_parent" + android:layout_height="fill_parent" + android:orientation="horizontal" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_below="@+id/LinearLayout01"> + + <ImageView + android:id="@+id/photo" + android:layout_width="match_parent" + android:layout_height="250dp" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_below="@+id/LinearLayout01" + android:layout_weight="1" + app:srcCompat="@android:drawable/alert_light_frame" /> + </LinearLayout> + <LinearLayout + android:id="@+id/LinearLayout03" + android:layout_width="match_parent" + android:layout_height="fill_parent" + android:orientation="horizontal" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_below="@+id/LinearLayout02"> + + <Button + android:id="@+id/add" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Send" /> + + <Button + android:id="@+id/take" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_marginBottom="52dp" + android:layout_marginLeft="50dp" + android:layout_marginStart="26dp" + android:layout_toEndOf="@+id/add" + android:layout_toRightOf="@+id/add" + android:onClick="launchCamera" + android:text="Capture" /> + + <Button + android:id="@+id/loc" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" + android:layout_marginLeft="60dp" + android:text="LOCATION" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/LinearLayout04" + android:layout_width="match_parent" + android:layout_height="fill_parent" + android:orientation="horizontal" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_below="@+id/LinearLayout03"> + + <EditText + android:id="@+id/query" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_marginBottom="28dp" + android:ems="10" + android:hint="Queries" + android:inputType="textPersonName" /> + + </LinearLayout> + <LinearLayout + android:id="@+id/LinearLayout05" + android:layout_width="match_parent" + android:layout_height="fill_parent" + android:orientation="horizontal" + android:gravity="center" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_below="@+id/LinearLayout04"> + + <TextView + android:id="@+id/textloc" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:textSize="18sp" /> + </LinearLayout> + <LinearLayout + android:id="@+id/LinearLayout06" + android:layout_width="match_parent" + android:layout_height="fill_parent" + android:orientation="horizontal" + android:gravity="center" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_below="@+id/LinearLayout05"> + + <TextView + android:id="@+id/address" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="TextView" /> + </LinearLayout> + + </RelativeLayout> + + +</android.support.v4.widget.NestedScrollView> diff --git a/app/src/main/res/layout/content_single_view.xml b/app/src/main/res/layout/content_single_view.xml index 91d30ff5a8eeb2556e57441c45b7cd4c1c1ad328..86472513c44d0fb7cb874b5c075db3e46c35417d 100644 --- a/app/src/main/res/layout/content_single_view.xml +++ b/app/src/main/res/layout/content_single_view.xml @@ -36,13 +36,13 @@ android:id="@+id/texttime" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignLeft="@+id/textdate" - android:layout_alignStart="@+id/textdate" - android:layout_below="@+id/textdate" - android:layout_marginTop="26dp" + android:layout_marginTop="22dp" android:text="TextView" android:textColor="@android:color/holo_orange_dark" - android:textSize="18sp" /> + android:textSize="18sp" + android:layout_below="@+id/textdate" + android:layout_alignLeft="@+id/textdate" + android:layout_alignStart="@+id/textdate" /> <TextView android:id="@+id/comm" @@ -70,13 +70,19 @@ android:id="@+id/textView12" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignBaseline="@+id/texttime" - android:layout_alignBottom="@+id/texttime" - android:layout_alignEnd="@+id/textView11" - android:layout_alignRight="@+id/textView11" android:text="Time : " android:textColor="@android:color/holo_orange_light" - android:textSize="18sp" /> + android:textSize="18sp" + android:layout_above="@+id/SingleView" + android:layout_alignLeft="@+id/textView11" + android:layout_alignStart="@+id/textView11" /> + + <ProgressBar + android:id="@+id/progressBar2" + style="?android:attr/progressBarStyleHorizontal" + android:layout_width="match_parent" + android:layout_height="15dp" + android:layout_below="@+id/SingleView" /> </RelativeLayout> diff --git a/app/src/main/res/menu/menu_new_logged_in.xml b/app/src/main/res/menu/menu_new_logged_in.xml new file mode 100644 index 0000000000000000000000000000000000000000..9438345db218605443681d4b1c5694adf9eccdaa --- /dev/null +++ b/app/src/main/res/menu/menu_new_logged_in.xml @@ -0,0 +1,10 @@ +<menu 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" + tools:context="com.example.srinivasan.database2.NewLoggedIn"> + <item + android:id="@+id/action_settings" + android:orderInCategory="100" + android:title="@string/action_settings" + app:showAsAction="never" /> +</menu> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b8b1c8c97c45bf0158299bac5d3ffa897a911dbd..f9c61de8bb7807c83d7acb04a5c3eabf208e0078 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -133,4 +133,5 @@ <string name="r41">100% of wards</string> <string name="r42">60%-79% of wards</string> <string name="r43"><![CDATA[<60% of wards]]></string> + <string name="title_activity_new_logged_in">NewLoggedIn</string> </resources>