diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..c42bdfc --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +DigiPune \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..760ea46 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7158618 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f3f2ec0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/2ndOcober.iml b/2ndOcober.iml new file mode 100644 index 0000000..f044e2d --- /dev/null +++ b/2ndOcober.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/8thOct_NoDelete.iml b/8thOct_NoDelete.iml new file mode 100644 index 0000000..4d6456c --- /dev/null +++ b/8thOct_NoDelete.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/API/Geo/GCM.php b/API/Geo/GCM.php new file mode 100644 index 0000000..a1b8cd8 --- /dev/null +++ b/API/Geo/GCM.php @@ -0,0 +1,58 @@ + $registatoin_ids, + 'data' => $message, + ); + + $headers = array( + 'Authorization: key=' . GOOGLE_API_KEY, + 'Content-Type: application/json' + ); + // Open connection + $ch = curl_init(); + + // Set the url, number of POST vars, POST data + curl_setopt($ch, CURLOPT_URL, $url); + + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + // Disabling SSL Certificate support temporarly + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); + + // Execute post + $result = curl_exec($ch); + if ($result === FALSE) { + die('Curl failed: ' . curl_error($ch)); + } + + // Close connection + curl_close($ch); + echo $result; + } + +} + +?> \ No newline at end of file diff --git a/API/Geo/PMPML/DB_connect.php b/API/Geo/PMPML/DB_connect.php new file mode 100644 index 0000000..22ccc8d --- /dev/null +++ b/API/Geo/PMPML/DB_connect.php @@ -0,0 +1,33 @@ +close(); + } + + // Connecting to database + public function connect() { + require_once 'db_config.php'; + // connecting to mysql + $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD); + // selecting database + mysql_select_db(DB_DATABASE); + + // return database handler + return $con; + } + + // Closing database connection + public function close() { + mysql_close(); + } + +} +?> \ No newline at end of file diff --git a/API/Geo/PMPML/db_config.php b/API/Geo/PMPML/db_config.php new file mode 100644 index 0000000..034a8fe --- /dev/null +++ b/API/Geo/PMPML/db_config.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/API/Geo/PMPML/from_to.php b/API/Geo/PMPML/from_to.php new file mode 100644 index 0000000..e7ed51f --- /dev/null +++ b/API/Geo/PMPML/from_to.php @@ -0,0 +1,101 @@ + \ No newline at end of file diff --git a/API/Geo/PMPML/routewise.php b/API/Geo/PMPML/routewise.php new file mode 100644 index 0000000..e8a6a11 --- /dev/null +++ b/API/Geo/PMPML/routewise.php @@ -0,0 +1,63 @@ + \ No newline at end of file diff --git a/API/Geo/alert.php b/API/Geo/alert.php new file mode 100644 index 0000000..e1b064d --- /dev/null +++ b/API/Geo/alert.php @@ -0,0 +1,32 @@ +getAllUsers(); + + + +while($row = mysql_fetch_array($all)) +{ +$current_id = $row["gcm_regid"]; +$registatoin_ids = array($current_id); + + $message = array("title" => $title,"messageC" =>$messageC, "user_name" => $user_name,"type" => $alert); + + $result = $gcm->send_notification($registatoin_ids, $message); + +} + + +?> \ No newline at end of file diff --git a/API/Geo/category_update.php b/API/Geo/category_update.php new file mode 100644 index 0000000..1863a30 --- /dev/null +++ b/API/Geo/category_update.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/API/Geo/check_pass.php b/API/Geo/check_pass.php new file mode 100644 index 0000000..70ebeba --- /dev/null +++ b/API/Geo/check_pass.php @@ -0,0 +1,38 @@ +getAllUsers(); + + while($row = mysql_fetch_array($all)) + { + if($row["user_name"] == $user_name) + { + if($row["password"]==$password) + { + $response["success"] = 1; + echo json_encode($response); + } + else{ + $response["success"] = 0; + echo json_encode($response); + + } + } + } + +} else { + $response["success"] = 0; + echo json_encode($response); +} +?> \ No newline at end of file diff --git a/API/Geo/compaint_curr_count.php b/API/Geo/compaint_curr_count.php new file mode 100644 index 0000000..e69de29 diff --git a/API/Geo/db_config.php b/API/Geo/db_config.php new file mode 100644 index 0000000..ea5f320 --- /dev/null +++ b/API/Geo/db_config.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/API/Geo/db_connect.php b/API/Geo/db_connect.php new file mode 100644 index 0000000..cde5e37 --- /dev/null +++ b/API/Geo/db_connect.php @@ -0,0 +1,47 @@ +connect(); + } + + // destructor + function __destruct() { + // closing db connection + $this->close(); + } + + /** + * Function to connect with database + */ + function connect() { + // import database connection variables + require_once __DIR__ . '/db_config.php'; + + // Connecting to mysql database + $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error()); + + // Selecing database + $db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error()); + + // returing connection cursor + return $con; + } + + /** + * Function to close db connection + */ + function close() { + // closing db connection + mysql_close(); + } + +} + +?> \ No newline at end of file diff --git a/API/Geo/db_functions.php b/API/Geo/db_functions.php new file mode 100644 index 0000000..e3d2a3e --- /dev/null +++ b/API/Geo/db_functions.php @@ -0,0 +1,54 @@ +db = new DB_Connect(); + $this->db->connect(); + } + + // destructor + function __destruct() { + + } + + /** + * Storing new user + * returns user details + */ + public function storeUser($user_name, $email, $gcm_regid) { + // insert user into database + $result = mysql_query("INSERT INTO Geo(user_name, email, gcm_regid) VALUES('$user_name', '$email', '$gcm_regid')"); + // check for successful store + if ($result) { + // get user details + $id = mysql_insert_id(); // last inserted id + $result = mysql_query("SELECT * FROM Geo WHERE id = $id") or die(mysql_error()); + // return user details + if (mysql_num_rows($result) > 0) { + return mysql_fetch_array($result); + } else { + return false; + } + } else { + return false; + } + } + + /** + * Getting all users + */ + public function getAllUsers() { + $result = mysql_query("select * FROM Geo"); + return $result; + } + +} + +?> \ No newline at end of file diff --git a/API/Geo/favourite.php b/API/Geo/favourite.php new file mode 100644 index 0000000..a473ebc --- /dev/null +++ b/API/Geo/favourite.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/API/Geo/fence.php b/API/Geo/fence.php new file mode 100644 index 0000000..f0e1b32 --- /dev/null +++ b/API/Geo/fence.php @@ -0,0 +1,89 @@ + $message); + +$db = new DB_Functions(); +$gcm = new GCM(); + +$all = $db->getAllUsers(); + +while($row = mysql_fetch_array($all)) +{ +if($row["user_name"] == $user_name) +{ + $giood1=$row["gcm_regid"]; + $iood1 = array($giood1); +$roo1=$gcm->send_notification($iood1,$message); +$fav1 = $row["fav1"]; +$fav2 = $row["fav2"]; +$fav3 = $row["fav3"]; +$fav4 = $row["fav4"]; + + $allq = $db->getAllUsers(); + while($f1=mysql_fetch_array($allq)) + { + if($f1["user_name"]==$fav1) + { + $gid1=$f1["gcm_regid"]; + $id1 = array($gid1); + + + print_r($id1); + print_r($message); + $r1=$gcm->send_notification($id1,$message); + } + } + + /*while($f2=mysql_fetch_array($all)) + { + if($f2["user_name"]==$fav2) + { + $gid2=$f2["gcm_regid"]; + $id2=array($gid2); + + + $r2=$gcm->send_notification($id2,$message); + } + } + + + while($f3=mysql_fetch_array($all)) + { + if($f3["user_name"]==$fav3) + { + $gid3=$f3["gcm_regid"]; + $id3=array($gid3); + $r3=$gcm->send_notification($id3,$message); + } + } + + while($f4=mysql_fetch_array($all)) + { + if($f4["user_name"]==$fav4) + { + $gid4=$f4["gcm_regid"]; + $id4=array($gid4); + $r4=$gcm->send_notification($id4,$message); + } + } +*/ + +} +} + + + +} + +?> \ No newline at end of file diff --git a/API/Geo/fence2.php b/API/Geo/fence2.php new file mode 100644 index 0000000..f25b5a4 --- /dev/null +++ b/API/Geo/fence2.php @@ -0,0 +1,73 @@ +getAllUsers(); + + +$result = mysql_fetch_array($result); + +$current_id2 = $result ["gcm_regid"]; +$registatoin_ids2 = array($current_id2); +$message2 = array("message" => $message,"user_name" => $user_name); + + + include_once './db_config.php'; + + // Set POST variables + $url = 'https://android.googleapis.com/gcm/send'; + + $fields = array( + 'registration_ids' => $registatoin_ids2, + 'data' => $message2, + ); + + $headers = array( + 'Authorization: key=' . GOOGLE_API_KEY, + 'Content-Type: application/json' + ); + // Open connection + $ch = curl_init(); + + // Set the url, number of POST vars, POST data + curl_setopt($ch, CURLOPT_URL, $url); + + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + // Disabling SSL Certificate support temporarly + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); + + // Execute post + $result = curl_exec($ch); + if ($result === FALSE) { + die('Curl failed: ' . curl_error($ch)); + } + + // Close connection + curl_close($ch); + echo $result; + +} + +?> \ No newline at end of file diff --git a/API/Geo/fence3.php b/API/Geo/fence3.php new file mode 100644 index 0000000..26da77f --- /dev/null +++ b/API/Geo/fence3.php @@ -0,0 +1,35 @@ + $message); + +$dbw = new DB_Functions(); +$gcmw = new GCM(); + +$allw = $dbw->getAllUsers(); + +while($roww = mysql_fetch_array($allw)) +{ +if($roww["user_name"] == $user_name) +{ + $giood1=$roww["gcm_regid"]; + $iood1 = array($giood1); +$roo1=$gcmw->send_notification($iood1,$message); +} +} + + + +} + +?> \ No newline at end of file diff --git a/API/Geo/fetch_category.php b/API/Geo/fetch_category.php new file mode 100644 index 0000000..2ddee57 --- /dev/null +++ b/API/Geo/fetch_category.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/API/Geo/from_to.php b/API/Geo/from_to.php new file mode 100644 index 0000000..ad328ad --- /dev/null +++ b/API/Geo/from_to.php @@ -0,0 +1,91 @@ + \ No newline at end of file diff --git a/API/Geo/get_complaints.php b/API/Geo/get_complaints.php new file mode 100644 index 0000000..1c5253b --- /dev/null +++ b/API/Geo/get_complaints.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/API/Geo/get_location.php b/API/Geo/get_location.php new file mode 100644 index 0000000..99cc9ec --- /dev/null +++ b/API/Geo/get_location.php @@ -0,0 +1,129 @@ + \ No newline at end of file diff --git a/API/Geo/get_product_exists.php b/API/Geo/get_product_exists.php new file mode 100644 index 0000000..c0aa85b --- /dev/null +++ b/API/Geo/get_product_exists.php @@ -0,0 +1,67 @@ + 0) { + + $result = mysql_fetch_array($result); + + $product = array(); + //$product["device_id"] = $result["device_id"]; + //$product["latitude"] = $result["latitude"]; + //$product["longitude"] = $result["longitude"]; + + + $response["success"] = 1; + + // user node + $response["gps_coordinates"] = array(); + + array_push($response["gps_coordinates"], $product); + + // echoing JSON response + echo json_encode($response); + } else { + // no product found + $response["success"] = 0; + $response["message"] = "No product found"; + + // echo no users JSON + echo json_encode($response); + } + } else { + // no product found + $response["success"] = 0; + $response["message"] = "No product found"; + + // echo no users JSON + echo json_encode($response); + } +} else { + // required field is missing + $response["success"] = 0; + $response["message"] = "Required field(s) is missing"; + + // echoing JSON response + echo json_encode($response); +} +?> \ No newline at end of file diff --git a/API/Geo/history.php b/API/Geo/history.php new file mode 100644 index 0000000..a870361 --- /dev/null +++ b/API/Geo/history.php @@ -0,0 +1,103 @@ + + + + History || FindX + + + + + + + + +
+ + \ No newline at end of file diff --git a/API/Geo/history_status.php b/API/Geo/history_status.php new file mode 100644 index 0000000..69dd607 --- /dev/null +++ b/API/Geo/history_status.php @@ -0,0 +1,105 @@ + + + + History || FindX + + + + + + + + +
+ + \ No newline at end of file diff --git a/API/Geo/icons.png b/API/Geo/icons.png new file mode 100644 index 0000000..0b63b94 Binary files /dev/null and b/API/Geo/icons.png differ diff --git a/API/Geo/image.jpg b/API/Geo/image.jpg new file mode 100644 index 0000000..1c46a20 Binary files /dev/null and b/API/Geo/image.jpg differ diff --git a/API/Geo/location.php b/API/Geo/location.php new file mode 100644 index 0000000..573f877 --- /dev/null +++ b/API/Geo/location.php @@ -0,0 +1,96 @@ + + + + + + + + + FindX + + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/API/Geo/login.php b/API/Geo/login.php new file mode 100644 index 0000000..1c172b8 --- /dev/null +++ b/API/Geo/login.php @@ -0,0 +1,63 @@ + \ No newline at end of file diff --git a/API/Geo/password_rec.php b/API/Geo/password_rec.php new file mode 100644 index 0000000..e69de29 diff --git a/API/Geo/phpsqlajax_dbinfo.php b/API/Geo/phpsqlajax_dbinfo.php new file mode 100644 index 0000000..2cfcbe3 --- /dev/null +++ b/API/Geo/phpsqlajax_dbinfo.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/API/Geo/phpsqlajax_genxml2.php b/API/Geo/phpsqlajax_genxml2.php new file mode 100644 index 0000000..8600890 --- /dev/null +++ b/API/Geo/phpsqlajax_genxml2.php @@ -0,0 +1,63 @@ +','>',$xmlStr); +$xmlStr=str_replace('"','"',$xmlStr); +$xmlStr=str_replace("'",''',$xmlStr); +$xmlStr=str_replace("&",'&',$xmlStr); +return $xmlStr; +} + +if(isset($_GET['user_name'])&&isset($_GET['num'])){ + +$user_name=$_GET['user_name']; +$num=$_GET['num']; + +// Opens a connection to a MySQL server +$connection=mysql_connect ('mysql.hostinger.in', $username, $password); +if (!$connection) { + die('Not connected : ' . mysql_error()); +} + +// Set the active MySQL database +$db_selected = mysql_select_db($database, $connection); +if (!$db_selected) { + die ('Can\'t use db : ' . mysql_error()); +} + +// Select all the rows in the markers table +$query = "SELECT * +FROM $user_name +ORDER BY $user_name.`time` DESC +LIMIT 0 , $num"; +$result = mysql_query($query); +if (!$result) { + die('Invalid query: ' . mysql_error()); +} + +header("Content-type: text/xml"); + +// Start XML file, echo parent node +echo ''; + +// Iterate through the rows, printing XML nodes for each +while ($row = @mysql_fetch_assoc($result)){ + // ADD TO XML DOCUMENT NODE + echo ''; +} + +// End XML file +echo ''; + +} + +?> \ No newline at end of file diff --git a/API/Geo/register.php b/API/Geo/register.php new file mode 100644 index 0000000..2b84257 --- /dev/null +++ b/API/Geo/register.php @@ -0,0 +1,32 @@ +storeUser($user_name, $email, $gcm_regid); + + $registatoin_ids = array($gcm_regid); + $message = array("product" => "shirt"); + + $result = $gcm->send_notification($registatoin_ids, $message); + + echo $result; +} else { + // user details missing +} +?> \ No newline at end of file diff --git a/API/Geo/send_message.php b/API/Geo/send_message.php new file mode 100644 index 0000000..20e03c9 --- /dev/null +++ b/API/Geo/send_message.php @@ -0,0 +1,17 @@ + $message); + + $result = $gcm->send_notification($registatoin_ids, $message); + + echo $result; +} +?> \ No newline at end of file diff --git a/API/Geo/signup_app.php b/API/Geo/signup_app.php new file mode 100644 index 0000000..0e5e65d --- /dev/null +++ b/API/Geo/signup_app.php @@ -0,0 +1,77 @@ + \ No newline at end of file diff --git a/API/Geo/sos.php b/API/Geo/sos.php new file mode 100644 index 0000000..8948287 --- /dev/null +++ b/API/Geo/sos.php @@ -0,0 +1,82 @@ +getAllUsers(); + + + +while($row = mysql_fetch_array($all)) +{ + +if($row["user_name"] != $user_name) +{ +$current_id = $row["gcm_regid"]; + + $curlat = $row["latitude"]; + $curlon = $row["longitude"]; + +if(($lla < $curlat) && ($curlat< $ula) && ($llo < $curlon) && ($curlon< $ulo)) +{ + $registatoin_ids = array($current_id); + $message = array("latitude" => $lat,"number" =>$number, "longitude" => $lon,"name" => $name, "user_name" => $user_name, "time"=>$time, "type" =>"sos"); + + $result = $gcm->send_notification($registatoin_ids, $message); + } + + +else{ +if($row["user_name"] == $fav1 || $row["user_name"] == $fav2 || $row["user_name"] == $fav3 || $row["user_name"] == $fav4) +{ + $registatoin_ids = array($current_id); + $message = array("latitude" => $lat,"number" =>$number, "longitude" => $lon,"name" => $name, "user_name" => $user_name, "time"=>$time, "type" =>"sos"); + + $result = $gcm->send_notification($registatoin_ids, $message); +} +} + + +} +} + + + + + +} +?> \ No newline at end of file diff --git a/API/Geo/status.php b/API/Geo/status.php new file mode 100644 index 0000000..ba35dca --- /dev/null +++ b/API/Geo/status.php @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/API/Geo/test.php b/API/Geo/test.php new file mode 100644 index 0000000..2b5ba94 --- /dev/null +++ b/API/Geo/test.php @@ -0,0 +1,129 @@ + + + + + + + + + Geo + + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/API/Geo/update_app.php b/API/Geo/update_app.php new file mode 100644 index 0000000..c1a379e --- /dev/null +++ b/API/Geo/update_app.php @@ -0,0 +1,72 @@ + 0) { + + $result = mysql_fetch_array($result); + $trueIMEI = $result["IMEI"]; +} +} + +if($imei== $trueIMEI){ + + $sql = "INSERT INTO $user_name (latitude,longitude,time) +VALUES ('$latitude','$longitude','$time')"; + +mysql_query($sql); + + // get a product from products table + $result = mysql_query("UPDATE Geo SET longitude = '$longitude', latitude = '$latitude', time='$time' , history = '$history' , sharing_on = '$sharing_on' WHERE user_name= '$user_name'"); + $result = mysql_fetch_array($result); + if (($result)) { + + + + $response["success"] = 1; + $response["message"] = "Product successfully created."; + + + + // echoing JSON response + echo json_encode($response); + } + + else { + // failed to insert row + $response["success"] = 0; + $response["message"] = "Oops! An error occurred."; + + // echoing JSON response + echo json_encode($response); + } + +} + + + ?> \ No newline at end of file diff --git a/API/Geo/upload_photo.php b/API/Geo/upload_photo.php new file mode 100644 index 0000000..13d84fb --- /dev/null +++ b/API/Geo/upload_photo.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/DigiPune.iml b/DigiPune.iml new file mode 100644 index 0000000..1b6e10f --- /dev/null +++ b/DigiPune.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Geo Material Design.iml b/Geo Material Design.iml new file mode 100644 index 0000000..cc2fd92 --- /dev/null +++ b/Geo Material Design.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Geo_11thAug.iml b/Geo_11thAug.iml new file mode 100644 index 0000000..7d52a13 --- /dev/null +++ b/Geo_11thAug.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Geo_16thJuly.iml b/Geo_16thJuly.iml new file mode 100644 index 0000000..dfcd826 --- /dev/null +++ b/Geo_16thJuly.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Geo_28thAug.iml b/Geo_28thAug.iml new file mode 100644 index 0000000..bacf94f --- /dev/null +++ b/Geo_28thAug.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MaterialDesign.iml b/MaterialDesign.iml new file mode 100644 index 0000000..aa264cb --- /dev/null +++ b/MaterialDesign.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..0749789 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..0b0e13b --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion '25.0.0' + + defaultConfig { + applicationId "in.skylinelabs.digiPune" + minSdkVersion 15 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:22.1.0' + compile 'com.android.support:support-v4:22.2.0' + compile 'com.android.support:recyclerview-v7:21.0.+' + compile 'com.google.android.gms:play-services:7.5.0' + compile 'com.github.clans:fab:1.5.4' + compile 'com.android.support:cardview-v7:21.0.+' + compile 'de.hdodenhof:circleimageview:1.3.0' + compile 'com.android.support:design:22.2.0' + compile 'com.skyfishjy.ripplebackground:library:1.0.1' + compile 'com.gordonwong:material-sheet-fab:1.0.4' + compile 'com.loopj.android:android-async-http:1.4.9' +} + diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..17ca83f --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/lincoln/Softwares/adt-bundle-mac-x86_64-20140702/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/in/skylinelabs/Geo/ApplicationTest.java b/app/src/androidTest/java/in/skylinelabs/Geo/ApplicationTest.java new file mode 100644 index 0000000..08741e8 --- /dev/null +++ b/app/src/androidTest/java/in/skylinelabs/Geo/ApplicationTest.java @@ -0,0 +1,13 @@ +package in.skylinelabs.digiPune; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..3638d2f --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/AboutDevelopers.java b/app/src/main/java/in/skylinelabs/digiPune/activity/AboutDevelopers.java new file mode 100644 index 0000000..0b37394 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/AboutDevelopers.java @@ -0,0 +1,266 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Intent; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.TransitionDrawable; +import android.net.Uri; +import android.support.v4.view.ViewCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.view.animation.OvershootInterpolator; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; + +import in.skylinelabs.digiPune.R; + +public class AboutDevelopers extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener { + + + FloatingActionButton fab, fb, web, email; + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + Boolean closed; + TextView webtxt, emailtxt, fbtxt; + + RelativeLayout rel; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.about_developers); + + displayView(8); + + closed = true; + + rel = (RelativeLayout) findViewById(R.id.rel); + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + + + fab = (FloatingActionButton) findViewById(R.id.fab); + web = (FloatingActionButton) findViewById(R.id.web); + fb = (FloatingActionButton) findViewById(R.id.fb); + email = (FloatingActionButton) findViewById(R.id.email); + + webtxt = (TextView) findViewById(R.id.textWebsite); + fbtxt = (TextView) findViewById(R.id.textFacebook); + emailtxt = (TextView) findViewById(R.id.textEmail); + + + web.setVisibility(View.GONE); + fb.setVisibility(View.GONE); + email.setVisibility(View.GONE); + webtxt.setVisibility(View.GONE); + fbtxt.setVisibility(View.GONE); + emailtxt.setVisibility(View.GONE); + + + web.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + String url = "http://www.skylinelabs.in"; + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(url)); + startActivity(i); + } + }); + + fb.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + String url = "http://www.facebook.com/theterribilis"; + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(url)); + startActivity(i); + } + }); + + email.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( + "mailto","contact@skylinelabs.in", null)); + intent.putExtra(Intent.EXTRA_SUBJECT, "digiPune feedback"); + intent.putExtra(Intent.EXTRA_TEXT, "Hi ! It was an awesome experience using digiPune! "); + startActivity(Intent.createChooser(intent, "Contact developers")); + } + }); + + + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(closed) + { + open(); + closed = false; + + final OvershootInterpolator interpolator = new OvershootInterpolator(); + ViewCompat.animate(fab).rotation(135f).withLayer().setDuration(300).setInterpolator(interpolator).start(); + + } + + else + { + close(); + closed = true; + + final OvershootInterpolator interpolator = new OvershootInterpolator(); + ViewCompat.animate(fab).rotation(0f).withLayer().setDuration(300).setInterpolator(interpolator).start(); + + + } + } + }); + + } + + void open() + { + ColorDrawable[] color = {new ColorDrawable(Color.parseColor("#00ffffff")), new ColorDrawable(Color.parseColor("#CC000000"))}; + TransitionDrawable trans = new TransitionDrawable(color); + //This will work also on old devices. The latest API says you have to use setBackground instead. + rel.setBackgroundDrawable(trans); + trans.startTransition(100); + + + //rel.setBackgroundColor(Color.parseColor("#CC000000")); + web.setVisibility(View.VISIBLE); + fb.setVisibility(View.VISIBLE); + email.setVisibility(View.VISIBLE); + webtxt.setVisibility(View.VISIBLE); + fbtxt.setVisibility(View.VISIBLE); + emailtxt.setVisibility(View.VISIBLE); + + } + + void close() + { + rel.setBackgroundColor(Color.parseColor("#00ffffff")); + web.setVisibility(View.GONE); + fb.setVisibility(View.GONE); + email.setVisibility(View.GONE); + webtxt.setVisibility(View.GONE); + fbtxt.setVisibility(View.GONE); + emailtxt.setVisibility(View.GONE); + + + } + + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + title = "digiPune"; + break; + case 1: + finish(); + i = new Intent(this, MyLocation.class); + startActivity(i); + title = "My Location"; + break; + case 2: + finish(); + i = new Intent(this, Location_event.class); + startActivity(i); + title ="GeoFencing"; + break; + case 3: + finish(); + i = new Intent(this, Setting.class); + startActivity(i); + title ="Settings"; + break; + case 4: + finish(); + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + title ="SOS Contacts"; + break; + case 5: + finish(); + i = new Intent(this, Favourites.class); + startActivity(i); + title ="Favourites"; + break; + case 6: + finish(); + i = new Intent(this, History.class); + startActivity(i); + title ="History"; + break; + /*case 6: + finish(); + i = new Intent(AboutDevelopers.this, GeoFencing.class); + startActivity(i); + break; + case 7: + finish(); + i = new Intent(AboutDevelopers.this, Help.class); + startActivity(i); + break;*/ + case 7: + Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( + "mailto","contact@skylinelabs.in", null)); + intent.putExtra(Intent.EXTRA_SUBJECT, "digiPune feedback"); + intent.putExtra(Intent.EXTRA_TEXT, "Hi ! It was an awesome experience using digiPune! "); + startActivity(Intent.createChooser(intent, "Contact developers")); + break; + case 8: + + title ="About"; + break; + case 9: + Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=" + this.getPackageName()); + Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); + try { + startActivity(goToMarket); + } + catch(Exception e) + { + + } + break; + + case 10: + finish(); + i = new Intent(this, Privacypolicy.class); + startActivity(i); + title ="Privacy"; + break; + + default: + break; + } + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Alert_Send.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Alert_Send.java new file mode 100644 index 0000000..fdeae5c --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Alert_Send.java @@ -0,0 +1,125 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.AlertDialog; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; +import android.view.View; +import android.view.WindowManager; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.EditText; +import android.widget.ProgressBar; + +import com.github.clans.fab.FloatingActionButton; + +import in.skylinelabs.digiPune.R; + +public class Alert_Send extends ActionBarActivity { + + FloatingActionButton btn; + EditText edtTitle, edtMessage; + + AlertDialog alertDialog; + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + WebView wb; + + ProgressBar prgbr; + + View.OnClickListener snackaction,snackaction1;; + + + + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_alert__ssend); + + snackaction1 = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("digiPune"); + + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + + btn = (FloatingActionButton) findViewById(R.id.button1); + edtTitle = (EditText) findViewById(R.id.editText2); + edtMessage = (EditText) findViewById(R.id.editText); + + wb = (WebView) findViewById(R.id.webView3); + wb.setVisibility(View.GONE); + wb.getSettings().setJavaScriptEnabled(true); + wb.getSettings().setAllowFileAccess(true); + wb.getSettings().setJavaScriptCanOpenWindowsAutomatically(false); + wb.getSettings().setBuiltInZoomControls(true); + wb.getSettings().setSupportZoom(true); + wb.setWebViewClient(new WebViewClient()); + + wb.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) { + if (progress < 100) { + + } + + if (progress == 100) { + Snackbar.make(findViewById(android.R.id.content), "Alert Sent", Snackbar.LENGTH_LONG) + .setAction("OK", snackaction1) + .setActionTextColor(Color.WHITE) + .show(); + + } + } + }); + + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String Title, Message; + Title = edtTitle.getText().toString(); + Message = edtMessage.getText().toString(); + wb.loadUrl("http://www.skylinelabs.in/Geo/alert.php?user_name="+settings.getString("user_name","")+"&title="+Title+"&message="+Message); + + } + }); + + + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + + + + + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/App_intro.java b/app/src/main/java/in/skylinelabs/digiPune/activity/App_intro.java new file mode 100644 index 0000000..62c1eaa --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/App_intro.java @@ -0,0 +1,115 @@ +package in.skylinelabs.digiPune.activity; + +import android.graphics.Color; +import android.os.Build; +import android.os.Bundle; +import android.support.v4.view.ViewPager; +import android.support.v7.app.ActionBarActivity; +import android.view.View; +import android.widget.TextView; + +import in.skylinelabs.digiPune.R; + +public class App_intro extends ActionBarActivity { + + TextView skip, next; + + @Override protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_app_intro); + + + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + + skip = (TextView) findViewById(R.id.skip); + next = (TextView) findViewById(R.id.next); + + skip.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + getWindow().setStatusBarColor(Color.TRANSPARENT); + } + + + + + + + final ViewPager customViewpager = (ViewPager) findViewById(R.id.viewpager_custom); + CircleIndicator customIndicator = (CircleIndicator) findViewById(R.id.indicator_custom); + DemoPagerAdapter customPagerAdapter = new DemoPagerAdapter(getSupportFragmentManager()); + customViewpager.setAdapter(customPagerAdapter); + customIndicator.setViewPager(customViewpager); + + customViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int i, float v, int i2) { + if(customViewpager.getCurrentItem()==4) { + next.setText("Done"); + next.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + finish(); + + } + }); + } + + } + + @Override + public void onPageSelected(int i) { + + } + + @Override + public void onPageScrollStateChanged(int i) { + + } + }); + + if(customViewpager.getCurrentItem()!=5) { + next.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + customViewpager.setCurrentItem(customViewpager.getCurrentItem() + 1); + } + + }); + + } + + + customViewpager.setPageTransformer(true, new ViewPager.PageTransformer() { + @Override + public void transformPage(View view, float position) { + // Ensures the views overlap each other. + view.setTranslationX(view.getWidth() * -position); + + // Alpha property is based on the view position. + if (position <= -1.0F || position >= 1.0F) { + view.setAlpha(0.0F); + } else if (position == 0.0F) { + view.setAlpha(1.0F); + } else { // position is between -1.0F & 0.0F OR 0.0F & 1.0F + view.setAlpha(1.0F - Math.abs(position)); + } + + + } + }); + } + + + + + } + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/BootCompletedReceiver.java b/app/src/main/java/in/skylinelabs/digiPune/activity/BootCompletedReceiver.java new file mode 100644 index 0000000..f83dce2 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/BootCompletedReceiver.java @@ -0,0 +1,33 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.ActivityManager; +import android.app.ActivityManager.RunningServiceInfo; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + + +public class BootCompletedReceiver extends BroadcastReceiver { + + final static String TAG = "BootCompletedReceiver"; + + + + @Override + public void onReceive(Context context, Intent arg1) { + + + ActivityManager manager = (ActivityManager)context. getSystemService(Context.ACTIVITY_SERVICE); + for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) + { + + if (digiPune.class.getName().equals(service.service.getClassName())) { + //running + } + else{ + context.startService(new Intent(context, digiPune.class)); + } + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Bus_Fetch.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Bus_Fetch.java new file mode 100644 index 0000000..ef93bd6 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Bus_Fetch.java @@ -0,0 +1,988 @@ +package in.skylinelabs.digiPune.activity; + +import android.annotation.SuppressLint; +import android.annotation.TargetApi; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.location.Location; +import android.location.LocationManager; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Build; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; +import com.gordonwong.materialsheetfab.MaterialSheetFab; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +import in.skylinelabs.digiPune.R; + + +public class Bus_Fetch extends ActionBarActivity implements android.location.LocationListener, GoogleMap.OnCameraChangeListener, GoogleMap.OnMapLoadedCallback { + + private ProgressDialog pDialog; + + + private Toolbar mToolbar; + + MaterialSheetFab materialSheetFab; + + String BusNumber; + + String start, end; + + GoogleMap map; + + public static int i; + + ProgressBar prgbr, markerp; + + TextView txt1, txt2, textView3; + + long date; + @SuppressLint("SimpleDateFormat") + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + final Context context = this; + + String post; + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + Boolean catopen = false; + + EditText toolbarSearchView; + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0;//0 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 30 * 1; // 1/2 minute + + //Declaring a Location Manager + protected LocationManager locationManager; + + + FloatingActionButton btn2; + + + + JSONParser jsonParser = new JSONParser(); + + private static final String url_get_category = "http://www.skylinelabs.in/Geo/PMPML/routewise.php"; + + + AlertDialog alertDialog; + + Boolean searchByNumberb = false, searchByRoute = false; + + FloatingActionButton btn1; + + Marker[] mrkgrp = new Marker[1000000]; + + View.OnClickListener snackaction, snackaction1; + + CustomAutoCompleteView myAutoComplete, myAutoComplete2; + + // adapter for auto-complete + ArrayAdapter myAdapter, myAdapter2; + + // for database operations + DatabaseHandler databaseH; + + // just to add some initial value + String[] item = new String[]{"Please search..."}; + + + @Override + protected void onStop() { + super.onStop(); // Always call the superclass method first + } + + @Override + protected void onPause() { + super.onPause(); + + } + + @Override + protected void onResume() { + + super.onResume(); + + } + + public String[] getItemsFromDb(String searchTerm) { + + // add items on the array dynamically + List products = databaseH.read(searchTerm); + int rowCount = products.size(); + + String[] item = new String[rowCount]; + int x = 0; + + for (MyObject record : products) { + + item[x] = record.objectName; + x++; + } + + return item; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_bus__fetch); + + /**************************************************************************************/ + + try { + + } catch (Exception e) { + + } + + /**************************************************************************************/ + + try { + + // instantiate database handler + databaseH = new DatabaseHandler(Bus_Fetch.this); + + // put sample data to database + new CreateBusDatabase().execute(); + // autocompletetextview is in activity_main.xml + myAutoComplete = (CustomAutoCompleteView) findViewById(R.id.myautocomplete1); + + // add the listener so it will tries to suggest while the user types + myAutoComplete.addTextChangedListener(new CustomAutoCompleteTextChangedListener1(this)); + + // set our adapter + myAdapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, item); + myAutoComplete.setAdapter(myAdapter); + + } catch (NullPointerException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + /**************************************************************************************/ + + /**************************************************************************************/ + + try { + + myAutoComplete2 = (CustomAutoCompleteView) findViewById(R.id.myautocomplete2); + // add the listener so it will tries to suggest while the user types + myAutoComplete2.addTextChangedListener(new CustomAutoCompleteTextChangedListener2(this)); + // set our adapter + myAdapter2 = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, item); + myAutoComplete2.setAdapter(myAdapter2); + + + } catch (NullPointerException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + /**************************************************************************************/ + + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + toolbarSearchView = (EditText) findViewById(R.id.search_view); + toolbarSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + searchByNumber(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + Bus_Fetch.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + return true; + } + return false; + } + }); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + + // display the first navigation drawer view on app launch + + getLocation(); + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + + markerp = (ProgressBar) findViewById(R.id.progressBar1); + markerp.setVisibility(View.GONE); + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + + + map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { + @Override + public boolean onMarkerClick(Marker marker) { + + final Marker mk = marker; + + snackaction1 = new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent callvictim = new Intent(Intent.ACTION_CALL); + callvictim.setData(Uri.parse("tel:" + mk.getSnippet())); + startActivity(callvictim); + } + }; + + Snackbar.make(findViewById(android.R.id.content), "Estimated arrival time :", Snackbar.LENGTH_LONG) + .setAction("Call", snackaction1) + .setActionTextColor(Color.WHITE) + .show(); + + return false; + } + }); + + + map.setOnCameraChangeListener(this); + map.setOnMapLoadedCallback(Bus_Fetch.this); + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + + txt1 = (TextView) findViewById(R.id.textView1); + txt2 = (TextView) findViewById(R.id.textView2); + + btn1 = (FloatingActionButton) findViewById(R.id.button1); + btn1.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) { + start = myAutoComplete.getText().toString(); + end = myAutoComplete2.getText().toString(); + if (end.equals(start) || start == null || end == null || start == "" || end == "") { + if (end.equals(start)) { + Snackbar.make(findViewById(android.R.id.content), "Start and End points cant be same", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } else if (start == null || start == "") { + Snackbar.make(findViewById(android.R.id.content), "Start point can't be empty", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } else if (end == null || end == "") { + Snackbar.make(findViewById(android.R.id.content), "End point can't be empty", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } else { + searchByNumberb = false; + searchByRoute = true; + new GetByRoute().execute(); + map.clear(); + markerp.setVisibility(View.VISIBLE); + } + } + } + + }); + + btn2 = (FloatingActionButton) findViewById(R.id.location); + btn2.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + // Toast.makeText(getApplicationContext(),getLatitude(),Toast.LENGTH_LONG).show(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + }); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_bus__fetch, menu); + return true; + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + Bus_Fetch.this); + LayoutInflater factory = LayoutInflater.from(Bus_Fetch.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.friendlocation_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + } + + if (id == R.id.action_search) { + + searchByNumber(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + Bus_Fetch.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + + } + + + return super.onOptionsItemSelected(item); + } + + + @Override + public void onBackPressed() { + // TODO Auto-generated method stub + //super.onBackPressed(); + + if (!catopen) { + finish(); + } else { + materialSheetFab.hideSheet(); + } + + } + + @Override + public void onStatusChanged(String provider, int status, + Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + // .makeText(getApplicationContext(),"Please enable internet",Toast.LENGTH_LONG).show(); + + Snackbar.make(findViewById(android.R.id.content), "Please enable location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(Bus_Fetch.this); + map.setOnCameraChangeListener(Bus_Fetch.this); + textView3.setVisibility(View.VISIBLE); + prgbr.setVisibility(View.VISIBLE); + } + + + @Override + public void onMapLoaded() { + + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + @Override + public void onLocationChanged(Location arg0) { + + map.setOnMapLoadedCallback(Bus_Fetch.this); + + if(searchByNumberb) { + new GetByNumberUpdate().execute(); + markerp.setVisibility(View.VISIBLE); + } + + else if(searchByRoute){ + + markerp.setVisibility(View.VISIBLE); + } + else + markerp.setVisibility(View.GONE); + + + } + + public Location getLocation() { + try { + locationManager = (LocationManager) this.getBaseContext().getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) { + // no network provider is enabled + } else { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) { + if (location == null) { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } catch (Exception e) { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + + public void updateGPSCoordinates() { + if (location != null) { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + public double getLatitude() { + if (location != null) { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() { + if (location != null) { + longitude = location.getLongitude(); + } + + return longitude; + } + + /** + * Function to check GPS/wifi enabled + */ + + class CreateBusDatabase extends AsyncTask { + + @Override + protected void onPreExecute() { + pDialog = new ProgressDialog(Bus_Fetch.this); + pDialog.setMessage("Settings up bus database...."); + pDialog.setIndeterminate(false); + pDialog.setCancelable(false); + pDialog.show(); + } + + protected String doInBackground(String... args) { + + databaseH.create(new MyObject("PMC")); + databaseH.create(new MyObject("E_SQUARE")); + databaseH.create(new MyObject("AUNDH")); + databaseH.create(new MyObject("WAKAD")); + databaseH.create(new MyObject("RAKSHAK_CHOWK")); + databaseH.create(new MyObject("INFOSYS_PHASE_2")); + databaseH.create(new MyObject("HINJEWADI_PHASE_3")); + databaseH.create(new MyObject("PUNE_STATION")); + databaseH.create(new MyObject("PUNE_UNIVERSITY")); + databaseH.create(new MyObject("BANER")); + databaseH.create(new MyObject("BALEWADI")); + databaseH.create(new MyObject("DANGE_CHOWK")); + databaseH.create(new MyObject("DANGE_CHOWK")); + + pDialog.dismiss(); + + return null; + } + } + + public void searchByNumber() { + searchByNumberb = true; + searchByRoute = false; + BusNumber = toolbarSearchView.getText().toString(); + new GetByNumber().execute(); + map.clear(); + markerp.setVisibility(View.VISIBLE); + } + + + + class GetByNumber extends AsyncTask { + + JSONObject json2; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("route", BusNumber)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json2 = jsonParser.makeHttpRequest( + url_get_category, "GET", params); + Log.d("These are your markers",json2.toString()); + + } + + catch (Exception e1) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + markerp.setVisibility(View.GONE); + + } + }); + return null; + } + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + JSONArray values = null; + try { + values = json2.getJSONArray("result"); + final int numberOfItemsInResp = values.length(); + + if(numberOfItemsInResp == 0) + { + Snackbar.make(findViewById(android.R.id.content), "No buses found", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + for (int i = 0; i < numberOfItemsInResp; i++) + { + JSONObject coordinates = values.getJSONObject(i); + Log.e("Values bagh", coordinates.toString()); + + MarkerOptions markerOption = new MarkerOptions().position(new LatLng(10, 10)); + mrkgrp[i] = map.addMarker(markerOption); + mrkgrp[i].setVisible(false); + mrkgrp[i].setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrkgrp[i].setTitle("From :" + coordinates.getString("start") + " " + "To :" + coordinates.getString("end")); + mrkgrp[i].setSnippet("Bus number " + BusNumber); + mrkgrp[i].setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrkgrp[i].setVisible(true); + + } + markerp.setVisibility(View.GONE); + int no = numberOfItemsInResp ; + Snackbar.make(findViewById(android.R.id.content), no+ " buses found", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } catch (JSONException e) { + Log.e("Error in markers", e.toString()); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + markerp.setVisibility(View.GONE); + } + } + }); + } + return null; + } + } + + + class GetByNumberUpdate extends AsyncTask { + + JSONObject json2; + Boolean updated = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("route", BusNumber)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (isInternetPresent) { + try { + + json2 = jsonParser.makeHttpRequest( + url_get_category, "GET", params); + updated = true; + + } + catch (Exception e1) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + updated = false; + markerp.setVisibility(View.GONE); + + + } + }); + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if (isInternetPresent1 && updated) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + JSONArray values = null; + try { + values = json2.getJSONArray("result"); + final int numberOfItemsInResp = values.length(); + + map.clear(); + + + for (int i = 0; i < numberOfItemsInResp; i++) + { + JSONObject coordinates = values.getJSONObject(i); + Log.e("Values bagh", coordinates.toString()); + + MarkerOptions markerOption = new MarkerOptions().position(new LatLng(10, 10)); + mrkgrp[i] = map.addMarker(markerOption); + mrkgrp[i].setVisible(false); + mrkgrp[i].setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrkgrp[i].setTitle("From :" + coordinates.getString("start") + " " + "To :" + coordinates.getString("end")); + mrkgrp[i].setSnippet("Bus number " + BusNumber); + mrkgrp[i].setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrkgrp[i].setVisible(true); + + } + markerp.setVisibility(View.GONE); + + } catch (JSONException e) { + Log.e("Error in markers", e.toString()); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + markerp.setVisibility(View.GONE); + } + } + }); + } + return null; + } + } + + + class GetByRoute extends AsyncTask { + + JSONObject json2; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("endloc", end)); + params.add(new BasicNameValuePair("startloc", start)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json2 = jsonParser.makeHttpRequest( + "http://www.skylinelabs.in/Geo/PMPML/from_to.php", "GET", params); + Log.d("These are your markers",json2.toString()); + + } + + catch (Exception e1) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + markerp.setVisibility(View.GONE); + + } + }); + return null; + } + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + JSONArray values = null; + try { + values = json2.getJSONArray("result"); + final int numberOfItemsInResp = values.length(); + + if(numberOfItemsInResp == 0) + { + Snackbar.make(findViewById(android.R.id.content), "No buses found", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + for (int i = 0; i < numberOfItemsInResp; i++) + { + JSONObject coordinates = values.getJSONObject(i); + Log.e("Values bagh", coordinates.toString()); + + MarkerOptions markerOption = new MarkerOptions().position(new LatLng(10, 10)); + mrkgrp[i] = map.addMarker(markerOption); + mrkgrp[i].setVisible(false); + mrkgrp[i].setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrkgrp[i].setTitle("From :" + coordinates.getString("start") + " " + "To :" + coordinates.getString("end")); + mrkgrp[i].setSnippet("Bus number " + BusNumber); + mrkgrp[i].setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrkgrp[i].setVisible(true); + + } + markerp.setVisibility(View.GONE); + + } catch (JSONException e) { + Log.e("Error in markers", e.toString()); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + markerp.setVisibility(View.GONE); + } + } + }); + } + return null; + } + } + + + +} + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/CircleIndicator.java b/app/src/main/java/in/skylinelabs/digiPune/activity/CircleIndicator.java new file mode 100644 index 0000000..95bc1a3 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/CircleIndicator.java @@ -0,0 +1,220 @@ +package in.skylinelabs.digiPune.activity; + +import android.animation.Animator; +import android.animation.AnimatorInflater; +import android.content.Context; +import android.content.res.TypedArray; +import android.support.annotation.AnimatorRes; +import android.support.annotation.DrawableRes; +import android.support.v4.view.ViewPager; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.animation.Interpolator; +import android.widget.LinearLayout; + +import in.skylinelabs.digiPune.R; + +import static android.support.v4.view.ViewPager.OnPageChangeListener; + +public class CircleIndicator extends LinearLayout implements OnPageChangeListener { + + private final static int DEFAULT_INDICATOR_WIDTH = 5; + private ViewPager mViewpager; + private int mIndicatorMargin = -1; + private int mIndicatorWidth = -1; + private int mIndicatorHeight = -1; + private int mAnimatorResId = R.animator.scale_with_alpha; + private int mAnimatorReverseResId = 0; + private int mIndicatorBackgroundResId = R.drawable.white_radius; + private int mIndicatorUnselectedBackgroundResId = R.drawable.white_radius; + private int mCurrentPosition = 0; + private Animator mAnimationOut; + private Animator mAnimationIn; + + public CircleIndicator(Context context) { + super(context); + init(context, null); + } + + public CircleIndicator(Context context, AttributeSet attrs) { + super(context, attrs); + init(context, attrs); + } + + private void init(Context context, AttributeSet attrs) { + setOrientation(LinearLayout.HORIZONTAL); + setGravity(Gravity.CENTER); + handleTypedArray(context, attrs); + checkIndicatorConfig(context); + } + + private void handleTypedArray(Context context, AttributeSet attrs) { + if (attrs == null) { + return; + } + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleIndicator); + mIndicatorWidth = + typedArray.getDimensionPixelSize(R.styleable.CircleIndicator_ci_width, -1); + mIndicatorHeight = + typedArray.getDimensionPixelSize(R.styleable.CircleIndicator_ci_height, -1); + mIndicatorMargin = + typedArray.getDimensionPixelSize(R.styleable.CircleIndicator_ci_margin, -1); + + mAnimatorResId = typedArray.getResourceId(R.styleable.CircleIndicator_ci_animator, + R.animator.scale_with_alpha); + mAnimatorReverseResId = + typedArray.getResourceId(R.styleable.CircleIndicator_ci_animator_reverse, 0); + mIndicatorBackgroundResId = + typedArray.getResourceId(R.styleable.CircleIndicator_ci_drawable, + R.drawable.white_radius); + mIndicatorUnselectedBackgroundResId = + typedArray.getResourceId(R.styleable.CircleIndicator_ci_drawable_unselected, + mIndicatorBackgroundResId); + typedArray.recycle(); + } + + /** + * Create and configure Indicator in Java code. + */ + public void configureIndicator(int indicatorWidth, int indicatorHeight, int indicatorMargin) { + configureIndicator(indicatorWidth, indicatorHeight, indicatorMargin, + R.animator.scale_with_alpha, 0, R.drawable.white_radius, R.drawable.white_radius); + } + + public void configureIndicator(int indicatorWidth, int indicatorHeight, int indicatorMargin, + @AnimatorRes int animatorId, @AnimatorRes int animatorReverseId, + @DrawableRes int indicatorBackgroundId, + @DrawableRes int indicatorUnselectedBackgroundId) { + + mIndicatorWidth = indicatorWidth; + mIndicatorHeight = indicatorHeight; + mIndicatorMargin = indicatorMargin; + + mAnimatorResId = animatorId; + mAnimatorReverseResId = animatorReverseId; + mIndicatorBackgroundResId = indicatorBackgroundId; + mIndicatorUnselectedBackgroundResId = indicatorUnselectedBackgroundId; + + checkIndicatorConfig(getContext()); + } + + private void checkIndicatorConfig(Context context) { + mIndicatorWidth = (mIndicatorWidth < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorWidth; + mIndicatorHeight = + (mIndicatorHeight < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorHeight; + mIndicatorMargin = + (mIndicatorMargin < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorMargin; + + mAnimatorResId = (mAnimatorResId == 0) ? R.animator.scale_with_alpha : mAnimatorResId; + mAnimationOut = AnimatorInflater.loadAnimator(context, mAnimatorResId); + if (mAnimatorReverseResId == 0) { + mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorResId); + mAnimationIn.setInterpolator(new ReverseInterpolator()); + } else { + mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId); + } + mIndicatorBackgroundResId = (mIndicatorBackgroundResId == 0) ? R.drawable.white_radius + : mIndicatorBackgroundResId; + mIndicatorUnselectedBackgroundResId = + (mIndicatorUnselectedBackgroundResId == 0) ? mIndicatorBackgroundResId + : mIndicatorUnselectedBackgroundResId; + } + + public void setViewPager(ViewPager viewPager) { + mViewpager = viewPager; + mCurrentPosition = mViewpager.getCurrentItem(); + createIndicators(viewPager); + mViewpager.removeOnPageChangeListener(this); + mViewpager.addOnPageChangeListener(this); + onPageSelected(mCurrentPosition); + } + + /** + * @deprecated User ViewPager addOnPageChangeListener + */ + @Deprecated + public void setOnPageChangeListener(OnPageChangeListener onPageChangeListener) { + if (mViewpager == null) { + throw new NullPointerException("can not find Viewpager , setViewPager first"); + } + mViewpager.removeOnPageChangeListener(onPageChangeListener); + mViewpager.addOnPageChangeListener(onPageChangeListener); + } + + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + } + + @Override + public void onPageSelected(int position) { + + if (mViewpager.getAdapter() == null || mViewpager.getAdapter().getCount() <= 0) { + return; + } + + if (mAnimationIn.isRunning()) mAnimationIn.end(); + if (mAnimationOut.isRunning()) mAnimationOut.end(); + + View currentIndicator = getChildAt(mCurrentPosition); + currentIndicator.setBackgroundResource(mIndicatorUnselectedBackgroundResId); + mAnimationIn.setTarget(currentIndicator); + mAnimationIn.start(); + + View selectedIndicator = getChildAt(position); + selectedIndicator.setBackgroundResource(mIndicatorBackgroundResId); + mAnimationOut.setTarget(selectedIndicator); + mAnimationOut.start(); + + mCurrentPosition = position; + } + + @Override + public void onPageScrollStateChanged(int state) { + } + + private void createIndicators(ViewPager viewPager) { + removeAllViews(); + if (viewPager.getAdapter() == null) { + return; + } + + int count = viewPager.getAdapter().getCount(); + if (count <= 0) { + return; + } + addIndicator(mIndicatorBackgroundResId, mAnimationOut); + for (int i = 1; i < count; i++) { + addIndicator(mIndicatorUnselectedBackgroundResId, mAnimationIn); + } + } + + private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) { + if (animator.isRunning()) animator.end(); + + View Indicator = new View(getContext()); + Indicator.setBackgroundResource(backgroundDrawableId); + addView(Indicator, mIndicatorWidth, mIndicatorHeight); + LayoutParams lp = (LayoutParams) Indicator.getLayoutParams(); + lp.leftMargin = mIndicatorMargin; + lp.rightMargin = mIndicatorMargin; + Indicator.setLayoutParams(lp); + + animator.setTarget(Indicator); + animator.start(); + } + + private class ReverseInterpolator implements Interpolator { + @Override + public float getInterpolation(float value) { + return Math.abs(1.0f - value); + } + } + + public int dip2px(float dpValue) { + final float scale = getResources().getDisplayMetrics().density; + return (int) (dpValue * scale + 0.5f); + } + +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/ColorFragment.java b/app/src/main/java/in/skylinelabs/digiPune/activity/ColorFragment.java new file mode 100644 index 0000000..87b4995 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/ColorFragment.java @@ -0,0 +1,73 @@ +package in.skylinelabs.digiPune.activity; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import in.skylinelabs.digiPune.R; + +public class ColorFragment extends Fragment { + + private static final String ARG_COLOR = "color"; + private static final String ARG_INT = "position"; + private int mColor, pos; + + public static ColorFragment newInstance(int param1, int param2) { + ColorFragment fragment = new ColorFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_COLOR, param1); + args.putInt(ARG_INT, param2); + + fragment.setArguments(args); + return fragment; + } + + public ColorFragment() { + + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mColor = getArguments().getInt(ARG_COLOR); + pos = getArguments().getInt(ARG_INT); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + if (pos == 0) { + View v = inflater.inflate(R.layout.intro_1, container, false); + v.setBackgroundColor(mColor); + return v; + } + if (pos == 1) { + View v = inflater.inflate(R.layout.intro_2, container, false); + v.setBackgroundColor(mColor); + return v; + } + if (pos == 2) { + View v = inflater.inflate(R.layout.intro_3, container, false); + v.setBackgroundColor(mColor); + return v; + } + if (pos == 3) { + View v = inflater.inflate(R.layout.intro_4, container, false); + v.setBackgroundColor(mColor); + return v; + } + if (pos == 4) { + View v = inflater.inflate(R.layout.intro_5, container, false); + v.setBackgroundColor(mColor); + return v; + } + + else + return null; + + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/ComplaintPortal.java b/app/src/main/java/in/skylinelabs/digiPune/activity/ComplaintPortal.java new file mode 100644 index 0000000..bd43cf0 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/ComplaintPortal.java @@ -0,0 +1,228 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.os.AsyncTask; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.MarkerOptions; + +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import in.skylinelabs.digiPune.R; +import in.skylinelabs.digiPune.complaint_cardview.FeedItem; +import in.skylinelabs.digiPune.complaint_cardview.FeedItemAdapter; + + +public class ComplaintPortal extends ActionBarActivity { + + private Toolbar mToolbar; + FloatingActionButton btn; + + JSONParser jsonParser = new JSONParser(); + + View.OnClickListener snackaction,snackaction1; + + List result = new ArrayList(); + RecyclerView recList; + FeedItemAdapter ca; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_complaint_portal); + recList = (RecyclerView) findViewById(R.id.cardList); + recList.setHasFixedSize(true); + LinearLayoutManager llm = new LinearLayoutManager(this); + llm.setOrientation(LinearLayoutManager.VERTICAL); + recList.setLayoutManager(llm); + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("Swach Bharat"); + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + new GetCategoryUpdate().execute(); + ca = new FeedItemAdapter(this, result); + recList.setAdapter(ca); + recList.addOnItemTouchListener( + new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() { + @Override + public void onItemClick(View view, int position) { + // do whateverv + //switch (position) { + // case 0: + TextView tid = (TextView) view.findViewById(R.id.ID); + TextView lat = (TextView) view.findViewById(R.id.latitude); + TextView lon = (TextView) view.findViewById(R.id.logitude); + TextView ttitle = (TextView) view.findViewById(R.id.title); + TextView td = (TextView) view.findViewById(R.id.description); + TextView turl = (TextView) view.findViewById(R.id.url); + Intent i = new Intent(ComplaintPortal.this, SwachBharatActivity.class); + i.putExtra("title", ttitle.getText()); + i.putExtra("id", tid.getText()); + i.putExtra("description", td.getText()); + i.putExtra("url", turl.getText()); + i.putExtra("lat", lat.getText()); + i.putExtra("lon", lon.getText()); + startActivity(i); + //break; + + } + }) + ); + btn = (FloatingActionButton) findViewById(R.id.button1); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i = new Intent(ComplaintPortal.this, Upload_Complaint.class); + startActivity(i); + } + }); + + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_complaint_portal, menu); + return true; + + + + } + class GetCategoryUpdate extends AsyncTask { + + JSONObject json2; + Boolean updated = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + ca.notifyDataSetChanged(); + + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("category", "police")); + + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (isInternetPresent) { + try { + + json2 = jsonParser.makeHttpRequest( + "http://www.skylinelabs.in/Compalaint_Portal/fetch_category.php", "GET", params); + updated = true; + + } catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error. Enable internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + updated = false; + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if (isInternetPresent1 && updated) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + JSONArray values = null; + try { + values = json2.getJSONArray("result"); + final int numberOfItemsInResp = values.length(); + + + + for (int i = 0; i < numberOfItemsInResp; i++) { + JSONObject coordinates = values.getJSONObject(i); + Log.e("result", coordinates.toString()); + FeedItem fi1 = new FeedItem(); + fi1.title = coordinates.getString("title"); + fi1.id = coordinates.getString("id"); + fi1.description = coordinates.getString("description"); + String imgurl = coordinates.getString("image"); + fi1.imgurl = imgurl.replaceAll("\\\\", ""); + fi1.latitude = coordinates.getString("latitude"); + fi1.longitude = coordinates.getString("longitude"); + result.add(fi1); + + } + + } catch (JSONException e) { + Log.e("Error in markers", e.toString()); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + return null; + } + } + + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Conductor_Activity.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Conductor_Activity.java new file mode 100644 index 0000000..a9f0a06 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Conductor_Activity.java @@ -0,0 +1,37 @@ +package in.skylinelabs.digiPune.activity; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +import in.skylinelabs.digiPune.R; + +public class Conductor_Activity extends ActionBarActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_conductor_); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_conductor_, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + + + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/ConnectionDetector.java b/app/src/main/java/in/skylinelabs/digiPune/activity/ConnectionDetector.java new file mode 100644 index 0000000..bac9f3d --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/ConnectionDetector.java @@ -0,0 +1,37 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; + +public class ConnectionDetector { + + private Context _context; + + public ConnectionDetector(Context context){ + this._context = context; + } + + public boolean isConnectingToInternet(){ + ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE); + if (connectivity != null) + { + NetworkInfo[] info = connectivity.getAllNetworkInfo(); + if (info != null) + for (int i = 0; i < info.length; i++) + if (info[i].getState() == NetworkInfo.State.CONNECTED) + { + return true; + } + + NetworkInfo mWifi = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + + if (mWifi.isConnected()) { + + return true; + } + + } + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteTextChangedListener1.java b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteTextChangedListener1.java new file mode 100644 index 0000000..68b3eb7 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteTextChangedListener1.java @@ -0,0 +1,43 @@ +package in.skylinelabs.digiPune.activity; + + import android.content.Context; + import android.text.Editable; + import android.text.TextWatcher; + import android.widget.ArrayAdapter; + +public class CustomAutoCompleteTextChangedListener1 implements TextWatcher{ + + public static final String TAG = "CustomAutoCompleteTextChangedListener1.java"; + Context context; + + public CustomAutoCompleteTextChangedListener1(Context context){ + this.context = context; + } + + @Override + public void afterTextChanged(Editable s) { + // TODO Auto-generated method stub + + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + // TODO Auto-generated method stub + + } + + @Override + public void onTextChanged(CharSequence userInput, int start, int before, int count) { + + Bus_Fetch mainActivity = ((Bus_Fetch) context); + // query the database based on the user input + mainActivity.item = mainActivity.getItemsFromDb(userInput.toString()); + + mainActivity.myAdapter.notifyDataSetChanged(); + mainActivity.myAdapter = new ArrayAdapter(mainActivity, android.R.layout.simple_dropdown_item_1line, mainActivity.item); + mainActivity.myAutoComplete.setAdapter(mainActivity.myAdapter); + + } + +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteTextChangedListener2.java b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteTextChangedListener2.java new file mode 100644 index 0000000..d1d459e --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteTextChangedListener2.java @@ -0,0 +1,53 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; +import android.widget.ArrayAdapter; + +/** + * Created by Jay Lohokare on 26-Sep-15. + */ +public class CustomAutoCompleteTextChangedListener2 implements TextWatcher { + + public static final String TAG = "CustomAutoCompleteTextChangedListener1.java"; + Context context; + + public CustomAutoCompleteTextChangedListener2(Context context) { + this.context = context; + } + + @Override + public void afterTextChanged(Editable s) { + // TODO Auto-generated method stub + + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + // TODO Auto-generated method stub + + } + + @Override + public void onTextChanged(CharSequence userInput, int start, int before, int count) { + + + Bus_Fetch mainActivity = ((Bus_Fetch) context); + + // query the database based on the user input + mainActivity.item = mainActivity.getItemsFromDb(userInput.toString()); + + // update the adapater + + /* mainActivity.myAdapter.notifyDataSetChanged(); + mainActivity.myAdapter = new ArrayAdapter(mainActivity, android.R.layout.simple_dropdown_item_1line, mainActivity.item); + mainActivity.myAutoComplete.setAdapter(mainActivity.myAdapter);*/ + mainActivity.myAdapter2.notifyDataSetChanged(); + mainActivity.myAdapter2 = new ArrayAdapter(mainActivity, android.R.layout.simple_dropdown_item_1line, mainActivity.item); + mainActivity.myAutoComplete2.setAdapter(mainActivity.myAdapter2); + + } + +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteView.java b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteView.java new file mode 100644 index 0000000..80e4806 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomAutoCompleteView.java @@ -0,0 +1,38 @@ +package in.skylinelabs.digiPune.activity; +import android.content.Context; +import android.util.AttributeSet; +import android.widget.AutoCompleteTextView; + +public class CustomAutoCompleteView extends AutoCompleteTextView { + + public CustomAutoCompleteView(Context context) { + super(context); + // TODO Auto-generated constructor stub + } + + public CustomAutoCompleteView(Context context, AttributeSet attrs) { + super(context, attrs); + // TODO Auto-generated constructor stub + } + + public CustomAutoCompleteView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + // TODO Auto-generated constructor stub + } + + // this is how to disable AutoCompleteTextView filter + @Override + protected void performFiltering(final CharSequence text, final int keyCode) { + String filterText = ""; + super.performFiltering(filterText, keyCode); + } + + /* + * after a selection we have to capture the new value and append to the existing text + */ + @Override + protected void replaceText(final CharSequence text) { + super.replaceText(text); + } + +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/CustomSpinnerAdapter.java b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomSpinnerAdapter.java new file mode 100644 index 0000000..bb1b264 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/CustomSpinnerAdapter.java @@ -0,0 +1,54 @@ +package in.skylinelabs.digiPune.activity; + +import java.util.ArrayList; +import android.content.Context; +import android.content.res.Resources; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import in.skylinelabs.digiPune.R; + +// Custom Adapter for Spinner +public class CustomSpinnerAdapter extends ArrayAdapter { + + private Context context1; + private ArrayList data; + public Resources res; + LayoutInflater inflater; + + public CustomSpinnerAdapter(Context context, ArrayList objects) { + super(context, R.layout.spinner_row, objects); + + context1 = context; + data = objects; + + inflater = (LayoutInflater) context1 + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + } + + @Override + public View getDropDownView(int position, View convertView, ViewGroup parent) { + return getCustomView(position, convertView, parent); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + return getCustomView(position, convertView, parent); + } + + // This funtion called for each row ( Called data.size() times ) + public View getCustomView(int position, View convertView, ViewGroup parent) { + + View row = inflater.inflate(R.layout.spinner_row, parent, false); + + TextView tvCategory = (TextView) row.findViewById(R.id.tvCategory); + + tvCategory.setText(data.get(position).toString()); + + return row; + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/DatabaseHandler.java b/app/src/main/java/in/skylinelabs/digiPune/activity/DatabaseHandler.java new file mode 100644 index 0000000..2a70697 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/DatabaseHandler.java @@ -0,0 +1,156 @@ +package in.skylinelabs.digiPune.activity; + +import java.util.ArrayList; +import java.util.List; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +public class DatabaseHandler extends SQLiteOpenHelper { + + // for our logs + public static final String TAG = "DatabaseHandler.java"; + + // database version + private static final int DATABASE_VERSION = 4; + + // database name + protected static final String DATABASE_NAME = "BusStopsDatabase"; + + // table details + public String tableName = "busStops"; + public String fieldObjectId = "id"; + public String fieldObjectName = "name"; + + // constructor + public DatabaseHandler(Context context) { + super(context, DATABASE_NAME, null, DATABASE_VERSION); + } + + // creating table + @Override + public void onCreate(SQLiteDatabase db) { + + String sql = ""; + + sql += "CREATE TABLE " + tableName; + sql += " ( "; + sql += fieldObjectId + " INTEGER PRIMARY KEY AUTOINCREMENT, "; + sql += fieldObjectName + " TEXT "; + sql += " ) "; + + db.execSQL(sql); + + + String notSQL="CREATE TABLE notificcation (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, message TEXT)"; + db.execSQL(notSQL); + } + + // When upgrading the database, it will drop the current table and recreate. + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + + String sql = "DROP TABLE IF EXISTS " + tableName; + db.execSQL(sql); + + onCreate(db); + } + + // create new record + // @param myObj contains details to be added as single row. + public boolean create(MyObject myObj) { + + boolean createSuccessful = false; + + if(!checkIfExists(myObj.objectName)){ + + SQLiteDatabase db = this.getWritableDatabase(); + + ContentValues values = new ContentValues(); + values.put(fieldObjectName, myObj.objectName); + createSuccessful = db.insert(tableName, null, values) > 0; + + db.close(); + + if(createSuccessful){ + Log.e(TAG, myObj.objectName + " created."); + } + } + + return createSuccessful; + } + + // check if a record exists so it won't insert the next time you run this code + public boolean checkIfExists(String objectName){ + + boolean recordExists = false; + + SQLiteDatabase db = this.getWritableDatabase(); + Cursor cursor = db.rawQuery("SELECT " + fieldObjectId + " FROM " + tableName + " WHERE " + fieldObjectName + " = '" + objectName + "'", null); + + if(cursor!=null) { + + if(cursor.getCount()>0) { + recordExists = true; + } + } + + cursor.close(); + db.close(); + + return recordExists; + } + + // Read records related to the search term + public List read(String searchTerm) { + + List recordsList = new ArrayList(); + + // select query + String sql = ""; + sql += "SELECT * FROM " + tableName; + sql += " WHERE " + fieldObjectName + " LIKE '%" + searchTerm + "%'"; + sql += " ORDER BY " + fieldObjectId + " DESC"; + sql += " LIMIT 0,5"; + + SQLiteDatabase db = this.getWritableDatabase(); + + // execute the query + Cursor cursor = db.rawQuery(sql, null); + + // looping through all rows and adding to list + if (cursor.moveToFirst()) { + do { + + // int productId = Integer.parseInt(cursor.getString(cursor.getColumnIndex(fieldProductId))); + String objectName = cursor.getString(cursor.getColumnIndex(fieldObjectName)); + MyObject myObject = new MyObject(objectName); + + // add to list + recordsList.add(myObject); + + } while (cursor.moveToNext()); + } + + cursor.close(); + db.close(); + + // return the list of records + return recordsList; + } + + public void addBusDtabase() + { + + } + + public void getNearbyBus(Double Lat, Double Lon) + { + + } + +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/DemoPagerAdapter.java b/app/src/main/java/in/skylinelabs/digiPune/activity/DemoPagerAdapter.java new file mode 100644 index 0000000..fc5ee5e --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/DemoPagerAdapter.java @@ -0,0 +1,45 @@ +package in.skylinelabs.digiPune.activity; + +import android.graphics.Color; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; + +import java.util.Random; + +public class DemoPagerAdapter extends FragmentPagerAdapter { + + private int pagerCount = 5; + + private Random random = new Random(); + + public DemoPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int i) { + if(i==0) + return ColorFragment.newInstance(Color.parseColor("#0d47a1"), i);//red + + if(i==1) + return ColorFragment.newInstance(Color.parseColor("#00958a"), i);//pink + + if(i==2) + return ColorFragment.newInstance(Color.parseColor("#ff5252"), i);//green + if(i==3) + return ColorFragment.newInstance(Color.parseColor("#ffab40"), i); + + if(i==4) + return ColorFragment.newInstance(Color.parseColor("#0d47a1"), i); + + else + return null; + + } + + @Override + public int getCount() { + return pagerCount; + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Fab.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Fab.java new file mode 100644 index 0000000..3d016d4 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Fab.java @@ -0,0 +1,108 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Context; +import android.support.design.widget.FloatingActionButton; +import android.util.AttributeSet; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; +import android.view.animation.ScaleAnimation; + +import com.gordonwong.materialsheetfab.AnimatedFab; + +import in.skylinelabs.digiPune.R; + +/** + * Created by Gordon Wong on 7/17/2015. + * + * Sample floating action button implementation. + */ +public class Fab extends FloatingActionButton implements AnimatedFab { + + private static final int FAB_ANIM_DURATION = 200; + + public Fab(Context context) { + super(context); + } + + public Fab(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public Fab(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + /** + * Shows the FAB. + */ + @Override + public void show() { + show(0, 0); + } + + /** + * Shows the FAB and sets the FAB's translation. + * + * @param translationX translation X value + * @param translationY translation Y value + */ + @Override + public void show(float translationX, float translationY) { + // Set FAB's translation + setTranslation(translationX, translationY); + + // Only use scale animation if FAB is hidden + if (getVisibility() != View.VISIBLE) { + // Pivots indicate where the animation begins from + float pivotX = getPivotX() + translationX; + float pivotY = getPivotY() + translationY; + + ScaleAnimation anim; + // If pivots are 0, that means the FAB hasn't been drawn yet so just use the + // center of the FAB + if (pivotX == 0 || pivotY == 0) { + anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, + Animation.RELATIVE_TO_SELF, 0.5f); + } else { + anim = new ScaleAnimation(0, 1, 0, 1, pivotX, pivotY); + } + + // Animate FAB expanding + anim.setDuration(FAB_ANIM_DURATION); + anim.setInterpolator(getInterpolator()); + startAnimation(anim); + } + setVisibility(View.VISIBLE); + } + + /** + * Hides the FAB. + */ + @Override + public void hide() { + // Only use scale animation if FAB is visible + if (getVisibility() == View.VISIBLE) { + // Pivots indicate where the animation begins from + float pivotX = getPivotX() + getTranslationX(); + float pivotY = getPivotY() + getTranslationY(); + + // Animate FAB shrinking + ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY); + anim.setDuration(FAB_ANIM_DURATION); + anim.setInterpolator(getInterpolator()); + startAnimation(anim); + } + setVisibility(View.INVISIBLE); + } + + private void setTranslation(float translationX, float translationY) { + animate().setInterpolator(getInterpolator()).setDuration(FAB_ANIM_DURATION) + .translationX(translationX).translationY(translationY); + } + + private Interpolator getInterpolator() { + return AnimationUtils.loadInterpolator(getContext(), R.interpolator.msf_interpolator); + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Favourites.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Favourites.java new file mode 100644 index 0000000..abbae59 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Favourites.java @@ -0,0 +1,333 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.WindowManager; +import android.widget.EditText; +import android.widget.ImageView; + +import com.github.clans.fab.FloatingActionButton; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import in.skylinelabs.digiPune.R; + + +public class Favourites extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener { + + FloatingActionButton btn; + EditText edt1, edt2, edt3, edt4; + String one,two,three,four,name; + + private ProgressDialog pDialog; + JSONParser jsonParser = new JSONParser(); + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + AlertDialog alertDialog; + + + + private static final String favourites = "http://www.skylinelabs.in/Geo/favourite.php"; + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.favourites); + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + displayView(8); + + edt1 = (EditText) findViewById(R.id.editText1); + edt2 = (EditText) findViewById(R.id.editText2); + edt3 = (EditText) findViewById(R.id.editText3); + edt4 = (EditText) findViewById(R.id.editText4); + + edt1.setHint("Enter fav 1"); + edt2.setHint("Enter fav 2"); + edt3.setHint("Enter fav 3"); + edt4.setHint("Enter fav 4"); + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + name =settings.getString("user_name", ""); + + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + + edt1.setText(settings.getString("fav_1", "")); + edt2.setText(settings.getString("fav_2", "")); + edt3.setText(settings.getString("fav_3", "")); + edt4.setText(settings.getString("fav_3", "")); + + + + btn = (FloatingActionButton) findViewById(R.id.button1); + btn.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + + + one = edt1.getText().toString(); + + + two = edt2.getText().toString(); + + three = edt3.getText().toString(); + + + four = edt4.getText().toString(); + + + ConnectionDetector cd1 = new ConnectionDetector(Favourites.this); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(!isInternetPresent1) + { + AlertDialog.Builder builder = new AlertDialog.Builder(Favourites.this); + builder.setMessage("Internet Unavailable. Please enable internet and try again") + .setCancelable(true) + .setTitle("Network Error") + .setPositiveButton("Ok", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert1 = builder.create(); + alert1.show(); + } + else + { + new CreateNewProduct().execute(); + } + } + }); + + + } + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + break; + case 1: + finish(); + Intent i2 = new Intent(this, ComplaintPortal.class); + startActivity(i2); + break; + case 2: + finish(); + i = new Intent(this, Bus_Fetch.class); + startActivity(i); + break; + case 3: + finish(); + i = new Intent(this, FindGov.class); + startActivity(i); + break; + case 4: + finish(); + i = new Intent(this, MyLocation.class); + startActivity(i); + break; + case 5: + finish(); + i = new Intent(this, History.class); + startActivity(i); + break; + case 6: + finish(); + i = new Intent(this, Setting.class); + startActivity(i); + break; + case 7: + finish(); + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + break; + case 8: + + break; + + default: + break; + } + } + + + class CreateNewProduct extends AsyncTask { + + JSONObject json, json1; + @Override + protected void onPreExecute() { + super.onPreExecute(); + pDialog = new ProgressDialog(Favourites.this); + pDialog.setMessage("Updating favourites"); + pDialog.setIndeterminate(false); + pDialog.setCancelable(false); + pDialog.show(); + } + + + + protected String doInBackground(String... args) { + + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("fav_1", one)); + params.add(new BasicNameValuePair("fav_2", two)); + params.add(new BasicNameValuePair("fav_3",three)); + params.add(new BasicNameValuePair("fav_4",four)); + params.add(new BasicNameValuePair("user_name",name)); + + try { + + JSONObject json = jsonParser.makeHttpRequest(favourites, + "GET", params); + + settings.edit().putString("fav_1", one).commit(); + settings.edit().putString("fav_2", two).commit(); + settings.edit().putString("fav_3", three).commit(); + settings.edit().putString("fav_4", four).commit(); + pDialog.dismiss(); + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(Favourites.this); + builder.setMessage("Favourites updated") + .setCancelable(true) + .setTitle("Success") + .setPositiveButton("Ok", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert1 = builder.create(); + alert1.show(); + } + + }); + } + + catch (Exception e1) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(Favourites.this); + builder.setMessage("Something went wrong while trying to set FAVs. Please retry.") + .setCancelable(true) + .setTitle("Network Error") + .setPositiveButton("Ok", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + settings.edit().putBoolean("sos_error", false).commit(); + + new CreateNewProduct().execute(); + } + }); + AlertDialog alert1 = builder.create(); + alert1.show(); + } + + }); + + } + + + return null; + } + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_log_in, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + this); + LayoutInflater factory = LayoutInflater.from(this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.sos_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + return super.onOptionsItemSelected(item); + } + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/FinalWidget.java b/app/src/main/java/in/skylinelabs/digiPune/activity/FinalWidget.java new file mode 100644 index 0000000..ebb7a6a --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/FinalWidget.java @@ -0,0 +1,56 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.PendingIntent; +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.Context; +import android.content.Intent; +import android.widget.RemoteViews; + +import in.skylinelabs.digiPune.R; + + +/** + * Implementation of App Widget functionality. + */ +public class FinalWidget extends AppWidgetProvider { + + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + // There may be multiple widgets active, so update all of them + final int N = appWidgetIds.length; + for (int i = 0; i < N; i++) { + updateAppWidget(context, appWidgetManager, appWidgetIds[i]); + } + } + + + @Override + public void onEnabled(Context context) { + // Enter relevant functionality for when the first widget is created + } + + @Override + public void onDisabled(Context context) { + // Enter relevant functionality for when the last widget is disabled + } + + static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, + int appWidgetId) { + + + //CharSequence widgetText = context.getString(R.string.appwidget_text); + // Construct the RemoteViews object + RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.final_widget); + + Intent configIntent = new Intent(context, sos.class); + + PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0); + + views.setOnClickPendingIntent(R.id.button1, configPendingIntent); + + appWidgetManager.updateAppWidget(appWidgetId, views); + } +} + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/FindGov.java b/app/src/main/java/in/skylinelabs/digiPune/activity/FindGov.java new file mode 100644 index 0000000..0e47094 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/FindGov.java @@ -0,0 +1,748 @@ +package in.skylinelabs.digiPune.activity; + +import android.annotation.TargetApi; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.location.Location; +import android.location.LocationManager; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Build; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; +import com.gordonwong.materialsheetfab.MaterialSheetFab; +import com.gordonwong.materialsheetfab.MaterialSheetFabEventListener; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import in.skylinelabs.digiPune.R; + +public class FindGov extends ActionBarActivity implements android.location.LocationListener, GoogleMap.OnCameraChangeListener, GoogleMap.OnMapLoadedCallback { + + + private Toolbar mToolbar; + + MaterialSheetFab materialSheetFab; + + ListView listView; + String categorys; + + GoogleMap map; + public static int i; + + ProgressBar prgbr, marker; + + TextView txt1, txt2, textView3, textView4; + + final Context context = this; + + String mystringuername; + String mystringpassword; + + + + String post; + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + Boolean catopen = false; + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0;//0 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 30 * 1; // 1/2 minute + + //Declaring a Location Manager + protected LocationManager locationManager; + + + FloatingActionButton btn2; + + Marker[] mrkgrp = new Marker[1000000]; + + + JSONParser jsonParser = new JSONParser(); + private static final String url_update_product = "http://www.skylinelabs.in/Geo/get_location.php"; + private static final String url_get_category = "http://www.skylinelabs.in/Geo/fetch_category.php"; + + + AlertDialog alertDialog; + + + Fab btn1; + + + View.OnClickListener snackaction,snackaction1;; + + + + + @Override + protected void onStop() { + + super.onStop(); // Always call the superclass method first + + + } + + @Override + protected void onPause() { + super.onPause(); + + } + + @Override + protected void onResume() { + + super.onResume(); + + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_find_gov); + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + + + getLocation(); + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + + textView4 = (TextView) findViewById(R.id.textView4); + marker = (ProgressBar) findViewById(R.id.progressBar1); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + + + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + + + + + map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { + @Override + public boolean onMarkerClick(Marker marker) { + + final Marker mk = marker; + + snackaction1 = new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent callvictim = new Intent(Intent.ACTION_CALL); + callvictim.setData(Uri.parse("tel:" + mk.getSnippet())); + startActivity(callvictim); + } + }; + + Snackbar.make(findViewById(android.R.id.content), "Call " + marker.getSnippet() + " ?", Snackbar.LENGTH_LONG) + .setAction("Call", snackaction1) + .setActionTextColor(Color.WHITE) + .show(); + + return false; + } + }); + + + map.setOnCameraChangeListener(this); + map.setOnMapLoadedCallback(FindGov.this); + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + mystringuername = settings.getString("user_name", ""); + mystringpassword = settings.getString("password", ""); + + txt1 = (TextView) findViewById(R.id.textView1); + txt2 = (TextView) findViewById(R.id.textView2); + + btn1 = (Fab)findViewById(R.id.button1); + btn1.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + } + + }); + + /***************************************************************************************************************/ + + View sheetView = findViewById(R.id.fab_sheet); + View overlay = findViewById(R.id.overlay); + int sheetColor = getResources().getColor(R.color.white); + int fabColor = getResources().getColor(R.color.colorPrimary); + + // Initialize material sheet FAB + materialSheetFab = new MaterialSheetFab<>(btn1, sheetView, overlay, sheetColor, fabColor); + + materialSheetFab.setEventListener(new MaterialSheetFabEventListener() { + @Override + public void onShowSheet() { + + catopen = true; + // Called when sheet is shown + } + + @Override + public void onHideSheet() { + + catopen = false; + // Called when sheet is hidden + } + }); + + + listView = (ListView) findViewById(R.id.fab_list); + + + + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, + long id) { + categorys = (String) parent.getItemAtPosition(position); + materialSheetFab.hideSheet(); + if(categorys != "PMPML") + { + + } + + else { + prgbr.setVisibility(View.VISIBLE); + map.clear(); + new GetCategory().execute(); + } + + } + }); + +/***************************************************************************************************************/ + + + btn2 = (FloatingActionButton)findViewById(R.id.location); + btn2.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + // Toast.makeText(getApplicationContext(),getLatitude(),Toast.LENGTH_LONG).show(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + }); + } + + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_find_gov, menu); + return true; + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + FindGov.this); + LayoutInflater factory = LayoutInflater.from(FindGov.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.friendlocation_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + + return super.onOptionsItemSelected(item); + } + + + @Override + public void onBackPressed() { + // TODO Auto-generated method stub + //super.onBackPressed(); + + if(!catopen) { + finish(); + } + + else + { + materialSheetFab.hideSheet(); + } + + } + @Override + public void onStatusChanged(String provider, int status, + Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + // .makeText(getApplicationContext(),"Please enable internet",Toast.LENGTH_LONG).show(); + + Snackbar.make(findViewById(android.R.id.content), "Please enable location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(FindGov.this); + map.setOnCameraChangeListener(FindGov.this); + textView3.setVisibility(View.VISIBLE); + prgbr.setVisibility(View.VISIBLE); + } + + + + @Override + public void onMapLoaded() { + + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + @Override + public void onLocationChanged(Location arg0) { + + map.setOnMapLoadedCallback(FindGov.this); + //map.clear(); + new GetCategoryUpdate().execute(); + + + } + + public Location getLocation() + { + try + { + locationManager = (LocationManager)this.getBaseContext().getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(FindGov.this); + } + } + + /** + * Function to get latitude + */ + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + /** + * Function to check GPS/wifi enabled + */ + + + class GetCategory extends AsyncTask { + + JSONObject json2; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("category", categorys)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json2 = jsonParser.makeHttpRequest( + url_get_category, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + JSONArray values = null; + try { + values = json2.getJSONArray("result"); + final int numberOfItemsInResp = values.length(); + + if(numberOfItemsInResp == 0) + { + Snackbar.make(findViewById(android.R.id.content), "No digiPune user found belonging to the selected category", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + + for (int i = 0; i < numberOfItemsInResp; i++) + { + JSONObject coordinates = values.getJSONObject(i); + Log.e("Values bagh", coordinates.toString()); + + MarkerOptions markerOption = new MarkerOptions().position(new LatLng(10, 10)); + mrkgrp[i] = map.addMarker(markerOption); + mrkgrp[i].setVisible(false); + mrkgrp[i].setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrkgrp[i].setTitle(coordinates.getString("user_name") + "\n" + "(Last seen : " + coordinates.getString("time") + ")"); + mrkgrp[i].setSnippet(coordinates.getString("contact")); + mrkgrp[i].setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrkgrp[i].setVisible(true); + + } + prgbr.setVisibility(View.GONE); + + } catch (JSONException e) { + Log.e("Error in markers", e.toString()); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + return null; + } + } + + + class GetCategoryUpdate extends AsyncTask { + + JSONObject json2; + Boolean updated = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("category", categorys)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (isInternetPresent) { + try { + + json2 = jsonParser.makeHttpRequest( + url_get_category, "GET", params); + updated = true; + + } catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + updated = false; + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if (isInternetPresent1 && updated) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + JSONArray values = null; + try { + values = json2.getJSONArray("result"); + final int numberOfItemsInResp = values.length(); + + map.clear(); + + + for (int i = 0; i < numberOfItemsInResp; i++) { + JSONObject coordinates = values.getJSONObject(i); + Log.e("Values bagh", coordinates.toString()); + + MarkerOptions markerOption = new MarkerOptions().position(new LatLng(10, 10)); + mrkgrp[i] = map.addMarker(markerOption); + mrkgrp[i].setVisible(false); + mrkgrp[i].setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrkgrp[i].setTitle(coordinates.getString("user_name") + "\n" + "(Last seen : " + coordinates.getString("time") + ")"); + mrkgrp[i].setSnippet(coordinates.getString("contact")); + mrkgrp[i].setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrkgrp[i].setVisible(true); + + } + prgbr.setVisibility(View.GONE); + + } catch (JSONException e) { + Log.e("Error in markers", e.toString()); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + return null; + } + } + +} + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/FirstTime_Settings.java b/app/src/main/java/in/skylinelabs/digiPune/activity/FirstTime_Settings.java new file mode 100644 index 0000000..efbfecf --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/FirstTime_Settings.java @@ -0,0 +1,467 @@ +package in.skylinelabs.digiPune.activity; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Build; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewAnimationUtils; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.widget.AdapterView; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.Switch; + +import com.github.clans.fab.FloatingActionButton; + +import in.skylinelabs.digiPune.R; + +public class FirstTime_Settings extends ActionBarActivity { + + + private Toolbar mToolbar; + + AlertDialog alertDialog; + + FloatingActionButton redo; + + Switch bck, upd, hst, doupdt, onDty; + + String user_name; + + String category; + + + WebView webView; + + View.OnClickListener snackaction; + + Boolean firsttime = true; + + ProgressBar prgbr; + + Spinner cat; + + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_first_time__settings); + + onDty = (Switch) findViewById(R.id.switchonDuty); + + + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + prgbr = (ProgressBar) findViewById(R.id.pgb); + prgbr.setVisibility(View.GONE); + + cat = (Spinner) findViewById(R.id.spinner); + + cat.setSelection(0); + + cat.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, final int position, long id) { + category = parent.getItemAtPosition(position).toString(); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (firsttime) { + firsttime = false; + } else { + + if (!isInternetPresent) { + + + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } else { + + + String user_name = settings.getString("user_name", ""); + webView = (WebView) findViewById(R.id.webView2); + webView.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) { + + + if (progress < 100 && prgbr.getVisibility() == ProgressBar.GONE) { + prgbr.setVisibility(ProgressBar.VISIBLE); + cat.setClickable(false); + redo.setClickable(false); + } + prgbr.setProgress(progress); + if (progress == 100) { + prgbr.setVisibility(ProgressBar.GONE); + cat.setClickable(true); + redo.setClickable(true); + settings.edit().putString("category", category).commit(); + settings.edit().putInt("category_pos", position).commit(); + Snackbar.make(findViewById(android.R.id.content), "Updated category", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + } + }); + + webView.loadUrl("http://www.skylinelabs.in/Geo/category_update.php?category=" + category + "&user_name=" + user_name); + + + } + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + + + + RelativeLayout mControlsContainer = (RelativeLayout) findViewById(R.id.rel3); + + mControlsContainer.setVisibility(View.GONE); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("Settings"); + + + redo = (FloatingActionButton) findViewById(R.id.redo); + redo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent i = new Intent(FirstTime_Settings.this, FriendLocation.class); + startActivity(i); + + + + Intent i2 = new Intent(FirstTime_Settings.this, App_intro.class); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + + + final View myView = findViewById(R.id.rel3); + final View myView1 = findViewById(R.id.rel4); + final View myView2 = findViewById(R.id.scrollView1); + myView2.setVisibility(View.GONE); + + try{ + // get the center for the clipping circle + int cx = myView1.getMeasuredWidth(); + int cy = myView1.getMeasuredHeight(); + + // get the final radius for the clipping circle + int finalRadius = Math.max(myView1.getWidth() * 2, myView1.getHeight() * 2) / 2; + + // Toast.makeText(getApplicationContext(), finalRadius + " " + cx + " " + cy, Toast.LENGTH_LONG).show(); + + // create the animator for this view (the start radius is zero) + + Animator anim = + ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius); + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + + Intent i2 = new Intent(FirstTime_Settings.this, App_intro.class); + i2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + startActivity(i2); + finish(); + } + }); + + anim.start(); + + } + + catch(Exception e) + { + + + } + + myView.setVisibility(View.VISIBLE); + + + + + // previously invisible view + + } + + else + startActivity(i2); + + + } + }); + +/****************************************************************************************************************/ + /*Background update switch*/ + bck = (Switch)findViewById(R.id.switch2); + if (settings.getBoolean("FindX_background_enabled", true)) + bck.setChecked(true); + else + bck.setChecked(false); + + bck.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if(bck.isChecked()){ + settings.edit().putBoolean("FindX_background_enabled", true).commit(); + + } + else{ + settings.edit().putBoolean("FindX_background_enabled", false).commit(); + + } + } + }); + +/**************************************************************************************************************/ + /*Background update switch*/ + doupdt = (Switch)findViewById(R.id.switch4); + if (settings.getBoolean("FindX_update_enabled", true)) + doupdt.setChecked(true); + else + doupdt.setChecked(false); + + doupdt.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if (doupdt.isChecked()) { + settings.edit().putBoolean("FindX_update_enabled", true).commit(); + + } else { + settings.edit().putBoolean("FindX_update_enabled", false).commit(); + + } + } + }); + +/****************************************************************************************************************/ + /*Sharing on switch*/ + upd= (Switch)findViewById(R.id.switch1); + + if (settings.getBoolean("FindX_share_enabled", true)) + { + upd.setChecked(true); + } + + else + { + upd.setChecked(false); + } + + upd.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if(upd.isChecked()){ + settings.edit().putBoolean("FindX_share_enabled", true).commit(); + + } + else{ + settings.edit().putBoolean("FindX_share_enabled", false).commit(); + settings.edit().putBoolean("FindX_onDuty_enabled", false).commit(); + onDty.setChecked(false); + + } + AlertDialog.Builder builder = new AlertDialog.Builder(FirstTime_Settings.this); + builder.setMessage("Changes will take place only when digiPune connects to internet") + .setCancelable(true) + .setTitle("Information") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } + + }); + + /****************************************************************************************************************/ + /*On Duty switch*/ + + if (settings.getBoolean("FindX_onDuty_enabled", true)) + { + onDty.setChecked(true); + } + + else + { + onDty.setChecked(false); + } + + onDty.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + + if (upd.isChecked()) { + + if (onDty.isChecked()) { + settings.edit().putBoolean("FindX_onDuty_enabled", true).commit(); + + } else { + settings.edit().putBoolean("FindX_onDuty_enabled", false).commit(); + + } + AlertDialog.Builder builder = new AlertDialog.Builder(FirstTime_Settings.this); + builder.setMessage("Changes will take place only when digiPune connects to internet") + .setCancelable(true) + .setTitle("Information") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } + + else + { + onDty.setChecked(false); + Snackbar.make(findViewById(android.R.id.content), "Switch on Sharing Location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + }); +/****************************************************************************************************************/ + /*History on switch*/ + hst= (Switch)findViewById(R.id.switch3); + + if (settings.getBoolean("FindX_history_enabled", true)) + { + hst.setChecked(true); + } + + else + { + hst.setChecked(false); + } + + hst.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if(hst.isChecked()){ + settings.edit().putBoolean("FindX_history_enabled", true).commit(); + + } + else{ + settings.edit().putBoolean("FindX_history_enabled", false).commit(); + + } + AlertDialog.Builder builder = new AlertDialog.Builder(FirstTime_Settings.this); + builder.setMessage("Changes will take place only when digiPune connects to internet") + .setCancelable(true) + .setTitle("Information") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } + + }); + } + + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_first_time__settings, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + FirstTime_Settings.this); + LayoutInflater factory = LayoutInflater.from(FirstTime_Settings.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.settings_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + return super.onOptionsItemSelected(item); + } + + @Override + public void onBackPressed() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/FragmentDrawer.java b/app/src/main/java/in/skylinelabs/digiPune/activity/FragmentDrawer.java new file mode 100644 index 0000000..6e9e688 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/FragmentDrawer.java @@ -0,0 +1,190 @@ +package in.skylinelabs.digiPune.activity; + + +import android.content.Context; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.GestureDetector; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; + +import java.util.ArrayList; +import java.util.List; + +import in.skylinelabs.digiPune.R; +import in.skylinelabs.digiPune.adapter.NavigationDrawerAdapter; +import in.skylinelabs.digiPune.model.NavDrawerItem; + + +public class FragmentDrawer extends Fragment { + + private static String TAG = FragmentDrawer.class.getSimpleName(); + private RecyclerView recyclerView; + private ActionBarDrawerToggle mDrawerToggle; + private DrawerLayout mDrawerLayout; + private NavigationDrawerAdapter adapter; + private View containerView; + private static String[] titles = null; + private static int[] icons = {R.drawable.ic_action_place,R.drawable.ic_action_map,R.drawable.ic_action_search, R.drawable.ic_action_cc_bcc, R.drawable.ic_action_location_found, R.drawable.ic_action_rotate_left, R.drawable.ic_action_settings, R.drawable.ic_action_about,R.drawable.ic_action_favorite}; + private FragmentDrawerListener drawerListener; + + public FragmentDrawer() { + + + + } + + public void setDrawerListener(FragmentDrawerListener listener) { + this.drawerListener = listener; + } + + public static List getData() { + List data = new ArrayList<>(); + + + // preparing navigation drawer items + for (int i = 0; i < titles.length; i++) { + NavDrawerItem navItem = new NavDrawerItem(); + navItem.setTitle(titles[i]); + navItem.setIcon(icons[i]); + data.add(navItem); + } + return data; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // post = 0; + // drawer labels + titles = getActivity().getResources().getStringArray(R.array.nav_drawer_labels); + + + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflating view layout + View layout = inflater.inflate(R.layout.navigation_drawer, container, false); + recyclerView = (RecyclerView) layout.findViewById(R.id.drawerList); + + + + + + + adapter = new NavigationDrawerAdapter(getActivity(), getData()); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), recyclerView, new ClickListener() { + @Override + public void onClick(View view, int position) { + drawerListener.onDrawerItemSelected(view, position); + mDrawerLayout.closeDrawer(containerView); + Pre_launch_activity.post = position; + } + + @Override + public void onLongClick(View view, int position) { + + } + })); + // View v = recyclerView.getChildAt(0); + // RelativeLayout rl = (RelativeLayout)v.findViewById(R.id.row); + //Toast.makeText(getActivity(),v.toString(),Toast.LENGTH_LONG).show(); + return layout; + } + + + public void setUp(int fragmentId, DrawerLayout drawerLayout, final Toolbar toolbar) { + containerView = getActivity().findViewById(fragmentId); + mDrawerLayout = drawerLayout; + mDrawerToggle = new ActionBarDrawerToggle(getActivity(), drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) { + @Override + public void onDrawerOpened(View drawerView) { + super.onDrawerOpened(drawerView); + getActivity().invalidateOptionsMenu(); + } + + @Override + public void onDrawerClosed(View drawerView) { + super.onDrawerClosed(drawerView); + getActivity().invalidateOptionsMenu(); + } + + @Override + public void onDrawerSlide(View drawerView, float slideOffset) { + super.onDrawerSlide(drawerView, slideOffset); + toolbar.setAlpha(1 - slideOffset / 2); + } + }; + + mDrawerLayout.setDrawerListener(mDrawerToggle); + mDrawerLayout.post(new Runnable() { + @Override + public void run() { + mDrawerToggle.syncState(); + } + }); + + } + + public static interface ClickListener { + public void onClick(View view, int position); + + public void onLongClick(View view, int position); + } + + static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener { + + private GestureDetector gestureDetector; + private ClickListener clickListener; + + public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) { + this.clickListener = clickListener; + gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { + @Override + public boolean onSingleTapUp(MotionEvent e) { + return true; + } + + @Override + public void onLongPress(MotionEvent e) { + View child = recyclerView.findChildViewUnder(e.getX(), e.getY()); + if (child != null && clickListener != null) { + clickListener.onLongClick(child, recyclerView.getChildPosition(child)); + } + } + }); + } + + @Override + public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { + + View child = rv.findChildViewUnder(e.getX(), e.getY()); + if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) { + clickListener.onClick(child, rv.getChildPosition(child)); + } + return false; + } + + @Override + public void onTouchEvent(RecyclerView rv, MotionEvent e) { + } + + + } + + public interface FragmentDrawerListener { + public void onDrawerItemSelected(View view, int position); + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/FriendLocation.java b/app/src/main/java/in/skylinelabs/digiPune/activity/FriendLocation.java new file mode 100644 index 0000000..4095fd2 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/FriendLocation.java @@ -0,0 +1,1882 @@ + +package in.skylinelabs.digiPune.activity; + + + + import android.annotation.SuppressLint; + import android.annotation.TargetApi; + import android.app.AlertDialog; + import android.content.Context; + import android.content.DialogInterface; + import android.content.Intent; + import android.content.SharedPreferences; + import android.graphics.Color; + import android.location.Location; + import android.location.LocationManager; + import android.net.Uri; + import android.os.AsyncTask; + import android.os.Build; + import android.os.Bundle; + import android.support.design.widget.Snackbar; + import android.support.v4.widget.DrawerLayout; + import android.support.v7.app.ActionBarActivity; + import android.support.v7.widget.Toolbar; + import android.util.Log; + import android.view.KeyEvent; + import android.view.LayoutInflater; + import android.view.Menu; + import android.view.MenuItem; + import android.view.View; + import android.view.inputmethod.EditorInfo; + import android.view.inputmethod.InputMethodManager; + import android.widget.EditText; + import android.widget.ImageView; + import android.widget.ListView; + import android.widget.ProgressBar; + import android.widget.TextView; + import android.provider.Settings; + + import java.text.SimpleDateFormat; + import java.util.ArrayList; + import java.util.List; + + import in.skylinelabs.digiPune.R; + + import com.github.clans.fab.FloatingActionButton; + import com.google.android.gms.maps.CameraUpdate; + import com.google.android.gms.maps.CameraUpdateFactory; + import com.google.android.gms.maps.GoogleMap; + import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; + import com.google.android.gms.maps.GoogleMap.OnMapLoadedCallback; + import com.google.android.gms.maps.MapFragment; + import com.google.android.gms.maps.model.BitmapDescriptorFactory; + import com.google.android.gms.maps.model.CameraPosition; + import com.google.android.gms.maps.model.LatLng; + import com.google.android.gms.maps.model.Marker; + import com.google.android.gms.maps.model.MarkerOptions; + import com.gordonwong.materialsheetfab.MaterialSheetFab; + + import org.apache.http.NameValuePair; + import org.apache.http.message.BasicNameValuePair; + import org.json.JSONArray; + import org.json.JSONException; + import org.json.JSONObject; + +public class FriendLocation extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener, android.location.LocationListener, OnCameraChangeListener, OnMapLoadedCallback { + + private static String TAG = FriendLocation.class.getSimpleName(); + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + MaterialSheetFab materialSheetFab; + + ListView listView; + String categorys; + + GoogleMap map; + ProgressBar pgb; + JSONObject json1; + + + public static int i; + + ProgressBar prgbr, marker; + + TextView txt1, txt2, textView3, textView4; + + long date; + @SuppressLint("SimpleDateFormat") + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + final Context context = this; + + String mystringuername; + String mystringpassword; + + String mydevice_id1, password1, mydevice_id2, password2, mydevice_id3, password3, mydevice_id4, password4; + + + MarkerOptions marker2 = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions marker3 = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions marker4 = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions marker1 = new MarkerOptions().position(new LatLng(10, 10)); + + Marker mrk1, mrk2, mrk3, mrk4; + + + String nation, post, area, address; + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + public static boolean mylocationOn; + Boolean catopen = false; + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0;//0 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 30 * 1; // 1/2 minute + + //Declaring a Location Manager + protected LocationManager locationManager; + + boolean first, second, third, fourth; + + FloatingActionButton btn2; + + Marker[] mrkgrp = new Marker[1000000]; + + EditText edttxt1; + + JSONParser jsonParser = new JSONParser(); + private static final String url_update_product = "http://www.skylinelabs.in/Geo/get_location.php"; + private static final String url_get_category = "http://www.skylinelabs.in/Geo/fetch_category.php"; + + AlertDialog alertDialog; + + FloatingActionButton btn1; + + + View.OnClickListener snackaction,snackaction1;; + + + + + @Override + protected void onStop() { + + super.onStop(); // Always call the superclass method first + digiPune.MIN_TIME_BW_UPDATES = 1000 * 60 * 10; + + digiPune.isOn = false; + + } + + @Override + protected void onPause() { + super.onPause(); + digiPune.isOn = false; + } + + @Override + protected void onResume() { + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + if (digiPune.mRunning){ + } + else{ + context.startService(new Intent(context, digiPune.class)); + } + + if(settings.getBoolean("FindX_update_enabled", true)) + { + digiPune.isOn = true; + } + else + digiPune.isOn = false; + + + digiPune.MIN_TIME_BW_UPDATES = 1000 * 60 * 2; + // TODO Auto-generated method stub + super.onResume(); + + //Pre_launch_activity.post = 0; + + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders == null || locationProviders.equals("")) { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setTitle("Location Access Error"); + alertDialogBuilder.setMessage("Please allow digiPune to access location"); + alertDialogBuilder.setCancelable(false); + + alertDialogBuilder.setPositiveButton("Settings", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface arg0, int arg1) { + + startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); + alertDialog.dismiss(); + + } + }); + alertDialogBuilder.setNegativeButton("Exit", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + + alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } else { + } + + + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.friend_location); + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + if(settings.getBoolean("FindX_update_enabled", true)) + { + digiPune.isOn = true; + } + else { + digiPune.isOn = false; + } + + digiPune.MIN_TIME_BW_UPDATES = 1000 * 60 * 2; + + + if (digiPune.mRunning){ + // Toast.makeText(getApplicationContext(),"Service chalu hoti re",Toast.LENGTH_LONG).show(); + + + } + else{ + context.startService(new Intent(context, digiPune.class)); + // Toast.makeText(getApplicationContext(),"Chalu keli service",Toast.LENGTH_LONG).show(); + + } + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + + // display the first navigation drawer view on app launch + displayView(0); + + getLocation(); + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + + textView4 = (TextView) findViewById(R.id.textView4); + marker = (ProgressBar) findViewById(R.id.progressBar1); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + + + EditText toolbarSearchView = (EditText) findViewById(R.id.search_view); + toolbarSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + search(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + FriendLocation.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + return true; + } + return false; + } + }); + + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + + + + + map.setOnMapLoadedCallback(new OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { + @Override + public boolean onMarkerClick(Marker marker) { + + final Marker mk = marker; + + snackaction1 = new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent callvictim = new Intent(Intent.ACTION_CALL); + callvictim.setData(Uri.parse("tel:" + mk.getSnippet())); + startActivity(callvictim); + } + }; + + Snackbar.make(findViewById(android.R.id.content), "Call " + marker.getSnippet() + " ?", Snackbar.LENGTH_LONG) + .setAction("Call", snackaction1) + .setActionTextColor(Color.WHITE) + .show(); + + return false; + } + }); + + + map.setOnCameraChangeListener(FriendLocation.this); + map.setOnMapLoadedCallback(FriendLocation.this); + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + mrk1 = map.addMarker(marker1); + mrk1.setVisible(false); + + mrk2 = map.addMarker(marker2); + mrk2.setVisible(false); + + mrk3 = map.addMarker(marker3); + mrk3.setVisible(false); + + mrk4 = map.addMarker(marker4); + mrk4.setVisible(false); + + + mystringuername = settings.getString("user_name", ""); + mystringpassword = settings.getString("password", ""); + + txt1 = (TextView) findViewById(R.id.textView1); + txt2 = (TextView) findViewById(R.id.textView2); + + edttxt1 = (EditText) findViewById(R.id.search_view); + + edttxt1.setHint(" digiPune ID"); + + first = true; + second = false; + third = false; + fourth = false; + + btn1 = (FloatingActionButton)findViewById(R.id.button1); + btn1.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + Intent sharingIntent = new Intent(Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi! Locate me using digiPune app" + "\n" + "\n" + "digiPune ID :" + "\n" + mystringuername + "\n" + "\n" + "\n" + "To access location live, download digiPune on google play" + "\n" + "https://play.google.com/store/apps/details?id=" + context.getPackageName() + "\n\n" + "Or access the location online at" + "\n" + "www.skylinelabs.in/digiPune" + "\n\n" + "Shared via digiPune"); + startActivity(Intent.createChooser(sharingIntent, "Send digiPune ID")); + } + + }); + + +/***************************************************************************************************************/ + + + btn2 = (FloatingActionButton)findViewById(R.id.location); + btn2.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + // Toast.makeText(getApplicationContext(),getLatitude(),Toast.LENGTH_LONG).show(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + }); + } + + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.friendlocation_menu, menu); + return true; + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + FriendLocation.this); + LayoutInflater factory = LayoutInflater.from(FriendLocation.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.friendlocation_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + if(id == R.id.share) { + Intent sharingIntent = new Intent(Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi! Locate me using digiPune app" + "\n" + "\n" + "digiPune ID :" + "\n" + mystringuername + "\n" + "\n" + "\n" + "To access location live, download digiPune on google play" + "\n" + "https://play.google.com/store/apps/details?id=" + context.getPackageName() + "\n\n" + "Or access the location online at" + "\n" + "www.skylinelabs.in/digiPune" + "\n\n" + "Shared via digiPune"); + startActivity(Intent.createChooser(sharingIntent, "Send digiPune ID")); + + } + if(id == R.id.action_search) { + search(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + FriendLocation.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + } + + return super.onOptionsItemSelected(item); + } + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + Pre_launch_activity.post=0; + break; + case 1: + Intent i2 = new Intent(this, ComplaintPortal.class); + startActivity(i2); + break; + case 2: + i = new Intent(this, Bus_Fetch.class); + startActivity(i); + break; + case 3: + i = new Intent(this, FindGov.class); + startActivity(i); + break; + case 4: + i = new Intent(this, MyLocation.class); + startActivity(i); + break; + case 5: + i = new Intent(this, History.class); + startActivity(i); + break; + case 6: + i = new Intent(this, Setting.class); + startActivity(i); + break; + case 7: + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + break; + case 8: + i = new Intent(this, Favourites.class); + startActivity(i); + break; + + default: + break; + } + } + @Override + public void onBackPressed() { + // TODO Auto-generated method stub + //super.onBackPressed(); + + if(!catopen) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + final AlertDialog alert; + + builder.setMessage("Are you sure you want to exit ?") + .setCancelable(true) + .setTitle("Exit?") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + digiPune.MIN_TIME_BW_UPDATES = 1000 * 60 * 10; + finish(); + } + }); + builder.setNegativeButton("No", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + alert = builder.create(); + alert.show(); + } + + else + { + materialSheetFab.hideSheet(); + } + + } + @Override + public void onStatusChanged(String provider, int status, + Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + // .makeText(getApplicationContext(),"Please enable internet",Toast.LENGTH_LONG).show(); + + Snackbar.make(findViewById(android.R.id.content), "Please enable location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(FriendLocation.this); + map.setOnCameraChangeListener(FriendLocation.this); + textView3.setVisibility(View.VISIBLE); + prgbr.setVisibility(View.VISIBLE); + } + + + + @Override + public void onMapLoaded() { + + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + @Override + public void onLocationChanged(Location arg0) { + + map.setOnMapLoadedCallback(FriendLocation.this); + + if(first) + { + + } + + if(second) + { + mrk1.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + if(mrk1.isVisible()) + new UpdateProduct1().execute(); + } + + else + //Toast.makeText(getApplicationContext(),"Unable to update marker locations",Toast.LENGTH_LONG).show(); + + Snackbar.make(findViewById(android.R.id.content), "Unable to update marker locations", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + if(third) + { + + mrk2.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + mrk1.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + if(mrk1.isVisible() && mrk2.isVisible()) + { + new UpdateProduct1().execute(); + new UpdateProduct2().execute(); + } + } + else + // Toast.makeText(getApplicationContext(),"Unable to update marker locations",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Unable to update marker locations", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + + } + + if(fourth) + { + + mrk2.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + mrk1.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + mrk3.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + if(mrk1.isVisible() && mrk2.isVisible() && mrk3.isVisible()) + { + new UpdateProduct1().execute(); + new UpdateProduct2().execute(); + new UpdateProduct3().execute(); + } + } + else + //Toast.makeText(getApplicationContext(),"Unable to update marker locations",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Unable to update marker locations", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + + } + + if(!first && !second && !third && !fourth) + { + + mrk2.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + mrk1.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + mrk3.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + mrk4.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); + + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + if(mrk1.isVisible() && mrk2.isVisible() && mrk3.isVisible() && mrk4.isVisible()) + { + new UpdateProduct1().execute(); + new UpdateProduct2().execute(); + new UpdateProduct3().execute(); + new UpdateProduct4().execute(); + } + } + else + // Toast.makeText(getApplicationContext(),"Unable to update marker locations",Toast.LENGTH_LONG).show(); + + Snackbar.make(findViewById(android.R.id.content), "Unable to update marker locations", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + + } + + public Location getLocation() + { + try + { + locationManager = (LocationManager)this.getBaseContext().getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(FriendLocation.this); + } + } + + /** + * Function to get latitude + */ + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + /** + * Function to check GPS/wifi enabled + */ + public boolean canGetLocation() + { + return this.canGetLocation; + } + class UpdateProduct1 extends AsyncTask { + + JSONObject json2; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id1)); + params.add(new BasicNameValuePair("password", password1)); + params.add(new BasicNameValuePair("self", mystringuername)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + + if(isInternetPresent) + { + try { + + json2 = jsonParser.makeHttpRequest( + url_update_product, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(), "Network error Unable to fetch location", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json2.getInt("success"); + + if(success == 1) + { + + JSONArray values = json2.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + mrk1.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk1.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk1.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk1.setVisible(true); + + json2 = null; + } + + else if(success ==0) + { + //Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + + + } catch (JSONException e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + + return null; + } + + + } + + + + class UpdateProduct2 extends AsyncTask { + + JSONObject json2; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id2)); + params.add(new BasicNameValuePair("password", password2)); + params.add(new BasicNameValuePair("self", mystringuername)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json2 = jsonParser.makeHttpRequest( + url_update_product, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json2.getInt("success"); + + if(success == 1) + { + + JSONArray values = json2.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + mrk2.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk2.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk2.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk2.setVisible(true); + + json2 = null; + } + + else if(success ==0) + { + // Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + + + } catch (JSONException e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + + return null; + } + + + } + + class UpdateProduct3 extends AsyncTask { + + JSONObject json2; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id3)); + params.add(new BasicNameValuePair("password", password3)); + params.add(new BasicNameValuePair("self", mystringuername)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json2 = jsonParser.makeHttpRequest( + url_update_product, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json2.getInt("success"); + + if(success == 1) + { + + JSONArray values = json2.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + mrk3.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk3.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk3.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk3.setVisible(true); + + json2 = null; + } + + else if(success ==0) + { + // Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + + + } catch (JSONException e1) { + //Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + + return null; + } + + + } + + class UpdateProduct4 extends AsyncTask { + + JSONObject json2; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + protected String doInBackground(String... args) { + + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id4)); + params.add(new BasicNameValuePair("password", password4)); + params.add(new BasicNameValuePair("self", mystringuername)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json2 = jsonParser.makeHttpRequest( + url_update_product, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json2.getInt("success"); + + if (success == 1) + { + + JSONArray values = json2.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + mrk4.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk4.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk4.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk4.setVisible(true); + + json2 = null; + } + + else if(success ==0) + { + //Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + + + } catch (JSONException e1) { + //Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + + return null; + } + + + } + class CreateNewProduct1 extends AsyncTask { + + JSONObject json; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + + } + + protected String doInBackground(String... args) { + + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id1)); + params.add(new BasicNameValuePair("password", password1)); + params.add(new BasicNameValuePair("self", mystringuername)); + + + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json = jsonParser.makeHttpRequest( + url_update_product, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + } + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json.getInt("success"); + if(success == 1) + { + + JSONArray values = json.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + + mrk1.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk1.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk1.setSnippet(coordinates.getString("contact")); + mrk1.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk1.setVisible(true); + mrk1.showInfoWindow(); + first = false; + second = true; + third = false; + fourth = false; + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + edttxt1.setText(""); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))) + + .zoom(12.8f) + + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + + } + + if(success ==0) + { + // Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + //Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + btn1.setClickable(true); + + } + }); + } + + + return null; + } + + + } + + + class CreateNewProduct2 extends AsyncTask { + + + JSONObject json1; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + + } + + protected String doInBackground(String... args) { + + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id2)); + params.add(new BasicNameValuePair("password", password2)); + params.add(new BasicNameValuePair("self", mystringuername)); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json1 = jsonParser.makeHttpRequest( + url_update_product, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + + } + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json1.getInt("success"); + if(success == 1) + { + + JSONArray values = json1.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + + mrk2.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk2.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk2.setSnippet(coordinates.getString("contact")); + mrk2.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk2.setVisible(true); + mrk2.showInfoWindow(); + + first = false; + second = false; + third = true; + fourth = false; + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + edttxt1.setText(""); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))) + + .zoom(12.8f) + + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + if(success ==0) + { + // Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + btn1.setClickable(true); + + } + }); + + } + + + + return null; + } + + + } + + class CreateNewProduct3 extends AsyncTask { + + JSONObject json; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + + } + + protected String doInBackground(String... args) { + + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id3)); + params.add(new BasicNameValuePair("password", password3)); + params.add(new BasicNameValuePair("self", mystringuername)); + + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) + { + try { + + json = jsonParser.makeHttpRequest( + url_update_product, "GET", params); + + } + + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + } + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json.getInt("success"); + if(success == 1) + { + + JSONArray values = json.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + + mrk3.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk3.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk3.setSnippet(coordinates.getString("contact")); + mrk3.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk3.setVisible(true); + mrk3.showInfoWindow(); + + first = false; + second = false; + third = false; + fourth = true; + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + edttxt1.setText(""); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))) + + .zoom(12.8f) + + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + if(success ==0) + { + // Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + btn1.setClickable(true); + + } + }); + } + + return null; + } + + + } + + class CreateNewProduct4 extends AsyncTask { + + JSONObject json; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + + } + + protected String doInBackground(String... args) { + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id4)); + params.add(new BasicNameValuePair("password", password4)); + params.add(new BasicNameValuePair("self", mystringuername)); + + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + if(isInternetPresent) + { + try { + + json = jsonParser.makeHttpRequest( + url_update_product, "POST", params); + } + catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + return null; + } + } + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + if(isInternetPresent1) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + int success = json.getInt("success"); + if(success == 1) + { + + JSONArray values = json.getJSONArray("gps_coordinates"); + JSONObject coordinates = values.getJSONObject(0); + + + mrk4.setPosition(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))); + mrk4.setTitle("(Last seen : " + coordinates.getString("time") + ")"); + mrk4.setSnippet(coordinates.getString("contact")); + mrk4.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk4.setVisible(true); + mrk4.showInfoWindow(); + + first = false; + second = false; + third = false; + fourth = false; + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + edttxt1.setText(""); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(coordinates.getString("latitude")), Double.parseDouble(coordinates.getString("longitude")))) + + .zoom(12.8f) + + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + if(success ==0) + { + // Toast.makeText(getApplicationContext(),"Location access denied",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Location access denied", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + textView4.setVisibility(View.GONE); + marker.setVisibility(View.GONE); + } + btn1.setClickable(true); + + } + }); + } + + return null; + } + + + } + + void search() { + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (isInternetPresent) { + + if (first) { + mydevice_id1 = edttxt1.getText().toString(); + password1 = ""; + btn1.setClickable(false); + textView4.setText("Forming marker"); + textView4.setVisibility(View.VISIBLE); + marker.setVisibility(View.VISIBLE); + new CreateNewProduct1().execute(); + + } + + if (second) { + + + if (!edttxt1.getText().toString().equalsIgnoreCase(mydevice_id1)) { + mydevice_id2 = edttxt1.getText().toString(); + password2 = ""; + btn1.setClickable(false); + textView4.setText("Forming marker"); + textView4.setVisibility(View.VISIBLE); + marker.setVisibility(View.VISIBLE); + new CreateNewProduct2().execute(); + } else + // Toast.makeText(getApplicationContext(), "Marker already exists for " + mydevice_id1, Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Marker already exists for " + mydevice_id1, Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + if (third) { + + if (!edttxt1.getText().toString().equalsIgnoreCase(mydevice_id1)) { + if (!edttxt1.getText().toString().equalsIgnoreCase(mydevice_id2)) { + mydevice_id3 = edttxt1.getText().toString(); + password3 = ""; + btn1.setClickable(false); + textView4.setText("Forming marker"); + textView4.setVisibility(View.VISIBLE); + marker.setVisibility(View.VISIBLE); + + + new CreateNewProduct3().execute(); + } else + //Toast.makeText(getApplicationContext(), "Marker already exists for " + mydevice_id2, Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Marker already exists for " + mydevice_id2, Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } else + // Toast.makeText(getApplicationContext(), "Marker already exists for " + mydevice_id1, Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Marker already exists for " + mydevice_id1, Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + + if (fourth) { + if (!edttxt1.getText().toString().equalsIgnoreCase(mydevice_id1)) { + if (!edttxt1.getText().toString().equalsIgnoreCase(mydevice_id2)) { + if (!edttxt1.getText().toString().equalsIgnoreCase(mydevice_id3)) { + mydevice_id4 = edttxt1.getText().toString(); + password4 = ""; + btn1.setClickable(false); + textView4.setText("Forming marker"); + textView4.setVisibility(View.VISIBLE); + marker.setVisibility(View.VISIBLE); + new CreateNewProduct4().execute(); + } else + // Toast.makeText(getApplicationContext(), "Marker already exists for " + mydevice_id3, Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Marker already exists for " + mydevice_id3, Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } else + // Toast.makeText(getApplicationContext(), "Marker already exists for " + mydevice_id2, Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Marker already exists for " + mydevice_id2, Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } else + // Toast.makeText(getApplicationContext(), "Marker already exists for " + mydevice_id1, Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Marker already exists for " + mydevice_id1, Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + + if (!first && !second && !third && !fourth) { + // Toast.makeText(getApplicationContext(), "Currently digiPune can track only 4 friend", Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Currently digiPune can track only 4 friend", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + btn1.setVisibility(View.GONE); + + } + + } else + // Toast.makeText(getApplicationContext(), "Please conect to internet", Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Please conect to internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + +} + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/GPSTracker.java b/app/src/main/java/in/skylinelabs/digiPune/activity/GPSTracker.java new file mode 100644 index 0000000..e47eed7 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/GPSTracker.java @@ -0,0 +1,319 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationManager; +import android.os.Bundle; +import android.os.IBinder; +import android.util.Log; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; + + +public class GPSTracker extends Service implements android.location.LocationListener +{ + + + private final Context mContext; + + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + Location location= null; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; //10 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute + + //Declaring a Location Manager + protected LocationManager locationManager; + + public GPSTracker(Context context) + { + this.mContext = context; + getLocation(); + } + + public Location getLocation() + { + try + { + locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(GPSTracker.this); + } + } + + /** + * Function to get latitude + */ + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + /** + * Function to check GPS/wifi enabled + */ + public boolean canGetLocation() + { + return this.canGetLocation; + } + + + /** + * Get list of address by latitude and longitude + * @return null or List
+ */ + public List
getGeocoderAddress(Context context) + { + if (location != null) + { + Geocoder geocoder = new Geocoder(context, Locale.ENGLISH); + try + { + List
addresses = geocoder.getFromLocation(latitude, longitude, 1); + return addresses; + } + catch (IOException e) + { + //e.printStackTrace(); + Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e); + } + } + + return null; + } + + /** + * Try to get AddressLine + * @return null or addressLine + */ + public String getAddressLine(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String addressLine = address.getAddressLine(0); + + return addressLine; + } + else + { + return null; + } + } + + /** + * Try to get Locality + * @return null or locality + */ + public String getLocality(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String locality = address.getLocality(); + + return locality; + } + else + { + return null; + } + } + + /** + * Try to get Postal Code + * @return null or postalCode + */ + public String getPostalCode(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String postalCode = address.getPostalCode(); + + return postalCode; + } + else + { + return null; + } + } + + /** + * Try to get CountryName + * @return null or postalCode + */ + public String getCountryName(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String countryName = address.getCountryName(); + + return countryName; + } + else + { + return null; + } + } + + @Override + public void onLocationChanged(Location location) { + + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + + } + + @Override + public IBinder onBind(Intent intent) { + // TODO Auto-generated method stub + return null; + } + + + + + + +} + + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/GcmBroadcastReceiver.java b/app/src/main/java/in/skylinelabs/digiPune/activity/GcmBroadcastReceiver.java new file mode 100644 index 0000000..c980017 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/GcmBroadcastReceiver.java @@ -0,0 +1,19 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.support.v4.content.WakefulBroadcastReceiver; + +public class GcmBroadcastReceiver extends WakefulBroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + // Explicitly specify that GcmIntentService will handle the intent. + ComponentName comp = new ComponentName(context.getPackageName(), + GcmMessageHandler.class.getName()); + // Start the service, keeping the device awake while it is launching. + startWakefulService(context, (intent.setComponent(comp))); + // setResultCode(Activity.RESULT_OK); + //Log.d(null, "Receiver"); + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/GcmMessageHandler.java b/app/src/main/java/in/skylinelabs/digiPune/activity/GcmMessageHandler.java new file mode 100644 index 0000000..4bd6425 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/GcmMessageHandler.java @@ -0,0 +1,182 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.IntentService; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.NotificationCompat; +import android.support.v4.app.NotificationCompat.WearableExtender; +import android.util.Log; + +import com.google.android.gms.gcm.GoogleCloudMessaging; + +import in.skylinelabs.digiPune.R; + + +public class GcmMessageHandler extends IntentService { + + private NotificationManager mNotificationManager; + NotificationCompat.Builder builder; + + NotificationManager notificationManager; + Notification myNotification; + + private static final int MY_NOTIFICATION_ID1 = 1; + private static final int MY_NOTIFICATION_ID2 = 2; + + String msgFromActivity; + String extraOut; + + + + public GcmMessageHandler() { + super("in.skylinelabs.digiPune.GcmIntentService"); + + } + + + @Override + protected void onHandleIntent(Intent intent) { + + try{ + Bundle extras = intent.getExtras(); + + GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); + String messageType = gcm.getMessageType(intent); + + + String type =extras.getString("type"); + + Log.d("Bagh re type",type); + String abc = type.toString(); + + String x = ("sos").toString(); + + String xy = ("alert").toString(); + + if(abc.equals(x)) { +/***************************************************************************************************************************/ + + + + String name = extras.getString("name"); + String lat = extras.getString("latitude"); + String lon = extras.getString("longitude"); + String user_id = extras.getString("user_name"); + String number = extras.getString("number"); + String time =extras.getString("time"); + + + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + settings.edit().putString("sos_user_id", user_id).commit(); + settings.edit().putString("sos_lat", lat).commit(); + settings.edit().putString("sos_lon", lon).commit(); + settings.edit().putString("sos_user_name", name).commit(); + settings.edit().putString("sos_number", number).commit(); + settings.edit().putString("sos_time", time).commit(); + + String actual_name = settings.getString("name", ""); + + + Intent open_map = new Intent(this, sos_map.class); + PendingIntent pIntent = + PendingIntent.getActivity(this, 0, open_map, + PendingIntent.FLAG_UPDATE_CURRENT); + + + Intent callvictim = new Intent(Intent.ACTION_CALL); + callvictim.setData(Uri.parse("tel:" + number)); + PendingIntent pIntent2 = + PendingIntent.getActivity(this, 0, callvictim, + PendingIntent.FLAG_UPDATE_CURRENT); + + Intent navigate = new Intent(Intent.ACTION_VIEW, + Uri.parse("http://maps.google.com/maps?f=d&daddr=" + lat + "," + lon)); + PendingIntent pIntent3 = + PendingIntent.getActivity(this, 0, callvictim, + PendingIntent.FLAG_UPDATE_CURRENT); + + NotificationCompat.Action act_call = + new NotificationCompat.Action.Builder(R.drawable.ic_action_call, + "Call Victim", pIntent2) + .build(); + + NotificationCompat.Action act_nav = + new NotificationCompat.Action.Builder(R.drawable.ic_action_directions, + "Navigate to Victim", pIntent3) + .build(); + + + myNotification = new NotificationCompat.Builder(getApplicationContext()) + .setContentTitle(type + " received") + .setDefaults(Notification.DEFAULT_ALL) + .setContentText(name + " needs your help !!") + .setTicker("Notification!") + .setDefaults(Notification.DEFAULT_SOUND) + .setAutoCancel(true) + .setSmallIcon(R.drawable.findx_logo) + .extend(new WearableExtender().addAction(act_call)) + + .setContentIntent(pIntent).setAutoCancel(true) + .build(); + + notificationManager.notify(MY_NOTIFICATION_ID1, myNotification); + + + } + + if(abc.equals(xy)) { +/***************************************************************************************************************************/ + + + String title = extras.getString("title"); + String message = extras.getString("messageC"); + + Intent open_map = new Intent(this, Alert_Send.class); + PendingIntent pIntent = + PendingIntent.getActivity(this, 0, open_map, + PendingIntent.FLAG_UPDATE_CURRENT); + + + + myNotification = new NotificationCompat.Builder(getApplicationContext()) + .setContentTitle(title) + .setDefaults(Notification.DEFAULT_ALL) + .setContentText(message) + .setTicker("Notification!") + .setDefaults(Notification.DEFAULT_SOUND) + .setAutoCancel(true) + .setSmallIcon(R.drawable.findx_logo) + .setContentIntent(pIntent).setAutoCancel(true) + .build(); + + notificationManager.notify(MY_NOTIFICATION_ID1, myNotification); + + + } + + } + + + + + catch(Exception e){} + } + + + @Override + public void onCreate() { + // TODO Auto-generated method stub + super.onCreate(); + notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); + } +} + + \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/History.java b/app/src/main/java/in/skylinelabs/digiPune/activity/History.java new file mode 100644 index 0000000..50600b4 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/History.java @@ -0,0 +1,324 @@ +/******************No check on both edttxt being non empty********************/ + + +package in.skylinelabs.digiPune.activity; + + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.Color; +import android.location.Location; +import android.net.Uri; +import android.os.Bundle; +import android.support.design.widget.Snackbar; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.location.LocationListener; + +import in.skylinelabs.digiPune.R; + + +public class History extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener,LocationListener { + + final Context context = this; + + View.OnClickListener snackaction; + + + Double Latitude, Longitude; + + AlertDialog alertDialog; + + GPSTracker gps; + + String URL = "http://skylinelabs.in/Geo/history.php"; + + ProgressBar prgbr; + FloatingActionButton btn1; + EditText edttxt1; + String user, number; + WebView webView; + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.history); + + gps = new GPSTracker(History.this); + Latitude = gps.getLatitude(); + Longitude = gps.getLongitude(); + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(History.this); + + EditText toolbarSearchView = (EditText) findViewById(R.id.search_view); + toolbarSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + history(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + History.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + return true; + } + return false; + } + }); + + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.GONE); + + webView = (WebView) findViewById(R.id.map); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setAllowFileAccess(true); + webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false); + webView.getSettings().setBuiltInZoomControls(true); + webView.getSettings().setSupportZoom(true); + webView.setWebViewClient(new WebViewClient()); + + webView.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) { + if (progress < 100 && prgbr.getVisibility() == ProgressBar.GONE) { + prgbr.setVisibility(ProgressBar.VISIBLE); + } + prgbr.setProgress(progress); + if (progress == 100) { + prgbr.setVisibility(ProgressBar.GONE); + } + } + }); + + webView.loadUrl("http://www.skylinelabs.in/Geo/history.php"); + + edttxt1 = (EditText) findViewById(R.id.search_view); + edttxt1.setHint(" digiPune ID"); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(!isInternetPresent) { + + // Toast.makeText(getApplicationContext(), " Please Enable Internet " , Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + } + + + + @Override + public void onBackPressed() { + this.finish(); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_history, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + this); + LayoutInflater factory = LayoutInflater.from(this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.history_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + + if(id == R.id.action_search) { + history(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + History.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + } + + if(id == R.id.action_history) { + URL = "http://skylinelabs.in/Geo/history.php"; + } + + if(id == R.id.action_status) { + URL = "http://skylinelabs.in/Geo/history_status.php"; + } + return super.onOptionsItemSelected(item); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + break; + case 1: + finish(); + Intent i2 = new Intent(this, ComplaintPortal.class); + startActivity(i2); + break; + case 2: + finish(); + i = new Intent(this, Bus_Fetch.class); + startActivity(i); + break; + case 3: + finish(); + i = new Intent(this, FindGov.class); + startActivity(i); + break; + case 4: + finish(); + i = new Intent(this, MyLocation.class); + startActivity(i); + break; + case 5: + + break; + case 6: + finish(); + i = new Intent(this, Setting.class); + startActivity(i); + break; + case 7: + finish(); + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + break; + case 8: + finish(); + i = new Intent(this, Favourites.class); + startActivity(i); + break; + + default: + break; + } + } + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + + void history() + { + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) { + user = edttxt1.getText().toString(); + + if (user == null && user == "") { + webView.setVisibility(ProgressBar.GONE); + // Toast.makeText(this, "Please enter digiPune ID", Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Please enter digiPune ID", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } else { + webView.loadUrl(URL+"?user_name=" + user + "&num=5000"); + + } + } + + else + { + Toast.makeText(this, "Please connect to internet", Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Please connect to internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + + } + } + @Override + public void onLocationChanged(Location gps) { + // TODO Auto-generated method stub + Latitude = gps.getLatitude(); + Longitude = gps.getLongitude(); + } + + + +} + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/JSONParser.java b/app/src/main/java/in/skylinelabs/digiPune/activity/JSONParser.java new file mode 100644 index 0000000..ba668dd --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/JSONParser.java @@ -0,0 +1,117 @@ +package in.skylinelabs.digiPune.activity; + +import android.util.Log; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URLEncodedUtils; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.util.List; + +public class JSONParser { + + + static InputStream is = null; + static JSONObject jObj = null; + static String json = ""; + + // constructor + public JSONParser() { + + } + + // function get json from url + // by making HTTP POST or GET mehtod + public JSONObject makeHttpRequest(String url, String method, + List params) { + + // Making HTTP request + try { + + // check for request method + if(method == "POST"){ + // request method is POST + // defaultHttpClient + HttpParams httpParameters = new BasicHttpParams(); + HttpConnectionParams.setConnectionTimeout(httpParameters, 20000); + HttpConnectionParams.setSoTimeout(httpParameters, 20000); + DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); + + + + HttpPost httpPost = new HttpPost(url); + httpPost.setEntity(new UrlEncodedFormEntity(params)); + + HttpResponse httpResponse = httpClient.execute(httpPost); + HttpEntity httpEntity = httpResponse.getEntity(); + is = httpEntity.getContent(); + + }else if(method == "GET"){ + // request method is GET + + HttpParams httpParameters = new BasicHttpParams(); + HttpConnectionParams.setConnectionTimeout(httpParameters, 20000); + HttpConnectionParams.setSoTimeout(httpParameters, 20000); + DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); + + + + String paramString = URLEncodedUtils.format(params, "utf-8"); + url += "?" + paramString; + HttpGet httpGet = new HttpGet(url); + + HttpResponse httpResponse = httpClient.execute(httpGet); + HttpEntity httpEntity = httpResponse.getEntity(); + is = httpEntity.getContent(); + } + + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + try { + BufferedReader reader = new BufferedReader(new InputStreamReader( + is, "iso-8859-1"), 8); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + is.close(); + json = sb.toString(); + } catch (Exception e) { + Log.e("Buffer Error", "Error converting result " + e.toString()); + } + + // try parse the string to a JSON object + try { + jObj = new JSONObject(json); + } catch (JSONException e) { + Log.e("JSON Parser", "Error parsing data " + e.toString()); + } + + // return JSON String + return jObj; + + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Location_event.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Location_event.java new file mode 100644 index 0000000..39186d2 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Location_event.java @@ -0,0 +1,2038 @@ +package in.skylinelabs.digiPune.activity; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.annotation.TargetApi; +import android.app.ActionBar; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationManager; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.support.design.widget.Snackbar; +import android.support.v4.view.ViewCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewAnimationUtils; +import android.view.Window; +import android.view.animation.OvershootInterpolator; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.AdapterView; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.Switch; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.api.GoogleApiClient; +import com.google.android.gms.common.api.ResultCallback; +import com.google.android.gms.common.api.Status; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; + +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import in.skylinelabs.digiPune.R; + +public class Location_event extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback,FragmentDrawer.FragmentDrawerListener, android.location.LocationListener, GoogleMap.OnCameraChangeListener, GoogleMap.OnMapLoadedCallback{ + + int a[]={0,0}; + + private View mFab; + public FrameLayout mFabContainer; + public RelativeLayout mControlsContainer; + + public final static float SCALE_FACTOR = 130f; + public final static int ANIMATION_DURATION = 300; + public final static int MINIMUN_X_DISTANCE = 200; + + private boolean mRevealFlag; + private float mFabSize; + + Boolean rev = false; + + + View.OnClickListener snackaction; + + AlertDialog alertDialog; + + String addresstxt; + + Double FLat, FLon; + + MarkerOptions homeo = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions worko = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions othero = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions tempo = new MarkerOptions().position(new LatLng(10, 10)); + + Marker homem,otherm, tempm, workm; + + private FloatingActionButton mAddGeofencesButton; + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + TextView textView3; + + ProgressBar prgbr, prgbr1; + + Boolean home, other, work; + + String Latitude, Longitude; + + GoogleMap map; + + String mystringLatitude; + String mystringLongitude; + + + String nation, post, area, address; + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0; //0 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 10 * 1; // 10 sec + + //Declaring a Location Manager + protected LocationManager locationManager; + + String networkTS; + + final Context context = this; + + FloatingActionButton btn3,addb ; + + private SharedPreferences mSharedPreferences; + + EditText add, edt1; + private Spinner spinner_nav; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_location_event); + home = true; + other=false; + work = false; + + addb = (FloatingActionButton) findViewById(R.id.sel); + + + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + mAddGeofencesButton= (FloatingActionButton) findViewById(R.id.add); + mAddGeofencesButton.setVisibility(View.GONE); + + mAddGeofencesButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(home) { + + homem.setPosition(new LatLng(FLat, FLon)); + + homem.setSnippet("Home"); + try { + // homem.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + homem.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + homem.setVisible(true); + homem.showInfoWindow(); + tempm.setVisible(false); + + + + + + settings.edit().putBoolean("home_geofence", true).commit(); + settings.edit().putString("home_geofence_lat", FLat.toString()).commit(); + settings.edit().putString("home_geofence_lon", FLon.toString()).commit(); + + /////////////////////int x = array_loader(getLatitude(),getLongitude(),FLat,FLon,0.005); + //Toast.makeText(getApplicationContext(), " Geofence set " + x, Toast.LENGTH_LONG).show(); + + } + if(other){ + + + otherm.setPosition(new LatLng(FLat,FLon)); + + otherm.setSnippet("Home"); + try { + // otherm.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + otherm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + otherm.setVisible(true); + otherm.showInfoWindow(); + tempm.setVisible(false); + + + + settings.edit().putBoolean("other_geofence", true).commit(); + settings.edit().putString("other_geofence_lat", FLat.toString()).commit(); + settings.edit().putString("other_geofence_lon", FLon.toString()).commit(); + // Toast.makeText(getApplicationContext(), " Geofence set ", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Geofence set", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + if(work){ + + + workm.setPosition(new LatLng(FLat, FLon)); + + workm.setSnippet("Work"); + try { + // workm.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + workm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + workm.setVisible(true); + workm.showInfoWindow(); + tempm.setVisible(false); + + + + settings.edit().putBoolean("work_geofence", true).commit(); + settings.edit().putString("work_geofence_lat", FLat.toString()).commit(); + settings.edit().putString("work_geofence_lon", FLon.toString()).commit(); + // Toast.makeText(getApplicationContext(), " Geofence set ", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Geofence set", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(!isInternetPresent) { + + //Toast.makeText(getApplicationContext(), " Please Enable Internet ", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + getLocation(); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + spinner_nav = (Spinner) findViewById(R.id.spinner_nav); + + + addItemsToSpinner(); + + Button ab =(Button) findViewById(R.id.actionbutton); + // final Dialog homedialog = new Dialog(context); + ab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + // setContentView(R.layout.alert); + final Switch wifi_toggle, data_toggle, silent_toggle; + final CheckBox wifi, data, silent,notify, reminder; + final EditText reminder_edit; + + wifi_toggle = (Switch) findViewById(R.id.wifi_switch); + data_toggle = (Switch)findViewById(R.id.data_switch); + silent_toggle = (Switch) findViewById(R.id.silent_switch); + + wifi= (CheckBox) findViewById(R.id.wifi_check); + data= (CheckBox) findViewById(R.id.data_check); + silent= (CheckBox) findViewById(R.id.silent_check); + notify= (CheckBox) findViewById(R.id.notify_check); + reminder= (CheckBox) findViewById(R.id.reminder_check); + + reminder_edit = (EditText) findViewById(R.id.reminder_editText); + Button ok = (Button)findViewById(R.id.ok); + + if(home) + { + wifi.setChecked(settings.getBoolean("home_wifi", false)); + data.setChecked(settings.getBoolean("home_data", false)); + silent.setChecked(settings.getBoolean("home_silent", false)); + notify.setChecked(settings.getBoolean("home_notify", false)); + reminder.setChecked(settings.getBoolean("home_reminder", false)); + + wifi_toggle.setChecked(settings.getBoolean("home_wifi_state", false)); + data_toggle.setChecked(settings.getBoolean("home_data_state", false)); + silent_toggle.setChecked(settings.getBoolean("home_silent_state", false)); + + reminder_edit.setText(settings.getString("home_reminder_text", "")); + + if(!wifi.isChecked()) + wifi_toggle.setEnabled(false); + if(!data.isChecked()) + data_toggle.setEnabled(false); + if(!silent.isChecked()) + silent_toggle.setEnabled(false); + if(!reminder.isChecked()) + reminder_edit.setEnabled(false); + + wifi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(wifi.isChecked()) { + wifi_toggle.setEnabled(true); + } + else + wifi_toggle.setEnabled(false); + } + }); + data.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(data.isChecked()) { + data_toggle.setEnabled(true); + } + else + data_toggle.setEnabled(false); + + } + }); + silent.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(silent.isChecked()) { + silent_toggle.setEnabled(true); + } + else + silent_toggle.setEnabled(false); + } + }); + reminder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(reminder.isChecked()){ + reminder_edit.setEnabled(true); + } + else + reminder_edit.setEnabled(false); + } + }); + + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + settings.edit().putBoolean("home_wifi", wifi.isChecked()).commit(); + settings.edit().putBoolean("home_data", data.isChecked()).commit(); + settings.edit().putBoolean("home_silent", silent.isChecked()).commit(); + settings.edit().putBoolean("home_notify", notify.isChecked()).commit(); + settings.edit().putBoolean("home_reminder", reminder.isChecked()).commit(); + + + settings.edit().putBoolean("home_wifi_state", wifi_toggle.isChecked()).commit(); + settings.edit().putBoolean("home_data_state", data_toggle.isChecked()).commit(); + settings.edit().putBoolean("home_silent_state", silent_toggle.isChecked()).commit(); + + settings.edit().putString("home_reminder_text", reminder_edit.getText().toString()).commit(); + mControlsContainer.setVisibility(View.GONE); + + + } + }); + + + } + + if(work) + { + wifi.setChecked(settings.getBoolean("work_wifi", false)); + data.setChecked(settings.getBoolean("work_data", false)); + silent.setChecked(settings.getBoolean("work_silent", false)); + notify.setChecked(settings.getBoolean("work_notify", false)); + reminder.setChecked(settings.getBoolean("work_reminder", false)); + + wifi_toggle.setChecked(settings.getBoolean("work_wifi_state", false)); + data_toggle.setChecked(settings.getBoolean("work_data_state", false)); + silent_toggle.setChecked(settings.getBoolean("work_silent_state", false)); + + reminder_edit.setText(settings.getString("work_reminder_text", "")); + if(!wifi.isChecked()) + wifi_toggle.setEnabled(false); + if(!data.isChecked()) + data_toggle.setEnabled(false); + if(!silent.isChecked()) + silent_toggle.setEnabled(false); + if(!reminder.isChecked()) + reminder_edit.setEnabled(false); + wifi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(wifi.isChecked()) { + wifi_toggle.setEnabled(true); + } + else + wifi_toggle.setEnabled(false); + } + }); + data.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(data.isChecked()) { + data_toggle.setEnabled(true); + } + else + data_toggle.setEnabled(false); + + } + }); + silent.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(silent.isChecked()) { + silent_toggle.setEnabled(true); + } + else + silent_toggle.setEnabled(false); + } + }); + reminder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(reminder.isChecked()){ + reminder_edit.setEnabled(true); + } + else + reminder_edit.setEnabled(false); + } + }); + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + settings.edit().putBoolean("work_wifi", wifi.isChecked()).commit(); + settings.edit().putBoolean("work_data", data.isChecked()).commit(); + settings.edit().putBoolean("work_silent", silent.isChecked()).commit(); + settings.edit().putBoolean("work_notify", notify.isChecked()).commit(); + settings.edit().putBoolean("work_reminder", reminder.isChecked()).commit(); + + + settings.edit().putBoolean("work_wifi_state", wifi_toggle.isChecked()).commit(); + settings.edit().putBoolean("work_data_state", data_toggle.isChecked()).commit(); + settings.edit().putBoolean("work_silent_state", silent_toggle.isChecked()).commit(); + + settings.edit().putString("work_reminder_text", reminder_edit.getText().toString()).commit(); + mControlsContainer.setVisibility(View.GONE); + + + + } + }); + + + } + + + if(other) + { + wifi.setChecked(settings.getBoolean("other_wifi", false)); + data.setChecked(settings.getBoolean("other_data", false)); + silent.setChecked(settings.getBoolean("other_silent", false)); + notify.setChecked(settings.getBoolean("other_notify", false)); + reminder.setChecked(settings.getBoolean("other_reminder", false)); + + wifi_toggle.setChecked(settings.getBoolean("other_wifi_state", false)); + data_toggle.setChecked(settings.getBoolean("other_data_state", false)); + silent_toggle.setChecked(settings.getBoolean("other_silent_state", false)); + + reminder_edit.setText(settings.getString("other_reminder_text", "")); + if(!wifi.isChecked()) + wifi_toggle.setEnabled(false); + if(!data.isChecked()) + data_toggle.setEnabled(false); + if(!silent.isChecked()) + silent_toggle.setEnabled(false); + if(!reminder.isChecked()) + reminder_edit.setEnabled(false); + + wifi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(wifi.isChecked()) { + wifi_toggle.setEnabled(true); + } + else + wifi_toggle.setEnabled(false); + } + }); + data.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(data.isChecked()) { + data_toggle.setEnabled(true); + } + else + data_toggle.setEnabled(false); + + } + }); + silent.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(silent.isChecked()) { + silent_toggle.setEnabled(true); + } + else + silent_toggle.setEnabled(false); + } + }); + reminder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(reminder.isChecked()){ + reminder_edit.setEnabled(true); + } + else + reminder_edit.setEnabled(false); + } + }); + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + settings.edit().putBoolean("other_wifi", wifi.isChecked()).commit(); + settings.edit().putBoolean("other_data", data.isChecked()).commit(); + settings.edit().putBoolean("other_silent", silent.isChecked()).commit(); + settings.edit().putBoolean("other_notify", notify.isChecked()).commit(); + settings.edit().putBoolean("other_reminder", reminder.isChecked()).commit(); + + + settings.edit().putBoolean("other_wifi_state", wifi_toggle.isChecked()).commit(); + settings.edit().putBoolean("other_data_state", data_toggle.isChecked()).commit(); + settings.edit().putBoolean("other_silent_state", silent_toggle.isChecked()).commit(); + + settings.edit().putString("other_reminder_text", reminder_edit.getText().toString()).commit(); + + mControlsContainer.setVisibility(View.GONE); + + + } + }); + + + } + + + + + Window window = getWindow(); + window.setLayout(ActionBar.LayoutParams.FILL_PARENT, ActionBar.LayoutParams.FILL_PARENT); + } + }); + edt1 = (EditText) findViewById(R.id.search_view); + add = (EditText) findViewById(R.id.search_view); + add.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + search(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + Location_event.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + return true; + } + return false; + } + }); + + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + + map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + + + + + + map.setOnMapLoadedCallback(Location_event.this); + + map.setOnCameraChangeListener(Location_event.this); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + + homem = map.addMarker(homeo); + homem.setVisible(false); + otherm = map.addMarker(othero); + otherm.setVisible(false); + tempm = map.addMarker(tempo); + tempm.setVisible(false); + workm = map.addMarker(worko); + workm.setVisible(false); + + btn3 = (FloatingActionButton)findViewById(R.id.location); + btn3.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + }); + + + if(settings.getBoolean("home_geofence",false)) + { + homem.setPosition(new LatLng(Double.parseDouble(settings.getString("home_geofence_lat", "0")), Double.parseDouble(settings.getString("home_geofence_lon", "0")))); + + homem.setTitle("Home"); + + camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(settings.getString("home_geofence_lat", "0")), Double.parseDouble(settings.getString("home_geofence_lon", "0")))) + .zoom(12.8f) + + .build(); + + camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + try { + // homem.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + homem.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + homem.setVisible(true); + homem.showInfoWindow(); + + } + + + + map.setOnMapClickListener(new GoogleMap.OnMapClickListener() { + + @Override + public void onMapClick(LatLng point) { + + try { + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (!isInternetPresent) { + + // Toast.makeText(getApplicationContext(), " Please Enable Internet ", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } else { + + + FLat = point.latitude; + FLon = point.longitude; + // Toast.makeText(getApplicationContext(), FLat.toString() + FLon.toString(), Toast.LENGTH_LONG).show(); + + Geocoder geocoder; + List
addresses; + geocoder = new Geocoder(context, Locale.getDefault()); + + + try { + addresses = geocoder.getFromLocation(FLat, FLon, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5 + } catch (Exception e) { + + } + if (home) { + tempm.setPosition(new LatLng(FLat, FLon)); + + tempm.setTitle("Click '+' to Set this as Home"); + try { + // tempm.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + } + if (work) { + tempm.setPosition(new LatLng(FLat, FLon)); + + tempm.setTitle("Click '+' to Set this as Work"); + try { + // tempm.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + } + + if (other) { + tempm.setPosition(new LatLng(FLat, FLon)); + + tempm.setTitle("Click '+' to Set this as Other"); + try { + //tempm.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + } + + if (!home && !other && !work) { + // Toast.makeText(getApplicationContext(), "Select Geofence category ", Toast.LENGTH_LONG).show(); + + } + + mAddGeofencesButton.setVisibility(View.VISIBLE); + + + } + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), " Couldnt fetch location please check internet connection ", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Couldnt fetch location please check internet connection", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + + homem.showInfoWindow(); + otherm.showInfoWindow(); + workm.showInfoWindow(); + + + + + + + + + /**************************************************Animation Part**************************************/ + + mFab = findViewById(R.id.sel); + mFabSize = getResources().getDimensionPixelSize(R.dimen.fab_size); + + mFabContainer = (FrameLayout) findViewById(R.id.fab_container2); + mControlsContainer = (RelativeLayout) findViewById(R.id.inflate); + + mControlsContainer.setVisibility(View.GONE); + + rev = false; + + /**************************************************Animation Part**************************************/ + + } + + + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + title = "digiPune"; + break; + case 1: + finish(); + i = new Intent(this, MyLocation.class); + startActivity(i); + title = "My Location"; + break; + case 2: + + title ="GeoFencing"; + break; + case 3: + finish(); + i = new Intent(this, Setting.class); + startActivity(i); + title ="Settings"; + break; + case 4: + finish(); + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + title ="SOS Contacts"; + break; + case 5: + finish(); + i = new Intent(this, Favourites.class); + startActivity(i); + title ="Favourites"; + break; + case 6: + finish(); + i = new Intent(this, History.class); + startActivity(i); + title ="History"; + break; + + case 7: + Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( + "mailto","contact@skylinelabs.in", null)); + intent.putExtra(Intent.EXTRA_SUBJECT, "digiPune feedback"); + intent.putExtra(Intent.EXTRA_TEXT, "Hi ! It was an awesome experience using digiPune! "); + startActivity(Intent.createChooser(intent, "Contact developers")); + break; + case 8: + finish(); + i = new Intent(this, AboutDevelopers.class); + startActivity(i); + title ="About"; + break; + case 9: + Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=" + this.getPackageName()); + Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); + try { + startActivity(goToMarket); + } + catch(Exception e) + { + + } + break; + + case 10: + finish(); + i = new Intent(this, Privacypolicy.class); + startActivity(i); + title ="Privacy"; + break; + + default: + break; + } + } + + + + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + @Override + public void onLocationChanged(Location location) { + + map.setOnMapLoadedCallback(Location_event.this); + this.location = location; + + + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null) + { + + mystringLatitude = String.valueOf(getLatitude()); + mystringLongitude = String.valueOf(getLongitude()); + // Toast.makeText(this,"Activity OLC Update " + networkTS,Toast.LENGTH_SHORT).show(); + + + } + + + this.location = location; + Latitude = String.valueOf(getLatitude()); + Longitude = String.valueOf(getLongitude()); + } + + public Location getLocation() + { + try + { + locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(Location_event.this); + } + } + + + + public List
getGeocoderAddress(Context context) + { + if (location != null) + { + Geocoder geocoder = new Geocoder(context, Locale.ENGLISH); + try + { + List
addresses = geocoder.getFromLocation(latitude, longitude, 1); + return addresses; + } + catch (IOException e) + { + //e.printStackTrace(); + Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e); + } + } + + return null; + } + + + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + + finish(); + } + + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(null); + prgbr.setVisibility(View.VISIBLE); + map.setOnCameraChangeListener(Location_event.this); + map.setOnMapLoadedCallback(Location_event.this); + textView3.setVisibility(View.VISIBLE); + + /* map.setOnCameraChangeListener(MyLocation.this);*/ + } + + @Override + public void onMapLoaded() { + // TODO Auto-generated method stub + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + + @Override + public void onConnected(Bundle bundle) { + + } + + @Override + public void onConnectionSuspended(int i) { + + } + + @Override + public void onConnectionFailed(ConnectionResult connectionResult) { + + } + + @Override + public void onResult(Status status) { + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_location_event, menu); + return true; + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + /* + if(!settings.getBoolean("other_geofence",false) && !settings.getBoolean("home_geofence",false) && !settings.getBoolean("work_geofence",false)) + { + Toast.makeText(getApplicationContext(), "Geo fence not set", Toast.LENGTH_LONG).show(); + + }*/ + + + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + Location_event.this); + LayoutInflater factory = LayoutInflater.from(Location_event.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.friendlocation_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + if(id == R.id.action_search) { + + search(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + Location_event.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + + } + + + + return super.onOptionsItemSelected(item); + } + + + void search() + { + addresstxt = edt1.getText().toString(); + new GetLocation().execute(); + } + + public void addItemsToSpinner() { + + ArrayList list = new ArrayList(); + list.add("Home"); + list.add("Work"); + list.add("Other"); + + CustomSpinnerAdapter spinAdapter = new CustomSpinnerAdapter( + getApplicationContext(), list); + + spinner_nav.setAdapter(spinAdapter); + + spinner_nav.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView adapter, View v, + int position, long id) { + // On selecting a spinner item + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + String item = adapter.getItemAtPosition(position).toString(); + if (item == "Home") { + if (settings.getBoolean("home_geofence", false)) { + homem.setPosition(new LatLng(Double.parseDouble(settings.getString("home_geofence_lat", "0")), Double.parseDouble(settings.getString("home_geofence_lon", "0")))); + + homem.setSnippet("Home"); + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(settings.getString("home_geofence_lat", "0")), Double.parseDouble(settings.getString("home_geofence_lon", "0")))) + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + try { + // homem.setTitle(address.toString()); + } catch (Exception e) { + // Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + homem.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + homem.setVisible(true); + otherm.hideInfoWindow(); + homem.showInfoWindow(); + workm.hideInfoWindow(); + + } + homem.setVisible(true); + otherm.hideInfoWindow(); + homem.showInfoWindow(); + workm.hideInfoWindow(); + + otherm.setVisible(false); + workm.setVisible(false); + tempm.setVisible(false); + + home = true; + other = false; + work = false; + if (settings.getBoolean("home_geofence", false)) { + // Toast.makeText(getApplicationContext(), "Home already exists", Toast.LENGTH_LONG).show(); + + } + } + + if (item == "Work") { + if (settings.getBoolean("work_geofence", false)) { + workm.setPosition(new LatLng(Double.parseDouble(settings.getString("work_geofence_lat", "0")), Double.parseDouble(settings.getString("work_geofence_lon", "0")))); + + workm.setTitle("Work"); + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(settings.getString("work_geofence_lat", "0")), Double.parseDouble(settings.getString("work_geofence_lon", "0")))) + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + workm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + workm.setVisible(true); + + + workm.showInfoWindow(); + otherm.hideInfoWindow(); + homem.hideInfoWindow(); + } + + workm.setVisible(true); + workm.showInfoWindow(); + otherm.hideInfoWindow(); + homem.hideInfoWindow(); + homem.setVisible(false); + otherm.setVisible(false); + tempm.setVisible(false); + + + home = false; + other = false; + work = true; + if (settings.getBoolean("work_geofence", false)) { + // Toast.makeText(getApplicationContext(), "Work already exists", Toast.LENGTH_LONG).show(); + + } + } + + if (item == "Other") { + if (settings.getBoolean("other_geofence", false)) { + otherm.setPosition(new LatLng(Double.parseDouble(settings.getString("other_geofence_lat", "0")), Double.parseDouble(settings.getString("other_geofence_lon", "0")))); + + otherm.setTitle("Other"); + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(settings.getString("other_geofence_lat", "0")), Double.parseDouble(settings.getString("other_geofence_lon", "0")))) + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + try { + // otherm.setTitle(address.toString()); + } catch (Exception e) { + //Toast.makeText(getApplicationContext(), "Unable to fetch address", Toast.LENGTH_LONG).show(); + + } + otherm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + otherm.setVisible(true); + + + otherm.showInfoWindow(); + homem.hideInfoWindow(); + workm.hideInfoWindow(); + + } + otherm.setVisible(true); + + otherm.showInfoWindow(); + homem.hideInfoWindow(); + workm.hideInfoWindow(); + + + workm.setVisible(false); + homem.setVisible(false); + tempm.setVisible(false); + + + home = false; + other = true; + work = false; + if (settings.getBoolean("other_geofence", false)) { + // Toast.makeText(getApplicationContext(), "Other already exists", Toast.LENGTH_LONG).show(); + + } + } + // Showing selected spinner item + // Toast.makeText(getApplicationContext(), "Selected : " + item, + // Toast.LENGTH_LONG).show(); + + Snackbar.make(findViewById(android.R.id.content), "Selected : " + item, Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + @Override + public void onNothingSelected(AdapterView arg0) { + // TODO Auto-generated method stub + + } + }); + + } + + + + int array_loader(double curr_lat,double curr_lon,double centre_lat,double centre_lon,double radius) + { + + + a[0]=geofence(curr_lat, curr_lon, centre_lat, centre_lon, radius); + // Toast.makeText(getApplicationContext(), String.valueOf(a[0]) , Toast.LENGTH_LONG).show(); + + // Toast.makeText(getApplicationContext(), String.valueOf(a[0])+" " + String.valueOf(a[1]) , Toast.LENGTH_LONG).show(); + + + if(a[0]==0&&a[1]==0) + { a[1]=a[0]; + return 2;} //NO change + + if(a[0]==1&&a[1]==1) + {a[1]=a[0]; + return 2;} //No change + + if(a[0]==1&&a[1]==0) + {a[1]=a[0]; + return 1;} //came in + + if(a[0]==0&&a[1]==1) + {a[1]=a[0]; + return 0;} // went out + + + + + return 5; + + + + } + + int geofence(double curr_lat,double curr_lon,double centre_lat,double centre_lon,double radius) + { + double k; + k=Math.sqrt(Math.sqrt(((curr_lat-centre_lat)*(curr_lat-centre_lat)-(curr_lon-centre_lon)*(curr_lon-centre_lon))*((curr_lat-centre_lat)*(curr_lat-centre_lat)-(curr_lon-centre_lon)*(curr_lon-centre_lon)))); + // Toast.makeText(getApplicationContext(), String.valueOf(k) , Toast.LENGTH_LONG).show(); + + if(k= Build.VERSION_CODES.LOLLIPOP) { + enterReveal(); + } else { + mControlsContainer.setVisibility(View.VISIBLE); + final OvershootInterpolator interpolator = new OvershootInterpolator(); + ViewCompat.animate(addb).rotation(135f).withLayer().setDuration(300).setInterpolator(interpolator).start(); + + } + + + ClickStuff(); + rev = true; + + } + + else + { + spinner_nav.setVisibility(View.VISIBLE); + rev = false; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + exitReveal(); + } + + else + { + mControlsContainer.setVisibility(View.GONE); + final OvershootInterpolator interpolator = new OvershootInterpolator(); + ViewCompat.animate(addb).rotation(0f).withLayer().setDuration(300).setInterpolator(interpolator).start(); + + } + } + + } + + + + + void ClickStuff() + { + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + // setContentView(R.layout.alert); + final Switch wifi_toggle, data_toggle, silent_toggle; + final CheckBox wifi, data, silent,notify, reminder; + final EditText reminder_edit; + + wifi_toggle = (Switch) findViewById(R.id.wifi_switch); + data_toggle = (Switch)findViewById(R.id.data_switch); + silent_toggle = (Switch) findViewById(R.id.silent_switch); + + wifi= (CheckBox) findViewById(R.id.wifi_check); + data= (CheckBox) findViewById(R.id.data_check); + silent= (CheckBox) findViewById(R.id.silent_check); + notify= (CheckBox) findViewById(R.id.notify_check); + reminder= (CheckBox) findViewById(R.id.reminder_check); + + reminder_edit = (EditText) findViewById(R.id.reminder_editText); + Button ok = (Button)findViewById(R.id.ok); + + if(home) + { + wifi.setChecked(settings.getBoolean("home_wifi", false)); + data.setChecked(settings.getBoolean("home_data", false)); + silent.setChecked(settings.getBoolean("home_silent", false)); + notify.setChecked(settings.getBoolean("home_notify", false)); + reminder.setChecked(settings.getBoolean("home_reminder", false)); + + wifi_toggle.setChecked(settings.getBoolean("home_wifi_state", false)); + data_toggle.setChecked(settings.getBoolean("home_data_state", false)); + silent_toggle.setChecked(settings.getBoolean("home_silent_state", false)); + + reminder_edit.setText(settings.getString("home_reminder_text", "")); + + if(!wifi.isChecked()) + wifi_toggle.setEnabled(false); + if(!data.isChecked()) + data_toggle.setEnabled(false); + if(!silent.isChecked()) + silent_toggle.setEnabled(false); + if(!reminder.isChecked()) + reminder_edit.setEnabled(false); + + wifi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(wifi.isChecked()) { + wifi_toggle.setEnabled(true); + } + else + wifi_toggle.setEnabled(false); + } + }); + data.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(data.isChecked()) { + data_toggle.setEnabled(true); + } + else + data_toggle.setEnabled(false); + + } + }); + silent.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(silent.isChecked()) { + silent_toggle.setEnabled(true); + } + else + silent_toggle.setEnabled(false); + } + }); + reminder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(reminder.isChecked()){ + reminder_edit.setEnabled(true); + } + else + reminder_edit.setEnabled(false); + } + }); + + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + spinner_nav.setVisibility(View.VISIBLE); + + settings.edit().putBoolean("home_wifi", wifi.isChecked()).commit(); + settings.edit().putBoolean("home_data", data.isChecked()).commit(); + settings.edit().putBoolean("home_silent", silent.isChecked()).commit(); + settings.edit().putBoolean("home_notify", notify.isChecked()).commit(); + settings.edit().putBoolean("home_reminder", reminder.isChecked()).commit(); + settings.edit().putBoolean("home_wifi_state", wifi_toggle.isChecked()).commit(); + settings.edit().putBoolean("home_data_state", data_toggle.isChecked()).commit(); + settings.edit().putBoolean("home_silent_state", silent_toggle.isChecked()).commit(); + settings.edit().putString("home_reminder_text", reminder_edit.getText().toString()).commit(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + exitReveal(); + } + + else + { + mControlsContainer.setVisibility(View.GONE); + } + + + + } + }); + + + } + + if(work) + { + wifi.setChecked(settings.getBoolean("work_wifi", false)); + data.setChecked(settings.getBoolean("work_data", false)); + silent.setChecked(settings.getBoolean("work_silent", false)); + notify.setChecked(settings.getBoolean("work_notify", false)); + reminder.setChecked(settings.getBoolean("work_reminder", false)); + + wifi_toggle.setChecked(settings.getBoolean("work_wifi_state", false)); + data_toggle.setChecked(settings.getBoolean("work_data_state", false)); + silent_toggle.setChecked(settings.getBoolean("work_silent_state", false)); + + reminder_edit.setText(settings.getString("work_reminder_text", "")); + if(!wifi.isChecked()) + wifi_toggle.setEnabled(false); + if(!data.isChecked()) + data_toggle.setEnabled(false); + if(!silent.isChecked()) + silent_toggle.setEnabled(false); + if(!reminder.isChecked()) + reminder_edit.setEnabled(false); + wifi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(wifi.isChecked()) { + wifi_toggle.setEnabled(true); + } + else + wifi_toggle.setEnabled(false); + } + }); + data.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(data.isChecked()) { + data_toggle.setEnabled(true); + } + else + data_toggle.setEnabled(false); + + } + }); + silent.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(silent.isChecked()) { + silent_toggle.setEnabled(true); + } + else + silent_toggle.setEnabled(false); + } + }); + reminder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(reminder.isChecked()){ + reminder_edit.setEnabled(true); + } + else + reminder_edit.setEnabled(false); + } + }); + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + settings.edit().putBoolean("work_wifi", wifi.isChecked()).commit(); + settings.edit().putBoolean("work_data", data.isChecked()).commit(); + settings.edit().putBoolean("work_silent", silent.isChecked()).commit(); + settings.edit().putBoolean("work_notify", notify.isChecked()).commit(); + settings.edit().putBoolean("work_reminder", reminder.isChecked()).commit(); + + + settings.edit().putBoolean("work_wifi_state", wifi_toggle.isChecked()).commit(); + settings.edit().putBoolean("work_data_state", data_toggle.isChecked()).commit(); + settings.edit().putBoolean("work_silent_state", silent_toggle.isChecked()).commit(); + + settings.edit().putString("work_reminder_text", reminder_edit.getText().toString()).commit(); + + + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + exitReveal(); + } + + else + { + mControlsContainer.setVisibility(View.GONE); + } + + + + } + }); + + + } + + + if(other) + { + wifi.setChecked(settings.getBoolean("other_wifi", false)); + data.setChecked(settings.getBoolean("other_data", false)); + silent.setChecked(settings.getBoolean("other_silent", false)); + notify.setChecked(settings.getBoolean("other_notify", false)); + reminder.setChecked(settings.getBoolean("other_reminder", false)); + + wifi_toggle.setChecked(settings.getBoolean("other_wifi_state", false)); + data_toggle.setChecked(settings.getBoolean("other_data_state", false)); + silent_toggle.setChecked(settings.getBoolean("other_silent_state", false)); + + reminder_edit.setText(settings.getString("other_reminder_text", "")); + if(!wifi.isChecked()) + wifi_toggle.setEnabled(false); + if(!data.isChecked()) + data_toggle.setEnabled(false); + if(!silent.isChecked()) + silent_toggle.setEnabled(false); + if(!reminder.isChecked()) + reminder_edit.setEnabled(false); + + wifi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(wifi.isChecked()) { + wifi_toggle.setEnabled(true); + } + else + wifi_toggle.setEnabled(false); + } + }); + data.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(data.isChecked()) { + data_toggle.setEnabled(true); + } + else + data_toggle.setEnabled(false); + + } + }); + silent.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(silent.isChecked()) { + silent_toggle.setEnabled(true); + } + else + silent_toggle.setEnabled(false); + } + }); + reminder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(reminder.isChecked()){ + reminder_edit.setEnabled(true); + } + else + reminder_edit.setEnabled(false); + } + }); + + ok.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + settings.edit().putBoolean("other_wifi", wifi.isChecked()).commit(); + settings.edit().putBoolean("other_data", data.isChecked()).commit(); + settings.edit().putBoolean("other_silent", silent.isChecked()).commit(); + settings.edit().putBoolean("other_notify", notify.isChecked()).commit(); + settings.edit().putBoolean("other_reminder", reminder.isChecked()).commit(); + + + settings.edit().putBoolean("other_wifi_state", wifi_toggle.isChecked()).commit(); + settings.edit().putBoolean("other_data_state", data_toggle.isChecked()).commit(); + settings.edit().putBoolean("other_silent_state", silent_toggle.isChecked()).commit(); + + settings.edit().putString("other_reminder_text", reminder_edit.getText().toString()).commit(); + + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + exitReveal(); + } + + else + { + mControlsContainer.setVisibility(View.GONE); + } + + + } + }); + + } + + } + + + void enterReveal() { + + final OvershootInterpolator interpolator = new OvershootInterpolator(); + ViewCompat.animate(addb).rotation(135f).withLayer().setDuration(300).setInterpolator(interpolator).start(); + + + final View myView = findViewById(R.id.map); + + + try{ + // get the center for the clipping circle + int cx = myView.getMeasuredWidth(); + int cy = 0; + + // get the final radius for the clipping circle + int finalRadius = Math.max(myView.getWidth() * 2, myView.getHeight() * 2) / 2; + + // Toast.makeText(getApplicationContext(), finalRadius + " " + cx + " " + cy, Toast.LENGTH_LONG).show(); + + // create the animator for this view (the start radius is zero) + + Animator anim = + ViewAnimationUtils.createCircularReveal(mControlsContainer, cx, cy, 0, finalRadius); + + anim.start(); + + } + + catch(Exception e) + { + + + } + + mControlsContainer.setVisibility(View.VISIBLE); + + // previously invisible view + + + } + + + + void exitReveal() { + + final OvershootInterpolator interpolator = new OvershootInterpolator(); + ViewCompat.animate(addb).rotation(0f).withLayer().setDuration(300).setInterpolator(interpolator).start(); + + final View myView = findViewById(R.id.inflate); + + try{ + // previously visible view + + // get the center for the clipping circle + int cx = myView.getMeasuredWidth() - 25; + int cy = 0; + + // get the final radius for the clipping circle + int initialRadius = Math.max(myView.getWidth() * 2, myView.getHeight() * 2) / 2; + + // Toast.makeText(getApplicationContext(), initialRadius + " " + cx + " " + cy, Toast.LENGTH_LONG).show(); + + // create the animation (the final radius is zero) + Animator anim = + ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, 0); + + // make the view invisible when the animation is done + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + myView.setVisibility(View.INVISIBLE); + } + }); + + // start the animation + anim.start(); + } + + catch(Exception e) + { + myView.setVisibility(View.GONE); + + } + + + + } + + + + + /*******************************************************************************/ + + class GetLocation extends AsyncTask { + + JSONObject json, json2; + Boolean i,j,k = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + + protected String doInBackground(String... args) { + + + try { + + Geocoder coder = new Geocoder(context); + List
listadd; + + listadd = coder.getFromLocationName(addresstxt, 5); + + if (listadd == null) { + //Toast.makeText(getApplicationContext(), "Location not found, try again error step 1", + // .LENGTH_LONG).show(); + + } + + Address location = listadd.get(0); + FLat = location.getLatitude(); + FLon = location.getLongitude(); + + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + // Toast.makeText(getApplicationContext(), " " + FLat + " " + FLon, Toast.LENGTH_LONG).show(); + + if (home) { + tempm.setPosition(new LatLng(FLat, FLon)); + tempm.setTitle(addresstxt + "\n"); + tempm.setSnippet("Home"); + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + mAddGeofencesButton.setVisibility(View.VISIBLE); + } + + if (work) { + tempm.setPosition(new LatLng(FLat, FLon)); + tempm.setTitle(addresstxt + "\n"); + tempm.setSnippet("Work"); + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + mAddGeofencesButton.setVisibility(View.VISIBLE); + } + + if (other) { + tempm.setPosition(new LatLng(FLat, FLon)); + tempm.setTitle(addresstxt + "\n"); + tempm.setSnippet("Other"); + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + mAddGeofencesButton.setVisibility(View.VISIBLE); + } + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(FLat, FLon)) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + }); + + + } + + catch(Exception e) + { + } + + return null; + } + } +} + + + +/************************************************/ + + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Log_in.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Log_in.java new file mode 100644 index 0000000..faecec5 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Log_in.java @@ -0,0 +1,772 @@ +package in.skylinelabs.digiPune.activity; + + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONObject; + +import android.app.ActivityManager; +import android.app.ActivityManager.RunningServiceInfo; +import android.app.ActivityOptions; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.graphics.PorterDuff; +import android.location.Location; +import android.location.LocationManager; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.provider.Settings; +import android.support.design.widget.TextInputLayout; +import android.support.v7.app.ActionBarActivity; +import android.telephony.TelephonyManager; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import com.google.android.gms.gcm.GoogleCloudMessaging; +import com.google.android.gms.location.LocationListener; + +import in.skylinelabs.digiPune.R; +public class Log_in extends ActionBarActivity implements LocationListener { + + Button btn; + EditText edttxt1,edttxt2, edttxt3, edttxt4, edttxt5; + + Boolean error; + TextView txt1, txt2, help; + AlertDialog alertDialog1; + + Button txt; + + private ProgressDialog pDialog; + + GPSTracker gps; + + TextInputLayout lNameLayout,lNameLayout1,lNameLayout2,lNameLayout4,lNameLayout5; + + AlertDialog alertDialog; + + String email; + + long date; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + String networkTS; + + Date date1; + + Bundle savedInstanceState; + + String mystringLatitude; + String mystringLongitude; + + String name; + + static String mydevice_id, password; + + final Context context = this; + + private static final String url_create_product = "http://www.skylinelabs.in/Geo/signup_app.php"; + private static final String url_product_exists = "http://www.skylinelabs.in/Geo/get_product_exists.php"; + private static final String url_check_password = "http://www.skylinelabs.in/Geo/check_pass.php"; + private static final String url_login = "http://www.skylinelabs.in/Geo/login.php"; + JSONParser jsonParser = new JSONParser(); + + + GoogleCloudMessaging gcm; + String regid = ""; + + String myPhoneNumber; + + + @Override + protected void onResume() { + // TODO Auto-generated method stub + super.onResume(); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + + + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders == null || locationProviders.equals("")) { + + + if(!alertDialog.isShowing()) + { + alertDialog.show(); + } + + } + } + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_log_in); + //this.getActionBar().hide(); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + + + + + txt = (Button) findViewById(R.id.textView5); + txt.getBackground().setColorFilter(Color.parseColor("#1565c0"), PorterDuff.Mode.MULTIPLY); + + txt.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + + Intent i = new Intent(Log_in.this, Sign_up.class); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + startActivity(i, + ActivityOptions.makeSceneTransitionAnimation(Log_in.this).toBundle()); + } else { + startActivity(i); + } + finish(); + } + }); + + + lNameLayout = (TextInputLayout) findViewById(R.id + .fNameLayout); + lNameLayout1 = (TextInputLayout) findViewById(R.id + .fNameLayout2); + lNameLayout2 = (TextInputLayout) findViewById(R.id + .fNameLayout3); + lNameLayout4 = (TextInputLayout) findViewById(R.id + .fNameLayout4); + lNameLayout5 = (TextInputLayout) findViewById(R.id + .fNameLayoutEmail); + + + btn = (Button) findViewById(R.id.button1); + btn.getBackground().setColorFilter(Color.parseColor("#1565c0"), PorterDuff.Mode.MULTIPLY); + + edttxt1 = (EditText) findViewById(R.id.editText3); + + edttxt2 = (EditText) findViewById(R.id.editText1); + + + edttxt3 = (EditText) findViewById(R.id.editText2); + + + edttxt4 = (EditText) findViewById(R.id.editText4); + + edttxt5 = (EditText) findViewById(R.id.editTextEmail); + + + + edttxt2.clearFocus(); + edttxt1.requestFocus(); + + + try{ + + TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); + myPhoneNumber = tMgr.getLine1Number(); + edttxt3.setText(myPhoneNumber); + } + + catch(Exception e) + { + + } + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Please allow digiPune to access location"); + alertDialogBuilder.setTitle("Location Access Error"); + alertDialogBuilder.setCancelable(false); + + alertDialogBuilder.setPositiveButton("Settings", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface arg0, int arg1) { + alertDialog.dismiss(); + startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); + } + }); + alertDialogBuilder.setNegativeButton("Exit", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + + } + }); + alertDialog = alertDialogBuilder.create(); + + gps = new GPSTracker(Log_in.this); + + txt1 = (TextView) findViewById(R.id.textView1); + txt2 = (TextView) findViewById(R.id.textView2); + + + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders == null || locationProviders.equals("")) { + + + if(!alertDialog.isShowing()) + { + alertDialog.show(); + } + + } + + + + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + mydevice_id = edttxt1.getText().toString(); + name = edttxt2.getText().toString(); + myPhoneNumber = edttxt3.getText().toString(); + password = edttxt4.getText().toString(); + settings.edit().putString("number", myPhoneNumber).commit(); + + lNameLayout.setErrorEnabled(false); + + lNameLayout1.setErrorEnabled(false); + + lNameLayout2.setErrorEnabled(false); + + lNameLayout4.setErrorEnabled(false); + + lNameLayout5.setErrorEnabled(false); + + + + + + if(edttxt5.getText().toString().matches("") || edttxt1.getText().toString().matches("") || edttxt2.getText().toString().matches("") || edttxt3.getText().toString().matches("")) + { + if(edttxt1.getText().toString().matches("")) + { + lNameLayout.setErrorEnabled(true); + lNameLayout.setError("*Required field"); + } + + if(edttxt2.getText().toString().matches("")) + { + lNameLayout1.setErrorEnabled(true); + lNameLayout1.setError("*Required field"); + } + + if(edttxt3.getText().toString().matches("")) + { + lNameLayout2.setErrorEnabled(true); + lNameLayout2.setError("*Required field"); + } + + if(edttxt5.getText().toString().matches("")) + { + lNameLayout5.setErrorEnabled(true); + lNameLayout5.setError("*Required field"); + } + + + } + + + + + else + { + + + try + { + mystringLatitude = String.valueOf(gps.getLatitude()); + mystringLongitude = String.valueOf(gps.getLongitude()); + + email = edttxt5.getText().toString(); + + + date = gps.locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime(); + networkTS = sdf.format(date); + + + new CreateNewProduct().execute(); + } + + catch(Exception e) + { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Log_in.this); + alertDialogBuilder.setMessage("It appears that you device hasnt connected to google location service. Please do the following : \n" + "1.Ensure that device has working internet connection\n" +"2.Ensure that location access in device settings has been turned with mobile network location activated\n" + "3.Finally, restart your device to obtain location fix if above steps dont work" ); + alertDialogBuilder.setTitle("Location Access Error"); + + alertDialogBuilder.setPositiveButton("Exit", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + + + + } + + + } + + else + { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Log_in.this); + alertDialogBuilder.setMessage("Unable to connect to internet. Please connect to internet" ); + alertDialogBuilder.setTitle("Internet Error"); + + alertDialogBuilder.setPositiveButton("Retry", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + } + + + + }); + + } + + class CreateNewProduct extends AsyncTask { + + JSONObject json, json2; + Boolean i,j,k = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pDialog = new ProgressDialog(Log_in.this); + pDialog.setMessage("Loging in...."); + pDialog.setIndeterminate(false); + pDialog.setCancelable(false); + pDialog.show(); + + + } + + + protected String doInBackground(String... args) { + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id)); + + //Check if userId exists + try + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + pDialog.setMessage("Checking if user name exists"); + } + }); + + json = jsonParser.makeHttpRequest( + url_product_exists, "GET", params); + i = true; + } + catch (Exception e1) { + + + i=false; + + pDialog.dismiss(); + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Log_in.this); + alertDialogBuilder.setMessage("Something went wrong while signing up. Please try again" ); + alertDialogBuilder.setTitle("Error"); + + alertDialogBuilder.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + }); + + } + + if(i) + + { + try { + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + pDialog.setMessage("Registering with GCM"); + } + }); + + if (gcm == null) { + gcm = GoogleCloudMessaging.getInstance(getApplicationContext()); + } + + regid = gcm.register("324467972262"); + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + settings.edit().putString("gcm_regid", regid).commit(); + j = true; + + + } catch (Exception ex) { + j = false; + pDialog.dismiss(); + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Log_in.this); + alertDialogBuilder.setMessage("Error communicating to GCM servers. Please try again"); + alertDialogBuilder.setTitle("Connection Error"); + + alertDialogBuilder.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + }); + } + + if (j) { + try { + + int success = json.getInt("success"); + + //UserID doesnt exist, create new product + if (success == 1) { + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + pDialog.setMessage("Checking if password matches"); + } + }); + + params.add(new BasicNameValuePair("password", password)); + + json2 = jsonParser.makeHttpRequest(url_check_password, + "POST", params); + + k=true; + + } + + //User Id exists + if (success == 0) { + + pDialog.dismiss(); + runOnUiThread(new Runnable() { + // + @Override + public void run() { + lNameLayout.setErrorEnabled(true); + lNameLayout.setError("digiPune ID doesnt exist"); + k=false; + } + }); + } + + } catch (Exception e1) { + + k=false; + pDialog.dismiss(); + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Log_in.this); + alertDialogBuilder.setMessage("Something went wrong.Please try again"); + alertDialogBuilder.setTitle("Error"); + + alertDialogBuilder.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + }); + + + } + } + } + + + if(k) + { + try + { + int success2 = json2.getInt("success"); + if (success2 == 1) { + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + pDialog.setMessage("Loging in...."); + } + }); + + + params.add(new BasicNameValuePair("latitude", mystringLatitude)); + params.add(new BasicNameValuePair("longitude", mystringLongitude)); + params.add(new BasicNameValuePair("sharing_on", "1")); + params.add(new BasicNameValuePair("time", sdf.format(date))); + params.add(new BasicNameValuePair("gcm_regid", regid)); + TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); + String imei = tMgr.getDeviceId(); + params.add(new BasicNameValuePair("IMEI",imei)); + params.add(new BasicNameValuePair("contact", myPhoneNumber)); + params.add(new BasicNameValuePair("email", email)); + + + + JSONObject json = jsonParser.makeHttpRequest(url_login, + "POST", params); + + + pDialog.dismiss(); + finish(); + Intent i = new Intent(Log_in.this, App_intro.class); + Intent i2 = new Intent(Log_in.this, FriendLocation.class); + startActivity(i2); + startActivity(i); + + final String PREFS_NAME = "GeoPreferences"; + + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + settings.edit().putString("name", name).commit(); + settings.edit().putString("user_name", mydevice_id).commit(); + settings.edit().putString("password", password).commit(); + settings.edit().putBoolean("FindX_share_enabled", true).commit(); + settings.edit().putBoolean("FindX_history_enabled", true).commit(); + settings.edit().putBoolean("FindX_background_enabled", true).commit(); + settings.edit().putBoolean("my_first_time", false).commit(); + settings.edit().putString("category_pos", "1").apply(); + + + //Checking if background activity running + ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { + + if (digiPune.class.getName().equals(service.service.getClassName())) { + //running + } else { + context.startService(new Intent(context, digiPune.class)); + } + + } + + } + + if (success2 == 0) { + + pDialog.dismiss(); + runOnUiThread(new Runnable() { + // + @Override + public void run() { + lNameLayout4.setErrorEnabled(true); + lNameLayout4.setError("*Password doesnt match"); + } + }); + + + } + + + + } + + catch (Exception e1) { + + + pDialog.dismiss(); + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Log_in.this); + alertDialogBuilder.setMessage("Something went wrong.Please try again"); + alertDialogBuilder.setTitle("Error"); + + alertDialogBuilder.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + }); + + + } + + + + } + + return null; + } + + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_log_in, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + switch (item.getItemId()) { + case android.R.id.home: { + Intent i2 = new Intent(Log_in.this, Sign_up.class); + i2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + startActivity(i2); + finish(); + return true; + } + + + case R.id.info: { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + Log_in.this); + LayoutInflater factory = LayoutInflater.from(Log_in.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.mylocation_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + return super.onOptionsItemSelected(item); + + } + + default: + return super.onOptionsItemSelected(item); + } + } + + + @Override + public void onLocationChanged(Location gps) { + // TODO Auto-generated method stub + mystringLatitude = String.valueOf(gps.getLatitude()); + mystringLongitude = String.valueOf(gps.getLongitude()); + } + + @Override + public void onBackPressed() { + Intent i2 = new Intent(Log_in.this, Sign_up.class); + i2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + startActivity(i2); + finish(); + } +} + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/MyLocation.java b/app/src/main/java/in/skylinelabs/digiPune/activity/MyLocation.java new file mode 100644 index 0000000..d888607 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/MyLocation.java @@ -0,0 +1,883 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationManager; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.provider.Settings; +import android.support.design.widget.Snackbar; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; +import com.google.android.gms.maps.GoogleMap.OnMapLoadedCallback; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Locale; + +import in.skylinelabs.digiPune.R; + +public class MyLocation extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener, android.location.LocationListener, OnCameraChangeListener, OnMapLoadedCallback { + + GoogleMap map; + + AlertDialog alertDialog; + + EditText edttxt; + + WebView web; + + String status, Latitude, Longitude; + + + TextView txt1, txt2,textView3; + + ProgressBar prgbr, prgbr1; + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + long date; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + final Context context = this; + + String mystringLatitude; + String mystringLongitude; + + static String mydevice_id; + + String nation, post, area, address; + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + //public static boolean mylocationOn; + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0; //0 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 10 * 1; // 10 sec + + //Declaring a Location Manager + protected LocationManager locationManager; + + String networkTS; + + FloatingActionButton btn1,btn2; + + @Override + public void onPause() { + super.onPause(); // Always call the superclass method first + + } + + @Override + public void onResume() { + super.onResume(); // Always call the superclass method first + + + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders == null || locationProviders.equals("")) { + finish(); + + } + } + + View.OnClickListener snackaction; + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.my_location); + + getLocation(); + + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + edttxt=(EditText) findViewById(R.id.search_view); + edttxt.setHint(" Enter Status"); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + displayView(4); + + + EditText toolbarSearchView = (EditText) findViewById(R.id.search_view); + toolbarSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_GO) { + statusUpdate(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + MyLocation.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + return true; + } + return false; + } + }); + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + prgbr1 = (ProgressBar) findViewById(R.id.progressBar2); + prgbr1.setVisibility(View.GONE); + + web = (WebView) findViewById(R.id.webView1); + web.getSettings().setJavaScriptEnabled(true); + web.getSettings().setBuiltInZoomControls(true); + web.getSettings().setSupportZoom(true); + web.setVisibility(View.GONE); + web.setWebViewClient(new WebViewClient()); + web.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) { + if (progress < 100 && prgbr.getVisibility() == ProgressBar.GONE) { + prgbr1.setVisibility(ProgressBar.VISIBLE); + } + prgbr1.setProgress(progress); + if (progress == 100) { + prgbr1.setVisibility(ProgressBar.GONE); + edttxt.setText(""); + //Toast.makeText(MyLocation.this, "Status updated", Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Status updated", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + + + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + + map.setOnMapLoadedCallback(new OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + map.setOnMapLoadedCallback(MyLocation.this); + + map.setOnCameraChangeListener(MyLocation.this); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + + txt1 = (TextView) findViewById(R.id.textView1); + txt2 = (TextView) findViewById(R.id.textView2); + + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + mydevice_id = settings.getString("user_name", ""); + + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null) + { + mystringLatitude = String.valueOf(getLatitude()); + mystringLongitude = String.valueOf(getLongitude()); + date = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime(); + networkTS = sdf.format(date); + new CreateNewProduct().execute(); + // Toast.makeText(this,"Activity Start Update" + networkTS,Toast.LENGTH_SHORT).show(); + } + + + btn1 = (FloatingActionButton)findViewById(R.id.button1); + btn1.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + + } + }); + + + + btn2 = (FloatingActionButton)findViewById(R.id.location); + btn2.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + } + + }); + + + + + + + } + + @Override + public void onLocationChanged(Location location) { + + map.setOnMapLoadedCallback(MyLocation.this); + + + this.location = location; + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + mydevice_id = settings.getString("user_name", ""); + + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null) + { + date = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime(); + networkTS = sdf.format(date); + mystringLatitude = String.valueOf(getLatitude()); + mystringLongitude = String.valueOf(getLongitude()); + // Toast.makeText(this,"Activity OLC Update " + networkTS,Toast.LENGTH_SHORT).show(); + + new CreateNewProduct().execute(); + } + + txt1.setText(area); + txt2.setText(address); + + this.location = location; + Latitude = String.valueOf(getLatitude()); + Longitude = String.valueOf(getLongitude()); + } + + public Location getLocation() + { + try + { + locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(MyLocation.this); + } + } + + /** + * Function to get latitude + */ + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + /** + * Function to check GPS/wifi enabled + */ + public boolean canGetLocation() + { + return this.canGetLocation; + } + + + /** + * Get list of address by latitude and longitude + * @return null or List
+ */ + public List
getGeocoderAddress(Context context) + { + if (location != null) + { + Geocoder geocoder = new Geocoder(context, Locale.ENGLISH); + try + { + List
addresses = geocoder.getFromLocation(latitude, longitude, 1); + return addresses; + } + catch (IOException e) + { + //e.printStackTrace(); + Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e); + } + } + + return null; + } + + /** + * Try to get AddressLine + * @return null or addressLine + */ + public String getAddressLine(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String addressLine = address.getAddressLine(0); + + return addressLine; + } + else + { + return null; + } + } + + /** + * Try to get Locality + * @return null or locality + */ + public String getLocality(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String locality = address.getLocality(); + + return locality; + } + else + { + return null; + } + } + + /** + * Try to get Postal Code + * @return null or postalCode + */ + public String getPostalCode(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String postalCode = address.getPostalCode(); + + return postalCode; + } + else + { + return null; + } + } + + /** + * Try to get CountryName + * @return null or postalCode + */ + public String getCountryName(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String countryName = address.getCountryName(); + + return countryName; + } + else + { + return null; + } + } + + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + // TODO Auto-generated method stub + + + } + + @Override + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + + finish(); + } + + + + + class CreateNewProduct extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + + protected String doInBackground(String... args) { + + + try + { + if(getLocality(getApplicationContext()) != null) + nation = getCountryName(getApplicationContext()); + else + nation = ""; + + + if(getLocality(getApplicationContext()) != null) + area = getLocality(getApplicationContext()); + else + area = ""; + + if(getAddressLine(getApplicationContext()) != null) + address = getAddressLine(getApplicationContext()); + else + address = ""; + } + catch (Exception e1) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + //Toast.makeText(getApplicationContext(),"Network error Unable to fetch address",Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error Unable to fetch address", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + }); + + } + + + + + + return null; + } + + + } + + + @Override + protected void onRestart() { + // TODO Auto-generated method stub + super.onRestart(); + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders == null || locationProviders.equals("")) { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Please allow findX to access location"); + alertDialogBuilder.setTitle("Location Access Error"); + + alertDialogBuilder.setPositiveButton("Settings", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface arg0, int arg1) { + + startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); + } + }); + alertDialogBuilder.setNegativeButton("Exit", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + + +} + + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(null); + prgbr.setVisibility(View.VISIBLE); + map.setOnCameraChangeListener(MyLocation.this); + map.setOnMapLoadedCallback(MyLocation.this); + textView3.setVisibility(View.VISIBLE); + + /* map.setOnCameraChangeListener(MyLocation.this);*/ + } + + @Override + public void onMapLoaded() { + // TODO Auto-generated method stub + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + @Override + public void onBackPressed() { + this.finish(); + } + + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.mylocation_menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if(id == R.id.action_go) { + statusUpdate(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + MyLocation.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + } + + if(id == R.id.share) { + Intent sharingIntent = new Intent(Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + String nation1, area1, address1; + + if(nation != null) + nation1 = nation; + else + nation1 = ""; + + if(area != null) + area1 = area; + else + area1 = ""; + + if(address != null) + address1 = address; + else + address1 = ""; + + sharingIntent.putExtra(Intent.EXTRA_TEXT, "Hi ! Here is my location" + "\n\n" +"Address :" + "\n" +"Latitude : " + mystringLatitude + "\n" + "Longitude : " + mystringLongitude + "\n" + nation1 + "\n" + area1 + "\n" + address1+ "\n\n" +"Time : "+sdf.format(date)+"\n"+"\n" +"To know current location, click on the following link :\n"+ "http://www.google.com/maps/place/" + mystringLatitude + "," + mystringLongitude +"\n" + "Shared via digiPune"); + startActivity(Intent.createChooser(sharingIntent, "Share your location")); + + } + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + MyLocation.this); + LayoutInflater factory = LayoutInflater.from(MyLocation.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.mylocation_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + return super.onOptionsItemSelected(item); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + break; + case 1: + finish(); + Intent i2 = new Intent(this, ComplaintPortal.class); + startActivity(i2); + break; + case 2: + finish(); + i = new Intent(this, Bus_Fetch.class); + startActivity(i); + break; + case 3: + finish(); + i = new Intent(this, FindGov.class); + startActivity(i); + break; + case 4: + + break; + case 5: + finish(); + i = new Intent(this, History.class); + startActivity(i); + break; + case 6: + finish(); + i = new Intent(this, Setting.class); + startActivity(i); + break; + case 7: + finish(); + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + break; + case 8: + finish(); + i = new Intent(this, Favourites.class); + startActivity(i); + break; + + default: + break; + } + } + + void statusUpdate() + { + date = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime(); + networkTS = sdf.format(date); + + Latitude = String.valueOf(getLatitude()); + Longitude = String.valueOf(getLongitude()); + + InputMethodManager inputManager = (InputMethodManager) + getSystemService(Context.INPUT_METHOD_SERVICE); + + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + String status = edttxt.getText().toString(); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if(isInternetPresent) { + try { + web.loadUrl("http://skylinelabs.in/Geo/status.php?user_name=" + mydevice_id + "&latitude=" + Latitude + "&longitude=" + Longitude + "&time=" + sdf.format(date) + "&status=" + status); + } catch (Exception e) { + + } + + } + + else + { + //Toast.makeText(this, "Please connect to internet", Toast.LENGTH_SHORT).show(); + Snackbar.make(findViewById(android.R.id.content), "Please connect to internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + } + + +} + + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/MyObject.java b/app/src/main/java/in/skylinelabs/digiPune/activity/MyObject.java new file mode 100644 index 0000000..35fc285 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/MyObject.java @@ -0,0 +1,13 @@ +package in.skylinelabs.digiPune.activity; + +public class MyObject { + + public String objectName; + + // constructor for adding sample data + public MyObject(String objectName){ + + this.objectName = objectName; + } + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/No_SignUp.java b/app/src/main/java/in/skylinelabs/digiPune/activity/No_SignUp.java new file mode 100644 index 0000000..4e087c5 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/No_SignUp.java @@ -0,0 +1,94 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Intent; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.CardView; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; + +import in.skylinelabs.digiPune.R; + +public class No_SignUp extends ActionBarActivity { + + private Toolbar mToolbar; + + CardView one,two,three; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_no__sign_up); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("digiPune"); + + one = (CardView) findViewById(R.id.card1); + two = (CardView) findViewById(R.id.card2); + three = (CardView) findViewById(R.id.card3); + + one.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i2 = new Intent(No_SignUp.this, Bus_Fetch.class); + startActivity(i2); + } + }); + + two.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i2 = new Intent(No_SignUp.this, FindGov.class); + startActivity(i2); + } + }); + + three.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i2 = new Intent(No_SignUp.this, ComplaintPortal.class); + startActivity(i2); + } + }); + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_no__sign_up, menu); + return true; + + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.info) { + + return true; + } + + if(id == R.id.signup) { + + finish(); + this.getSharedPreferences("GeoPreferences", 0).edit().clear().commit(); + Intent i = new Intent(No_SignUp.this, Pre_launch_activity.class); + startActivity(i); + return true; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Pre_launch_activity.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Pre_launch_activity.java new file mode 100644 index 0000000..ceb3c55 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Pre_launch_activity.java @@ -0,0 +1,286 @@ +package in.skylinelabs.digiPune.activity; +import android.app.Activity; +import android.app.ActivityManager; +import android.app.AlertDialog; +import android.content.ComponentName; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Bundle; + +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.GooglePlayServicesUtil; + + + +public class Pre_launch_activity extends Activity{ + + final Context context = this; + public static int post=0; + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + //this.getActionBar().hide(); + + final String PREFS_NAME = "GeoPreferences"; + + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + int status = GooglePlayServicesUtil + .isGooglePlayServicesAvailable(getApplicationContext()); + if (status == ConnectionResult.SUCCESS) { + // Success! Do what you want + + if (settings.getBoolean("my_first_time", true)) { + + Intent i2 = new Intent(Pre_launch_activity.this, Sign_up.class); + startActivity(i2); + finish(); + } + else{ + + if(settings.getBoolean("signup_skip",false)) + { + Intent i2 = new Intent(Pre_launch_activity.this, No_SignUp.class); + startActivity(i2); + int flag=(PackageManager.COMPONENT_ENABLED_STATE_DISABLED); + ComponentName component=new ComponentName(Pre_launch_activity.this, BootCompletedReceiver.class); + getPackageManager() + .setComponentEnabledSetting(component, flag, + PackageManager.DONT_KILL_APP); + + finish(); + } + + else { + Intent i2 = new Intent(Pre_launch_activity.this, FriendLocation.class); + startActivity(i2); + + ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { + + if (digiPune.class.getName().equals(service.service.getClassName())) { + //running + } else { + digiPune.MIN_TIME_BW_UPDATES = 1000 * 2 * 60; + context.startService(new Intent(context, digiPune.class)); + + } + + } + finish(); + } + + } + + } + else { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( + Pre_launch_activity.this); + + // set title + alertDialogBuilder.setTitle("Google play services error"); + + // set dialog message + alertDialogBuilder + .setMessage( + "This Application wants you to update Google Play Services App") + .setCancelable(false) + .setPositiveButton("Update", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int id) { + callMarketPlace(); + + + } + }) + .setNegativeButton("Cancel", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int id) { + // if this button is clicked, just close + // the dialog box and do nothing + finish(); + dialog.cancel(); + } + }); + + alertDialogBuilder.show(); + + } + + } + + public void callMarketPlace() { + try { + + startActivityForResult( + new Intent(Intent.ACTION_VIEW, + Uri.parse("market://details?id=" + + "com.google.android.gms")), 1); + } catch (android.content.ActivityNotFoundException anfe) { + startActivityForResult(new Intent(Intent.ACTION_VIEW, + Uri.parse("https://play.google.com/store/apps/details?id=" + + "com.google.android.gms")), 1); + } + } +} + + + + + + + + + + + + + + +/*package in.skylinelabs.digiPune.activity; +import android.app.Activity; +import android.app.ActivityManager; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Bundle; + +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.GooglePlayServicesUtil; + + + +public class Pre_launch_activity extends Activity{ + + final Context context = this; + public static int post=0; + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + //this.getActionBar().hide(); + + final String PREFS_NAME = "GeoPreferences"; + + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + int status = GooglePlayServicesUtil + .isGooglePlayServicesAvailable(getApplicationContext()); + if (status == ConnectionResult.SUCCESS) { + // Success! Do what you want + + if (settings.getBoolean("my_first_time", true)) { + + Intent i2 = new Intent(Pre_launch_activity.this, Sign_up.class); + startActivity(i2); + finish(); + } + else{ + + + if(settings.getBoolean("sign_up_skip", false)) { + Intent i2 = new Intent(this, No_SignUp.class); + startActivity(i2); + finish(); + } + else{ + + Intent i2 = new Intent(this, FriendLocation.class); + startActivity(i2); + + ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { + + if (digiPune.class.getName().equals(service.service.getClassName())) { + //running + } else { + + context.startService(new Intent(context, digiPune.class)); + digiPune.MIN_TIME_BW_UPDATES = 1000 * 2 * 60; + + } + + } + + finish(); + } + + + + + } + + + + + } + else { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( + Pre_launch_activity.this); + + // set title + alertDialogBuilder.setTitle("Google play services error"); + + // set dialog message + alertDialogBuilder + .setMessage( + "This Application wants you to update Google Play Services App") + .setCancelable(false) + .setPositiveButton("Update", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int id) { + callMarketPlace(); + + + } + }) + .setNegativeButton("Cancel", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int id) { + // if this button is clicked, just close + // the dialog box and do nothing + finish(); + dialog.cancel(); + } + }); + + alertDialogBuilder.show(); + + } + + } + + public void callMarketPlace() { + try { + + startActivityForResult( + new Intent(Intent.ACTION_VIEW, + Uri.parse("market://details?id=" + + "com.google.android.gms")), 1); + } catch (android.content.ActivityNotFoundException anfe) { + startActivityForResult(new Intent(Intent.ACTION_VIEW, + Uri.parse("https://play.google.com/store/apps/details?id=" + + "com.google.android.gms")), 1); + } + } +} + + +*/ + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Privacypolicy.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Privacypolicy.java new file mode 100644 index 0000000..db9fc4e --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Privacypolicy.java @@ -0,0 +1,183 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Intent; +import android.net.Uri; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.View; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.ProgressBar; + +import in.skylinelabs.digiPune.R; + +public class Privacypolicy extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener { + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + WebView wb; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_privacypolicy); + + + displayView(10); + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + + wb = (WebView) findViewById(R.id.webView); + wb.getSettings().setJavaScriptEnabled(true); + wb.loadUrl("http://www.skylinelabs.in/digiPune/privacy/"); + + final ProgressBar Pbar; + + Pbar = (ProgressBar)findViewById(R.id.progressBar1); + + wb.setWebViewClient(new WebViewClient() { + public boolean shouldOverrideUrlLoading(WebView viewx, String urlx) { + viewx.loadUrl(urlx); + return false; + } + }); + + wb.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) + { + if(progress < 100 && Pbar.getVisibility() == ProgressBar.GONE){ + Pbar.setVisibility(ProgressBar.VISIBLE); + } + Pbar.setProgress(progress); + if(progress == 100) { + Pbar.setVisibility(ProgressBar.GONE); + } + } + }); + + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + // getMenuInflater().inflate(R.menu.menu_privacypolicy, menu); + return true; + + } + + + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + title = "digiPune"; + break; + case 1: + finish(); + i = new Intent(this, MyLocation.class); + startActivity(i); + title = "My Location"; + break; + case 2: + finish(); + i = new Intent(this, Location_event.class); + startActivity(i); + title ="GeoFencing"; + break; + case 3: + finish(); + i = new Intent(this, Setting.class); + startActivity(i); + title ="Settings"; + break; + case 4: + finish(); + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + title ="SOS Contacts"; + break; + case 5: + finish(); + i = new Intent(this, Favourites.class); + startActivity(i); + title ="Favourites"; + break; + case 6: + finish(); + i = new Intent(this, History.class); + startActivity(i); + title ="History"; + break; + /*case 6: + finish(); + i = new Intent(AboutDevelopers.this, GeoFencing.class); + startActivity(i); + break; + case 7: + finish(); + i = new Intent(AboutDevelopers.this, Help.class); + startActivity(i); + break;*/ + case 7: + Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( + "mailto", "contact@skylinelabs.in", null)); + intent.putExtra(Intent.EXTRA_SUBJECT, "digiPune feedback"); + intent.putExtra(Intent.EXTRA_TEXT, "Hi ! It was an awesome experience using digiPune! "); + startActivity(Intent.createChooser(intent, "Contact developers")); + break; + case 8: + finish(); + i = new Intent(this, AboutDevelopers.class); + startActivity(i); + title ="About"; + break; + case 9: + Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=" + this.getPackageName()); + Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); + try { + startActivity(goToMarket); + } + catch(Exception e) + { + + } + break; + + case 10: + /* finish(); + i = new Intent(this, Privacypolicy.class); + startActivity(i);*/ + title ="Privacy"; + break; + + + default: + break; + } + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/RecyclerItemClickListener.java b/app/src/main/java/in/skylinelabs/digiPune/activity/RecyclerItemClickListener.java new file mode 100644 index 0000000..a3d7f3f --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/RecyclerItemClickListener.java @@ -0,0 +1,38 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Context; +import android.support.v7.widget.RecyclerView; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.view.View; + + +public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener { + private OnItemClickListener mListener; + + public interface OnItemClickListener { + public void onItemClick(View view, int position); + } + + GestureDetector mGestureDetector; + + public RecyclerItemClickListener(Context context, OnItemClickListener listener) { + mListener = listener; + mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { + @Override public boolean onSingleTapUp(MotionEvent e) { + return true; + } + }); + } + + @Override public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) { + View childView = view.findChildViewUnder(e.getX(), e.getY()); + if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) { + mListener.onItemClick(childView, view.getChildPosition(childView)); + return true; + } + return false; + } + + @Override public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) { } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/SOS_Contacts.java b/app/src/main/java/in/skylinelabs/digiPune/activity/SOS_Contacts.java new file mode 100644 index 0000000..53315b7 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/SOS_Contacts.java @@ -0,0 +1,362 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.provider.ContactsContract; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.WindowManager; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.Toast; + +import com.github.clans.fab.FloatingActionButton; + +import in.skylinelabs.digiPune.R; + +public class SOS_Contacts extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener { + + FloatingActionButton btn; + ImageButton c1,c2,c3,c4; + EditText edt1, edt2, edt3, edt4; + Boolean one,two,three,four = false; + + AlertDialog alertDialog; + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.sos_contacts); + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + displayView(7); + + edt1 = (EditText) findViewById(R.id.editText1); + edt2 = (EditText) findViewById(R.id.editText2); + edt3 = (EditText) findViewById(R.id.editText3); + edt4 = (EditText) findViewById(R.id.editText4); + + edt1.setHint("Enter phone number 1"); + edt2.setHint("Enter phone number 2"); + edt3.setHint("Enter phone number 3"); + edt4.setHint("Enter phone number 4"); + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + + edt1.setText(settings.getString("sos_1", "")); + edt2.setText(settings.getString("sos_2", "")); + edt3.setText(settings.getString("sos_3", "")); + edt4.setText(settings.getString("sos_4", "")); + + c1 = (ImageButton) findViewById(R.id.con1); + c2 = (ImageButton) findViewById(R.id.con2); + c3 = (ImageButton) findViewById(R.id.con3); + c4 = (ImageButton) findViewById(R.id.con4); + + c1.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + one = true; + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); + startActivityForResult(intent, 1); + + } + }); + + c2.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + two = true; + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); + startActivityForResult(intent, 1); + + } + }); + c3.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + three = true; + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); + startActivityForResult(intent, 1); + + } + }); + c4.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + four = true; + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); + startActivityForResult(intent, 1); + + } + }); + + + + + btn = (FloatingActionButton) findViewById(R.id.button1); + btn.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + String one1 = edt1.getText().toString(); + settings.edit().putString("sos_1", one1).commit(); + + String two1 = edt2.getText().toString(); + settings.edit().putString("sos_2", two1).commit(); + + String three1 = edt3.getText().toString(); + settings.edit().putString("sos_3", three1).commit(); + + String four1 = edt4.getText().toString(); + settings.edit().putString("sos_4", four1).commit(); + + + + + AlertDialog.Builder builder = new AlertDialog.Builder(SOS_Contacts.this); + builder.setMessage("Contacts Set") + .setCancelable(true) + .setTitle("digiPune SOS Contacts") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert1 = builder.create(); + alert1.show(); + + } + }); + + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + //super.onActivityResult(requestCode, resultCode, data); + if(resultCode != Activity.RESULT_CANCELED){ + if (data != null) { + Uri uri = data.getData(); + + if (uri != null) { + Cursor c = null; + try { + c = getContentResolver().query(uri, new String[]{ + ContactsContract.CommonDataKinds.Phone.NUMBER, + ContactsContract.CommonDataKinds.Phone.TYPE }, + null, null, null); + + if (c != null && c.moveToFirst()) { + String number = c.getString(0); + int type = c.getInt(1); + if(one) + { + showSelectedNumber1(type, number); + } + else if(two) + { + showSelectedNumber2(type, number); + } + else if(three) + { + showSelectedNumber3(type, number); + } + + else if(four) + { + showSelectedNumber4(type, number); + } + + } + else + { + Toast.makeText(SOS_Contacts.this, "c is null", + Toast.LENGTH_LONG).show(); + } + } + + catch(Exception e) + { + Toast.makeText(SOS_Contacts.this, "Something went wrong. Try again", + Toast.LENGTH_LONG).show(); + e.printStackTrace(); + } + + finally { + if (c != null) { + c.close(); + } + } + + } + }} + } + + + public void showSelectedNumber1(int type, String number) { + edt1.setText(number); + one = false; + } + + public void showSelectedNumber2(int type, String number) { + edt2.setText(number); + two = false; + } + + + public void showSelectedNumber3(int typ , String number) { + edt3.setText(number); + three=false; + } + + + public void showSelectedNumber4(int type, String number) { + edt4.setText(number); + four = false; + } + + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + break; + case 1: + finish(); + Intent i2 = new Intent(this, ComplaintPortal.class); + startActivity(i2); + break; + case 2: + finish(); + i = new Intent(this, Bus_Fetch.class); + startActivity(i); + break; + case 3: + finish(); + i = new Intent(this, FindGov.class); + startActivity(i); + break; + case 4: + finish(); + i = new Intent(this, MyLocation.class); + startActivity(i); + break; + case 5: + finish(); + i = new Intent(this, History.class); + startActivity(i); + break; + case 6: + finish(); + i = new Intent(this, Setting.class); + startActivity(i); + break; + case 7: + + break; + case 8: + finish(); + i = new Intent(this, Favourites.class); + startActivity(i); + break; + + default: + break; + } + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_log_in, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + SOS_Contacts.this); + LayoutInflater factory = LayoutInflater.from(SOS_Contacts.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.sos_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + return super.onOptionsItemSelected(item); + } + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/SelectHome.java b/app/src/main/java/in/skylinelabs/digiPune/activity/SelectHome.java new file mode 100644 index 0000000..60e74b2 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/SelectHome.java @@ -0,0 +1,747 @@ +package in.skylinelabs.digiPune.activity; + +import android.annotation.TargetApi; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationManager; +import android.os.AsyncTask; +import android.os.Build; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.api.GoogleApiClient; +import com.google.android.gms.common.api.ResultCallback; +import com.google.android.gms.common.api.Status; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import in.skylinelabs.digiPune.R; + +public class SelectHome extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback, android.location.LocationListener, GoogleMap.OnCameraChangeListener, GoogleMap.OnMapLoadedCallback{ + + int a[]={0,0}; + + double SavLat = 0; + double SavLon = 0; + View.OnClickListener snackaction ,snackaction1; + + AlertDialog alertDialog; + + private static final String url_update_home = "http://www.skylinelabs.in/Geo/update_home.php"; + + + JSONParser jsonParser = new JSONParser(); + + + String addresstxt; + + Double FLat, FLon; + + MarkerOptions tempo = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions finalo = new MarkerOptions().position(new LatLng(10, 10)); + + Marker tempm, finalm; + + private FloatingActionButton mAddGeofencesButton; + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + TextView textView3; + + ProgressBar prgbr; + + Boolean home; + + String Latitude, Longitude; + + GoogleMap map; + + String mystringLatitude; + String mystringLongitude; + + + String post; + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0; //0 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 10 * 1; // 10 sec + + //Declaring a Location Manager + protected LocationManager locationManager; + + + final Context context = this; + + FloatingActionButton btn3,addb ; + + EditText add, edt1; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_select_home); + + addb = (FloatingActionButton) findViewById(R.id.sel); + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + snackaction1 = new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }; + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + mAddGeofencesButton = (FloatingActionButton) findViewById(R.id.add); + mAddGeofencesButton.setVisibility(View.GONE); + + mAddGeofencesButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) { + + new UpdateHome().execute(); + } + + else + { + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (!isInternetPresent) { + + //Toast.makeText(getApplicationContext(), " Please Enable Internet ", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + getLocation(); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setTitle("Select location"); + + + edt1 = (EditText) findViewById(R.id.search_view); + add = (EditText) findViewById(R.id.search_view); + add.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + search(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + SelectHome.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + return true; + } + return false; + } + }); + + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + + map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + + map.setOnMapLoadedCallback(this); + + map.setOnCameraChangeListener(this); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + + tempm = map.addMarker(tempo); + tempm.setVisible(false); + + finalm = map.addMarker(finalo); + finalm.setVisible(false); + + + finalm.setPosition(new LatLng(getLatitude(), getLongitude())); + Upload_Complaint.lat = getLatitude(); + Upload_Complaint.lon = getLongitude(); + + finalm.setTitle("Current Location"); + finalm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + finalm.setVisible(true); + + CameraPosition camPos2 = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(),getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate2 = CameraUpdateFactory.newCameraPosition(camPos2); + + map.moveCamera(camUpdate2); + + + + + + btn3 = (FloatingActionButton) findViewById(R.id.location); + btn3.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + CameraPosition camPos = new CameraPosition.Builder() + .target(new LatLng(getLatitude(), getLongitude())) + .zoom(12.8f) + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + map.moveCamera(camUpdate); + } + }); + + map.setOnMapClickListener(new GoogleMap.OnMapClickListener() { + + @Override + public void onMapClick(LatLng point) { + + try { + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (!isInternetPresent) { + + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + else { + + FLat = point.latitude; + FLon = point.longitude; + SavLat = FLat; + SavLon = FLon; + + tempm.setPosition(new LatLng(FLat, FLon)); + tempm.setTitle("Click to set this as location"); + tempm.setSnippet(""); + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + + mAddGeofencesButton.setVisibility(View.VISIBLE); + } + } catch (Exception e) { + Snackbar.make(findViewById(android.R.id.content), "Couldnt fetch location please check internet connection", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + + + } + + + + + + + @Override + public void onLocationChanged(Location location) { + + map.setOnMapLoadedCallback(this); + this.location = location; + + + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null) + { + + mystringLatitude = String.valueOf(getLatitude()); + mystringLongitude = String.valueOf(getLongitude()); + // Toast.makeText(this,"Activity OLC Update " + networkTS,Toast.LENGTH_SHORT).show(); + } + + + this.location = location; + Latitude = String.valueOf(getLatitude()); + Longitude = String.valueOf(getLongitude()); + } + + public Location getLocation() + { + try + { + locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(this); + } + } + + + + public List
getGeocoderAddress(Context context) + { + if (location != null) + { + Geocoder geocoder = new Geocoder(context, Locale.ENGLISH); + try + { + List
addresses = geocoder.getFromLocation(latitude, longitude, 1); + return addresses; + } + catch (IOException e) + { + //e.printStackTrace(); + Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e); + } + } + + return null; + } + + + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + + finish(); + } + + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(null); + prgbr.setVisibility(View.VISIBLE); + map.setOnCameraChangeListener(this); + map.setOnMapLoadedCallback(this); + textView3.setVisibility(View.VISIBLE); + + /* map.setOnCameraChangeListener(MyLocation.this);*/ + } + + @Override + public void onMapLoaded() { + // TODO Auto-generated method stub + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + + @Override + public void onConnected(Bundle bundle) { + + } + + @Override + public void onConnectionSuspended(int i) { + + } + + @Override + public void onConnectionFailed(ConnectionResult connectionResult) { + + } + + @Override + public void onResult(Status status) { + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_location_event, menu); + return true; + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + default: + return super.onOptionsItemSelected(item); + + } + + } + + void search() + { + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) { + addresstxt = edt1.getText().toString(); + new GetLocation().execute(); + } + else + { + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + /*******************************************************************************/ + class GetLocation extends AsyncTask { + + Boolean i = false; + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + protected String doInBackground(String... args) { + + try { + Geocoder coder = new Geocoder(context); + List
listadd; + listadd = coder.getFromLocationName(addresstxt, 5); + if (listadd == null) { + } + Address location = listadd.get(0); + FLat = location.getLatitude(); + FLon = location.getLongitude(); + SavLat = FLat; + SavLon = FLon; + + runOnUiThread(new Runnable() { + @Override + public void run() { + tempm.setPosition(new LatLng(FLat, FLon)); + tempm.setTitle(addresstxt + "\n"); + tempm.setSnippet("Click to set as location"); + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + mAddGeofencesButton.setVisibility(View.VISIBLE); + CameraPosition camPos = new CameraPosition.Builder() + .target(new LatLng(FLat, FLon)) + .zoom(12.8f) + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + map.moveCamera(camUpdate); + } + }); + } + catch(Exception e) + { + } + return null; + } + } + + class UpdateHome extends AsyncTask { + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + ProgressDialog pDialog; + JSONObject json; + Boolean i = false; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pDialog = new ProgressDialog(SelectHome.this); + pDialog.setMessage("Saving location"); + pDialog.setIndeterminate(false); + pDialog.setCancelable(false); + pDialog.show(); + } + + protected String doInBackground(String... args) { + + try + { + + i=true; + } + catch (Exception e1) { + i=false; + } + + try { + if (i) { + settings.edit().putString("home_lat", String.valueOf(SavLat)).commit(); + settings.edit().putString("home_lon", String.valueOf(SavLon)).commit(); + Upload_Complaint.lat = SavLat; + Upload_Complaint.lon = SavLon; + + runOnUiThread(new Runnable() { + @Override + public void run() { + tempm.setVisible(false); + finalm.setPosition(new LatLng(SavLat, SavLon)); + finalm.setTitle("Home"); + finalm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + finalm.setVisible(true); + pDialog.dismiss(); + finish(); + } + }); + } + else + { + runOnUiThread(new Runnable() { + @Override + public void run() { + Snackbar.make(findViewById(android.R.id.content), "Couldnt update home location please check internet connection", Snackbar.LENGTH_LONG) + .setAction("Done", snackaction1) + .setActionTextColor(Color.WHITE) + .show(); + pDialog.dismiss(); + } + }); + } + + } + catch(Exception e) + { + + } + + return null; + + } + + + } + +} + + + +/************************************************/ + + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/SelectWork.java b/app/src/main/java/in/skylinelabs/digiPune/activity/SelectWork.java new file mode 100644 index 0000000..0ca7138 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/SelectWork.java @@ -0,0 +1,798 @@ +package in.skylinelabs.digiPune.activity; + +import android.annotation.TargetApi; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationManager; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.api.GoogleApiClient; +import com.google.android.gms.common.api.ResultCallback; +import com.google.android.gms.common.api.Status; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import in.skylinelabs.digiPune.R; + +/** + * Created by Jay Lohokare on 01-Oct-15. + */ +public class SelectWork extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback, android.location.LocationListener, GoogleMap.OnCameraChangeListener, GoogleMap.OnMapLoadedCallback{ + + int a[]={0,0}; + + double SavLat = 0; + double SavLon = 0; + View.OnClickListener snackaction ,snackaction1; + + AlertDialog alertDialog; + + private static final String url_update_home = "http://www.skylinelabs.in/Geo/update_work.php"; + + + JSONParser jsonParser = new JSONParser(); + + + String addresstxt; + + Double FLat, FLon; + + MarkerOptions tempo = new MarkerOptions().position(new LatLng(10, 10)); + MarkerOptions finalo = new MarkerOptions().position(new LatLng(10, 10)); + + Marker tempm, finalm; + + private FloatingActionButton mAddGeofencesButton; + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + TextView textView3; + + ProgressBar prgbr; + + Boolean home; + + String Latitude, Longitude; + + GoogleMap map; + + String mystringLatitude; + String mystringLongitude; + + + String post; + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + boolean canGetLocation = false; + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0; //0 metters + + //The minimum time beetwen updates in milliseconds + private static final long MIN_TIME_BW_UPDATES = 1000 * 10 * 1; // 10 sec + + //Declaring a Location Manager + protected LocationManager locationManager; + + + final Context context = this; + + FloatingActionButton btn3,addb ; + + EditText add, edt1; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_select_home); + + addb = (FloatingActionButton) findViewById(R.id.sel); + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + snackaction1 = new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }; + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + mAddGeofencesButton = (FloatingActionButton) findViewById(R.id.add); + mAddGeofencesButton.setVisibility(View.GONE); + + mAddGeofencesButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) { + + new UpdateHome().execute(); + } + + else + { + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (!isInternetPresent) { + + //Toast.makeText(getApplicationContext(), " Please Enable Internet ", Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + getLocation(); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + setSupportActionBar(mToolbar); + getSupportActionBar().setElevation(5); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setTitle("Select Work"); + + + edt1 = (EditText) findViewById(R.id.search_view); + add = (EditText) findViewById(R.id.search_view); + add.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + search(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + SelectWork.this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + return true; + } + return false; + } + }); + + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + + map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + + map.setOnMapLoadedCallback(this); + + map.setOnCameraChangeListener(this); + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(getLatitude(), getLongitude())) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + + tempm = map.addMarker(tempo); + tempm.setVisible(false); + + finalm = map.addMarker(finalo); + finalm.setVisible(false); + + + if(settings.getString("work_lat","") != "" && settings.getString("","") != null ) { + finalm.setPosition(new LatLng(Double.parseDouble(settings.getString("work_lat", "")), Double.parseDouble(settings.getString("work_lon", "")))); + finalm.setTitle("Work"); + finalm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + finalm.setVisible(true); + + CameraPosition camPos2 = new CameraPosition.Builder() + + .target(new LatLng(Double.parseDouble(settings.getString("work_lat", "")),Double.parseDouble(settings.getString("work_lon", "")) )) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate2 = CameraUpdateFactory.newCameraPosition(camPos2); + + map.moveCamera(camUpdate2); + + } + + + + btn3 = (FloatingActionButton) findViewById(R.id.location); + btn3.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + CameraPosition camPos = new CameraPosition.Builder() + .target(new LatLng(getLatitude(), getLongitude())) + .zoom(12.8f) + .build(); + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + map.moveCamera(camUpdate); + } + }); + + map.setOnMapClickListener(new GoogleMap.OnMapClickListener() { + + @Override + public void onMapClick(LatLng point) { + + try { + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (!isInternetPresent) { + + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + else { + + FLat = point.latitude; + FLon = point.longitude; + SavLat = FLat; + SavLon = FLon; + + tempm.setPosition(new LatLng(FLat, FLon)); + tempm.setTitle("Click to Set this as Work"); + tempm.setSnippet(""); + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + + mAddGeofencesButton.setVisibility(View.VISIBLE); + } + } catch (Exception e) { + Snackbar.make(findViewById(android.R.id.content), "Couldnt fetch location please check internet connection", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + + + } + + + + + + + @Override + public void onLocationChanged(Location location) { + + map.setOnMapLoadedCallback(this); + this.location = location; + + + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null) + { + + mystringLatitude = String.valueOf(getLatitude()); + mystringLongitude = String.valueOf(getLongitude()); + // Toast.makeText(this,"Activity OLC Update " + networkTS,Toast.LENGTH_SHORT).show(); + + + } + + + this.location = location; + Latitude = String.valueOf(getLatitude()); + Longitude = String.valueOf(getLongitude()); + } + + public Location getLocation() + { + try + { + locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + } + + return location; + } + + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(this); + } + } + + + + public List
getGeocoderAddress(Context context) + { + if (location != null) + { + Geocoder geocoder = new Geocoder(context, Locale.ENGLISH); + try + { + List
addresses = geocoder.getFromLocation(latitude, longitude, 1); + return addresses; + } + catch (IOException e) + { + //e.printStackTrace(); + Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e); + } + } + + return null; + } + + + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + + finish(); + } + + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(null); + prgbr.setVisibility(View.VISIBLE); + map.setOnCameraChangeListener(this); + map.setOnMapLoadedCallback(this); + textView3.setVisibility(View.VISIBLE); + + /* map.setOnCameraChangeListener(MyLocation.this);*/ + } + + @Override + public void onMapLoaded() { + // TODO Auto-generated method stub + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + + @Override + public void onConnected(Bundle bundle) { + + } + + @Override + public void onConnectionSuspended(int i) { + + } + + @Override + public void onConnectionFailed(ConnectionResult connectionResult) { + + } + + @Override + public void onResult(Status status) { + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_location_event, menu); + return true; + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + + int id = item.getItemId(); + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + this); + LayoutInflater factory = LayoutInflater.from(this); + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.friendlocation_help); + + alertadd.setView(view); + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + } + + if(id == R.id.action_search) { + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) { + search(); + InputMethodManager inputManager = + (InputMethodManager) context. + getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.hideSoftInputFromWindow( + this.getCurrentFocus().getWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + } + else + { + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + + } + + return super.onOptionsItemSelected(item); + } + + void search() + { + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) { + addresstxt = edt1.getText().toString(); + new GetLocation().execute(); + } + else + { + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + /*******************************************************************************/ + class GetLocation extends AsyncTask { + + Boolean i = false; + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + protected String doInBackground(String... args) { + + try { + Geocoder coder = new Geocoder(context); + List
listadd; + listadd = coder.getFromLocationName(addresstxt, 5); + if (listadd == null) { + } + Address location = listadd.get(0); + FLat = location.getLatitude(); + FLon = location.getLongitude(); + SavLat = FLat; + SavLon = FLon; + + runOnUiThread(new Runnable() { + @Override + public void run() { + tempm.setPosition(new LatLng(FLat, FLon)); + tempm.setTitle(addresstxt + "\n"); + tempm.setSnippet("Click to set as work "); + tempm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + tempm.setVisible(true); + mAddGeofencesButton.setVisibility(View.VISIBLE); + CameraPosition camPos = new CameraPosition.Builder() + .target(new LatLng(FLat, FLon)) + .zoom(12.8f) + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + map.moveCamera(camUpdate); + } + }); + } + catch(Exception e) + { + } + return null; + } + } + + class UpdateHome extends AsyncTask { + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + ProgressDialog pDialog; + JSONObject json; + Boolean i = false; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pDialog = new ProgressDialog(SelectWork.this); + pDialog.setMessage("Updating work location to servers...."); + pDialog.setIndeterminate(false); + pDialog.setCancelable(false); + pDialog.show(); + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", settings.getString("user_name",""))); + params.add(new BasicNameValuePair("work_lat", String.valueOf(SavLat))); + params.add(new BasicNameValuePair("work_lon", String.valueOf(SavLon))); + + try + { + json = jsonParser.makeHttpRequest( + url_update_home, "POST", params); + i=true; + } + catch (Exception e1) { + i=false; + runOnUiThread(new Runnable() { + @Override + public void run() { + Snackbar.make(findViewById(android.R.id.content), "Couldnt update work location please check internet connection", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + pDialog.dismiss(); + } + }); + } + + try { + if (i) { + settings.edit().putString("work_lat", String.valueOf(SavLat)).commit(); + settings.edit().putString("work_lon", String.valueOf(SavLon)).commit(); + runOnUiThread(new Runnable() { + @Override + public void run() { + tempm.setVisible(false); + finalm.setPosition(new LatLng(SavLat, SavLon)); + finalm.setTitle("Work"); + finalm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + finalm.setVisible(true); + pDialog.dismiss(); + } + }); + } + else + { + runOnUiThread(new Runnable() { + @Override + public void run() { + Snackbar.make(findViewById(android.R.id.content), "Couldnt update work location please check internet connection", Snackbar.LENGTH_LONG) + .setAction("Done", snackaction1) + .setActionTextColor(Color.WHITE) + .show(); + pDialog.dismiss(); + } + }); + } + } + catch(Exception e) + { + } + return null; + } + } +} + + + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Setting.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Setting.java new file mode 100644 index 0000000..fc2e1c8 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Setting.java @@ -0,0 +1,527 @@ +package in.skylinelabs.digiPune.activity; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.support.design.widget.Snackbar; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewAnimationUtils; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.widget.AdapterView; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.Switch; + +import com.github.clans.fab.FloatingActionButton; + +import in.skylinelabs.digiPune.R; + +public class Setting extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener { + + + private Toolbar mToolbar; + private FragmentDrawer drawerFragment; + + AlertDialog alertDialog; + + FloatingActionButton redo; + + Switch bck, upd, hst, doupdt, onDty; + + String user_name; + + String category; + + + WebView webView; + + View.OnClickListener snackaction; + + Boolean firsttime = true; + + ProgressBar prgbr; + + Spinner cat; + + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.settings); + + onDty = (Switch) findViewById(R.id.switchonDuty); + + + + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + prgbr = (ProgressBar) findViewById(R.id.pgb); + prgbr.setVisibility(View.GONE); + + cat = (Spinner) findViewById(R.id.spinner); + cat.setSelection(settings.getInt("category_pos", 1)); + + cat.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, final int position, long id) { + category = parent.getItemAtPosition(position).toString(); + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (firsttime) { + firsttime = false; + } else { + + if (!isInternetPresent) { + + + Snackbar.make(findViewById(android.R.id.content), "Please Enable Internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } else { + + + String user_name = settings.getString("user_name", ""); + webView = (WebView) findViewById(R.id.webView2); + webView.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) { + + + if (progress < 100 && prgbr.getVisibility() == ProgressBar.GONE) { + prgbr.setVisibility(ProgressBar.VISIBLE); + cat.setClickable(false); + redo.setClickable(false); + } + prgbr.setProgress(progress); + if (progress == 100) { + prgbr.setVisibility(ProgressBar.GONE); + cat.setClickable(true); + redo.setClickable(true); + settings.edit().putString("category", category).commit(); + settings.edit().putInt("category_pos", position).commit(); + Snackbar.make(findViewById(android.R.id.content), "Updated category", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + } + }); + + webView.loadUrl("http://www.skylinelabs.in/Geo/category_update.php?category=" + category + "&user_name=" + user_name); + + + } + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + + + + RelativeLayout mControlsContainer = (RelativeLayout) findViewById(R.id.rel3); + + mControlsContainer.setVisibility(View.GONE); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + + + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("digiPune"); + drawerFragment = (FragmentDrawer) + getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); + drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar); + drawerFragment.setDrawerListener(this); + displayView(6); + + redo = (FloatingActionButton) findViewById(R.id.redo); + redo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + + + + Intent i2 = new Intent(Setting.this, App_intro.class); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + + + final View myView = findViewById(R.id.rel3); + final View myView1 = findViewById(R.id.rel4); + final View myView2 = findViewById(R.id.scrollView1); + myView2.setVisibility(View.GONE); + + try{ + // get the center for the clipping circle + int cx = myView1.getMeasuredWidth(); + int cy = myView1.getMeasuredHeight(); + + // get the final radius for the clipping circle + int finalRadius = Math.max(myView1.getWidth() * 2, myView1.getHeight() * 2) / 2; + + // Toast.makeText(getApplicationContext(), finalRadius + " " + cx + " " + cy, Toast.LENGTH_LONG).show(); + + // create the animator for this view (the start radius is zero) + + Animator anim = + ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius); + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + + Intent i2 = new Intent(Setting.this, App_intro.class); + i2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + startActivity(i2); + finish(); + } + }); + + anim.start(); + + } + + catch(Exception e) + { + + + } + + myView.setVisibility(View.VISIBLE); + + + + + // previously invisible view + + } + + else + startActivity(i2); + } + }); + +/****************************************************************************************************************/ + /*Background update switch*/ + bck = (Switch)findViewById(R.id.switch2); + if (settings.getBoolean("FindX_background_enabled", true)) + bck.setChecked(true); + else + bck.setChecked(false); + + bck.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if(bck.isChecked()){ + settings.edit().putBoolean("FindX_background_enabled", true).commit(); + + } + else{ + settings.edit().putBoolean("FindX_background_enabled", false).commit(); + + } + } + }); + +/**************************************************************************************************************/ + /*Background update switch*/ + doupdt = (Switch)findViewById(R.id.switch4); + if (settings.getBoolean("FindX_update_enabled", true)) + doupdt.setChecked(true); + else + doupdt.setChecked(false); + + doupdt.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if (doupdt.isChecked()) { + settings.edit().putBoolean("FindX_update_enabled", true).commit(); + + } else { + settings.edit().putBoolean("FindX_update_enabled", false).commit(); + + } + } + }); + +/****************************************************************************************************************/ + /*Sharing on switch*/ + upd= (Switch)findViewById(R.id.switch1); + + if (settings.getBoolean("FindX_share_enabled", true)) + { + upd.setChecked(true); + } + + else + { + upd.setChecked(false); + } + + upd.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if(upd.isChecked()){ + settings.edit().putBoolean("FindX_share_enabled", true).commit(); + + } + else{ + settings.edit().putBoolean("FindX_share_enabled", false).commit(); + settings.edit().putBoolean("FindX_onDuty_enabled", false).commit(); + onDty.setChecked(false); + + } + AlertDialog.Builder builder = new AlertDialog.Builder(Setting.this); + builder.setMessage("Changes will take place only when digiPune connects to internet") + .setCancelable(true) + .setTitle("Information") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } + + }); + + /****************************************************************************************************************/ + /*On Duty switch*/ + + if (settings.getBoolean("FindX_onDuty_enabled", true)) + { + onDty.setChecked(true); + } + + else + { + onDty.setChecked(false); + } + + onDty.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + + if (upd.isChecked()) { + + if (onDty.isChecked()) { + settings.edit().putBoolean("FindX_onDuty_enabled", true).commit(); + + } else { + settings.edit().putBoolean("FindX_onDuty_enabled", false).commit(); + + } + AlertDialog.Builder builder = new AlertDialog.Builder(Setting.this); + builder.setMessage("Changes will take place only when digiPune connects to internet") + .setCancelable(true) + .setTitle("Information") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } + + else + { + onDty.setChecked(false); + Snackbar.make(findViewById(android.R.id.content), "Switch on Sharing Location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + }); +/****************************************************************************************************************/ + /*History on switch*/ + hst= (Switch)findViewById(R.id.switch3); + + if (settings.getBoolean("FindX_history_enabled", true)) + { + hst.setChecked(true); + } + + else + { + hst.setChecked(false); + } + + hst.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + if(hst.isChecked()){ + settings.edit().putBoolean("FindX_history_enabled", true).commit(); + + } + else{ + settings.edit().putBoolean("FindX_history_enabled", false).commit(); + + } + AlertDialog.Builder builder = new AlertDialog.Builder(Setting.this); + builder.setMessage("Changes will take place only when digiPune connects to internet") + .setCancelable(true) + .setTitle("Information") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } + + }); + } + + @Override + public void onDrawerItemSelected(View view, int position) { + displayView(position); + } + + private void displayView(int position) { + //Fragment fragment = null; + String title = getString(R.string.app_name); + Intent i; + switch (position) { + case 0: + finish(); + Pre_launch_activity.post=0; + break; + case 1: + finish(); + Intent i2 = new Intent(this, ComplaintPortal.class); + startActivity(i2); + break; + case 2: + finish(); + i = new Intent(this, Bus_Fetch.class); + startActivity(i); + break; + case 3: + finish(); + i = new Intent(this, FindGov.class); + startActivity(i); + break; + case 4: + finish(); + i = new Intent(this, MyLocation.class); + startActivity(i); + break; + case 5: + finish(); + i = new Intent(this, History.class); + startActivity(i); + break; + case 6: + + break; + case 7: + finish(); + i = new Intent(this, SOS_Contacts.class); + startActivity(i); + break; + case 8: + finish(); + i = new Intent(this, Favourites.class); + startActivity(i); + break; + + default: + break; + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_setting, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if(id == R.id.info) { + Intent i2 = new Intent(this, Alert_Send.class); + startActivity(i2); + } + + + + if(id == R.id.info) { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + Setting.this); + LayoutInflater factory = LayoutInflater.from(Setting.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.settings_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + + + } + + return super.onOptionsItemSelected(item); + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/ShoeNotifications.java b/app/src/main/java/in/skylinelabs/digiPune/activity/ShoeNotifications.java new file mode 100644 index 0000000..fd9079d --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/ShoeNotifications.java @@ -0,0 +1,37 @@ +package in.skylinelabs.digiPune.activity; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +import in.skylinelabs.digiPune.R; + +public class ShoeNotifications extends ActionBarActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_shoe_notifications); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_shoe_notifications, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + + + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Sign_up.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Sign_up.java new file mode 100644 index 0000000..6388cba --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Sign_up.java @@ -0,0 +1,733 @@ +package in.skylinelabs.digiPune.activity; + + +//https://halfthought.wordpress.com/2014/12/02/reveal-activity-transitions/ + + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONObject; + +import android.app.Activity; +import android.app.ActivityManager; +import android.app.ActivityManager.RunningServiceInfo; +import android.app.ActivityOptions; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.ComponentName; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.graphics.Color; +import android.graphics.PorterDuff; +import android.location.Location; +import android.location.LocationManager; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.provider.Settings; +import android.support.design.widget.TextInputLayout; +import android.telephony.TelephonyManager; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import com.google.android.gms.gcm.GoogleCloudMessaging; +import com.google.android.gms.location.LocationListener; + +import in.skylinelabs.digiPune.R; +public class Sign_up extends Activity implements LocationListener { + + Button btn; + EditText edttxt1,edttxt2, edttxt3, edttxt4, edttxt5; + + Boolean error; + + public static Boolean firstTime; + TextView txt1, txt2, help; + AlertDialog alertDialog1; + + String email; + + Button txt; + + private ProgressDialog pDialog; + + GPSTracker gps; + + TextInputLayout lNameLayout,lNameLayout1,lNameLayout2,lNameLayout4,lNameLayoutEmail; + + AlertDialog alertDialog; + + long date; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + String networkTS; + + Date date1; + + Bundle savedInstanceState; + + String mystringLatitude; + String mystringLongitude; + + String name; + + static String mydevice_id, password; + + final Context context = this; + + private static final String url_create_product = "http://www.skylinelabs.in/Geo/signup_app.php"; + private static final String url_product_exists = "http://www.skylinelabs.in/Geo/get_product_exists.php"; + JSONParser jsonParser = new JSONParser(); + + + GoogleCloudMessaging gcm; + String regid = ""; + + String myPhoneNumber; + + + @Override + protected void onResume() { + // TODO Auto-generated method stub + super.onResume(); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + + + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders == null || locationProviders.equals("")) { + + + if(!alertDialog.isShowing()) + { + alertDialog.show(); + } + + } + } + + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + + setContentView(R.layout.sign_up); + //this.getActionBar().hide(); + + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + + TextView skip = (TextView) findViewById(R.id.buttonSkip); + skip.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + settings.edit().putBoolean("signup_skip", true).commit(); + settings.edit().putBoolean("my_first_time", false).commit(); + int flag=(PackageManager.COMPONENT_ENABLED_STATE_DISABLED); + ComponentName component=new ComponentName(Sign_up.this, BootCompletedReceiver.class); + + getPackageManager() + .setComponentEnabledSetting(component, flag, + PackageManager.DONT_KILL_APP); + + finish(); + + Intent i = new Intent(Sign_up.this, No_SignUp.class); + startActivity(i); + + + + + + } + }); + + + txt = (Button) findViewById(R.id.textView5); + txt.getBackground().setColorFilter(Color.parseColor("#0d47a1"), PorterDuff.Mode.MULTIPLY); + + txt.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + + Intent i = new Intent(Sign_up.this, Log_in.class); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + startActivity(i, + ActivityOptions.makeSceneTransitionAnimation(Sign_up.this).toBundle()); + } + else + { + startActivity(i); + } + + finish(); + + } + }); + + + lNameLayout = (TextInputLayout) findViewById(R.id + .fNameLayout); + lNameLayout1 = (TextInputLayout) findViewById(R.id + .fNameLayout2); + lNameLayout2 = (TextInputLayout) findViewById(R.id + .fNameLayout3); + lNameLayout4 = (TextInputLayout) findViewById(R.id + .fNameLayout4); + + lNameLayoutEmail = (TextInputLayout) findViewById(R.id + .fNameLayoutEmail); + + + btn = (Button) findViewById(R.id.button1); + btn.getBackground().setColorFilter(Color.parseColor("#0d47a1"), PorterDuff.Mode.MULTIPLY); + edttxt1 = (EditText) findViewById(R.id.editText3); + + edttxt2 = (EditText) findViewById(R.id.editText1); + + edttxt3 = (EditText) findViewById(R.id.editText2); + + edttxt4 = (EditText) findViewById(R.id.editText4); + + edttxt5 = (EditText) findViewById(R.id.editTextEmail); + + + edttxt2.clearFocus(); + edttxt1.requestFocus(); + + + try{ + + TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); + myPhoneNumber = tMgr.getLine1Number(); + edttxt3.setText(myPhoneNumber); + } + + catch(Exception e) + { + + } + + + + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Please allow digiPune to access location"); + alertDialogBuilder.setTitle("Location Access Error"); + alertDialogBuilder.setCancelable(false); + + alertDialogBuilder.setPositiveButton("Settings", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface arg0, int arg1) { + alertDialog.dismiss(); + startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); + } + }); + alertDialogBuilder.setNegativeButton("Exit", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + + } + }); + alertDialog = alertDialogBuilder.create(); + + gps = new GPSTracker(Sign_up.this); + + txt1 = (TextView) findViewById(R.id.textView1); + txt2 = (TextView) findViewById(R.id.textView2); + + + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders == null || locationProviders.equals("")) { + + + if(!alertDialog.isShowing()) + { + alertDialog.show(); + } + + } + + + + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if(isInternetPresent1) + { + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + mydevice_id = edttxt1.getText().toString(); + name = edttxt2.getText().toString(); + myPhoneNumber = edttxt3.getText().toString(); + password = edttxt4.getText().toString(); + settings.edit().putString("number", myPhoneNumber).commit(); + + + lNameLayout.setErrorEnabled(false); + + lNameLayout1.setErrorEnabled(false); + + lNameLayout2.setErrorEnabled(false); + + lNameLayout4.setErrorEnabled(false); + + lNameLayoutEmail.setErrorEnabled(false); + + + + if(edttxt5.getText().toString().matches("") || edttxt1.getText().toString().matches("") || edttxt2.getText().toString().matches("") || edttxt3.getText().toString().matches("") || (edttxt4.getText().toString().trim().length() < 7)) + { + if(edttxt1.getText().toString().matches("")) + { + lNameLayout.setErrorEnabled(true); + lNameLayout.setError("*Required field"); + } + + if(edttxt2.getText().toString().matches("")) + { + lNameLayout1.setErrorEnabled(true); + lNameLayout1.setError("*Required field"); + } + + if(edttxt3.getText().toString().matches("")) + { + lNameLayout2.setErrorEnabled(true); + lNameLayout2.setError("*Required field"); + } + + if(edttxt5.getText().toString().matches("")) + { + lNameLayoutEmail.setErrorEnabled(true); + lNameLayoutEmail.setError("*Required field"); + } + + if(edttxt4.getText().toString().trim().length() < 7) + { + lNameLayout4.setErrorEnabled(true); + lNameLayout4.setError("*Minimum 6 characters"); + } + } + + + + + else + { + + try + { + mystringLatitude = String.valueOf(gps.getLatitude()); + mystringLongitude = String.valueOf(gps.getLongitude()); + + + date = gps.locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime(); + networkTS = sdf.format(date); + email = edttxt5.getText().toString(); + + + new CreateNewProduct().execute(); + } + + catch(Exception e) + { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Sign_up.this); + alertDialogBuilder.setMessage("It appears that you device hasnt connected to google location service. Please do the following : \n" + "1.Ensure that device has working internet connection\n" +"2.Ensure that location access in device settings has been turned with mobile network location activated\n" + "3.Finally, restart your device to obtain location fix if above steps dont work" ); + alertDialogBuilder.setTitle("Location Access Error"); + + alertDialogBuilder.setPositiveButton("Exit", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + + + + } + + + } + + else + { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Sign_up.this); + alertDialogBuilder.setMessage("Unable to connect to internet. Please connect to internet" ); + alertDialogBuilder.setTitle("Internet Error"); + + alertDialogBuilder.setPositiveButton("Retry", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + } + + + + }); + + } + + class CreateNewProduct extends AsyncTask { + + JSONObject json, json1; + Boolean i,j,k = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pDialog = new ProgressDialog(Sign_up.this); + pDialog.setMessage("Checking availability of digiPune ID...."); + pDialog.setIndeterminate(false); + pDialog.setCancelable(false); + pDialog.show(); + + + } + + /* protected void onPostExecute(String file_url) { + // dismiss the dialog after getting all products + pDialog.dismiss(); + + }*/ + + protected String doInBackground(String... args) { + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id)); + + //Check if userId exists + try + { + json = jsonParser.makeHttpRequest( + url_product_exists, "GET", params); + i = true; + } + catch (Exception e1) { + + + i=false; + + pDialog.dismiss(); + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Sign_up.this); + alertDialogBuilder.setMessage("Something went wrong while signing up. Please try again" ); + alertDialogBuilder.setTitle("Error"); + + alertDialogBuilder.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + }); + + } + + if(i) + + { + try { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + pDialog.setMessage("Registering with GCM"); + } + }); + + if (gcm == null) { + gcm = GoogleCloudMessaging.getInstance(getApplicationContext()); + } + + regid = gcm.register("#Enter GCM ID"); + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + settings.edit().putString("gcm_regid", regid).commit(); + j = true; + + + } catch (Exception ex) { + j = false; + pDialog.dismiss(); + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Sign_up.this); + alertDialogBuilder.setMessage("Error communicating to GCM servers. Please try again"); + alertDialogBuilder.setTitle("Connection Error"); + + alertDialogBuilder.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + }); + } + + if (j) { + try { + + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + pDialog.setMessage("Creating account"); + } + }); + + Log.d("Create Response", json.toString()); + int success = json.getInt("success"); + + //UserID doesnt exist, create new product + if (success == 0) { + params.add(new BasicNameValuePair("latitude", mystringLatitude)); + params.add(new BasicNameValuePair("longitude", mystringLongitude)); + params.add(new BasicNameValuePair("password", password)); + params.add(new BasicNameValuePair("sharing_on", "1")); + params.add(new BasicNameValuePair("time", sdf.format(date))); + params.add(new BasicNameValuePair("gcm_regid", regid)); + params.add(new BasicNameValuePair("contact", myPhoneNumber)); + params.add(new BasicNameValuePair("email", email)); + + TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); + String imei = tMgr.getDeviceId(); + params.add(new BasicNameValuePair("IMEI",imei)); + + JSONObject json = jsonParser.makeHttpRequest(url_create_product, + "POST", params); + + pDialog.dismiss(); + finish(); +/********************************************************************************************************************************/ + + /* Intent i = new Intent(Sign_up.this, App_intro.class); + Intent i2 = new Intent(Sign_up.this, FriendLocation.class); + startActivity(i2); + startActivity(i);*/ +/********************************************************************************************************************************/ + Intent i2 = new Intent(Sign_up.this, FriendLocation.class); + startActivity(i2); + + firstTime = true; + Intent i = new Intent(Sign_up.this, FirstTime_Settings.class); + startActivity(i); + + firstTime = false; + + final String PREFS_NAME = "GeoPreferences"; + + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + settings.edit().putString("name", name).apply(); + settings.edit().putString("user_name", mydevice_id).apply(); + settings.edit().putString("password", password).apply(); + settings.edit().putBoolean("FindX_share_enabled", true).apply(); + settings.edit().putBoolean("FindX_history_enabled", true).apply(); + settings.edit().putBoolean("FindX_background_enabled", true).apply(); + settings.edit().putBoolean("my_first_time", false).apply(); + settings.edit().putBoolean("signup_skip", false).commit(); + settings.edit().putBoolean("FindX_update_enabled", true).apply(); + settings.edit().putBoolean("FindX_onDuty_enabled", true).apply(); + settings.edit().putInt("category_pos",1).apply(); + + int flag=(PackageManager.COMPONENT_ENABLED_STATE_ENABLED); + ComponentName component=new ComponentName(Sign_up.this, BootCompletedReceiver.class); + + getPackageManager() + .setComponentEnabledSetting(component, flag, + PackageManager.DONT_KILL_APP); + + + //Checking if background activity running + ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { + + if (digiPune.class.getName().equals(service.service.getClassName())) { + //running + } else { + context.startService(new Intent(context, digiPune.class)); + } + + } + + } + + //User Id exists + if (success == 1) { + + pDialog.dismiss(); + runOnUiThread(new Runnable() { + // + @Override + public void run() { + lNameLayout.setErrorEnabled(true); + lNameLayout.setError("*digiPune ID already exists"); + } + }); + } + + } catch (Exception e1) { + + + pDialog.dismiss(); + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Sign_up.this); + alertDialogBuilder.setMessage("Something went wrong.Please try again"); + alertDialogBuilder.setTitle("Error"); + + alertDialogBuilder.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog1 = alertDialogBuilder.create(); + alertDialog1.show(); + } + }); + + + } + } + } + + return null; + } + + + } + + @Override + public void onLocationChanged(Location gps) { + // TODO Auto-generated method stub + mystringLatitude = String.valueOf(gps.getLatitude()); + mystringLongitude = String.valueOf(gps.getLongitude()); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_log_in, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + switch (item.getItemId()) { + + + + case R.id.info: { + AlertDialog.Builder alertadd = new AlertDialog.Builder( + Sign_up.this); + LayoutInflater factory = LayoutInflater.from(Sign_up.this); + + final View view = factory.inflate(R.layout.dialog_main, null); + + ImageView image = (ImageView) view.findViewById(R.id.imageView); + image.setImageResource(R.drawable.mylocation_help); + + alertadd.setView(view); + + + alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dlg, int sumthin) { + + } + }); + alertDialog = alertadd.create(); + alertDialog.show(); + return super.onOptionsItemSelected(item); + + } + + default: + return super.onOptionsItemSelected(item); + } + } + + + +} + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/SkylinelabsFlashScreen.java b/app/src/main/java/in/skylinelabs/digiPune/activity/SkylinelabsFlashScreen.java new file mode 100644 index 0000000..770398f --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/SkylinelabsFlashScreen.java @@ -0,0 +1,38 @@ +package in.skylinelabs.digiPune.activity; + +import android.content.Intent; +import android.graphics.Color; +import android.os.Build; +import android.os.Handler; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; + +import in.skylinelabs.digiPune.R; + +public class SkylinelabsFlashScreen extends ActionBarActivity { + private static int SPLASH_TIME_OUT = 500; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.skyline_labs_flash_screen); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + getWindow().setStatusBarColor(Color.TRANSPARENT); + } + + //this.getActionBar().hide(); + new Handler().postDelayed(new Runnable() { + + @Override + public void run() { + + Intent i = new Intent(SkylinelabsFlashScreen.this, Pre_launch_activity.class); + startActivity(i); + + finish(); + } + }, SPLASH_TIME_OUT); + } + + + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/SwachBharatActivity.java b/app/src/main/java/in/skylinelabs/digiPune/activity/SwachBharatActivity.java new file mode 100644 index 0000000..e89e423 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/SwachBharatActivity.java @@ -0,0 +1,259 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.ProgressDialog; +import android.graphics.Color; +import android.os.AsyncTask; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +import com.github.clans.fab.FloatingActionButton; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import in.skylinelabs.digiPune.R; +import in.skylinelabs.digiPune.complaint_cardview.ImageLoader; + +public class SwachBharatActivity extends ActionBarActivity { + JSONParser jsonParser = new JSONParser(); + ImageLoader imageLoader; + View.OnClickListener snackaction,snackaction1; + String id, lat, lon; + String joincount; + TextView jc; + ProgressDialog pd; + private Toolbar mToolbar; + GoogleMap map; + Marker finalm; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_swach_bharat); + mToolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setElevation(5); + getSupportActionBar().setTitle("Swach Bharat"); + Bundle extras = getIntent().getExtras(); + + String title = extras.getString("title"); + TextView tv = (TextView) findViewById(R.id.title); + tv.setText(title); + + id = extras.getString("id"); + lat = extras.getString("lat"); + lon = extras.getString("lon"); + + MarkerOptions finalo = new MarkerOptions().position(new LatLng(10,10)); + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.setMyLocationEnabled(true); + map.getUiSettings().setCompassEnabled(true); + map.getUiSettings().setRotateGesturesEnabled(true); + finalm = map.addMarker(finalo); + finalm.setVisible(false); + finalm.setPosition(new LatLng((Double.parseDouble(lat)), (Double.parseDouble(lon)))); + finalm.setTitle("Home"); + finalm.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + finalm.setVisible(true); + + CameraPosition camPos2 = new CameraPosition.Builder() + + .target(new LatLng((Double.parseDouble(lat)), (Double.parseDouble(lon)))) + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate2 = CameraUpdateFactory.newCameraPosition(camPos2); + + map.moveCamera(camUpdate2); + + String description = extras.getString("description"); + TextView td = (TextView) findViewById(R.id.description); + td.setText(description); + + String imgurl = extras.getString("url"); + ImageView iv = (ImageView) findViewById(R.id.img); + imageLoader = new ImageLoader(SwachBharatActivity.this); + imageLoader.DisplayImage(imgurl, iv); + + jc = (TextView) findViewById(R.id.joincount); + new JoinReceive().execute(); + FloatingActionButton join = (FloatingActionButton) findViewById(R.id.joinbutton); + join.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + new JoinUpdate().execute(); + } + }); + } + + class JoinUpdate extends AsyncTask { + + JSONObject json2; + Boolean updated = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + + new JoinReceive().execute(); + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("id", id)); + + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (isInternetPresent) { + try { + + json2 = jsonParser.makeHttpRequest( + "http://www.skylinelabs.in/Compalaint_Portal/complaint_count_increase.php", "GET", params); + updated = true; + + } catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error. Enable internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + updated = false; + return null; + } + + } + + + + return null; + } + } + + class JoinReceive extends AsyncTask { + + JSONObject json2; + Boolean updated = false; + + + @Override + protected void onPreExecute() { + super.onPreExecute(); + json2 = null; + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + jc.setText(joincount); + } + + protected String doInBackground(String... args) { + + List params = new ArrayList(); + params.add(new BasicNameValuePair("id", id)); + + + ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent = cd.isConnectingToInternet(); + + if (isInternetPresent) { + try { + + json2 = jsonParser.makeHttpRequest( + "http://www.skylinelabs.in/Compalaint_Portal/compaint_curr_count.php", "GET", params); + updated = true; + + } catch (Exception e1) { + // Toast.makeText(getApplicationContext(),"Network error Unable to fetch location",Toast.LENGTH_LONG).show(); + Snackbar.make(findViewById(android.R.id.content), "Network error. Enable internet", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + updated = false; + return null; + } + + } + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + + if (isInternetPresent1 && updated) { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + + try { + + + joincount = json2.getString("count"); + + } catch (JSONException e) { + Log.e("Error in markers", e.toString()); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + }); + } + return null; + } + } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/Upload_Complaint.java b/app/src/main/java/in/skylinelabs/digiPune/activity/Upload_Complaint.java new file mode 100644 index 0000000..eda452a --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/Upload_Complaint.java @@ -0,0 +1,449 @@ +package in.skylinelabs.digiPune.activity; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; +import android.support.design.widget.Snackbar; +import android.telephony.TelephonyManager; +import android.util.Base64; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.Switch; +import android.widget.Toast; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import cz.msebera.android.httpclient.Header; +import in.skylinelabs.digiPune.R; + +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; +import com.loopj.android.http.AsyncHttpClient; +import com.loopj.android.http.AsyncHttpResponseHandler; +import com.loopj.android.http.RequestParams; + +@SuppressLint("NewApi") +public class Upload_Complaint extends Activity { + ProgressDialog prgDialog; + String encodedString; + // RequestParams params = new RequestParams(); + String imgPath, fileName; + Bitmap bitmap; + private static int RESULT_LOAD_IMG = 1; + + GPSTracker gps; + + int an=0; + + public static Double lat =null, lon=null; + + GoogleMap map; + MarkerOptions marker = new MarkerOptions().position(new LatLng(10, 10)); + + Marker mrk; + + AlertDialog alertDialog; + + String networkTS; + long date; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + RequestParams params = new RequestParams(); + + View.OnClickListener snackaction,snackaction1; + + EditText titleedt, messageedt; + Switch anonymous; + + ImageView imgb; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_upload_complaint); + + gps = new GPSTracker(this); + + + + prgDialog = new ProgressDialog(this); + // Set Cancelable as False + prgDialog.setCancelable(false); + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + imgb = (ImageView) findViewById(R.id.imageLocation); + imgb.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent i = new Intent(Upload_Complaint.this, SelectHome.class); + startActivity(i); + } + }); + + titleedt = (EditText) findViewById(R.id.editTextTitle); + messageedt = (EditText) findViewById(R.id.editTextDescription); + + anonymous = (Switch) findViewById(R.id.switchAn); + anonymous.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (anonymous.isChecked()) { + anonymous.setText("Anonymous"); + an = 1; + + } else { + anonymous.setText("Non-Anonymous"); + an = 0; + } + } + }); + + } + + + + + public void loadImagefromGallery(View view) { + // Create intent to Open Image applications like Gallery, Google Photos + final CharSequence[] options = {"Click A Photo", "Select From Gallery"}; + + AlertDialog.Builder builder = new AlertDialog.Builder(Upload_Complaint.this); + builder.setTitle("Add Photo From Gallery"); + builder.setItems(options, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + + if (options[item].equals("Select From Gallery")) { + Intent galleryIntent = new Intent(Intent.ACTION_PICK, + android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + // Start the Intent + startActivityForResult(galleryIntent, RESULT_LOAD_IMG); + } else if (options[item].equals("Click A Photo")) { + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + File f = new File(android.os.Environment.getExternalStorageDirectory(), "temp.jpg"); + intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); + startActivityForResult(intent, 1); + } + } + }); + builder.show(); + + } + + // When Image is selected from Gallery + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + try { + // When an Image is picked + if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK + && null != data) { + // Get the Image from data + + Uri selectedImage = data.getData(); + String[] filePathColumn = { MediaStore.Images.Media.DATA }; + + // Get the cursor + Cursor cursor = getContentResolver().query(selectedImage, + filePathColumn, null, null, null); + // Move to first row + cursor.moveToFirst(); + + int columnIndex = cursor.getColumnIndex(filePathColumn[0]); + imgPath = cursor.getString(columnIndex); + cursor.close(); + ImageView imgView = (ImageView) findViewById(R.id.imgView2); + // Set the Image in ImageView + imgView.setImageBitmap(BitmapFactory + .decodeFile(imgPath)); + // Get the Image's file name + String fileNameSegments[] = imgPath.split("/"); + fileName = fileNameSegments[fileNameSegments.length - 1]; + + Calendar cal = Calendar.getInstance(); + int millisecond = cal.get(Calendar.MILLISECOND); + int second = cal.get(Calendar.SECOND); + int minute = cal.get(Calendar.MINUTE); + int hour = cal.get(Calendar.HOUR); + + TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); + String imei = tMgr.getDeviceId(); + + params.put("filename",imei + fileName + hour + minute + second + millisecond); + + } + else if(requestCode == 1) + { + File f = new File(Environment.getExternalStorageDirectory().toString()); + for(File temp: f.listFiles()) + if(temp.getName().equals("temp.jpg")){ + f = temp; + break; + } + imgPath = f.getAbsolutePath(); + ImageView imgView = (ImageView) findViewById(R.id.imgView2); + // Set the Image in ImageView + imgView.setImageBitmap(BitmapFactory + .decodeFile(imgPath)); + String fileNameSegments[] = imgPath.split("/"); + fileName = fileNameSegments[fileNameSegments.length - 1]; + + Calendar cal = Calendar.getInstance(); + int millisecond = cal.get(Calendar.MILLISECOND); + int second = cal.get(Calendar.SECOND); + int minute = cal.get(Calendar.MINUTE); + int hour = cal.get(Calendar.HOUR); + + TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); + String imei = tMgr.getDeviceId(); + + params.put("filename", imei + fileName + hour + minute + second + millisecond); + } + + else { + Snackbar.make(findViewById(android.R.id.content), "Please select an image", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + catch (Exception e) { + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Please try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + } + + // When Upload button is clicked + public void uploadImage(View v) { + String Title = titleedt.getText().toString(); + String Description = messageedt.getText().toString(); + + if(Title.equals(null) || Title.equals("") || Description.equals(null) || Description.equals("")) { + + + if(Title.equals(null) || Title.equals("")) + { + Snackbar.make(findViewById(android.R.id.content), "Title can't be empty", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + else if(Description.equals(null) || Description.equals("")) + { + Snackbar.make(findViewById(android.R.id.content), "Description can't be empty", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + else + { + params.put("title", Title); + params.put("description", Description); + if(an == 1){ + params.put("user_name","anonymous"); + } + else{ + final String PREFS_NAME = "GeoPreferences"; + final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + String user_name = settings.getString("user_name","anonymous"); + params.put("user_name",user_name); + } + + if(lat == null || lon == null) + { + lat = gps.getLatitude(); + lon = gps.getLongitude(); + + if(lat == null || lon == null) { + Snackbar.make(findViewById(android.R.id.content), "Location not available", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + else + { + Toast.makeText(Upload_Complaint.this, "Location set to current", Toast.LENGTH_SHORT).show(); + params.put("latitude", lat.toString()); + params.put("longitude", lon.toString()); + if (imgPath != null && !imgPath.isEmpty()) { + prgDialog.setMessage("Converting Image to Binary Data"); + prgDialog.show(); + encodeImagetoString(); + + } + else { + Snackbar.make(findViewById(android.R.id.content), "Please select an image", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + } + else + { + params.put("latitude", lat.toString()); + params.put("longitude", lon.toString()); + + if (imgPath != null && !imgPath.isEmpty()) { + prgDialog.setMessage("Converting Image to Binary Data"); + prgDialog.show(); + encodeImagetoString(); + + } + else { + Snackbar.make(findViewById(android.R.id.content), "Please select an image", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + + + + + + } + } + + // AsyncTask - To convert Image to String + public void encodeImagetoString() { + + try { + new AsyncTask() { + + protected void onPreExecute() { + + } + + ; + + @Override + protected String doInBackground(Void... params) { + BitmapFactory.Options options = null; + options = new BitmapFactory.Options(); + options.inSampleSize = 4; + bitmap = BitmapFactory.decodeFile(imgPath, + options); + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + // Must compress the Image to reduce image size to make upload easy + bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); + byte[] byte_arr = stream.toByteArray(); + // Encode Image to String + encodedString = Base64.encodeToString(byte_arr, 0); + return ""; + } + + @Override + protected void onPostExecute(String msg) { + prgDialog.setMessage("Calling Upload"); + // Put converted Image string into Async Http Post param + params.put("image", encodedString); + // Trigger Image upload + triggerImageUpload(); + } + }.execute(null, null, null); + } + catch (Exception e) + { + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Please try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + } + + public void triggerImageUpload() { + makeHTTPCall(); + } + + + public void makeHTTPCall() { + try { + + prgDialog.setMessage("Uploading image"); + AsyncHttpClient client = new AsyncHttpClient(); + // Don't forget to change the IP address to your LAN address. Port no as well. + client.post("http://www.skylinelabs.in/Compalaint_Portal/upload_app.php", + params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { + prgDialog.hide(); + Snackbar.make(findViewById(android.R.id.content), "Complaint successfully registered", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + finish(); + } + + @Override + public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { + prgDialog.hide(); + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Please try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + } + + }); + } + catch (Exception e) + { + Snackbar.make(findViewById(android.R.id.content), "Something went wrong. Please try again", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + prgDialog.hide(); + } + } + + @Override + protected void onDestroy() { + // TODO Auto-generated method stub + super.onDestroy(); + // Dismiss the progress bar when application is closed + if (prgDialog != null) { + prgDialog.dismiss(); + } + } + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/digiPune.java b/app/src/main/java/in/skylinelabs/digiPune/activity/digiPune.java new file mode 100644 index 0000000..0f6add4 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/digiPune.java @@ -0,0 +1,1112 @@ +package in.skylinelabs.digiPune.activity; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; +import org.json.JSONObject; + +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.Service; +import android.app.TaskStackBuilder; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationManager; +import android.media.AudioManager; +import android.net.ConnectivityManager; +import android.net.wifi.WifiManager; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.IBinder; +import android.provider.Settings; +import android.support.v7.app.NotificationCompat; +import android.telephony.TelephonyManager; +import android.util.Log; + +import in.skylinelabs.digiPune.R; + + +public class digiPune extends Service implements android.location.LocationListener +{ + + String reminder_text; + int a[]={0,0}; + int b[]={0,0}; + int c[]={0,0}; + + /*****************************************GPSVariables***********************************************/ + //flag for GPS Status + boolean isGPSEnabled = false; + + //flag for network status + boolean isNetworkEnabled = false; + + public static Boolean isOn = false; + boolean canGetLocation = false; + + String networkTS; + long date; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + Location location; + double latitude; + double longitude; + + //The minimum distance to change updates in metters + private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0; //0 metters + + //The minimum time beetwen updates in milliseconds + public static long MIN_TIME_BW_UPDATES = 1000 * 30 * 1 ; // 10 minutes + + //Declaring a Location Manager + protected LocationManager locationManager; + + /**********************************************************************************************/ + + + String mystringLatitude; + String mystringLongitude; + + static String mydevice_id, password; + JSONParser jsonParser = new JSONParser(); + private static final String url_update_product = "http://www.skylinelabs.in/Geo/update_app.php"; + + public static boolean mRunning = false; + + Boolean warned,internetw = false; + + @Override + public void onCreate() + { + mRunning = true; + super.onCreate(); + + + } + + + + public void updateGPSCoordinates() + { + if (location != null) + { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + + } + } + + /** + * Stop using GPS listener + * Calling this function will stop using GPS in your app + */ + + public void stopUsingGPS() + { + if (locationManager != null) + { + locationManager.removeUpdates(digiPune.this); + } + } + + /** + * Function to get latitude + */ + public double getLatitude() + { + if (location != null) + { + latitude = location.getLatitude(); + + } + + return latitude; + } + + /** + * Function to get longitude + */ + public double getLongitude() + { + if (location != null) + { + longitude = location.getLongitude(); + } + + return longitude; + } + + /** + * Function to check GPS/wifi enabled + */ + public boolean canGetLocation() + { + return this.canGetLocation; + } + + + /** + * Get list of address by latitude and longitude + * @return null or List
+ */ + public List
getGeocoderAddress(Context context) + { + if (location != null) + { + Geocoder geocoder = new Geocoder(context, Locale.ENGLISH); + try + { + List
addresses = geocoder.getFromLocation(latitude, longitude, 1); + return addresses; + } + catch (IOException e) + { + //e.printStackTrace(); + Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e); + } + } + + return null; + } + + /** + * Try to get AddressLine + * @return null or addressLine + */ + public String getAddressLine(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String addressLine = address.getAddressLine(0); + + return addressLine; + } + else + { + return null; + } + } + + /** + * Try to get Locality + * @return null or locality + */ + public String getLocality(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String locality = address.getLocality(); + + return locality; + } + else + { + return null; + } + } + + /** + * Try to get Postal Code + * @return null or postalCode + */ + public String getPostalCode(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String postalCode = address.getPostalCode(); + + return postalCode; + } + else + { + return null; + } + } + + /** + * Try to get CountryName + * @return null or postalCode + */ + public String getCountryName(Context context) + { + List
addresses = getGeocoderAddress(context); + if (addresses != null && addresses.size() > 0) + { + Address address = addresses.get(0); + String countryName = address.getCountryName(); + + return countryName; + } + else + { + return null; + } + } + + @Override + public void onLocationChanged(Location location) { + + mRunning = true; + + + + ConnectionDetector cd1 = new ConnectionDetector(getApplicationContext()); + Boolean isInternetPresent1 = cd1.isConnectingToInternet(); + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders != null || !locationProviders.equals("")) + { + //warned = false; + + /************************************************GeoFence*****************************************************/ + if(settings.getBoolean("home_geofence", false)) + { + int x = array_loader_a(getLatitude(),getLongitude(),Double.parseDouble(settings.getString("home_geofence_lat", "0")), Double.parseDouble(settings.getString("home_geofence_lon", "0")),0.005); + if(x==0) //Baher Gela + { + + } + + if(x==1) //Aaat Aala + { + + + if(settings.getBoolean("home_wifi", false)) + { + + if((settings.getBoolean("home_wifi_state", false))) + { + startWifi(); + } + else + { + stopWifi(); + } + } + if(settings.getBoolean("home_data", false)) + { + if((settings.getBoolean("home_data_state", false))) + { + startData(); + } + else + { + stopData(); + } + } + if(settings.getBoolean("home_silent", false)) + { + if((settings.getBoolean("home_silent_state", false))) + { + startSilent(); + } + else + { + stopSilent(); + } + } + if(settings.getBoolean("home_notify", false)) + { + donotify(); + } + if(settings.getBoolean("home_reminder", false)) + { + reminder_text = settings.getString("home_reminder_text",""); + reminder(); + } + + + + } + + if(x==2) //Kahich nahi zhala + { + + } + + } + + if(settings.getBoolean("work_geofence", false)) + { + int x = array_loader_b(getLatitude(),getLongitude(),Double.parseDouble(settings.getString("work_geofence_lat", "0")), Double.parseDouble(settings.getString("work_geofence_lon", "0")),0.005); + if(x==0) //Baher Gela + { + + } + + if(x==1) //Aaat Aala + { + + + if(settings.getBoolean("work_wifi", false)) + { + + if((settings.getBoolean("work_wifi_state", false))) + { + startWifi(); + } + else + { + stopWifi(); + } + } + if(settings.getBoolean("work_data", false)) + { + if((settings.getBoolean("work_data_state", false))) + { + startData(); + } + else + { + stopData(); + } + } + if(settings.getBoolean("work_silent", false)) + { + if((settings.getBoolean("work_silent_state", false))) + { + startSilent(); + } + else + { + stopSilent(); + } + } + if(settings.getBoolean("work_notify", false)) + { + donotify(); + } + if(settings.getBoolean("work_reminder", false)) + { + reminder_text = settings.getString("home_reminder_text",""); + reminder(); + } + + + + + } + + if(x==2) //Kahich nahi zhala + { + + } + + } + + if(settings.getBoolean("other_geofence", false)) + { + int x = array_loader_c(getLatitude(),getLongitude(),Double.parseDouble(settings.getString("other_geofence_lat", "0")), Double.parseDouble(settings.getString("other_geofence_lon", "0")),0.005); + if(x==0) //Baher Gela + { + + } + + if(x==1) //Aaat Aala + { + + + if(settings.getBoolean("other_wifi", false)) + { + + if((settings.getBoolean("other_wifi_state", false))) + { + startWifi(); + } + else + { + stopWifi(); + } + } + if(settings.getBoolean("other_data", false)) + { + if((settings.getBoolean("other_data_state", false))) + { + startData(); + } + else + { + stopData(); + } + } + if(settings.getBoolean("other_silent", false)) + { + if((settings.getBoolean("other_silent_state", false))) + { + startSilent(); + } + else + { + stopSilent(); + } + } + if(settings.getBoolean("other_notify", false)) + { + donotify(); + } + if(settings.getBoolean("other_reminder", false)) + { + reminder_text = settings.getString("other_reminder_text",""); + reminder(); + } + + + + + } + + if(x==2) //Kahich nahi zhala + { + + } + + } + +/**************************************************GeoFence******************************************************/ + + + if(settings.getBoolean("FindX_background_enabled", false) || isOn) + { + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null || locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) != null) + { + + + + + if(isInternetPresent1) { + //internetw = false; + + mydevice_id = settings.getString("user_name", ""); + password = settings.getString("password", ""); + date = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime(); + networkTS = sdf.format(date); + + this.location = location; + mystringLatitude = String.valueOf(getLatitude()); + mystringLongitude = String.valueOf(getLongitude()); + new CreateNewProduct().execute(); + } + else + { + + + } + } + else + { + + } + + } + + else + { + //Toast.makeText(this,"Service update bool false",Toast.LENGTH_SHORT).show(); + } + + } + + else + { + + } + + + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + // TODO Auto-generated method stub + if(!mRunning) + { + runFindX(); + } + + + } + + @Override + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + /*************************************Notify***************************************/ + + NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); + + Intent resultIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); + stackBuilder.addParentStack(Location_event.class); + + stackBuilder.addNextIntent(resultIntent); + PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(02,PendingIntent.FLAG_UPDATE_CURRENT); + + mBuilder.setContentIntent(resultPendingIntent); + mBuilder.setSmallIcon(R.drawable.findx_logo); + mBuilder.setContentTitle("digiPune Disconnected"); + mBuilder.setContentText("Please turn on Location"); + mBuilder.addAction(R.drawable.ic_action_settings, "Settings", resultPendingIntent); + + +// Adds the Intent that starts the Activity to the top of the stack + + + NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + +// notificationID allows you to update the notification later on. + mNotificationManager.notify(0, mBuilder.build()); + + /*************************************Notify***************************************/ + + + + + } + + @Override + public IBinder onBind(Intent intent) { + // TODO Auto-generated method stub + return null; + } + + + @Override + public void onDestroy() { + super.onDestroy(); + startService(new Intent(this, digiPune.class)); + mRunning = false; + } + + + public Location getLocation() + { + try + { + locationManager = (LocationManager)this.getBaseContext().getSystemService(LOCATION_SERVICE); + + //getting GPS status + isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + + //getting network status + isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (!isGPSEnabled && !isNetworkEnabled) + { + // no network provider is enabled + } + else + { + this.canGetLocation = true; + + //First get location from Network Provider + if (isNetworkEnabled) + { + locationManager.requestLocationUpdates( + LocationManager.NETWORK_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("Network", "Network"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + updateGPSCoordinates(); + } + } + + //if GPS Enabled get lat/long using GPS Services + if (isGPSEnabled) + { + if (location == null) + { + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MIN_TIME_BW_UPDATES, + MIN_DISTANCE_CHANGE_FOR_UPDATES, this); + + Log.d("GPS Enabled", "GPS Enabled"); + + if (locationManager != null) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + updateGPSCoordinates(); + } + } + } + } + } + catch (Exception e) + { + //e.printStackTrace(); + + Log.e("Error : Location", "Impossible to connect to LocationManager", e); + // Toast.makeText(getApplicationContext(),"Oops ! Unable to fetch location ",Toast.LENGTH_SHORT).show(); + return null; + } + + return location; + } + + + + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + if (locationProviders != null || !locationProviders.equals("")) + { + locationManager = (LocationManager)this.getBaseContext().getSystemService(LOCATION_SERVICE); + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null || locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) != null) { + + + runFindX(); + mRunning = true; + + } + + else + { + /*************************************Notify***************************************/ + + NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); + + Intent resultIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); + stackBuilder.addParentStack(Location_event.class); + + stackBuilder.addNextIntent(resultIntent); + PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(02,PendingIntent.FLAG_UPDATE_CURRENT); + + mBuilder.setContentIntent(resultPendingIntent); + mBuilder.setSmallIcon(R.drawable.findx_logo); + mBuilder.setContentTitle("digiPune Disconnected"); + mBuilder.setContentText("Please turn on Location"); + mBuilder.addAction(R.drawable.ic_action_settings, "Settings", resultPendingIntent); + + +// Adds the Intent that starts the Activity to the top of the stack + + + NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + +// notificationID allows you to update the notification later on. + mNotificationManager.notify(0, mBuilder.build()); + + /*************************************Notify***************************************/ + + mRunning = false; + } + } + + return START_STICKY; + } + + + class CreateNewProduct extends AsyncTask { + + JSONObject json, json1; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + + protected String doInBackground(String... args) { + + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name", mydevice_id)); + params.add(new BasicNameValuePair("password", password)); + params.add(new BasicNameValuePair("latitude",mystringLatitude)); + params.add(new BasicNameValuePair("longitude",mystringLongitude)); + + TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); + String imei = tMgr.getDeviceId(); + params.add(new BasicNameValuePair("IMEI",imei)); + + params.add(new BasicNameValuePair("time",sdf.format(date))); + if(settings.getBoolean("FindX_share_enabled", true)) + params.add(new BasicNameValuePair("sharing_on","1")); + else + params.add(new BasicNameValuePair("sharing_on","0")); + + + if(settings.getBoolean("FindX_history_enabled", true)) + params.add(new BasicNameValuePair("history","1")); + else + params.add(new BasicNameValuePair("history","0")); + + + if(settings.getBoolean("FindX_onDuty_enabled", true)) + params.add(new BasicNameValuePair("onDuty","1")); + else + params.add(new BasicNameValuePair("onDuty","0")); + + + try { + + JSONObject json = jsonParser.makeHttpRequest(url_update_product, + "POST", params); + } + + catch (Exception e1) { + } + + try { + + + Log.d("Create Response", json.toString()); + int success = json.getInt("success"); + + //UserID doesnt exist, create new product + if (success == 0) { + + } + } + catch(Exception e) + { + + } + + + return null; + } + + + } + + + public void runFindX() + { + + getLocation(); + mRunning = true; + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + mydevice_id = settings.getString("user_name", ""); + password = settings.getString("password", ""); + + + if(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) != null) + { + + mystringLatitude = String.valueOf(getLatitude()); + mystringLongitude = String.valueOf(getLongitude()); + + date = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime(); + networkTS = sdf.format(date); + } + + //Toast.makeText(this,"digiPune background service started",Toast.LENGTH_SHORT).show(); + + } + + int array_loader_a(double curr_lat,double curr_lon,double centre_lat,double centre_lon,double radius) + { + + + a[0]=geofence(curr_lat,curr_lon,centre_lat,centre_lon,radius); + // Toast.makeText(getApplicationContext(), String.valueOf(a[0]) , Toast.LENGTH_LONG).show(); + + // Toast.makeText(getApplicationContext(), String.valueOf(a[0]) + " " + String.valueOf(a[1]), + // + // .LENGTH_LONG).show(); + + + if(a[0]==0&&a[1]==0) + { a[1]=a[0]; + return 2;} //NO change + + if(a[0]==1&&a[1]==1) + {a[1]=a[0]; + return 2;} //No change + + if(a[0]==1&&a[1]==0) + {a[1]=a[0]; + return 1;} //came in + + if(a[0]==0&&a[1]==1) + {a[1]=a[0]; + return 0;} // went out + + + + + return 5; + + + + } + + int geofence(double curr_lat,double curr_lon,double centre_lat,double centre_lon,double radius) + { + double k; + k=Math.sqrt(Math.sqrt(((curr_lat - centre_lat) * (curr_lat - centre_lat) - (curr_lon - centre_lon) * (curr_lon - centre_lon)) * ((curr_lat - centre_lat) * (curr_lat - centre_lat) - (curr_lon - centre_lon) * (curr_lon - centre_lon)))); + // Toast.makeText(getApplicationContext(), String.valueOf(k) , Toast.LENGTH_LONG).show(); + + if(k parts = smsManager.divideMessage(message); + + if(one != "") + smsManager.sendMultipartTextMessage(one, null, parts, null, null); + + if(two != "") + smsManager.sendMultipartTextMessage(two, null, parts, null, null); + + if(three != "") + smsManager.sendMultipartTextMessage(three, null, parts, null, null); + + if(four != "") + smsManager.sendMultipartTextMessage(four, null, parts, null, null); + + + new CreateNewProduct().execute(); + + } + + class CreateNewProduct extends AsyncTask { + + final String PREFS_NAME = "GeoPreferences"; + + Boolean sent; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + + protected String doInBackground(String... args) { + + String user_name = settings.getString("user_name", ""); + String name = settings.getString("name", ""); + myPhoneNumber = settings.getString("number", ""); + + + List params = new ArrayList(); + params.add(new BasicNameValuePair("user_name",user_name)); + params.add(new BasicNameValuePair("latitude",Latitude)); + params.add(new BasicNameValuePair("longitude",Longitude)); + params.add(new BasicNameValuePair("phone_number", myPhoneNumber)); + params.add(new BasicNameValuePair("name", name)); + params.add(new BasicNameValuePair("time", sdf.format(date))); + + + + try{ + json = jsonParser.makeHttpRequest( + send_sos, "GET",params); + + sent = true; + + } + + catch(Exception e) + { + sent = false; + runOnUiThread(new Runnable() { + // + @Override + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(sos.this); + builder.setMessage("Internet Unavailable. Notification not sent. SMS sent") + .setCancelable(true) + .setTitle("Network Error") + .setPositiveButton("Retry", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert1 = builder.create(); + alert1.show(); + } + + }); + + + + } + + if(sent) + { + runOnUiThread(new Runnable() { + // + @Override + public void run() { + + txt.setText("SOS Sent"); + + AlertDialog.Builder builder = new AlertDialog.Builder(sos.this); + builder.setMessage("SOS Notifications sent. Expecting help soon") + .setCancelable(true) + .setTitle("Success") + .setPositiveButton("Ok", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + AlertDialog alert1 = builder.create(); + alert1.show(); + } + + }); + } + + return null; + } + } + + @Override + public void onLocationChanged(Location gps) { + // TODO Auto-generated method stub + Latitude = String.valueOf(gps.getLatitude()); + Longitude = String.valueOf(gps.getLongitude()); + } + + + @Override + public void onBackPressed() { + + } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + +} + + + + + diff --git a/app/src/main/java/in/skylinelabs/digiPune/activity/sos_map.java b/app/src/main/java/in/skylinelabs/digiPune/activity/sos_map.java new file mode 100644 index 0000000..ffe60e3 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/activity/sos_map.java @@ -0,0 +1,268 @@ +package in.skylinelabs.digiPune.activity; + +import android.app.AlertDialog; +import android.content.ComponentName; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.location.Location; +import android.net.Uri; +import android.os.Bundle; +import android.support.design.widget.Snackbar; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; +import com.google.android.gms.maps.GoogleMap.OnMapLoadedCallback; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CameraPosition; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; + +import in.skylinelabs.digiPune.R; + + +public class sos_map extends ActionBarActivity implements android.location.LocationListener, OnCameraChangeListener, OnMapLoadedCallback { + + + GoogleMap map; + ProgressBar prgbr; + Marker mrk1; + + TextView txt1,textView3; + + final Context context = this; + + MarkerOptions marker1 = new MarkerOptions().position(new LatLng(10,10)); + + Double Latitude, Longitude; + String user_name , user_id, number, time; + + Button call, navigate; + + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.sos_map); + + snackaction = new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }; + + + final String PREFS_NAME = "GeoPreferences"; + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); + Latitude = Double.parseDouble(settings.getString("sos_lat", "")); + Longitude = Double.parseDouble(settings.getString("sos_lon", "")); + user_name = settings.getString("sos_user_name", ""); + user_id = settings.getString("sos_user_id", ""); + number = settings.getString("sos_number", ""); + time = settings.getString("sos_time", ""); + + // getActionBar().setTitle("Help " +user_name); + //getActionBar().setDisplayHomeAsUpEnabled(true); + Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar1); + + setSupportActionBar(mToolbar); + + getSupportActionBar().setTitle("Help " +user_name); + //getSupportActionBar().setLogo(R.drawable.findx_logo); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + mToolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onBackPressed(); + } + }); + call = (Button) findViewById(R.id.button1); + call.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + + Log.d(null,number); + Intent callvictim = new Intent(Intent.ACTION_CALL); + callvictim.setData(Uri.parse("tel:" + number)); + startActivity(callvictim); + + } + }); + + + + navigate = (Button) findViewById(R.id.button2); + navigate.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + + Intent intent = new Intent(Intent.ACTION_VIEW, + Uri.parse("http://maps.google.com/maps?f=d&daddr="+Latitude+","+Longitude)); + intent.setComponent(new ComponentName("com.google.android.apps.maps", + "com.google.android.maps.MapsActivity")); + startActivity(intent); + + } + }); + + + + txt1 = (TextView) findViewById(R.id.textView1); + txt1.setText(user_name+" needs your help"); + + + textView3 = (TextView) findViewById(R.id.textView3); + textView3.setText("Loading Map"); + textView3.setVisibility(View.VISIBLE); + + prgbr = (ProgressBar) findViewById(R.id.progressBar1); + prgbr.setVisibility(View.VISIBLE); + + + map = ((MapFragment) getFragmentManager().findFragmentById( + R.id.map)).getMap(); + map.setMyLocationEnabled(true); + map.setMapType(GoogleMap.MAP_TYPE_NORMAL); + map.getUiSettings().setZoomControlsEnabled(true); + + map.setOnMapLoadedCallback(new OnMapLoadedCallback() { + public void onMapLoaded() { + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + }); + + map.setOnCameraChangeListener(sos_map.this); + map.setOnMapLoadedCallback(sos_map.this); + + CameraPosition camPos = new CameraPosition.Builder() + + .target(new LatLng(Latitude, Longitude)) + + .zoom(12.8f) + + .build(); + + CameraUpdate camUpdate = CameraUpdateFactory.newCameraPosition(camPos); + + map.moveCamera(camUpdate); + + mrk1 = map.addMarker(marker1); + + mrk1.setPosition(new LatLng(Latitude, Longitude)); + mrk1.setTitle(user_name + " ("+user_id +")" ); + + mrk1.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); + mrk1.setVisible(true); + mrk1.setSnippet("\nSOS Sent at "+time); + + } + + @Override + public void onCameraChange(CameraPosition arg0) { + // TODO Auto-generated method stub + map.setOnMapLoadedCallback(sos_map.this); + map.setOnCameraChangeListener(sos_map.this); + textView3.setVisibility(View.VISIBLE); + prgbr.setVisibility(View.VISIBLE); + } + + + + @Override + public void onMapLoaded() { + + prgbr.setVisibility(View.GONE); + textView3.setVisibility(View.GONE); + } + + @Override + public void onLocationChanged(Location location) { + // TODO Auto-generated method stub + + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + // TODO Auto-generated method stub + + } + + + View.OnClickListener snackaction; + + @Override + public void onProviderDisabled(String provider) { + // .makeText(getApplicationContext(),"Please enable internet",Toast.LENGTH_LONG).show(); + + Snackbar.make(findViewById(android.R.id.content), "Please enable location", Snackbar.LENGTH_LONG) + .setAction("Ok", snackaction) + .setActionTextColor(Color.WHITE) + .show(); + + } + + @Override + public void onBackPressed() { + // TODO Auto-generated method stub + //super.onBackPressed(); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + final AlertDialog alert; + + builder.setMessage("Are you sure you want to exit ?") + .setCancelable(true) + .setTitle("Exit?") + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + finish(); + } + }); + builder.setNegativeButton("No", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + alert = builder.create(); + alert.show(); + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/adapter/NavigationDrawerAdapter.java b/app/src/main/java/in/skylinelabs/digiPune/adapter/NavigationDrawerAdapter.java new file mode 100644 index 0000000..187b335 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/adapter/NavigationDrawerAdapter.java @@ -0,0 +1,86 @@ +package in.skylinelabs.digiPune.adapter; + +import android.content.Context; +import android.graphics.Color; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.util.Collections; +import java.util.List; + +import in.skylinelabs.digiPune.R; +import in.skylinelabs.digiPune.activity.Pre_launch_activity; +import in.skylinelabs.digiPune.model.NavDrawerItem; + + +public class NavigationDrawerAdapter extends RecyclerView.Adapter { + List data = Collections.emptyList(); + private LayoutInflater inflater; + private Context context; + + public NavigationDrawerAdapter(Context context, List data) { + this.context = context; + inflater = LayoutInflater.from(context); + this.data = data; + } + + public void delete(int position) { + data.remove(position); + notifyItemRemoved(position); + } + + @Override + public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = inflater.inflate(R.layout.nav_drawer_row, parent, false); + // view.setBackgroundColor(Color.GRAY); + MyViewHolder holder = new MyViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(MyViewHolder holder, int position) { + final NavDrawerItem current = data.get(position); + holder.title.setText(current.getTitle()); + holder.iv.setImageResource(current.getIcon()); + if(position == Pre_launch_activity.post) + holder.root.setBackgroundColor(Color.LTGRAY); + + + /* holder.root.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + current.isActive = !current.isActive; + } + }); + + if(current.isActive){ + holder.root.setBackgroundColor(Color.LTGRAY); + }else{ + holder.root.setBackgroundColor(Color.TRANSPARENT); + }*/ + } + + + + @Override + public int getItemCount() { + return data.size(); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + TextView title; + ImageView iv; + RelativeLayout root; + public MyViewHolder(View itemView) { + super(itemView); + title = (TextView) itemView.findViewById(R.id.title); + iv= (ImageView)itemView.findViewById(R.id.rowIcon); + root = (RelativeLayout)itemView.findViewById(R.id.row); + } + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FeedItem.java b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FeedItem.java new file mode 100644 index 0000000..aa6b99a --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FeedItem.java @@ -0,0 +1,18 @@ +package in.skylinelabs.digiPune.complaint_cardview; + +import android.graphics.Bitmap; + +/** + * Created by Reshul Dani on 07-10-2015. + */ +public class FeedItem { + public String title; + public String description; + public String imgurl; + public String id; + public String latitude; + public String longitude; + + + +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FeedItemAdapter.java b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FeedItemAdapter.java new file mode 100644 index 0000000..4b36ee0 --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FeedItemAdapter.java @@ -0,0 +1,128 @@ +package in.skylinelabs.digiPune.complaint_cardview; + +/** + * Created by Reshul Dani on 07-10-2015. + */ + +import android.app.Activity; +import android.location.Address; +import android.location.Geocoder; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; + +import in.skylinelabs.digiPune.R; + + +public class FeedItemAdapter extends RecyclerView.Adapter { + private Activity activity; + private List feedList; + public ImageLoader imageLoader; + + Geocoder geocoder; + List
addresses; + + public FeedItemAdapter(Activity a, List feedList) { + activity = a; + this.feedList = feedList; + imageLoader = new ImageLoader(activity.getApplicationContext()); + + geocoder = new Geocoder(activity.getApplicationContext(), Locale.getDefault()); + + + } + + @Override + public int getItemCount() { + return feedList.size(); + } + + @Override + public void onBindViewHolder(FeedViewHolder feedViewHolder, int i) { + FeedItem fi = feedList.get(i); + feedViewHolder.title.setText(fi.title); + feedViewHolder.url.setText(fi.imgurl); + feedViewHolder.id.setText(fi.id); + feedViewHolder.description.setText(fi.description); + feedViewHolder.latitude.setText(fi.latitude); + feedViewHolder.longitude.setText(fi.longitude); + feedViewHolder.b.setText("# " +fi.id); + imageLoader.DisplayImage(fi.imgurl, feedViewHolder.img); + + try { + addresses = geocoder.getFromLocation(Double.parseDouble(fi.latitude), Double.parseDouble(fi.longitude), 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5 + } catch (IOException e) { + e.printStackTrace(); + } + + String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex() + String city = addresses.get(0).getLocality(); + String state = addresses.get(0).getAdminArea(); + String country = addresses.get(0).getCountryName(); + String postalCode = addresses.get(0).getPostalCode(); + String knownName = addresses.get(0).getFeatureName(); + + + if(city == null) + { + city=""; + } + + if(address == null) + { + address=""; + } + if(postalCode == null) + { + postalCode=""; + } + + feedViewHolder.location.setText(address+ " "+city+" " +postalCode); + + } + + @Override + public FeedViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { + View itemView = LayoutInflater. + from(viewGroup.getContext()). + inflate(R.layout.card_layout, viewGroup, false); + + return new FeedViewHolder(itemView); + } + + + public static class FeedViewHolder extends RecyclerView.ViewHolder { + + protected TextView title; + protected TextView url; + protected TextView id; + protected TextView description; + protected ImageView img; + protected TextView location; + protected TextView latitude; + protected TextView longitude; + protected Button b; + public FeedViewHolder(View v) { + super(v); + title = (TextView) v.findViewById(R.id.title); + url = (TextView) v.findViewById(R.id.url); + description = (TextView) v.findViewById(R.id.description); + img = (ImageView) v.findViewById(R.id.img); + id = (TextView) v.findViewById(R.id.ID); + location = (TextView) v.findViewById(R.id.location); + latitude = (TextView) v.findViewById(R.id.latitude); + longitude = (TextView) v.findViewById(R.id.logitude); + b = (Button) v.findViewById(R.id.idbutton); + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FileCache.java b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FileCache.java new file mode 100644 index 0000000..bc5e85e --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/FileCache.java @@ -0,0 +1,35 @@ +package in.skylinelabs.digiPune.complaint_cardview; + +import java.io.File; +import android.content.Context; + +public class FileCache { + + private File cacheDir; + + public FileCache(Context context){ + //Find the dir to save cached images + if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) + cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"TempImages"); + else + cacheDir=context.getCacheDir(); + if(!cacheDir.exists()) + cacheDir.mkdirs(); + } + + public File getFile(String url){ + String filename=String.valueOf(url.hashCode()); + File f = new File(cacheDir, filename); + return f; + + } + + public void clear(){ + File[] files=cacheDir.listFiles(); + if(files==null) + return; + for(File f:files) + f.delete(); + } + +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/ImageLoader.java b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/ImageLoader.java new file mode 100644 index 0000000..ce7802e --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/ImageLoader.java @@ -0,0 +1,176 @@ +package in.skylinelabs.digiPune.complaint_cardview; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Collections; +import java.util.Map; +import java.util.WeakHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.widget.ImageView; + +import in.skylinelabs.digiPune.R; + + +public class ImageLoader { + + MemoryCache memoryCache=new MemoryCache(); + FileCache fileCache; + private Map imageViews=Collections.synchronizedMap(new WeakHashMap()); + ExecutorService executorService; + + public ImageLoader(Context context){ + fileCache=new FileCache(context); + executorService=Executors.newFixedThreadPool(5); + } + + int stub_id = R.drawable.findx_logo; + public void DisplayImage(String url, ImageView imageView) + { + + imageViews.put(imageView, url); + Bitmap bitmap=memoryCache.get(url); + if(bitmap!=null) + imageView.setImageBitmap(bitmap); + else + { + queuePhoto(url, imageView); + imageView.setImageResource(stub_id); + } + } + + private void queuePhoto(String url, ImageView imageView) + { + PhotoToLoad p=new PhotoToLoad(url, imageView); + executorService.submit(new PhotosLoader(p)); + } + + private Bitmap getBitmap(String url) + { + File f=fileCache.getFile(url); + + //from SD cache + Bitmap b = decodeFile(f); + if(b!=null) + return b; + + //from web + try { + Bitmap bitmap=null; + URL imageUrl = new URL(url); + HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection(); + conn.setConnectTimeout(30000); + conn.setReadTimeout(30000); + conn.setInstanceFollowRedirects(true); + InputStream is=conn.getInputStream(); + OutputStream os = new FileOutputStream(f); + Utils.CopyStream(is, os); + os.close(); + bitmap = decodeFile(f); + return bitmap; + } catch (Exception ex){ + ex.printStackTrace(); + return null; + } + } + + //decodes image and scales it to reduce memory consumption + private Bitmap decodeFile(File f){ + try { + //decode image size + BitmapFactory.Options o = new BitmapFactory.Options(); + o.inJustDecodeBounds = true; + BitmapFactory.decodeStream(new FileInputStream(f),null,o); + + //Find the correct scale value. It should be the power of 2. + final int REQUIRED_SIZE=70; + int width_tmp=o.outWidth, height_tmp=o.outHeight; + int scale=1; + while(true){ + if(width_tmp/2> cache=Collections.synchronizedMap(new HashMap>()); + + public Bitmap get(String id){ + if(!cache.containsKey(id)) + return null; + SoftReference ref=cache.get(id); + return ref.get(); + } + + public void put(String id, Bitmap bitmap){ + cache.put(id, new SoftReference(bitmap)); + } + + public void clear() { + cache.clear(); + } +} diff --git a/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/Utils.java b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/Utils.java new file mode 100644 index 0000000..5f49c3e --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/complaint_cardview/Utils.java @@ -0,0 +1,23 @@ +package in.skylinelabs.digiPune.complaint_cardview; + +import java.io.InputStream; +import java.io.OutputStream; + +public class Utils { + public static void CopyStream(InputStream is, OutputStream os) + { + final int buffer_size=1024; + try + { + byte[] bytes=new byte[buffer_size]; + for(;;) + { + int count=is.read(bytes, 0, buffer_size); + if(count==-1) + break; + os.write(bytes, 0, count); + } + } + catch(Exception ex){} + } +} \ No newline at end of file diff --git a/app/src/main/java/in/skylinelabs/digiPune/model/NavDrawerItem.java b/app/src/main/java/in/skylinelabs/digiPune/model/NavDrawerItem.java new file mode 100644 index 0000000..e8324bd --- /dev/null +++ b/app/src/main/java/in/skylinelabs/digiPune/model/NavDrawerItem.java @@ -0,0 +1,38 @@ +package in.skylinelabs.digiPune.model; + + +public class NavDrawerItem { + private boolean showNotify; + private String title; + private int mIcons; + public NavDrawerItem() { + + } + + public NavDrawerItem(boolean showNotify, String title, int mIcons) { + this.showNotify = showNotify; + this.title = title; + this.mIcons = mIcons; + } + + public boolean isShowNotify() { + return showNotify; + } + + public void setShowNotify(boolean showNotify) { + this.showNotify = showNotify; + } + + public String getTitle() { + return title; + } + public int getIcon() { + return mIcons; + } + public void setTitle(String title) { + this.title = title; + } + public void setIcon(int mIcons) { + this.mIcons = mIcons; + } +} diff --git a/app/src/main/res/animator/indicator_animator.xml b/app/src/main/res/animator/indicator_animator.xml new file mode 100644 index 0000000..ce81007 --- /dev/null +++ b/app/src/main/res/animator/indicator_animator.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/animator/indicator_animator_reverse.xml b/app/src/main/res/animator/indicator_animator_reverse.xml new file mode 100644 index 0000000..f32d6f3 --- /dev/null +++ b/app/src/main/res/animator/indicator_animator_reverse.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/animator/indicator_no_animator.xml b/app/src/main/res/animator/indicator_no_animator.xml new file mode 100644 index 0000000..fe9ddac --- /dev/null +++ b/app/src/main/res/animator/indicator_no_animator.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/animator/scale_with_alpha.xml b/app/src/main/res/animator/scale_with_alpha.xml new file mode 100644 index 0000000..8ef7f85 --- /dev/null +++ b/app/src/main/res/animator/scale_with_alpha.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/ic_action_about.png b/app/src/main/res/drawable-hdpi/ic_action_about.png new file mode 100644 index 0000000..077dcec Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_about.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_about_w.png b/app/src/main/res/drawable-hdpi/ic_action_about_w.png new file mode 100644 index 0000000..b1f1406 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_about_w.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_accept.png b/app/src/main/res/drawable-hdpi/ic_action_accept.png new file mode 100644 index 0000000..4c2e844 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_accept.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_add_group.png b/app/src/main/res/drawable-hdpi/ic_action_add_group.png new file mode 100644 index 0000000..45ebb52 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_add_group.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_camera.png b/app/src/main/res/drawable-hdpi/ic_action_camera.png new file mode 100644 index 0000000..87649ad Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_camera.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_cc_bcc.png b/app/src/main/res/drawable-hdpi/ic_action_cc_bcc.png new file mode 100644 index 0000000..82945ee Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_cc_bcc.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_crop.png b/app/src/main/res/drawable-hdpi/ic_action_crop.png new file mode 100644 index 0000000..b053d50 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_crop.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_email.png b/app/src/main/res/drawable-hdpi/ic_action_email.png new file mode 100644 index 0000000..15bbf70 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_email.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_favorite.png b/app/src/main/res/drawable-hdpi/ic_action_favorite.png new file mode 100644 index 0000000..076ef81 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_favorite.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_good.png b/app/src/main/res/drawable-hdpi/ic_action_good.png new file mode 100644 index 0000000..7b5097c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_good.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_important.png b/app/src/main/res/drawable-hdpi/ic_action_important.png new file mode 100644 index 0000000..73f95d1 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_important.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_location_found.png b/app/src/main/res/drawable-hdpi/ic_action_location_found.png new file mode 100644 index 0000000..681fc14 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_location_found.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_map.png b/app/src/main/res/drawable-hdpi/ic_action_map.png new file mode 100644 index 0000000..22c398b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_map.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_new.png b/app/src/main/res/drawable-hdpi/ic_action_new.png new file mode 100644 index 0000000..3bd2fa0 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_new.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_picture.png b/app/src/main/res/drawable-hdpi/ic_action_picture.png new file mode 100644 index 0000000..47f14bc Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_picture.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_place.png b/app/src/main/res/drawable-hdpi/ic_action_place.png new file mode 100644 index 0000000..935c28e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_place.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_replay.png b/app/src/main/res/drawable-hdpi/ic_action_replay.png new file mode 100644 index 0000000..b027f10 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_replay.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_rotate_left.png b/app/src/main/res/drawable-hdpi/ic_action_rotate_left.png new file mode 100644 index 0000000..6ebf438 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_rotate_left.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_search.png b/app/src/main/res/drawable-hdpi/ic_action_search.png new file mode 100644 index 0000000..f594b4e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_search.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_search_w.png b/app/src/main/res/drawable-hdpi/ic_action_search_w.png new file mode 100644 index 0000000..a70393b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_search_w.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_settings.png b/app/src/main/res/drawable-hdpi/ic_action_settings.png new file mode 100644 index 0000000..7887b0e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_settings.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_share.png b/app/src/main/res/drawable-hdpi/ic_action_share.png new file mode 100644 index 0000000..d52b66a Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_share_dark.png b/app/src/main/res/drawable-hdpi/ic_action_share_dark.png new file mode 100644 index 0000000..d54689a Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_share_dark.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_unread.png b/app/src/main/res/drawable-hdpi/ic_action_unread.png new file mode 100644 index 0000000..2488d83 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_unread.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_web_site.png b/app/src/main/res/drawable-hdpi/ic_action_web_site.png new file mode 100644 index 0000000..64c48a0 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_web_site.png differ diff --git a/app/src/main/res/drawable-hdpi/wic_action_web_site.png b/app/src/main/res/drawable-hdpi/wic_action_web_site.png new file mode 100644 index 0000000..8c4add4 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/wic_action_web_site.png differ diff --git a/app/src/main/res/drawable-mdpi/black_radius.xml b/app/src/main/res/drawable-mdpi/black_radius.xml new file mode 100644 index 0000000..712962a --- /dev/null +++ b/app/src/main/res/drawable-mdpi/black_radius.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-mdpi/black_radius_square.xml b/app/src/main/res/drawable-mdpi/black_radius_square.xml new file mode 100644 index 0000000..69436f3 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/black_radius_square.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-mdpi/ic_action_about.png b/app/src/main/res/drawable-mdpi/ic_action_about.png new file mode 100644 index 0000000..624e745 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_about.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_about_w.png b/app/src/main/res/drawable-mdpi/ic_action_about_w.png new file mode 100644 index 0000000..ae2acd5 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_about_w.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_accept.png b/app/src/main/res/drawable-mdpi/ic_action_accept.png new file mode 100644 index 0000000..41107b8 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_accept.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_add_group.png b/app/src/main/res/drawable-mdpi/ic_action_add_group.png new file mode 100644 index 0000000..133200a Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_add_group.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_camera.png b/app/src/main/res/drawable-mdpi/ic_action_camera.png new file mode 100644 index 0000000..bf2af6e Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_camera.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_cc_bcc.png b/app/src/main/res/drawable-mdpi/ic_action_cc_bcc.png new file mode 100644 index 0000000..d564291 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_cc_bcc.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_crop.png b/app/src/main/res/drawable-mdpi/ic_action_crop.png new file mode 100644 index 0000000..c3f55bd Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_crop.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_email.png b/app/src/main/res/drawable-mdpi/ic_action_email.png new file mode 100644 index 0000000..fe2d160 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_email.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_favorite.png b/app/src/main/res/drawable-mdpi/ic_action_favorite.png new file mode 100644 index 0000000..4a1e95b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_favorite.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_good.png b/app/src/main/res/drawable-mdpi/ic_action_good.png new file mode 100644 index 0000000..3bae16c Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_good.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_important.png b/app/src/main/res/drawable-mdpi/ic_action_important.png new file mode 100644 index 0000000..5715e4b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_important.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_location_found.png b/app/src/main/res/drawable-mdpi/ic_action_location_found.png new file mode 100644 index 0000000..93e73f1 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_location_found.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_map.png b/app/src/main/res/drawable-mdpi/ic_action_map.png new file mode 100644 index 0000000..22c398b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_map.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_new.png b/app/src/main/res/drawable-mdpi/ic_action_new.png new file mode 100644 index 0000000..ca185e4 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_new.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_picture.png b/app/src/main/res/drawable-mdpi/ic_action_picture.png new file mode 100644 index 0000000..ef318dd Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_picture.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_place.png b/app/src/main/res/drawable-mdpi/ic_action_place.png new file mode 100644 index 0000000..e4d3c66 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_place.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_replay.png b/app/src/main/res/drawable-mdpi/ic_action_replay.png new file mode 100644 index 0000000..36facba Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_replay.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_rotate_left.png b/app/src/main/res/drawable-mdpi/ic_action_rotate_left.png new file mode 100644 index 0000000..d6c801e Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_rotate_left.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_search.png b/app/src/main/res/drawable-mdpi/ic_action_search.png new file mode 100644 index 0000000..abf509b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_search.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_search_w.png b/app/src/main/res/drawable-mdpi/ic_action_search_w.png new file mode 100644 index 0000000..dea3962 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_search_w.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_settings.png b/app/src/main/res/drawable-mdpi/ic_action_settings.png new file mode 100644 index 0000000..ea8bba3 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_settings.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_share.png b/app/src/main/res/drawable-mdpi/ic_action_share.png new file mode 100644 index 0000000..0d9cbf4 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_share_dark.png b/app/src/main/res/drawable-mdpi/ic_action_share_dark.png new file mode 100644 index 0000000..6a64aa9 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_share_dark.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_unread.png b/app/src/main/res/drawable-mdpi/ic_action_unread.png new file mode 100644 index 0000000..71fb3d0 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_unread.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_web_site.png b/app/src/main/res/drawable-mdpi/ic_action_web_site.png new file mode 100644 index 0000000..0958a44 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_web_site.png differ diff --git a/app/src/main/res/drawable-mdpi/white_radius.xml b/app/src/main/res/drawable-mdpi/white_radius.xml new file mode 100644 index 0000000..69e0520 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/white_radius.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-mdpi/wic_action_web_site.png b/app/src/main/res/drawable-mdpi/wic_action_web_site.png new file mode 100644 index 0000000..8a57c83 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/wic_action_web_site.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_about.png b/app/src/main/res/drawable-xhdpi/ic_action_about.png new file mode 100644 index 0000000..3be3152 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_about.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_about_w.png b/app/src/main/res/drawable-xhdpi/ic_action_about_w.png new file mode 100644 index 0000000..4536a8d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_about_w.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_accept.png b/app/src/main/res/drawable-xhdpi/ic_action_accept.png new file mode 100644 index 0000000..6ee32b6 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_accept.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_add_group.png b/app/src/main/res/drawable-xhdpi/ic_action_add_group.png new file mode 100644 index 0000000..6bfacaa Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_add_group.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_camera.png b/app/src/main/res/drawable-xhdpi/ic_action_camera.png new file mode 100644 index 0000000..b4bd762 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_camera.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_cc_bcc.png b/app/src/main/res/drawable-xhdpi/ic_action_cc_bcc.png new file mode 100644 index 0000000..16758bb Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_cc_bcc.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_crop.png b/app/src/main/res/drawable-xhdpi/ic_action_crop.png new file mode 100644 index 0000000..3d27345 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_crop.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_email.png b/app/src/main/res/drawable-xhdpi/ic_action_email.png new file mode 100644 index 0000000..043b7b4 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_email.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_favorite.png b/app/src/main/res/drawable-xhdpi/ic_action_favorite.png new file mode 100644 index 0000000..2e23571 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_favorite.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_good.png b/app/src/main/res/drawable-xhdpi/ic_action_good.png new file mode 100644 index 0000000..0bb45d2 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_good.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_important.png b/app/src/main/res/drawable-xhdpi/ic_action_important.png new file mode 100644 index 0000000..dea7f6c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_important.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_location_found.png b/app/src/main/res/drawable-xhdpi/ic_action_location_found.png new file mode 100644 index 0000000..4c06441 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_location_found.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_map.png b/app/src/main/res/drawable-xhdpi/ic_action_map.png new file mode 100644 index 0000000..27e3234 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_map.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_new.png b/app/src/main/res/drawable-xhdpi/ic_action_new.png new file mode 100644 index 0000000..6038bee Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_new.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_picture.png b/app/src/main/res/drawable-xhdpi/ic_action_picture.png new file mode 100644 index 0000000..638d4ab Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_picture.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_place.png b/app/src/main/res/drawable-xhdpi/ic_action_place.png new file mode 100644 index 0000000..2f488b4 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_place.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_replay.png b/app/src/main/res/drawable-xhdpi/ic_action_replay.png new file mode 100644 index 0000000..8bcb743 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_replay.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_rotate_left.png b/app/src/main/res/drawable-xhdpi/ic_action_rotate_left.png new file mode 100644 index 0000000..94760ce Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_rotate_left.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_search.png b/app/src/main/res/drawable-xhdpi/ic_action_search.png new file mode 100644 index 0000000..96deb01 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_search.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_search_w.png b/app/src/main/res/drawable-xhdpi/ic_action_search_w.png new file mode 100644 index 0000000..19658e4 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_search_w.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_settings.png b/app/src/main/res/drawable-xhdpi/ic_action_settings.png new file mode 100644 index 0000000..a04fe1d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_settings.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_share.png b/app/src/main/res/drawable-xhdpi/ic_action_share.png new file mode 100644 index 0000000..40771e4 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_share_dark.png b/app/src/main/res/drawable-xhdpi/ic_action_share_dark.png new file mode 100644 index 0000000..2f6dc41 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_share_dark.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_unread.png b/app/src/main/res/drawable-xhdpi/ic_action_unread.png new file mode 100644 index 0000000..5189a3e Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_unread.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_web_site.png b/app/src/main/res/drawable-xhdpi/ic_action_web_site.png new file mode 100644 index 0000000..f800630 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_web_site.png differ diff --git a/app/src/main/res/drawable-xhdpi/wic_action_web_site.png b/app/src/main/res/drawable-xhdpi/wic_action_web_site.png new file mode 100644 index 0000000..2d759de Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/wic_action_web_site.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_about.png b/app/src/main/res/drawable-xxhdpi/ic_action_about.png new file mode 100644 index 0000000..7c7e764 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_about.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_about_w.png b/app/src/main/res/drawable-xxhdpi/ic_action_about_w.png new file mode 100644 index 0000000..f3db088 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_about_w.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_accept.png b/app/src/main/res/drawable-xxhdpi/ic_action_accept.png new file mode 100644 index 0000000..68c41de Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_accept.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_add_group.png b/app/src/main/res/drawable-xxhdpi/ic_action_add_group.png new file mode 100644 index 0000000..0db7fdb Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_add_group.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_camera.png b/app/src/main/res/drawable-xxhdpi/ic_action_camera.png new file mode 100644 index 0000000..a83d40c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_camera.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_cc_bcc.png b/app/src/main/res/drawable-xxhdpi/ic_action_cc_bcc.png new file mode 100644 index 0000000..6a94808 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_cc_bcc.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_crop.png b/app/src/main/res/drawable-xxhdpi/ic_action_crop.png new file mode 100644 index 0000000..b75a950 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_crop.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_email.png b/app/src/main/res/drawable-xxhdpi/ic_action_email.png new file mode 100644 index 0000000..273a778 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_email.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_favorite.png b/app/src/main/res/drawable-xxhdpi/ic_action_favorite.png new file mode 100644 index 0000000..5c3f0d9 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_favorite.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_good.png b/app/src/main/res/drawable-xxhdpi/ic_action_good.png new file mode 100644 index 0000000..bd4cecc Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_good.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_important.png b/app/src/main/res/drawable-xxhdpi/ic_action_important.png new file mode 100644 index 0000000..e596f32 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_important.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_location_found.png b/app/src/main/res/drawable-xxhdpi/ic_action_location_found.png new file mode 100644 index 0000000..43f18ea Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_location_found.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_map.png b/app/src/main/res/drawable-xxhdpi/ic_action_map.png new file mode 100644 index 0000000..b385ee8 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_map.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_new.png b/app/src/main/res/drawable-xxhdpi/ic_action_new.png new file mode 100644 index 0000000..c0cd3d9 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_new.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_picture.png b/app/src/main/res/drawable-xxhdpi/ic_action_picture.png new file mode 100644 index 0000000..88f8016 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_picture.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_place.png b/app/src/main/res/drawable-xxhdpi/ic_action_place.png new file mode 100644 index 0000000..1f7c8a9 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_place.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_replay.png b/app/src/main/res/drawable-xxhdpi/ic_action_replay.png new file mode 100644 index 0000000..499bfe1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_replay.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_rotate_left.png b/app/src/main/res/drawable-xxhdpi/ic_action_rotate_left.png new file mode 100644 index 0000000..42f8f54 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_rotate_left.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_search.png b/app/src/main/res/drawable-xxhdpi/ic_action_search.png new file mode 100644 index 0000000..2afc10a Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_search.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_search_w.png b/app/src/main/res/drawable-xxhdpi/ic_action_search_w.png new file mode 100644 index 0000000..a108638 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_search_w.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_settings.png b/app/src/main/res/drawable-xxhdpi/ic_action_settings.png new file mode 100644 index 0000000..a9c6b53 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_settings.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_share.png b/app/src/main/res/drawable-xxhdpi/ic_action_share.png new file mode 100644 index 0000000..22ed428 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_share_dark.png b/app/src/main/res/drawable-xxhdpi/ic_action_share_dark.png new file mode 100644 index 0000000..0630d31 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_share_dark.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_unread.png b/app/src/main/res/drawable-xxhdpi/ic_action_unread.png new file mode 100644 index 0000000..2ab7b24 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_unread.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_web_site.png b/app/src/main/res/drawable-xxhdpi/ic_action_web_site.png new file mode 100644 index 0000000..1ff3a60 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_web_site.png differ diff --git a/app/src/main/res/drawable-xxhdpi/wic_action_web_site.png b/app/src/main/res/drawable-xxhdpi/wic_action_web_site.png new file mode 100644 index 0000000..e24eed7 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/wic_action_web_site.png differ diff --git a/app/src/main/res/drawable/bus.jpg b/app/src/main/res/drawable/bus.jpg new file mode 100644 index 0000000..a8d5cd1 Binary files /dev/null and b/app/src/main/res/drawable/bus.jpg differ diff --git a/app/src/main/res/drawable/card_back.xml b/app/src/main/res/drawable/card_back.xml new file mode 100644 index 0000000..6820b77 --- /dev/null +++ b/app/src/main/res/drawable/card_back.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/emrald.png b/app/src/main/res/drawable/emrald.png new file mode 100644 index 0000000..7577680 Binary files /dev/null and b/app/src/main/res/drawable/emrald.png differ diff --git a/app/src/main/res/drawable/fav_help.png b/app/src/main/res/drawable/fav_help.png new file mode 100644 index 0000000..e7bd091 Binary files /dev/null and b/app/src/main/res/drawable/fav_help.png differ diff --git a/app/src/main/res/drawable/findx_logo.png b/app/src/main/res/drawable/findx_logo.png new file mode 100644 index 0000000..a484483 Binary files /dev/null and b/app/src/main/res/drawable/findx_logo.png differ diff --git a/app/src/main/res/drawable/findx_navdrawer_header.png b/app/src/main/res/drawable/findx_navdrawer_header.png new file mode 100644 index 0000000..7d4250d Binary files /dev/null and b/app/src/main/res/drawable/findx_navdrawer_header.png differ diff --git a/app/src/main/res/drawable/findx_promo.png b/app/src/main/res/drawable/findx_promo.png new file mode 100644 index 0000000..09e1083 Binary files /dev/null and b/app/src/main/res/drawable/findx_promo.png differ diff --git a/app/src/main/res/drawable/friendlocation_help.png b/app/src/main/res/drawable/friendlocation_help.png new file mode 100644 index 0000000..0456a6f Binary files /dev/null and b/app/src/main/res/drawable/friendlocation_help.png differ diff --git a/app/src/main/res/drawable/geofence.png b/app/src/main/res/drawable/geofence.png new file mode 100644 index 0000000..4ecdd5f Binary files /dev/null and b/app/src/main/res/drawable/geofence.png differ diff --git a/app/src/main/res/drawable/gov_logo.png b/app/src/main/res/drawable/gov_logo.png new file mode 100644 index 0000000..854794d Binary files /dev/null and b/app/src/main/res/drawable/gov_logo.png differ diff --git a/app/src/main/res/drawable/history_help.png b/app/src/main/res/drawable/history_help.png new file mode 100644 index 0000000..5d3611d Binary files /dev/null and b/app/src/main/res/drawable/history_help.png differ diff --git a/app/src/main/res/drawable/human.png b/app/src/main/res/drawable/human.png new file mode 100644 index 0000000..8365cf7 Binary files /dev/null and b/app/src/main/res/drawable/human.png differ diff --git a/app/src/main/res/drawable/ic_action_call.png b/app/src/main/res/drawable/ic_action_call.png new file mode 100644 index 0000000..2030e31 Binary files /dev/null and b/app/src/main/res/drawable/ic_action_call.png differ diff --git a/app/src/main/res/drawable/ic_action_directions.png b/app/src/main/res/drawable/ic_action_directions.png new file mode 100644 index 0000000..26afb15 Binary files /dev/null and b/app/src/main/res/drawable/ic_action_directions.png differ diff --git a/app/src/main/res/drawable/ic_action_search.png b/app/src/main/res/drawable/ic_action_search.png new file mode 100644 index 0000000..2afc10a Binary files /dev/null and b/app/src/main/res/drawable/ic_action_search.png differ diff --git a/app/src/main/res/drawable/ic_facebook_white_18dp.png b/app/src/main/res/drawable/ic_facebook_white_18dp.png new file mode 100644 index 0000000..2567d7e Binary files /dev/null and b/app/src/main/res/drawable/ic_facebook_white_18dp.png differ diff --git a/app/src/main/res/drawable/ic_launcher.png b/app/src/main/res/drawable/ic_launcher.png new file mode 100644 index 0000000..52b4be5 Binary files /dev/null and b/app/src/main/res/drawable/ic_launcher.png differ diff --git a/app/src/main/res/drawable/icon.png b/app/src/main/res/drawable/icon.png new file mode 100644 index 0000000..a5e4f51 Binary files /dev/null and b/app/src/main/res/drawable/icon.png differ diff --git a/app/src/main/res/drawable/mylocation_help.png b/app/src/main/res/drawable/mylocation_help.png new file mode 100644 index 0000000..74bd111 Binary files /dev/null and b/app/src/main/res/drawable/mylocation_help.png differ diff --git a/app/src/main/res/drawable/settings_help.png b/app/src/main/res/drawable/settings_help.png new file mode 100644 index 0000000..e30319e Binary files /dev/null and b/app/src/main/res/drawable/settings_help.png differ diff --git a/app/src/main/res/drawable/skyline_logo.png b/app/src/main/res/drawable/skyline_logo.png new file mode 100644 index 0000000..b94b463 Binary files /dev/null and b/app/src/main/res/drawable/skyline_logo.png differ diff --git a/app/src/main/res/drawable/sos.png b/app/src/main/res/drawable/sos.png new file mode 100644 index 0000000..56abd7e Binary files /dev/null and b/app/src/main/res/drawable/sos.png differ diff --git a/app/src/main/res/drawable/sos_help.png b/app/src/main/res/drawable/sos_help.png new file mode 100644 index 0000000..f4c8cda Binary files /dev/null and b/app/src/main/res/drawable/sos_help.png differ diff --git a/app/src/main/res/drawable/sos_intro.png b/app/src/main/res/drawable/sos_intro.png new file mode 100644 index 0000000..f60b83f Binary files /dev/null and b/app/src/main/res/drawable/sos_intro.png differ diff --git a/app/src/main/res/layout-xlarge/activity_bus__fetch.xml b/app/src/main/res/layout-xlarge/activity_bus__fetch.xml new file mode 100644 index 0000000..b8514f1 --- /dev/null +++ b/app/src/main/res/layout-xlarge/activity_bus__fetch.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/about_developers.xml b/app/src/main/res/layout/about_developers.xml new file mode 100644 index 0000000..e98ce25 --- /dev/null +++ b/app/src/main/res/layout/about_developers.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_alert__ssend.xml b/app/src/main/res/layout/activity_alert__ssend.xml new file mode 100644 index 0000000..b1f1d28 --- /dev/null +++ b/app/src/main/res/layout/activity_alert__ssend.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_app_intro.xml b/app/src/main/res/layout/activity_app_intro.xml new file mode 100644 index 0000000..137feac --- /dev/null +++ b/app/src/main/res/layout/activity_app_intro.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_bus__fetch.xml b/app/src/main/res/layout/activity_bus__fetch.xml new file mode 100644 index 0000000..551006b --- /dev/null +++ b/app/src/main/res/layout/activity_bus__fetch.xml @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_complaint_portal.xml b/app/src/main/res/layout/activity_complaint_portal.xml new file mode 100644 index 0000000..994c2cc --- /dev/null +++ b/app/src/main/res/layout/activity_complaint_portal.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_conductor_.xml b/app/src/main/res/layout/activity_conductor_.xml new file mode 100644 index 0000000..4cef3b6 --- /dev/null +++ b/app/src/main/res/layout/activity_conductor_.xml @@ -0,0 +1,50 @@ + + + + + + + +