diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild 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..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..fe21240 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1f4de78 --- /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/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..6892d2d --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + buildToolsVersion '26.0.2' + defaultConfig { + applicationId "com.example.wot.parentapp" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:26.+' + compile 'com.android.support:support-v4:26.+' + compile 'com.android.support:design:26.+' + compile 'com.android.support:cardview-v7:26.+' + compile 'cn.fanrunqi:waveprogress:1.0.1' + compile 'com.github.bumptech.glide:glide:3.7.0' + compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile 'com.google.android.gms:play-services-maps:11.0.4' + testCompile 'junit:junit:4.12' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..993d41d --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Users\WOT\AppData\Local\Android\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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/example/wot/parentapp/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/wot/parentapp/ExampleInstrumentedTest.java new file mode 100644 index 0000000..7ffd6eb --- /dev/null +++ b/app/src/androidTest/java/com/example/wot/parentapp/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.wot.parentapp; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.wot.parentapp", appContext.getPackageName()); + } +} diff --git a/app/src/debug/res/values/google_maps_api.xml b/app/src/debug/res/values/google_maps_api.xml new file mode 100644 index 0000000..10233eb --- /dev/null +++ b/app/src/debug/res/values/google_maps_api.xml @@ -0,0 +1,26 @@ + + + + AIzaSyAv445ajywBSmqyhJZRZcTJ4vHrpwRwvJE + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..711183c --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000..14a7acb Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/com/example/wot/parentapp/BatteryActivity.java b/app/src/main/java/com/example/wot/parentapp/BatteryActivity.java new file mode 100644 index 0000000..15cd37e --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/BatteryActivity.java @@ -0,0 +1,152 @@ +package com.example.wot.parentapp; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.widget.Toast; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import cn.fanrunqi.waveprogress.WaveProgressView; + +import static java.net.HttpURLConnection.HTTP_OK; + +public class BatteryActivity extends AppCompatActivity { + + WaveProgressView waveProgressView; + SharedPreferences sharedPreferences; + SharedPreferences.Editor editor; + String cid; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_battery); + + waveProgressView = (WaveProgressView)findViewById(R.id.waveProgressbar); + sharedPreferences = getSharedPreferences("PARENT",MODE_PRIVATE); + cid= sharedPreferences.getString("CHILD","no child"); + + new BatteryTask().execute(cid); + + + } + + private class BatteryTask extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(BatteryActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/getbattery.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("cid",strings[0]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("LoginResult",s); + if(s.equals("0 results")) + { + // Toast.makeText(LoginActivity.this, "Invalid username or password", Toast.LENGTH_SHORT).show(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(BatteryActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + finish(); + } + + else { + int percentage = Integer.parseInt(s); + waveProgressView.setCurrent(percentage,s+" %"); // 77, "788M/1024M" + waveProgressView.setMaxProgress(100); + waveProgressView.setText("#3949ab",100);//"#FFFF00", 41 + waveProgressView.setWaveColor("#5b9ef4"); //"#5b9ef4" + + waveProgressView.setWave(Float.parseFloat("30"),Float.parseFloat("200")); + waveProgressView.setmWaveSpeed(50);//The larger the value, the slower the vibration + // startActivity(new Intent(LoginActivity.this,SelectChildActivity.class)); + } + + } + } +} diff --git a/app/src/main/java/com/example/wot/parentapp/BlockSitesActivity.java b/app/src/main/java/com/example/wot/parentapp/BlockSitesActivity.java new file mode 100644 index 0000000..4deba9c --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/BlockSitesActivity.java @@ -0,0 +1,288 @@ +package com.example.wot.parentapp; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import static java.net.HttpURLConnection.HTTP_OK; + +public class BlockSitesActivity extends AppCompatActivity { + + ListView listView; + Button button; + EditText editText; + Toolbar toolbar; + SharedPreferences sharedPreferences; + String cid,text; + BlockSitesAdapter blockSitesAdapter; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_block_sites); + + button = (Button)findViewById(R.id.blocksitebtn); + editText = (EditText)findViewById(R.id.blocksiteet); + listView = (ListView)findViewById(R.id.blocksitelist); + toolbar = (Toolbar)findViewById(R.id.toolbar); + + setSupportActionBar(toolbar); + sharedPreferences = getSharedPreferences("PARENT",MODE_PRIVATE); + cid= sharedPreferences.getString("CHILD","no child"); + new SitesTask().execute(cid); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + text = editText.getText().toString(); + new AddSitesTask().execute(cid,text); + + } + }); + + } + + private class SitesTask extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(BlockSitesActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/retrievesites.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("cid",strings[0]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("LoginResult",s); + if(s.equals("0 results")) + { + Toast.makeText(BlockSitesActivity.this, "No blocked sites", Toast.LENGTH_SHORT).show(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(BlockSitesActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + + } + + else { + String[] sites,ids; + try { + JSONObject jsonObject = new JSONObject(s); + JSONArray jsonArray = jsonObject.optJSONArray("sites"); + sites = new String[jsonArray.length()]; + ids = new String[jsonArray.length()]; + for(int i=0;i + { + ProgressDialog pd = new ProgressDialog(BlockSitesActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/sendsites.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("cid",strings[0]); + builder.appendQueryParameter("site",strings[1]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("LoginResult",s); + if(s.equals("failed")) + { + Toast.makeText(BlockSitesActivity.this, "Failed to set", Toast.LENGTH_SHORT).show(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(BlockSitesActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + + } + + else if(s.equals("success")){ + editText.setText(""); + new SitesTask().execute(cid); + Toast.makeText(BlockSitesActivity.this, "Successfully added", Toast.LENGTH_SHORT).show(); + } + + } + } +} diff --git a/app/src/main/java/com/example/wot/parentapp/BlockSitesAdapter.java b/app/src/main/java/com/example/wot/parentapp/BlockSitesAdapter.java new file mode 100644 index 0000000..82bd076 --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/BlockSitesAdapter.java @@ -0,0 +1,189 @@ +package com.example.wot.parentapp; + +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.Context; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.annotation.IdRes; +import android.support.annotation.LayoutRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import static java.net.HttpURLConnection.HTTP_OK; + +/** + * Created by WOT on 9/9/2017. + */ + +public class BlockSitesAdapter extends ArrayAdapter { + + Activity activity; + String[] sites,ids; + public BlockSitesAdapter( Activity activity, int resource, String[] sites,String[] ids) { + super(activity, resource, sites); + this.activity = activity; + this.sites=sites; + this.ids = ids; + } + + private class ViewHolder{ + TextView sitetxt,idtxt; + ImageButton editimg,deleteim; + + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + + View view; + view = convertView; + final ViewHolder viewHolder; + if(convertView ==null) + { + LayoutInflater inflater = activity.getLayoutInflater(); + view = inflater.inflate(R.layout.blocksiteslayout,parent,false); + + viewHolder = new ViewHolder(); + viewHolder.sitetxt = (TextView)view.findViewById(R.id.blocksitetxt); + viewHolder.idtxt = (TextView)view.findViewById(R.id.blocksiteidtxt); + viewHolder.editimg = (ImageButton) view.findViewById(R.id.siteeditim); + viewHolder.deleteim = (ImageButton)view.findViewById(R.id.sitedeleteim); + viewHolder.sitetxt.setText(sites[position]); + viewHolder.idtxt.setText(ids[position]); + + + + viewHolder.deleteim.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String id = viewHolder.idtxt.getText().toString(); + + + new DeleteSitesTask().execute(id); + } + }); + + } + return view; + } + + private class DeleteSitesTask extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(activity); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/deletesites.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("id",strings[0]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("LoginResult",s); + if(s.equals("failed")) + { + Toast.makeText(activity, "Failed to delete", Toast.LENGTH_SHORT).show(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(activity, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + + } + + else if(s.equals("success")){ + activity.finish(); + Toast.makeText(activity, "Deleted", Toast.LENGTH_SHORT).show(); + } + + } + } +} diff --git a/app/src/main/java/com/example/wot/parentapp/ChildAccess.java b/app/src/main/java/com/example/wot/parentapp/ChildAccess.java new file mode 100644 index 0000000..a9a0bfa --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/ChildAccess.java @@ -0,0 +1,169 @@ +package com.example.wot.parentapp; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.Toast; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import static java.net.HttpURLConnection.HTTP_OK; + +public class ChildAccess extends AppCompatActivity { + + RadioGroup radioGroup; + Button button; + String s,text,cid; + SharedPreferences sharedPreferences; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_child_access); + + sharedPreferences = getSharedPreferences("PARENT",MODE_PRIVATE); + cid= sharedPreferences.getString("CHILD","no child"); + final RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radiog); + button = (Button)findViewById(R.id.sbtn); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int id=radioGroup.getCheckedRadioButtonId(); + RadioButton rb=(RadioButton)findViewById(id); + text = rb.getText().toString().trim(); + Log.i("rbText",text); + if(text.equals("Allow Access")) + { + s="true"; + } + else + { + s="false"; + } + new SendAccess().execute(cid,s); + } + }); + } + + private class SendAccess extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(ChildAccess.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/sendaccess.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("cid",strings[0]); + builder.appendQueryParameter("access",strings[1]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("SelectChildResult",s); + if(s.equals("0 results")) + { + Toast.makeText(ChildAccess.this, "Invalid", Toast.LENGTH_SHORT).show(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(ChildAccess.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + + } + else if(s.equals("success")) + { + Toast.makeText(ChildAccess.this, "Successfully updated", Toast.LENGTH_SHORT).show(); + startActivity(new Intent(ChildAccess.this,HomeActivity.class)); + finish(); + } + + + } + } +} diff --git a/app/src/main/java/com/example/wot/parentapp/HomeActivity.java b/app/src/main/java/com/example/wot/parentapp/HomeActivity.java new file mode 100644 index 0000000..38d1934 --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/HomeActivity.java @@ -0,0 +1,59 @@ +package com.example.wot.parentapp; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.CardView; +import android.view.View; + +public class HomeActivity extends AppCompatActivity { + + CardView screencard,sitecard,batterycard,trackcard,usagecard; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_home); + + screencard = (CardView)findViewById(R.id.cardscreenshot); + sitecard = (CardView)findViewById(R.id.cardblock); + batterycard = (CardView)findViewById(R.id.cardbattery); + trackcard = (CardView)findViewById(R.id.cardplace); + usagecard = (CardView)findViewById(R.id.cardusage); + + screencard.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(HomeActivity.this,ScreenshotActivity.class)); + } + }); + + sitecard.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(HomeActivity.this,BlockSitesActivity.class)); + } + }); + + batterycard.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(HomeActivity.this,BatteryActivity.class)); + } + }); + + trackcard.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(HomeActivity.this,MapsActivity.class)); + } + }); + + usagecard.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(HomeActivity.this,ChildAccess.class)); + } + }); + } +} diff --git a/app/src/main/java/com/example/wot/parentapp/LoginActivity.java b/app/src/main/java/com/example/wot/parentapp/LoginActivity.java new file mode 100644 index 0000000..7b32007 --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/LoginActivity.java @@ -0,0 +1,170 @@ +package com.example.wot.parentapp; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import static java.net.HttpURLConnection.HTTP_OK; + +public class LoginActivity extends AppCompatActivity { + + TextView signup; + Button signin; + String mail,pass; + EditText mailet,passet; + SharedPreferences sharedPreferences; + SharedPreferences.Editor editor; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + + signin = (Button)findViewById(R.id.signinbtn); + signup = (TextView)findViewById(R.id.loginsignuptxt); + mailet = (EditText)findViewById(R.id.loginmail); + passet = (EditText)findViewById(R.id.loginpass); + + sharedPreferences= getSharedPreferences("PARENT",MODE_PRIVATE); + + signin.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mail= mailet.getText().toString().trim(); + pass = passet.getText().toString().trim(); + new LoginTask().execute(mail,pass); + } + }); + + signup.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(LoginActivity.this,SignUpActivity.class)); + } + }); + } + + private class LoginTask extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(LoginActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/parentlogin.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("username",strings[0]); + builder.appendQueryParameter("password",strings[1]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("LoginResult",s); + if(s.equals("0 results")) + { + Toast.makeText(LoginActivity.this, "Invalid username or password", Toast.LENGTH_SHORT).show(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(LoginActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + + } + + else { + + editor= sharedPreferences.edit(); + editor.putString("USER",s); + editor.apply(); + // Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); + startActivity(new Intent (LoginActivity.this,SelectChildActivity.class)); + } + + } + } + +} diff --git a/app/src/main/java/com/example/wot/parentapp/MapsActivity.java b/app/src/main/java/com/example/wot/parentapp/MapsActivity.java new file mode 100644 index 0000000..a303fef --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/MapsActivity.java @@ -0,0 +1,188 @@ +package com.example.wot.parentapp; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.v4.app.FragmentActivity; +import android.os.Bundle; +import android.util.Log; +import android.widget.Toast; + +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.OnMapReadyCallback; +import com.google.android.gms.maps.SupportMapFragment; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.MarkerOptions; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import static java.net.HttpURLConnection.HTTP_OK; + +public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { + + private GoogleMap mMap; + double lon,lat; + String longitude,latitude,cid; + SharedPreferences sharedPreferences; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_maps); + sharedPreferences = getSharedPreferences("PARENT",MODE_PRIVATE); + cid= sharedPreferences.getString("CHILD","no child"); + new LocationTask().execute(cid); + } + + + + @Override + public void onMapReady(GoogleMap googleMap) { + mMap = googleMap; + + lon = Double.parseDouble(longitude); + lat = Double.parseDouble(latitude); + // Add a marker in Sydney and move the camera + LatLng location = new LatLng(lat, lon); + Log.i("Location",location.toString()); + mMap.addMarker(new MarkerOptions().position(location).title("Child Location")); + mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, 10.0f)); + + } + + private class LocationTask extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(MapsActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/getlocation.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("cid",strings[0]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("LoginResult",s); + if(s.equals("0 results")) + { + Toast.makeText(MapsActivity.this, "Location not available", Toast.LENGTH_SHORT).show(); + finish(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(MapsActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + finish(); + + } + + else { + try { + JSONObject jsonObject = new JSONObject(s); + JSONArray jsonArray = jsonObject.optJSONArray("location"); + for(int i=0;i + { + ProgressDialog pd = new ProgressDialog(ScreenshotActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/getscreen.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("cid",strings[0]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("LoginResult",s); + if(s.equals("0 results")) + { + Toast.makeText(ScreenshotActivity.this, "Screenshot not available", Toast.LENGTH_SHORT).show(); + finish(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(ScreenshotActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + finish(); + + } + + else { + + + Glide.with(ScreenshotActivity.this).load(s).placeholder(R.drawable.parentapp_logo).into(imageView); + + } + + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.screenshot_menu,menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if(id==R.id.screenshot_refresh) + { + new ScreenshotTask().execute(cid); + } + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/com/example/wot/parentapp/SelectChildActivity.java b/app/src/main/java/com/example/wot/parentapp/SelectChildActivity.java new file mode 100644 index 0000000..e210636 --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/SelectChildActivity.java @@ -0,0 +1,184 @@ +package com.example.wot.parentapp; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import static java.net.HttpURLConnection.HTTP_OK; + +public class SelectChildActivity extends AppCompatActivity { + + ListView listView; + SharedPreferences sharedPreferences; + SharedPreferences.Editor editor; + String user; + SelectChildAdapter selectChildAdapter; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_select_child); + + sharedPreferences = getSharedPreferences("PARENT",MODE_PRIVATE); + listView = (ListView)findViewById(R.id.selectchildlist); + user = sharedPreferences.getString("USER","no user"); + Log.i("user",user); + new LoginTask().execute(user); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + TextView idtxt = (TextView)view.findViewById(R.id.selectchildid); + editor = sharedPreferences.edit(); + editor.putString("CHILD",idtxt.getText().toString()); + editor.apply(); + // Toast.makeText(SelectChildActivity.this, idtxt.getText().toString(), Toast.LENGTH_SHORT).show(); + startActivity(new Intent(SelectChildActivity.this,HomeActivity.class)); + } + }); + } + + private class LoginTask extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(SelectChildActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/childlist.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("pid",strings[0]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else{ + Log.i("Error","Unsuccessfulcode"+rc); + return "unsuccessfull"; + } + + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + Log.i("SelectChildResult",s); + if(s.equals("0 results")) + { + Toast.makeText(SelectChildActivity.this, "Invalid", Toast.LENGTH_SHORT).show(); + } + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(SelectChildActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + + } + + else { + String[] name,id; + try { + JSONObject jsonObject = new JSONObject(s); + JSONArray jsonArray = jsonObject.optJSONArray("child"); + name = new String[jsonArray.length()]; + id = new String[jsonArray.length()]; + if(jsonArray==null) + { + Toast.makeText(SelectChildActivity.this, "No child added", Toast.LENGTH_SHORT).show(); + } + else { + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject1 = jsonArray.optJSONObject(i); + name[i] = jsonObject1.getString("name"); + id[i] = jsonObject1.getString("id"); + } + + selectChildAdapter = new SelectChildAdapter(SelectChildActivity.this, R.layout.selectchildlayout, name, id); + listView.setAdapter(selectChildAdapter); + } + } catch (JSONException e) { + e.printStackTrace(); + } + + } + + } + } + +} diff --git a/app/src/main/java/com/example/wot/parentapp/SelectChildAdapter.java b/app/src/main/java/com/example/wot/parentapp/SelectChildAdapter.java new file mode 100644 index 0000000..ffb5ee6 --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/SelectChildAdapter.java @@ -0,0 +1,57 @@ +package com.example.wot.parentapp; + +import android.app.Activity; +import android.content.Context; +import android.support.annotation.IdRes; +import android.support.annotation.LayoutRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.CardView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +/** + * Created by WOT on 8/29/2017. + */ + +public class SelectChildAdapter extends ArrayAdapter { + + Activity activity; + String[] name; + String[] id; + public SelectChildAdapter(@NonNull Activity context, @LayoutRes int resource, String[] name,String[] id) { + super(context, resource, name); + this.activity = context; + this.name = name; + this.id = id; + } + private class ViewHolder + { + TextView nametxt,idtxt; + CardView cardView; + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + + View v= convertView; + ViewHolder viewHolder; + if(v==null) + { + LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + v = inflater.inflate(R.layout.selectchildlayout,parent,false); + viewHolder = new ViewHolder(); + viewHolder.nametxt = (TextView)v.findViewById(R.id.selectchildname); + viewHolder.idtxt = (TextView)v.findViewById(R.id.selectchildid); + viewHolder.cardView = (CardView) v.findViewById(R.id.selectchildcard); + viewHolder.nametxt.setText(name[position]); + viewHolder.idtxt.setText(id[position]); + + } + return v; + } +} diff --git a/app/src/main/java/com/example/wot/parentapp/SignUpActivity.java b/app/src/main/java/com/example/wot/parentapp/SignUpActivity.java new file mode 100644 index 0000000..bc13cc9 --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/SignUpActivity.java @@ -0,0 +1,213 @@ +package com.example.wot.parentapp; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.net.Uri; +import android.os.AsyncTask; +import android.support.design.widget.TextInputLayout; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.Toast; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import static java.net.HttpURLConnection.HTTP_OK; + +public class SignUpActivity extends AppCompatActivity { + + EditText ename,eaddr,ephone,email; + RadioGroup radioGroup; + String name,addr,gender,phone,mail; + Button button; + TextInputLayout tname,taddr,tphone,tmail; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sign_up); + + ename = (EditText)findViewById(R.id.signupname); + eaddr = (EditText)findViewById(R.id.signupaddress); + ephone = (EditText)findViewById(R.id.signupphone); + email = (EditText)findViewById(R.id.signupmail); + button = (Button)findViewById(R.id.signupbtn); + radioGroup = (RadioGroup)findViewById(R.id.signuprg); + tname = (TextInputLayout)findViewById(R.id.namelayout); + taddr = (TextInputLayout)findViewById(R.id.addresslayout); + tphone = (TextInputLayout)findViewById(R.id.phonelayout); + tmail = (TextInputLayout)findViewById(R.id.maillayout); + + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + name = ename.getText().toString().trim(); + addr = eaddr.getText().toString().trim(); + phone = ephone.getText().toString().trim(); + mail = email.getText().toString().trim(); + int id = radioGroup.getCheckedRadioButtonId(); + RadioButton radioButton = (RadioButton)findViewById(id); + gender = radioButton.getText().toString(); + + if(name.isEmpty()) + { + tname.setErrorEnabled(true); + tname.setError("Enter your name"); + return; + } + else + { + tname.setErrorEnabled(false); + } + if(addr.isEmpty()) + { + taddr.setErrorEnabled(true); + taddr.setError("Enter Address"); + return; + } + else + { + taddr.setErrorEnabled(false); + } + if(phone.isEmpty()) + { + tphone.setErrorEnabled(true); + tphone.setError("Enter your phone number"); + return; + } + else + { + tphone.setErrorEnabled(false); + } + if(mail.isEmpty()|| !android.util.Patterns.EMAIL_ADDRESS.matcher(mail).matches()) + { + tmail.setErrorEnabled(true); + tmail.setError("Enter valid email"); + return; + } + else { + tmail.setErrorEnabled(false); + } + + new RegisterTask().execute(name,addr,gender,phone,mail); + + + } + }); + + } + + private class RegisterTask extends AsyncTask + { + ProgressDialog pd = new ProgressDialog(SignUpActivity.this); + HttpURLConnection connection; + URL url; + + @Override + protected void onPreExecute() { + super.onPreExecute(); + pd.setMessage("Loading..."); + pd.setCancelable(false); + pd.show(); + + } + + @Override + protected String doInBackground(String... strings) { + + try { + + url=new URL("https://app-1503993646.000webhostapp.com/parentchild/signup.php"); + + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + try { + connection=(HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10000); + connection.setReadTimeout(15000); + connection.setDoInput(true); + connection.setDoOutput(true); + + Uri.Builder builder =new Uri.Builder(); + builder.appendQueryParameter("name",strings[0]); + builder.appendQueryParameter("addr",strings[1]); + builder.appendQueryParameter("gender",strings[2]); + builder.appendQueryParameter("phone",strings[3]); + builder.appendQueryParameter("mail",strings[4]); + + + + String query = builder.build().getEncodedQuery(); + + OutputStream os=connection.getOutputStream(); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8")); + writer.write(query); + writer.flush(); + writer.close(); + os.close(); + connection.connect(); + + int rc = connection.getResponseCode(); + if(rc == HTTP_OK) + { + InputStream inputStream = connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb=new StringBuilder(); + String line; + while ((line=reader.readLine())!=null) + { + sb.append(line); + } + return sb.toString(); + } + else + return "unsuccessfull"; + + } catch (IOException e1) { + e1.printStackTrace(); + return "Exception"; + } + + + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + pd.dismiss(); + if(s.equalsIgnoreCase("Success")) + { + startActivity(new Intent(SignUpActivity.this,LoginActivity.class)); + } + + else if (s.equalsIgnoreCase("exception") || s.equalsIgnoreCase("unsuccessful")) { + + Toast.makeText(SignUpActivity.this, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show(); + + } + else if(s.equals("Already registered")) + { + Toast.makeText(SignUpActivity.this,"You are already registered",Toast.LENGTH_LONG).show(); + } + else { + Toast.makeText(SignUpActivity.this, "Error!", Toast.LENGTH_SHORT).show(); + } + + } + } + +} diff --git a/app/src/main/java/com/example/wot/parentapp/SplashActivity.java b/app/src/main/java/com/example/wot/parentapp/SplashActivity.java new file mode 100644 index 0000000..062e285 --- /dev/null +++ b/app/src/main/java/com/example/wot/parentapp/SplashActivity.java @@ -0,0 +1,45 @@ +package com.example.wot.parentapp; + +import android.annotation.SuppressLint; +import android.content.Intent; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.os.Handler; +import android.view.MotionEvent; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; + +/** + * An example full-screen activity that shows and hides the system UI (i.e. + * status bar and navigation/system bar) with user interaction. + */ +public class SplashActivity extends AppCompatActivity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // remove title + requestWindowFeature(Window.FEATURE_NO_TITLE); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + setContentView(R.layout.activity_splash); + thread.start(); + } + Thread thread = new Thread(new Runnable(){ + + @Override + public void run() { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + finally { + startActivity(new Intent(SplashActivity.this,LoginActivity.class)); + finish(); + } + } + }); + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/backgroundgradient.xml b/app/src/main/res/drawable/backgroundgradient.xml new file mode 100644 index 0000000..9d01fcb --- /dev/null +++ b/app/src/main/res/drawable/backgroundgradient.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/circlebackground.xml b/app/src/main/res/drawable/circlebackground.xml new file mode 100644 index 0000000..27b74f3 --- /dev/null +++ b/app/src/main/res/drawable/circlebackground.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_delete_black_24dp.xml b/app/src/main/res/drawable/ic_delete_black_24dp.xml new file mode 100644 index 0000000..050330e --- /dev/null +++ b/app/src/main/res/drawable/ic_delete_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_edit_black_24dp.xml b/app/src/main/res/drawable/ic_edit_black_24dp.xml new file mode 100644 index 0000000..599a5e3 --- /dev/null +++ b/app/src/main/res/drawable/ic_edit_black_24dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_refresh_black_24dp.xml b/app/src/main/res/drawable/ic_refresh_black_24dp.xml new file mode 100644 index 0000000..bd204e7 --- /dev/null +++ b/app/src/main/res/drawable/ic_refresh_black_24dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/parentapp_logo.png b/app/src/main/res/drawable/parentapp_logo.png new file mode 100644 index 0000000..0b6e02c Binary files /dev/null and b/app/src/main/res/drawable/parentapp_logo.png differ diff --git a/app/src/main/res/layout/activity_battery.xml b/app/src/main/res/layout/activity_battery.xml new file mode 100644 index 0000000..5f8b9c7 --- /dev/null +++ b/app/src/main/res/layout/activity_battery.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/main/res/layout/activity_block_sites.xml b/app/src/main/res/layout/activity_block_sites.xml new file mode 100644 index 0000000..200ab00 --- /dev/null +++ b/app/src/main/res/layout/activity_block_sites.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + +