diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..edfaff0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+
+androidkey.jks
diff --git a/src/app/src/main/AndroidManifest.xml b/src/app/src/main/AndroidManifest.xml
index 7c52a6e..ba193a4 100644
--- a/src/app/src/main/AndroidManifest.xml
+++ b/src/app/src/main/AndroidManifest.xml
@@ -12,7 +12,6 @@
-
= Build.VERSION_CODES.O) {
- v.vibrate(VibrationEffect.createWaveform(pattern, 0));
+ vibrator.vibrate(VibrationEffect.createWaveform(pattern, 0));
}
else{
- v.vibrate(pattern,0);
+ vibrator.vibrate(pattern,0);
}
}
private void stopRinging(){
ringtoneManager.stop();
- v.cancel();
- finishAffinity();
+ vibrator.cancel();
+ finishAndRemoveTask();
}
@Override
diff --git a/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java b/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java
index a9f3d96..1d9808a 100644
--- a/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java
+++ b/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java
@@ -59,4 +59,9 @@ public class Utils {
return String.valueOf(numberProto.getCountryCode());
}
+ // We'll remove parenthesis, dashes and whitespaces
+ public static String normalizePhoneNumber(String phoneNo){
+ return phoneNo.replaceAll("[-()\\s]", "");
+ }
+
}
diff --git a/src/app/src/main/java/com/xfarrow/locatemydevice/WhitelistContactsActivity.java b/src/app/src/main/java/com/xfarrow/locatemydevice/WhitelistContactsActivity.java
index abe4244..8b4f9f2 100644
--- a/src/app/src/main/java/com/xfarrow/locatemydevice/WhitelistContactsActivity.java
+++ b/src/app/src/main/java/com/xfarrow/locatemydevice/WhitelistContactsActivity.java
@@ -21,7 +21,7 @@ import java.util.ArrayList;
public class WhitelistContactsActivity extends AppCompatActivity {
private ListView contactsListView;
- private ArrayList contacts;
+ private ArrayList contactsListView_datasource;
private ArrayAdapter listviewAdapter;
private final WhitelistDbHandler whitelistDbHandler = new WhitelistDbHandler(this);
@@ -35,10 +35,10 @@ public class WhitelistContactsActivity extends AppCompatActivity {
setViews();
setListeners();
- contacts = whitelistDbHandler.getAllContacts();
+ contactsListView_datasource = whitelistDbHandler.getAllContacts();
listviewAdapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1,
- contacts);
+ contactsListView_datasource);
contactsListView.setAdapter(listviewAdapter);
}
@@ -58,9 +58,7 @@ public class WhitelistContactsActivity extends AppCompatActivity {
@Override
public boolean onItemLongClick(AdapterView> adapterView, View view, int i, long l) {
String number = (String)adapterView.getItemAtPosition(i);
- contacts.remove(number);
- listviewAdapter.notifyDataSetChanged();
- whitelistDbHandler.deleteContact(number);
+ removeNumberFromWhiteList(number);
return true;
}
});
@@ -98,23 +96,27 @@ public class WhitelistContactsActivity extends AppCompatActivity {
int phoneIndex = c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
int contactNameIndex = c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
String number = c.getString(phoneIndex);
- String contactName = c.getString(contactNameIndex);
- contactSelected(number);
+ String contactName = c.getString(contactNameIndex); // planned to show contact's name as well
+ addNumberToWhiteList(number);
}
c.close();
}
}
- private void contactSelected(String phoneNo){
- // We'll replace parenthesis, dashes and whitespaces to obtain a valid phone number
- phoneNo = phoneNo.replaceAll("[-()\\s]", "");
-
- if(contacts.contains(phoneNo)){
+ private void addNumberToWhiteList(String phoneNo){
+ phoneNo = Utils.normalizePhoneNumber(phoneNo);
+ if(contactsListView_datasource.contains(phoneNo)){
Toast.makeText(this, "Contact already in the list", Toast.LENGTH_SHORT).show();
return;
}
whitelistDbHandler.addContact(phoneNo);
- contacts.add(phoneNo);
+ contactsListView_datasource.add(phoneNo);
+ listviewAdapter.notifyDataSetChanged();
+ }
+
+ private void removeNumberFromWhiteList(String phoneNo){
+ whitelistDbHandler.deleteContact(phoneNo);
+ contactsListView_datasource.remove(phoneNo);
listviewAdapter.notifyDataSetChanged();
}
}
\ No newline at end of file