Skip to content
Snippets Groups Projects
Commit 9c9920e1 authored by viveksvdy2014's avatar viveksvdy2014
Browse files

Added First time run Instructions !

parent c4b4514f
No related branches found
No related tags found
No related merge requests found
package com.speedyapps.keepyousafe;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.annotation.MainThread;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
......@@ -14,12 +16,29 @@ import android.widget.ImageButton;
public class MainActivity extends AppCompatActivity {
Intent intent;
int choice;
SharedPreferences firsttime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firsttime = this.getSharedPreferences("firsttimecheck",MODE_PRIVATE);
SharedPreferences.Editor editor = firsttime.edit();
String checkString = firsttime.getString("status","false");
if(!checkString.equals("true")){
editor.putString("status","true");
editor.apply();
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.alert_dark_frame)
.setTitle("Instructions!")
.setMessage("How To Use : - \nStep 1 : - Add Trusted Contacts from your Existing Android Contacts to whom Distress Messages are to be Sent! \nStep 2 : - In Case of an Emergency, Open The App and Long Press The HELP Button! \nPlease Also Do the Following to Ensure Proper Functioning of the Application! \n1)If you have a Dual SIM phonw, Please set any one of them as default for sending SMS from settings > SIM cards! \n2) Add this app as an exception in any Task Killer apps if you are using any! \n3) Setup a PIN Code in the Next Screen for Security ! ")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.i("zz","OK");
}
}).show();
}
intent = new Intent(MainActivity.this,confirmationScreen.class);
choice=0;
Intent serviceIntent = new Intent(MainActivity.this,SMSReader.class);
......
......@@ -52,41 +52,33 @@ public class confirmationScreen extends AppCompatActivity {
handler.postDelayed(this,1000);
}
};
run2=new Runnable() {
@Override
public void run() {
if((!editText.getText().toString().equals("2020"))&&textView.getText().toString().equals("0")) {
distressCall();
}
else if(editText.getText().toString().equals("2020")){
if(editText.getText().toString().equals("2020")){
stopService(alarmIntent);
handler.removeCallbacks(run);
handler2.removeCallbacks(this);
Toast.makeText(confirmationScreen.this, "Distress Calls Cancelled!", Toast.LENGTH_SHORT).show();
Intent main = new Intent(confirmationScreen.this,MainActivity.class);
stopService(alarmIntent);
startActivity(main);
}
else if ((!editText.getText().toString().equals("2020")))
handler2.post(this);
else if(textView.getText().toString().equals("0")) {
distressCall();
handler2.postDelayed(this,100);
}
};
handler2.post(run2);
handler.post(run);
else
handler2.postDelayed(this,100);
}
public void onCancel(View view){
if((!editText.getText().toString().equals("2020"))&&textView.getText().toString().equals("0"))
distressCall();
else if(editText.getText().toString().equals("2020")){
handler.removeCallbacks(run);
Toast.makeText(this, "Cancelled Distress Signals!", Toast.LENGTH_SHORT).show();
Intent main = new Intent(confirmationScreen.this,MainActivity.class);
stopService(alarmIntent);
startActivity(main);
}
};
handler.post(run);
handler2.post(run2);
}
public void distressCall(){
startService(alarmIntent);
count = shared.getInt("count", 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment