diff --git a/Examples/restcomm-helloworld/app/app.iml b/Examples/restcomm-helloworld/app/app.iml
index 5bb2771e..a592b701 100644
--- a/Examples/restcomm-helloworld/app/app.iml
+++ b/Examples/restcomm-helloworld/app/app.iml
@@ -76,19 +76,14 @@
-
-
-
-
-
diff --git a/Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java b/Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java
index 2fd2629d..6168cace 100644
--- a/Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java
+++ b/Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java
@@ -60,7 +60,7 @@
//import org.webrtc.VideoRendererGui;
//import org.webrtc.VideoTrack;
-public class MainActivity extends Activity implements RCDeviceListener, RCConnectionListener, OnClickListener,
+public class =MainActivity extends Activity implements RCDeviceListener, RCConnectionListener, OnClickListener,
ServiceConnection {
private RCDevice device;
diff --git a/Examples/restcomm-olympus/.idea/codeStyleSettings.xml b/Examples/restcomm-olympus/.idea/codeStyleSettings.xml
new file mode 100644
index 00000000..719bb8bc
--- /dev/null
+++ b/Examples/restcomm-olympus/.idea/codeStyleSettings.xml
@@ -0,0 +1,228 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+ ^$
+
+
+
+
+
+
+
+
+ style
+ ^$
+
+
+
+
+
+
+
+
+ .*
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:layout_width
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:layout_height
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:layout_.*
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:width
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:height
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/restcomm-olympus/.idea/inspectionProfiles/Project_Default.xml b/Examples/restcomm-olympus/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..a6cb5d59
--- /dev/null
+++ b/Examples/restcomm-olympus/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/restcomm-olympus/.idea/inspectionProfiles/profiles_settings.xml b/Examples/restcomm-olympus/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..3b312839
--- /dev/null
+++ b/Examples/restcomm-olympus/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/restcomm-olympus/.idea/misc.xml b/Examples/restcomm-olympus/.idea/misc.xml
index fbb68289..5d199810 100644
--- a/Examples/restcomm-olympus/.idea/misc.xml
+++ b/Examples/restcomm-olympus/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/Examples/restcomm-olympus/app/app.iml b/Examples/restcomm-olympus/app/app.iml
index 2d848d21..ee5e2512 100644
--- a/Examples/restcomm-olympus/app/app.iml
+++ b/Examples/restcomm-olympus/app/app.iml
@@ -62,13 +62,6 @@
-
-
-
-
-
-
-
@@ -76,6 +69,13 @@
+
+
+
+
+
+
+
diff --git a/Examples/restcomm-olympus/app/src/main/AndroidManifest.xml b/Examples/restcomm-olympus/app/src/main/AndroidManifest.xml
index 5c519174..fe1579d5 100644
--- a/Examples/restcomm-olympus/app/src/main/AndroidManifest.xml
+++ b/Examples/restcomm-olympus/app/src/main/AndroidManifest.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/AddUserDialogFragment.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/AddUserDialogFragment.java
index d06265a0..8ff3865a 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/AddUserDialogFragment.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/AddUserDialogFragment.java
@@ -22,15 +22,31 @@
package org.restcomm.android.olympus;
+import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
+import android.app.ProgressDialog;
import android.content.DialogInterface;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.os.AsyncTask;
import android.os.Bundle;
+import android.provider.ContactsContract;
+import android.support.annotation.NonNull;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatDialogFragment;
import android.view.View;
+import android.widget.Button;
import android.widget.EditText;
+import android.widget.Toast;
+
+import org.apache.log4j.chainsaw.Main;
+
+import java.util.ArrayList;
+import java.util.Map;
import static org.restcomm.android.olympus.ContactsController.CONTACT_KEY;
import static org.restcomm.android.olympus.ContactsController.CONTACT_VALUE;
@@ -38,11 +54,17 @@
public class AddUserDialogFragment extends AppCompatDialogFragment {
public static final int DIALOG_TYPE_ADD_CONTACT = 0;
public static final int DIALOG_TYPE_UPDATE_CONTACT = 1;
- EditText txtUsername;
- EditText txtSipuri;
+
+ private ArrayList> contactList;
// Use this instance of the interface to deliver action events
ContactDialogListener listener;
+ private static final int MY_PERMISSIONS_REQUEST_READ_CONTACTS = 56;
+ //Defining Button and EditText variables
+ public Button buttonImportUsers;
+ EditText txtUsername;
+ EditText txtSipuri;
+ boolean permissionsStatus = false;
/* The activity that creates an instance of this dialog fragment must
* implement this interface in order to receive event callbacks.
@@ -57,8 +79,7 @@ public interface ContactDialogListener {
* Create a new instance of MyDialogFragment, providing "num"
* as an argument.
*/
- public static AddUserDialogFragment newInstance(int type, String username, String sipuri)
- {
+ public static AddUserDialogFragment newInstance(int type, String username, String sipuri) {
AddUserDialogFragment f = new AddUserDialogFragment();
// Supply num input as an argument.
@@ -75,31 +96,27 @@ public static AddUserDialogFragment newInstance(int type, String username, Strin
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
@Override
- public void onAttach(Activity activity)
- {
+ public void onAttach(Activity activity) {
super.onAttach(activity);
// Verify that the host activity implements the callback interface
try {
// Instantiate the NoticeDialogListener so we can send events to the host
listener = (ContactDialogListener) activity;
- }
- catch (ClassCastException e) {
+ } catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
- + " must implement ContactDialogListener");
+ + " must implement ContactDialogListener");
}
}
@Override
- public void onDetach()
- {
+ public void onDetach() {
super.onDetach();
listener = null;
}
@Override
- public void onCreate(Bundle savedInstanceState)
- {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@@ -119,12 +136,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Notice that for this doesn't work if onCreateView has been overriden as described above. To add
// custom view when using alert we need to use builder.setView() as seen below
@Override
- public Dialog onCreateDialog(Bundle savedInstanceState)
- {
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
// Get the layout inflater
View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_dialog_add_contact, null);
txtUsername = (EditText) view.findViewById(R.id.editText_username);
txtSipuri = (EditText) view.findViewById(R.id.editText_sipuri);
+ buttonImportUsers = (Button) view.findViewById(R.id.button_contactFromPhone);
String title = "Add Contact";
String positiveText = "Add";
@@ -138,29 +155,129 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
txtUsername.setEnabled(false);
}
+ buttonImportUsers.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ importContacts();
+ }
+ });
+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
+ //Checking if we have the permission to read contacts when the dialog gets invoked
+
+
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(view)
- .setTitle(title)
- .setPositiveButton(positiveText,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton)
- {
- listener.onDialogPositiveClick(getArguments().getInt("type"), txtUsername.getText().toString(),
- txtSipuri.getText().toString());
- }
- }
- )
- .setNegativeButton("Cancel",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton)
- {
- listener.onDialogNegativeClick();
- }
- }
- );
+ .setTitle(title)
+ .setPositiveButton(positiveText,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ listener.onDialogPositiveClick(getArguments().getInt("type"), txtUsername.getText().toString(),
+ txtSipuri.getText().toString());
+ }
+ }
+ )
+ .setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ listener.onDialogNegativeClick();
+ }
+ }
+ );
return builder.create();
+
+
+ }
+
+ public AddUserDialogFragment() {
+ super();
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+
+
+ switch (requestCode) {
+ case MY_PERMISSIONS_REQUEST_READ_CONTACTS: {
+ // If request is cancelled, the result arrays are empty.
+ if (grantResults.length > 0
+ && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+
+ importContacts();
+ } else {
+
+ Toast.makeText(getContext(), "Please provide the permissions to proceed", Toast.LENGTH_SHORT).show();
+ }
+ return;
+ }
+
+ // other 'case' lines to check for other
+ // permissions this app might request
+ }
}
+
+
+ /*
+ *Method used to import Phone contacts into the app
+ */
+
+ private void importContacts() {
+
+ if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
+
+ requestPermissions(new String[]{Manifest.permission.READ_CONTACTS},
+ MY_PERMISSIONS_REQUEST_READ_CONTACTS);
+
+
+ } else {
+
+
+ //Calling in the ContactAdapter Sub-class of MainFragment and passing the constructor and ArrayList to it
+ MainFragment.ContactAdapter contactAdapter = new MainFragment().new ContactAdapter(getContext(), contactList);
+ //Defining a cursor to query each value of the CONTENT_URI Column
+ final Cursor phones = getContext().getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
+ final ContactsController contactsController = new ContactsController(getContext());
+ //retrieving the contacts in Olympus's Table in an ArrayList
+ contactList = contactsController.retrieveContacts();
+
+ final ProgressDialog progressDialog = ProgressDialog.show(getContext(), "Loading", "Importing the contacts", true);
+
+ //Initiating a background thread as we don't wanna slow down the UI Thread :)
+ AsyncTask.execute(new Runnable() {
+ @Override
+ public void run() {
+
+ while (phones.moveToNext()) {
+
+
+ String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
+ String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
+
+ try {
+ //Adding the instantaneous Phone contact to the db and Notifying the view that A value has been added
+ contactsController.addContact(contactList, name, phoneNumber);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ //TODO: Fix the bug to update the Contact's list without destroying the lifeCycle
+
+ }
+
+
+ progressDialog.dismiss();
+
+ }
+ });
+ contactAdapter.notifyDataSetChanged();
+ }
+
+
+ }
+
+
}
\ No newline at end of file
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseContract.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseContract.java
index c3e58fa9..eea455c1 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseContract.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseContract.java
@@ -40,7 +40,9 @@ public class DatabaseVersions {
public static final int DB_VERSION_GROUND_ZERO = 14;
// Introducing delivery status field and SimpleCursorAdapter (issue #568)
public static final int DB_VERSION_DELIVERY_STATUS = 15;
- };
+ }
+
+ ;
public enum MessageDeliveryStatus {
TEXT_MESSAGE_PENDING, // 0
@@ -48,6 +50,15 @@ public enum MessageDeliveryStatus {
TEXT_MESSAGE_FAILED, // 2
}
+ public static abstract class AccountEntry implements BaseColumns {
+
+ public static final String TABLE_NAME_ACCOUNTS = "accounts";
+ public static final String COLUMN_NAME_ACCOUNTS_USERNAME = "username";
+ public static final String COLUMN_NAME_ACCOUNTS_PASSWORD = "password";
+ public static final String COLUMN_NAME_ACCOUNTS_DOMAIN = "domain";
+
+ }
+
// Inner class that defines the table contents
public static abstract class ContactEntry implements BaseColumns {
public static final String TABLE_NAME = "contact";
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseHelper.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseHelper.java
index c5c7bd60..a9eacb7c 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseHelper.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseHelper.java
@@ -24,9 +24,11 @@
import android.content.ContentValues;
import android.content.Context;
+import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
+
import org.restcomm.android.olympus.DatabaseContract.DatabaseVersions;
public class DatabaseHelper extends SQLiteOpenHelper {
@@ -36,27 +38,37 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "DatabaseHelper";
+ public static final String DATABASE_NAME_ACCOUNTS = "Olympus_Accounts.db";
+
//private static final String TEXT_TYPE = " TEXT";
//private static final String COMMA_SEP = ",";
private static final String SQL_CREATE_CONTACT_TABLE =
- "CREATE TABLE " + DatabaseContract.ContactEntry.TABLE_NAME + " (" +
- DatabaseContract.ContactEntry._ID + " INTEGER PRIMARY KEY," +
- DatabaseContract.ContactEntry.COLUMN_NAME_NAME + " TEXT NOT NULL UNIQUE, " +
- DatabaseContract.ContactEntry.COLUMN_NAME_URI + " TEXT NOT NULL" +
- " );";
+ "CREATE TABLE " + DatabaseContract.ContactEntry.TABLE_NAME + " (" +
+ DatabaseContract.ContactEntry._ID + " INTEGER PRIMARY KEY," +
+ DatabaseContract.ContactEntry.COLUMN_NAME_NAME + " TEXT NOT NULL UNIQUE, " +
+ DatabaseContract.ContactEntry.COLUMN_NAME_URI + " TEXT NOT NULL" +
+ " );";
+
+
+ public static final String SQL_CREATE_ACCOUNTS_TABLE =
+ "CREATE TABLE " + DatabaseContract.AccountEntry.TABLE_NAME_ACCOUNTS + " (" +
+ DatabaseContract.AccountEntry._ID + " INTEGER PRIMARY KEY," +
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_USERNAME + " TEXT NOT NULL UNIQUE, " +
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_PASSWORD + " TEXT NOT NULL, " +
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_DOMAIN + " TEXT NOT NULL );";
private static final String SQL_CREATE_MESSAGE_TABLE =
- "CREATE TABLE " + DatabaseContract.MessageEntry.TABLE_NAME + " (" +
- DatabaseContract.MessageEntry._ID + " INTEGER PRIMARY KEY," +
- DatabaseContract.MessageEntry.COLUMN_NAME_CONTACT_ID + " INTEGER, " +
- DatabaseContract.MessageEntry.COLUMN_NAME_JOB_ID + " TEXT, " +
- DatabaseContract.MessageEntry.COLUMN_NAME_TEXT + " TEXT NOT NULL, " +
- DatabaseContract.MessageEntry.COLUMN_NAME_TYPE + " TEXT NOT NULL, " +
- DatabaseContract.MessageEntry.COLUMN_NAME_TIMESTAMP + " DATETIME DEFAULT CURRENT_TIMESTAMP, " +
- DatabaseContract.MessageEntry.COLUMN_NAME_DELIVERY_STATUS + " INTEGER DEFAULT 1, " + // using default of 'success', so that DB upgrades work smoothly
- "FOREIGN KEY (" + DatabaseContract.MessageEntry.COLUMN_NAME_CONTACT_ID + ") REFERENCES " + DatabaseContract.ContactEntry.TABLE_NAME +
- "(" + DatabaseContract.ContactEntry._ID + ") " +
- " );";
+ "CREATE TABLE " + DatabaseContract.MessageEntry.TABLE_NAME + " (" +
+ DatabaseContract.MessageEntry._ID + " INTEGER PRIMARY KEY," +
+ DatabaseContract.MessageEntry.COLUMN_NAME_CONTACT_ID + " INTEGER, " +
+ DatabaseContract.MessageEntry.COLUMN_NAME_JOB_ID + " TEXT, " +
+ DatabaseContract.MessageEntry.COLUMN_NAME_TEXT + " TEXT NOT NULL, " +
+ DatabaseContract.MessageEntry.COLUMN_NAME_TYPE + " TEXT NOT NULL, " +
+ DatabaseContract.MessageEntry.COLUMN_NAME_TIMESTAMP + " DATETIME DEFAULT CURRENT_TIMESTAMP, " +
+ DatabaseContract.MessageEntry.COLUMN_NAME_DELIVERY_STATUS + " INTEGER DEFAULT 1, " + // using default of 'success', so that DB upgrades work smoothly
+ "FOREIGN KEY (" + DatabaseContract.MessageEntry.COLUMN_NAME_CONTACT_ID + ") REFERENCES " + DatabaseContract.ContactEntry.TABLE_NAME +
+ "(" + DatabaseContract.ContactEntry._ID + ") " +
+ " );";
// Upgrades statements
private static final String SQL_UPGRADE_GROUND_ZERO_2_DELIVERY_STATUS_MESSAGES_1 =
@@ -68,22 +80,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String SQL_DELETE_CONTACT_ENTRIES =
- "DROP TABLE IF EXISTS " + DatabaseContract.ContactEntry.TABLE_NAME;
+ "DROP TABLE IF EXISTS " + DatabaseContract.ContactEntry.TABLE_NAME;
private static final String SQL_DELETE_MESSAGE_ENTRIES =
- "DROP TABLE IF EXISTS " + DatabaseContract.MessageEntry.TABLE_NAME;
+ "DROP TABLE IF EXISTS " + DatabaseContract.MessageEntry.TABLE_NAME;
// Android context
Context context;
- public DatabaseHelper(Context context)
- {
+ public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
Log.i(TAG, "DatabaseHelper constructor");
this.context = context;
}
- public void onCreate(SQLiteDatabase db)
- {
+ public void onCreate(SQLiteDatabase db) {
Log.i(TAG, "Creating table contact: " + SQL_CREATE_CONTACT_TABLE);
db.execSQL(SQL_CREATE_CONTACT_TABLE);
Log.i(TAG, "Creating table message: " + SQL_CREATE_MESSAGE_TABLE);
@@ -93,12 +103,11 @@ public void onCreate(SQLiteDatabase db)
// Perform any updates if necessary. Remember that as more upgrade points get added we need to make sure that depending
// on the oldVersion all intermediate upgrades need to be applied
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
- {
- Log.i(TAG, "onUpgrade from: "+ oldVersion + ", to: " + newVersion);
- switch(oldVersion) {
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ Log.i(TAG, "onUpgrade from: " + oldVersion + ", to: " + newVersion);
+ switch (oldVersion) {
case DatabaseVersions.DB_VERSION_GROUND_ZERO:
- if (newVersion== DatabaseVersions.DB_VERSION_DELIVERY_STATUS) {
+ if (newVersion == DatabaseVersions.DB_VERSION_DELIVERY_STATUS) {
// we need to alter message table to add job_id and delivery status columns
Log.i(TAG, "Upgrading table messages: " + DatabaseContract.MessageEntry.TABLE_NAME);
Log.d(TAG, "Applying SQL command: " + SQL_UPGRADE_GROUND_ZERO_2_DELIVERY_STATUS_MESSAGES_1);
@@ -106,8 +115,8 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
Log.d(TAG, "Applying SQL command: " + SQL_UPGRADE_GROUND_ZERO_2_DELIVERY_STATUS_MESSAGES_2);
db.execSQL(SQL_UPGRADE_GROUND_ZERO_2_DELIVERY_STATUS_MESSAGES_2);
}
- //case DatabaseVersions.DB_VERSION_DELIVERY_STATUS:
- // ;
+ //case DatabaseVersions.DB_VERSION_DELIVERY_STATUS:
+ // ;
}
//db.execSQL(SQL_DELETE_CONTACT_ENTRIES);
@@ -115,21 +124,19 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
//onCreate(db);
}
- public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion)
- {
+ public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onUpgrade(db, oldVersion, newVersion);
}
// ---- Helpers
// Populate DB with sample contacts, targeting Restcomm sample applications
- private void populateSampleEntries(SQLiteDatabase db)
- {
+ private void populateSampleEntries(SQLiteDatabase db) {
// TODO: used to get exceptions when using this
// Gets the data repository in write mode
//SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
- for (String s: context.getResources().getStringArray(R.array.demo_apps)) {
+ for (String s : context.getResources().getStringArray(R.array.demo_apps)) {
String[] parts = s.split(", *");
String name = parts[0];
String uri = parts[1];
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseManager.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseManager.java
index e11aa519..2e7952d4 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseManager.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/DatabaseManager.java
@@ -34,37 +34,32 @@
import java.util.Map;
// Provides access to DB facilities
-class DatabaseManager {
+public class DatabaseManager {
private static DatabaseManager instance = new DatabaseManager();
private static DatabaseHelper databaseHelper = null;
private static final String TAG = "DatabaseManager";
- public static DatabaseManager getInstance()
- {
+ public static DatabaseManager getInstance() {
return instance;
}
- private DatabaseManager()
- {
+ public DatabaseManager() {
}
// Before we can use Database manager we need to first call open() and pass Android context
- public void open(Context context)
- {
+ public void open(Context context) {
if (databaseHelper == null) {
Log.i(TAG, "Database hasn't been opened; opening now");
// If this turns out to be slow, we might have to put it to background thread (AsyncTask, etc), but I think data are too little to cause us trouble
databaseHelper = new DatabaseHelper(context);
- }
- else {
+ } else {
Log.w(TAG, "Database is already open");
}
}
// ---- Contacts table
// Retrieve all contact entries from DB and return them
- ArrayList> retrieveContacts()
- {
+ ArrayList> retrieveContacts() {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened yet, please call open()");
}
@@ -75,22 +70,23 @@ ArrayList> retrieveContacts()
// Define a projection that specifies which columns from the database
// you will actually use after this query.
String[] columns = {
- DatabaseContract.ContactEntry.COLUMN_NAME_NAME,
- DatabaseContract.ContactEntry.COLUMN_NAME_URI,
+ DatabaseContract.ContactEntry.COLUMN_NAME_NAME,
+ DatabaseContract.ContactEntry.COLUMN_NAME_URI,
};
+
// How you want the results sorted in the resulting Cursor
//String sortOrder = DatabaseContract.ContactEntry.COLUMN_NAME_NAME + " ASC";
SQLiteDatabase db = databaseHelper.getReadableDatabase();
Cursor cursor = db.query(
- DatabaseContract.ContactEntry.TABLE_NAME, // The table to query
- columns, // The columns to return
- null, // The columns for the WHERE clause
- null, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- null // don't sort the results
+ DatabaseContract.ContactEntry.TABLE_NAME, // The table to query
+ columns, // The columns to return
+ null, // The columns for the WHERE clause
+ null, // The values for the WHERE clause
+ null, // don't group the rows
+ null, // don't filter by row groups
+ null // don't sort the results
);
ArrayList> contactList = new ArrayList>();
@@ -100,7 +96,7 @@ ArrayList> retrieveContacts()
// iterate the rows, read from db and populate contactList
do {
contactList.add(createContactEntry(cursor.getString(cursor.getColumnIndexOrThrow(DatabaseContract.ContactEntry.COLUMN_NAME_NAME)),
- cursor.getString(cursor.getColumnIndexOrThrow(DatabaseContract.ContactEntry.COLUMN_NAME_URI))));
+ cursor.getString(cursor.getColumnIndexOrThrow(DatabaseContract.ContactEntry.COLUMN_NAME_URI))));
} while (cursor.moveToNext());
}
cursor.close();
@@ -108,8 +104,26 @@ ArrayList> retrieveContacts()
return contactList;
}
- public void addContact(String name, String uri) throws SQLException
- {
+ //Method for adding account details to accounts.db
+ public void addAccount(String username, String password, String domain) throws SQLException {
+
+ if (databaseHelper == null) {
+
+ throw new RuntimeException("Retry");
+ }
+
+ SQLiteDatabase sqLiteDatabase = databaseHelper.getWritableDatabase();
+ ContentValues contentValues = new ContentValues();
+
+ contentValues.put(DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_USERNAME, username);
+ contentValues.put(DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_PASSWORD, password);
+ contentValues.put(DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_DOMAIN, domain);
+
+ sqLiteDatabase.insertOrThrow(DatabaseContract.AccountEntry.TABLE_NAME_ACCOUNTS, null, contentValues);
+
+ }
+
+ public void addContact(String name, String uri) throws SQLException {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened.");
}
@@ -129,8 +143,7 @@ public void addContact(String name, String uri) throws SQLException
* Add contact if it doesn't exist already.
* @return true if contact didn't exist (and hence was added), false if it existed
*/
- public boolean addContactIfNeded(String uri)
- {
+ public boolean addContactIfNeded(String uri) {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened.");
}
@@ -158,8 +171,7 @@ public boolean addContactIfNeded(String uri)
// Important: currently contactName passed by Application is in reality the user part of the sipuri, so to match a contact entry
// we try with COLUMN_NAME_URI, not COLUMN_NAME_NAME
- private int getContactIdFromName(String contactName)
- {
+ private int getContactIdFromName(String contactName) {
Cursor cursor = getContactFromName(contactName);
/*
@@ -189,16 +201,14 @@ private int getContactIdFromName(String contactName)
if (cursor.moveToFirst()) {
int contactId = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseContract.ContactEntry._ID));
return contactId;
- }
- else {
+ } else {
return -1;
}
}
// Important: currently contactName passed by Application is in reality the user part of the sipuri, so to match a contact entry
// we try with COLUMN_NAME_URI, not COLUMN_NAME_NAME
- private Cursor getContactFromName(String contactName)
- {
+ private Cursor getContactFromName(String contactName) {
// Only interested in the ID
/*
String[] columns = {
@@ -208,25 +218,24 @@ private Cursor getContactFromName(String contactName)
// Add the WHERE clause
String selection = DatabaseContract.ContactEntry.COLUMN_NAME_URI + " LIKE ?";
- String[] selectionArgs = { "%" + contactName + "%"};
+ String[] selectionArgs = {"%" + contactName + "%"};
SQLiteDatabase db = databaseHelper.getReadableDatabase();
Cursor cursor = db.query(
- DatabaseContract.ContactEntry.TABLE_NAME, // The table to query
- null, // The columns to return (all)
- selection, // The columns for the WHERE clause
- selectionArgs, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- null, // don't sort the results
- "1" // only keep one entry
+ DatabaseContract.ContactEntry.TABLE_NAME, // The table to query
+ null, // The columns to return (all)
+ selection, // The columns for the WHERE clause
+ selectionArgs, // The values for the WHERE clause
+ null, // don't group the rows
+ null, // don't filter by row groups
+ null, // don't sort the results
+ "1" // only keep one entry
);
return cursor;
}
- private Cursor getContactFromUri(String uri)
- {
+ private Cursor getContactFromUri(String uri) {
// Only interested in the ID
/*
String[] columns = {
@@ -236,26 +245,25 @@ private Cursor getContactFromUri(String uri)
// Add the WHERE clause
String selection = DatabaseContract.ContactEntry.COLUMN_NAME_URI + " LIKE ?";
- String[] selectionArgs = { uri };
+ String[] selectionArgs = {uri};
SQLiteDatabase db = databaseHelper.getReadableDatabase();
Cursor cursor = db.query(
- DatabaseContract.ContactEntry.TABLE_NAME, // The table to query
- null, // The columns to return (all)
- selection, // The columns for the WHERE clause
- selectionArgs, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- null, // don't sort the results
- "1" // only keep one entry
+ DatabaseContract.ContactEntry.TABLE_NAME, // The table to query
+ null, // The columns to return (all)
+ selection, // The columns for the WHERE clause
+ selectionArgs, // The values for the WHERE clause
+ null, // don't group the rows
+ null, // don't filter by row groups
+ null, // don't sort the results
+ "1" // only keep one entry
);
return cursor;
}
// Updates contact in DB. Returns -1 if contact is not found
- public int updateContact(String name, String uri)
- {
+ public int updateContact(String name, String uri) {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened.");
}
@@ -272,18 +280,18 @@ public int updateContact(String name, String uri)
// Add the WHERE clause
String selection = DatabaseContract.ContactEntry.COLUMN_NAME_NAME + " LIKE ?";
- String[] selectionArgs = { name };
+ String[] selectionArgs = {name};
int count = db.update(
- DatabaseContract.ContactEntry.TABLE_NAME,
- values,
- selection,
- selectionArgs);
+ DatabaseContract.ContactEntry.TABLE_NAME,
+ values,
+ selection,
+ selectionArgs);
if (count > 0) {
int i = 0;
ArrayList> allContacts = retrieveContacts();
- for (Map item: allContacts) {
+ for (Map item : allContacts) {
if (item.get("username").equals(name)) {
return i;
}
@@ -295,8 +303,7 @@ public int updateContact(String name, String uri)
}
// Removes contact from DB. Returns -1 if contact is not found
- public int removeContact(String name, String uri)
- {
+ public int removeContact(String name, String uri) {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened.");
}
@@ -304,7 +311,7 @@ public int removeContact(String name, String uri)
boolean found = false;
int i = 0;
ArrayList> allContacts = retrieveContacts();
- for (Map item: allContacts) {
+ for (Map item : allContacts) {
if (item.get("username").equals(name)) {
found = true;
break;
@@ -324,12 +331,12 @@ public int removeContact(String name, String uri)
// Add the WHERE clause
String selection = DatabaseContract.ContactEntry.COLUMN_NAME_NAME + " LIKE ?";
- String[] selectionArgs = { name };
+ String[] selectionArgs = {name};
int count = db.delete(
- DatabaseContract.ContactEntry.TABLE_NAME,
- selection,
- selectionArgs);
+ DatabaseContract.ContactEntry.TABLE_NAME,
+ selection,
+ selectionArgs);
if (count > 0) {
return i;
@@ -341,8 +348,7 @@ public int removeContact(String name, String uri)
// ---- Message table
// Retrieve all messages for a contact ordered by timestamp
//ArrayList> retrieveMessages(String contactName)
- Cursor retrieveMessages(String contactName)
- {
+ Cursor retrieveMessages(String contactName) {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened yet, please call open()");
}
@@ -350,14 +356,14 @@ Cursor retrieveMessages(String contactName)
SQLiteDatabase db = databaseHelper.getReadableDatabase();
// Add the WHERE clause
- String[] selectionArgs = { contactName };
+ String[] selectionArgs = {contactName};
// Here's an example: SELECT * FROM message INNER JOIN contact ON message.contact_id = contact._id WHERE contact.name LIKE ? ORDER BY timestamp ASC
String sqlQuery = "SELECT * FROM " + DatabaseContract.MessageEntry.TABLE_NAME + " INNER JOIN " +
- DatabaseContract.ContactEntry.TABLE_NAME + " ON message." + DatabaseContract.MessageEntry.COLUMN_NAME_CONTACT_ID + " = contact." +
- DatabaseContract.ContactEntry._ID + " " +
- "WHERE " + DatabaseContract.ContactEntry.TABLE_NAME + "." + DatabaseContract.ContactEntry.COLUMN_NAME_NAME + " LIKE ? " +
- "ORDER BY " + DatabaseContract.MessageEntry.COLUMN_NAME_TIMESTAMP + " ASC";
+ DatabaseContract.ContactEntry.TABLE_NAME + " ON message." + DatabaseContract.MessageEntry.COLUMN_NAME_CONTACT_ID + " = contact." +
+ DatabaseContract.ContactEntry._ID + " " +
+ "WHERE " + DatabaseContract.ContactEntry.TABLE_NAME + "." + DatabaseContract.ContactEntry.COLUMN_NAME_NAME + " LIKE ? " +
+ "ORDER BY " + DatabaseContract.MessageEntry.COLUMN_NAME_TIMESTAMP + " ASC";
Log.i(TAG, "Query String: " + sqlQuery);
Cursor cursor = db.rawQuery(sqlQuery, selectionArgs);
@@ -383,8 +389,7 @@ Cursor retrieveMessages(String contactName)
//return messageList;
}
- public void addMessage(String contactName, String messageText, boolean isLocal, String jobId, DatabaseContract.MessageDeliveryStatus deliveryStatus) throws SQLException
- {
+ public void addMessage(String contactName, String messageText, boolean isLocal, String jobId, DatabaseContract.MessageDeliveryStatus deliveryStatus) throws SQLException {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened.");
}
@@ -411,8 +416,7 @@ public void addMessage(String contactName, String messageText, boolean isLocal,
db.insertOrThrow(DatabaseContract.MessageEntry.TABLE_NAME, null, values);
}
- public void updateMessageStatus(String jobId, DatabaseContract.MessageDeliveryStatus deliveryStatus) throws SQLException
- {
+ public void updateMessageStatus(String jobId, DatabaseContract.MessageDeliveryStatus deliveryStatus) throws SQLException {
if (databaseHelper == null) {
throw new RuntimeException("Database hasn't been opened.");
}
@@ -427,7 +431,7 @@ public void updateMessageStatus(String jobId, DatabaseContract.MessageDeliverySt
// Add the WHERE clause
String selection = DatabaseContract.MessageEntry.COLUMN_NAME_JOB_ID + " LIKE ?";
- String[] selectionArgs = { jobId };
+ String[] selectionArgs = {jobId};
int count = db.update(
DatabaseContract.MessageEntry.TABLE_NAME,
@@ -437,21 +441,18 @@ public void updateMessageStatus(String jobId, DatabaseContract.MessageDeliverySt
}
// Helpers for adapters
- private HashMap createContactEntry(String name, String uri)
- {
+ private HashMap createContactEntry(String name, String uri) {
HashMap item = new HashMap();
item.put("username", name);
item.put("sipuri", uri);
return item;
}
- private HashMap createMessageEntry(String type, String name, String message)
- {
+ private HashMap createMessageEntry(String type, String name, String message) {
HashMap item = new HashMap();
if (type.equals("local")) {
item.put(MessageFragment.MESSAGE_CONTACT_KEY, "Me");
- }
- else {
+ } else {
item.put(MessageFragment.MESSAGE_CONTACT_KEY, name);
}
item.put(MessageFragment.MESSAGE_TEXT_KEY, message);
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainActivity.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainActivity.java
index e58fa7a5..7edb499c 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainActivity.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainActivity.java
@@ -22,6 +22,7 @@
package org.restcomm.android.olympus;
+import android.Manifest;
import android.app.AlertDialog;
import android.app.DialogFragment;
import android.content.ComponentCallbacks;
@@ -31,13 +32,18 @@
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.content.res.Configuration;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
@@ -45,6 +51,7 @@
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
+
import com.testfairy.TestFairy;
//import net.hockeyapp.android.CrashManager;
//import net.hockeyapp.android.UpdateManager;
@@ -60,14 +67,17 @@
import static org.restcomm.android.olympus.ContactsController.CONTACT_VALUE;
public class MainActivity extends AppCompatActivity
- implements MainFragment.Callbacks, RCDeviceListener,
- View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListener,
- AddUserDialogFragment.ContactDialogListener, ServiceConnection, ComponentCallbacks,
- ComponentCallbacks2 {
+ implements MainFragment.Callbacks, RCDeviceListener,
+ View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListener,
+ AddUserDialogFragment.ContactDialogListener, ServiceConnection, ComponentCallbacks,
+ ComponentCallbacks2 {
private RCDevice device = null;
boolean serviceBound = false;
+ //Defining Permissions int Constants
+ private static final int MY_PERMISSIONS_REQUEST_READ_CONTACTS = 56;
+
// DEBUG
//ArrayList list = new ArrayList<>();
@@ -79,13 +89,18 @@ public class MainActivity extends AppCompatActivity
private RCConnectivityStatus previousConnectivityStatus = RCConnectivityStatus.RCConnectivityStatusNone;
private static final String APP_VERSION = "Restcomm Android Olympus Client " + BuildConfig.VERSION_NAME + "#" + BuildConfig.VERSION_CODE; //"Restcomm Android Olympus Client 1.0.0-BETA4#20";
FloatingActionButton btnAdd;
+
+ //Defining SQLite related variables
+ DatabaseManager dbManager;
+ DatabaseHelper dbHelper;
+ SQLiteDatabase database;
+
public static String ACTION_DISCONNECTED_BACKGROUND = "org.restcomm.android.olympus.ACTION_DISCONNECTED_BACKGROUND";
private static final int CONNECTION_REQUEST = 1;
@Override
- protected void onCreate(Bundle savedInstanceState)
- {
+ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@@ -101,6 +116,9 @@ protected void onCreate(Bundle savedInstanceState)
// TODO set proper image at xhdpi with 48x48
toolbar.setNavigationIcon(R.drawable.bar_icon_24dp);
toolbar.setTitle(getTitle());
+ //Initialising DB related classes
+ dbHelper = new DatabaseHelper(this);
+ database = dbHelper.getWritableDatabase();
listFragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.item_list);
@@ -115,14 +133,14 @@ protected void onCreate(Bundle savedInstanceState)
// preferences
prefs.registerOnSharedPreferenceChangeListener(this);
+
// No longer needed, we'll change with toast
// set it to wifi by default to avoid the status message when starting with wifi
//previousConnectivityStatus = RCConnectivityStatus.RCConnectivityStatusWiFi;
}
@Override
- protected void onStart()
- {
+ protected void onStart() {
super.onStart();
// The activity is about to become visible.
Log.i(TAG, "%% onStart");
@@ -131,8 +149,7 @@ protected void onStart()
}
@Override
- protected void onResume()
- {
+ protected void onResume() {
super.onResume();
// The activity has become visible (it is now "resumed").
@@ -145,16 +162,36 @@ protected void onResume()
}
@Override
- protected void onPause()
- {
+ protected void onPause() {
super.onPause();
// Another activity is taking focus (this activity is about to be "paused").
Log.i(TAG, "%% onPause");
}
+ //
+ /*
+ public Cursor fetch() {
+
+ String[] columnsAccounts = {
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_USERNAME,
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_PASSWORD,
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_DOMAIN
+
+ };
+
+ Cursor cursor = database.query(DatabaseContract.AccountEntry.TABLE_NAME_ACCOUNTS, columnsAccounts, null, null, null, null, null);
+
+ if (cursor != null) {
+
+ cursor.moveToFirst();
+ }
+
+ return cursor;
+
+ }
+ */
@Override
- protected void onStop()
- {
+ protected void onStop() {
super.onStop();
// The activity is no longer visible (it is now "stopped")
Log.i(TAG, "%% onStop");
@@ -168,8 +205,7 @@ protected void onStop()
}
@Override
- protected void onDestroy()
- {
+ protected void onDestroy() {
super.onDestroy();
// The activity is about to be destroyed.
Log.i(TAG, "%% onDestroy");
@@ -195,21 +231,20 @@ private void unregisterManagers() {
}
*/
- public void onLowMemory()
- {
+ public void onLowMemory() {
Log.e(TAG, "onLowMemory");
}
+
@Override
- public void onTrimMemory(int level)
- {
+ public void onTrimMemory(int level) {
super.onTrimMemory(level);
Log.e(TAG, "onTrimMemory: " + level);
}
+
@Override
- public void onNewIntent(Intent intent)
- {
+ public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// We get this intent from CallActivity, when the App is in the background and the user has requested hangup via notification
@@ -221,8 +256,7 @@ public void onNewIntent(Intent intent)
// Callbacks for service binding, passed to bindService()
@Override
- public void onServiceConnected(ComponentName className, IBinder service)
- {
+ public void onServiceConnected(ComponentName className, IBinder service) {
Log.i(TAG, "%% onServiceConnected");
// We've bound to LocalService, cast the IBinder and get LocalService instance
RCDevice.RCDeviceBinder binder = (RCDevice.RCDeviceBinder) service;
@@ -258,8 +292,7 @@ public void onServiceConnected(ComponentName className, IBinder service)
if (device.getState() == RCDevice.DeviceState.OFFLINE) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorTextSecondary)));
- }
- else {
+ } else {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
handleExternalCall();
}
@@ -268,8 +301,7 @@ public void onServiceConnected(ComponentName className, IBinder service)
}
@Override
- public void onServiceDisconnected(ComponentName arg0)
- {
+ public void onServiceDisconnected(ComponentName arg0) {
Log.i(TAG, "%% onServiceDisconnected");
serviceBound = false;
}
@@ -278,8 +310,7 @@ public void onServiceDisconnected(ComponentName arg0)
* MainFragment Callbacks
*/
@Override
- public void onItemSelected(HashMap contact, MainFragment.ContactSelectionType type)
- {
+ public void onItemSelected(HashMap contact, MainFragment.ContactSelectionType type) {
Intent intent = new Intent(this, MessageActivity.class);
intent.setAction(MessageActivity.ACTION_OPEN_MESSAGE_SCREEN);
intent.putExtra(MessageActivity.EXTRA_CONTACT_NAME, contact.get(CONTACT_KEY));
@@ -290,8 +321,7 @@ public void onItemSelected(HashMap contact, MainFragment.Contact
//onActionClicked(ActionFragment.ActionType.ACTION_TYPE_VIDEO_CALL, contact.get(CONTACT_KEY), contact.get(CONTACT_VALUE));
}
- public void onContactUpdate(HashMap contact, int type)
- {
+ public void onContactUpdate(HashMap contact, int type) {
AddUserDialogFragment newFragment = AddUserDialogFragment.newInstance(AddUserDialogFragment.DIALOG_TYPE_UPDATE_CONTACT, contact.get(CONTACT_KEY), contact.get(CONTACT_VALUE));
newFragment.show(getSupportFragmentManager(), "dialog");
//newFragment.show(getFragmentManager(), "dialog");
@@ -308,13 +338,11 @@ public void onAccessoryClicked(HashMap contact)
/**
* Callbacks for AddUserDialogFragment
*/
- public void onDialogPositiveClick(int type, String username, String sipuri)
- {
+ public void onDialogPositiveClick(int type, String username, String sipuri) {
listFragment.updateContact(type, username, sipuri);
}
- public void onDialogNegativeClick()
- {
+ public void onDialogNegativeClick() {
}
@@ -350,8 +378,7 @@ public void onActionClicked(ActionFragment.ActionType action, String username, S
/**
* Main Activity onClick
*/
- public void onClick(View view)
- {
+ public void onClick(View view) {
if (view.getId() == R.id.imageButton_add) {
/* TODO: Issue #380: once we figure out the issue with the backgrounding we need to uncomment this, but also place it to a suitable place
Intent intent = new Intent(this, CallActivity.class);
@@ -377,36 +404,29 @@ public void onClick(View view)
/**
* RCDeviceListener callbacks
*/
- public void onStartListening(RCDevice device, RCDeviceListener.RCConnectivityStatus connectivityStatus)
- {
+ public void onStartListening(RCDevice device, RCDeviceListener.RCConnectivityStatus connectivityStatus) {
handleConnectivityUpdate(connectivityStatus, null);
}
- public void onStopListening(RCDevice device)
- {
+ public void onStopListening(RCDevice device) {
}
- public void onStopListening(RCDevice device, int errorCode, String errorText)
- {
+ public void onStopListening(RCDevice device, int errorCode, String errorText) {
if (errorCode == RCClient.ErrorCodes.SUCCESS.ordinal()) {
handleConnectivityUpdate(RCConnectivityStatus.RCConnectivityStatusNone, "RCDevice: " + errorText);
- }
- else {
+ } else {
handleConnectivityUpdate(RCConnectivityStatus.RCConnectivityStatusNone, "RCDevice Error: " + errorText);
}
}
- public void onInitialized(RCDevice device, RCDeviceListener.RCConnectivityStatus connectivityStatus, int statusCode, String statusText)
- {
+ public void onInitialized(RCDevice device, RCDeviceListener.RCConnectivityStatus connectivityStatus, int statusCode, String statusText) {
if (statusCode == RCClient.ErrorCodes.SUCCESS.ordinal()) {
handleConnectivityUpdate(connectivityStatus, "RCDevice successfully initialized, using: " + connectivityStatus);
- }
- else if (statusCode == RCClient.ErrorCodes.ERROR_DEVICE_NO_CONNECTIVITY.ordinal()) {
+ } else if (statusCode == RCClient.ErrorCodes.ERROR_DEVICE_NO_CONNECTIVITY.ordinal()) {
// This is not really an error, since if connectivity comes back the RCDevice will resume automatically
handleConnectivityUpdate(connectivityStatus, null);
- }
- else {
+ } else {
//Toast.makeText(getApplicationContext(), "RCDevice Initialization Error: " + statusText, Toast.LENGTH_LONG).show();
//showOkAlert("RCDevice Initialization Error", statusText);
//handleConnectivityUpdate(connectivityStatus, "RCDevice Initialization Error: " + statusText);
@@ -415,29 +435,24 @@ else if (statusCode == RCClient.ErrorCodes.ERROR_DEVICE_NO_CONNECTIVITY.ordinal(
}
- public void onInitializationError(int errorCode, String errorText)
- {
+ public void onInitializationError(int errorCode, String errorText) {
Toast.makeText(getApplicationContext(), "RCDevice Initialization Error: " + errorText, Toast.LENGTH_LONG).show();
}
- public void onReleased(RCDevice device, int statusCode, String statusText)
- {
+ public void onReleased(RCDevice device, int statusCode, String statusText) {
if (statusCode != RCClient.ErrorCodes.SUCCESS.ordinal()) {
//showOkAlert("RCDevice Release Error", statusText);
Toast.makeText(getApplicationContext(), "RCDevice Release Error: " + statusText, Toast.LENGTH_LONG).show();
- }
- else {
+ } else {
handleConnectivityUpdate(RCConnectivityStatus.RCConnectivityStatusNone, "RCDevice Released: " + statusText);
}
}
- public void onConnectivityUpdate(RCDevice device, RCConnectivityStatus connectivityStatus)
- {
+ public void onConnectivityUpdate(RCDevice device, RCConnectivityStatus connectivityStatus) {
handleConnectivityUpdate(connectivityStatus, null);
}
- public void handleConnectivityUpdate(RCConnectivityStatus connectivityStatus, String text)
- {
+ public void handleConnectivityUpdate(RCConnectivityStatus connectivityStatus, String text) {
if (text == null) {
if (connectivityStatus == RCConnectivityStatus.RCConnectivityStatusNone) {
text = "RCDevice connectivity change: Lost connectivity";
@@ -455,8 +470,7 @@ public void handleConnectivityUpdate(RCConnectivityStatus connectivityStatus, St
if (connectivityStatus == RCConnectivityStatus.RCConnectivityStatusNone) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorTextSecondary)));
- }
- else {
+ } else {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
handleExternalCall();
}
@@ -466,8 +480,7 @@ public void handleConnectivityUpdate(RCConnectivityStatus connectivityStatus, St
}
// Handle call issued by external App via CALL intent
- private void handleExternalCall()
- {
+ private void handleExternalCall() {
// We have connectivity (either wifi or cellular), check if we have any external call requests and service it
GlobalPreferences globalPreferences = new GlobalPreferences(getApplicationContext());
String externalCallUriString = globalPreferences.getExternalCallUri();
@@ -481,9 +494,8 @@ private void handleExternalCall()
//String normalized = externalCallUriString.replace("restcomm-sip", "sip");
// also replace '://' with ':' so that the SIP stack can understand it
//parsedUriString = normalized.replace("://", ":");
- parsedUriString = externalCallUriString.replace("restcomm-sip", "sip");
- }
- else {
+ parsedUriString = externalCallUriString.replace("restcomm-sip", "sip");
+ } else {
// either 'tel', 'restcomm-tel', 'client' or 'restcomm-client'. Return just the host part, like 'bob' or '1235' that the Restcomm SDK can handle
parsedUriString = externalCallUri.getSchemeSpecificPart();
}
@@ -498,18 +510,15 @@ private void handleExternalCall()
}
}
- public void onMessageSent(RCDevice device, int statusCode, String statusText, String jobId)
- {
+ public void onMessageSent(RCDevice device, int statusCode, String statusText, String jobId) {
}
- public boolean receivePresenceEvents(RCDevice device)
- {
+ public boolean receivePresenceEvents(RCDevice device) {
return false;
}
- public void onPresenceChanged(RCDevice device, RCPresenceEvent presenceEvent)
- {
+ public void onPresenceChanged(RCDevice device, RCPresenceEvent presenceEvent) {
}
@@ -517,14 +526,12 @@ public void onPresenceChanged(RCDevice device, RCPresenceEvent presenceEvent)
* Settings Menu callbacks
*/
@Override
- public void onConfigurationChanged(Configuration newConfig)
- {
+ public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
+ public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
@@ -532,8 +539,7 @@ public boolean onCreateOptionsMenu(Menu menu)
@Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
+ 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.
@@ -558,8 +564,7 @@ public boolean onOptionsItemSelected(MenuItem item)
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key)
- {
+ String key) {
}
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainFragment.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainFragment.java
index a2aa07af..e93e76cc 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainFragment.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/MainFragment.java
@@ -99,13 +99,11 @@ public interface Callbacks {
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
- public MainFragment()
- {
+ public MainFragment() {
}
@Override
- public void onCreate(Bundle savedInstanceState)
- {
+ public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "%% onCreate");
super.onCreate(savedInstanceState);
@@ -120,8 +118,7 @@ public void onCreate(Bundle savedInstanceState)
}
@Override
- public void onResume()
- {
+ public void onResume() {
Log.i(TAG, "%% onResume");
super.onResume();
@@ -132,13 +129,12 @@ public void onResume()
}
@Override
- public void onViewCreated(View view, Bundle savedInstanceState)
- {
+ public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// Restore the previously serialized activated item position.
if (savedInstanceState != null
- && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
+ && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
}
@@ -155,8 +151,7 @@ public void onViewCreated(View view, Bundle savedInstanceState)
}
@Override
- public void onAttach(Activity activity)
- {
+ public void onAttach(Activity activity) {
Log.i(TAG, "%% onCreate");
super.onAttach(activity);
@@ -169,8 +164,7 @@ public void onAttach(Activity activity)
}
@Override
- public void onDetach()
- {
+ public void onDetach() {
Log.i(TAG, "%% onCreate");
super.onDetach();
@@ -179,8 +173,7 @@ public void onDetach()
}
@Override
- public void onListItemClick(ListView listView, View view, int position, long id)
- {
+ public void onListItemClick(ListView listView, View view, int position, long id) {
super.onListItemClick(listView, view, position, id);
HashMap item = (HashMap) getListView().getItemAtPosition(position);
@@ -190,8 +183,7 @@ public void onListItemClick(ListView listView, View view, int position, long id)
}
@Override
- public void onSaveInstanceState(Bundle outState)
- {
+ public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (mActivatedPosition != ListView.INVALID_POSITION) {
// Serialize and persist the activated item position.
@@ -203,21 +195,18 @@ public void onSaveInstanceState(Bundle outState)
* Turns on activate-on-click mode. When this mode is on, list items will be
* given the 'activated' state when touched.
*/
- public void setActivateOnItemClick(boolean activateOnItemClick)
- {
+ public void setActivateOnItemClick(boolean activateOnItemClick) {
// When setting CHOICE_MODE_SINGLE, ListView will automatically
// give items the 'activated' state when touched.
getListView().setChoiceMode(activateOnItemClick
- ? ListView.CHOICE_MODE_SINGLE
- : ListView.CHOICE_MODE_NONE);
+ ? ListView.CHOICE_MODE_SINGLE
+ : ListView.CHOICE_MODE_NONE);
}
- private void setActivatedPosition(int position)
- {
+ private void setActivatedPosition(int position) {
if (position == ListView.INVALID_POSITION) {
getListView().setItemChecked(mActivatedPosition, false);
- }
- else {
+ } else {
getListView().setItemChecked(position, true);
}
@@ -226,8 +215,7 @@ private void setActivatedPosition(int position)
// Context Menu stuff
@Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
- {
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (v.getId() == android.R.id.list) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
@@ -241,8 +229,7 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMen
}
@Override
- public boolean onContextItemSelected(MenuItem item)
- {
+ public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
HashMap contact = (HashMap) contactList.get(info.position);
@@ -258,24 +245,20 @@ public boolean onContextItemSelected(MenuItem item)
}
// Called by Activity when contact is to be updated
- public void updateContact(int type, String username, String sipuri)
- {
+ public void updateContact(int type, String username, String sipuri) {
if (type == AddUserDialogFragment.DIALOG_TYPE_ADD_CONTACT) {
if (username.isEmpty() || sipuri.isEmpty()) {
showOkAlert("Addition Cancelled", "Both Username and SIP URI fields must be provided");
return;
- }
- else {
+ } else {
try {
this.contactsController.addContact(contactList, username, sipuri);
- }
- catch (Exception e) {
+ } catch (Exception e) {
showOkAlert("Failed to add contact", e.getMessage());
return;
}
}
- }
- else {
+ } else {
if (this.contactsController.updateContact(contactList, username, sipuri) == -1) {
// no contact was updated, no need to upate listAdapter
return;
@@ -295,14 +278,12 @@ public void onAccessoryClick(int position)
*/
// Helper methods
- private void showOkAlert(final String title, final String detail)
- {
+ private void showOkAlert(final String title, final String detail) {
AlertDialog alertDialog = new AlertDialog.Builder(getActivity(), R.style.SimpleAlertStyle).create();
alertDialog.setTitle(title);
alertDialog.setMessage(detail);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which)
- {
+ public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
@@ -314,34 +295,29 @@ public class ContactAdapter extends BaseAdapter {
private ArrayList> contactList;
private ContactAdapterListener listener;
- public ContactAdapter(Context context, ArrayList> contactList)
- {
+ public ContactAdapter(Context context, ArrayList> contactList) {
mInflater = LayoutInflater.from(context);
this.contactList = contactList;
//this.listener = listener;
}
@Override
- public int getCount()
- {
+ public int getCount() {
return contactList.size();
}
@Override
- public Object getItem(int position)
- {
+ public Object getItem(int position) {
return contactList.get(position);
}
@Override
- public long getItemId(int position)
- {
+ public long getItemId(int position) {
return position;
}
@Override
- public View getView(int position, View convertView, ViewGroup parent)
- {
+ public View getView(int position, View convertView, ViewGroup parent) {
View view;
ViewHolder holder;
if (convertView == null) {
@@ -351,8 +327,7 @@ public View getView(int position, View convertView, ViewGroup parent)
holder.sipuri = (TextView) view.findViewById(R.id.contact_sipuri);
//((ImageButton) view.findViewById(R.id.btn_accessory)).setOnClickListener(ContactButtonClickListener);
view.setTag(holder);
- }
- else {
+ } else {
view = convertView;
holder = (ViewHolder) view.getTag();
}
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsActivity.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsActivity.java
index 5877f8e3..9bc208d8 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsActivity.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsActivity.java
@@ -40,6 +40,7 @@
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
+import android.widget.Toast;
import org.restcomm.android.sdk.RCClient;
import org.restcomm.android.sdk.RCConnection;
@@ -50,7 +51,7 @@
import java.util.HashMap;
public class SettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener,
- ServiceConnection {
+ ServiceConnection {
private SettingsFragment settingsFragment;
SharedPreferences prefs;
HashMap params;
@@ -61,8 +62,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
private static final String TAG = "SettingsActivity";
@Override
- protected void onCreate(Bundle savedInstanceState)
- {
+ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
@@ -88,8 +88,7 @@ protected void onCreate(Bundle savedInstanceState)
alertDialog = new AlertDialog.Builder(SettingsActivity.this, R.style.SimpleAlertStyle).create();
}
- protected void onResume()
- {
+ protected void onResume() {
super.onResume();
Preference updatedPref = settingsFragment.findPreference(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC);
@@ -108,8 +107,7 @@ protected void onResume()
}
@Override
- protected void onStart()
- {
+ protected void onStart() {
super.onStart();
Log.i(TAG, "%% onStart");
@@ -118,8 +116,7 @@ protected void onStart()
}
@Override
- protected void onStop()
- {
+ protected void onStop() {
super.onStop();
Log.i(TAG, "%% onStop");
@@ -133,8 +130,7 @@ protected void onStop()
// Callbacks for service binding, passed to bindService()
@Override
- public void onServiceConnected(ComponentName className, IBinder service)
- {
+ public void onServiceConnected(ComponentName className, IBinder service) {
Log.i(TAG, "%% onServiceConnected");
// We've bound to LocalService, cast the IBinder and get LocalService instance
RCDevice.RCDeviceBinder binder = (RCDevice.RCDeviceBinder) service;
@@ -143,8 +139,7 @@ public void onServiceConnected(ComponentName className, IBinder service)
// We have the device reference
if (device.getState() == RCDevice.DeviceState.OFFLINE) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorTextSecondary)));
- }
- else {
+ } else {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
}
@@ -152,15 +147,13 @@ public void onServiceConnected(ComponentName className, IBinder service)
}
@Override
- public void onServiceDisconnected(ComponentName arg0)
- {
+ public void onServiceDisconnected(ComponentName arg0) {
Log.i(TAG, "%% onServiceDisconnected");
serviceBound = false;
}
@Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
+ 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.
@@ -170,16 +163,14 @@ public boolean onOptionsItemSelected(MenuItem item)
ErrorStruct errorStruct = RCUtils.validateParms((HashMap) prefs.getAll());
if (errorStruct.statusCode != RCClient.ErrorCodes.SUCCESS) {
showOkAlert("Error saving Settings", errorStruct.statusText);
- }
- else {
+ } else {
if (!device.updateParams(params)) {
// TODO:
//showOkAlert("RCDevice Error", "No Wifi connectivity");
}
NavUtils.navigateUpFromSameTask(this);
}
- }
- else {
+ } else {
NavUtils.navigateUpFromSameTask(this);
}
@@ -188,71 +179,59 @@ public boolean onOptionsItemSelected(MenuItem item)
return super.onOptionsItemSelected(item);
}
+
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key)
- {
+ String key) {
if (key.equals(RCDevice.ParameterKeys.SIGNALING_DOMAIN)) {
params.put(RCDevice.ParameterKeys.SIGNALING_DOMAIN, prefs.getString(RCDevice.ParameterKeys.SIGNALING_DOMAIN, "sip:cloud.restcomm.com:5060"));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.SIGNALING_USERNAME)) {
+ } else if (key.equals(RCDevice.ParameterKeys.SIGNALING_USERNAME)) {
params.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, prefs.getString(RCDevice.ParameterKeys.SIGNALING_USERNAME, "android-sdk"));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.SIGNALING_PASSWORD)) {
+ } else if (key.equals(RCDevice.ParameterKeys.SIGNALING_PASSWORD)) {
params.put(RCDevice.ParameterKeys.SIGNALING_PASSWORD, prefs.getString(RCDevice.ParameterKeys.SIGNALING_PASSWORD, "1234"));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED)) {
+ } else if (key.equals(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED)) {
params.put(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED, prefs.getBoolean(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED, true));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_URL)) {
+ } else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_URL)) {
params.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, prefs.getString(RCDevice.ParameterKeys.MEDIA_ICE_URL, ""));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME)) {
+ } else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME)) {
params.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, prefs.getString(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, ""));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD)) {
+ } else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD)) {
params.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, prefs.getString(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, ""));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) {
+ } else if (key.equals(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) {
params.put(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN, prefs.getString(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN, ""));
updated = true;
- }
- else if (key.equals(RCDevice.ParameterKeys.SIGNALING_SECURE_ENABLED)) {
+ } else if (key.equals(RCDevice.ParameterKeys.SIGNALING_SECURE_ENABLED)) {
params.put(RCDevice.ParameterKeys.SIGNALING_SECURE_ENABLED, prefs.getBoolean(RCDevice.ParameterKeys.SIGNALING_SECURE_ENABLED, false));
updated = true;
- }
- else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC)) {
+ } else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC)) {
params.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, "Default"));
Preference updatedPref = settingsFragment.findPreference(key);
if (updatedPref != null) {
updatedPref.setSummary(prefs.getString(key, ""));
}
updated = true;
- }
- else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC)) {
+ } else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC)) {
params.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, "Default"));
Preference updatedPref = settingsFragment.findPreference(key);
if (updatedPref != null) {
updatedPref.setSummary(prefs.getString(key, ""));
}
updated = true;
- }
- else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION)) {
+ } else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION)) {
params.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION, prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION, "Default"));
Preference updatedPref = settingsFragment.findPreference(key);
if (updatedPref != null) {
updatedPref.setSummary(prefs.getString(key, ""));
}
updated = true;
- }
- else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE)) {
+ } else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE)) {
params.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE, prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE, "Default"));
Preference updatedPref = settingsFragment.findPreference(key);
if (updatedPref != null) {
@@ -260,15 +239,21 @@ else if (key.equals(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_
}
updated = true;
}
+
+ /*else if (key.equals("account")) {
+
+ Toast.makeText(getApplicationContext(),"Hello",Toast.LENGTH_SHORT).show();
+ }
+
+ */
}
- private void showOkAlert(final String title, final String detail)
- {
+
+ private void showOkAlert(final String title, final String detail) {
alertDialog.setTitle(title);
alertDialog.setMessage(detail);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which)
- {
+ public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsFragment.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsFragment.java
index 8c5a40f6..b2e84829 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsFragment.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SettingsFragment.java
@@ -24,21 +24,28 @@
import android.os.Bundle;
import android.preference.EditTextPreference;
+import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog;
+import android.widget.Toast;
import org.restcomm.android.sdk.RCDevice;
public class SettingsFragment extends PreferenceFragment {
@Override
- public void onCreate(Bundle savedInstanceState)
- {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
+
+ // ListPreference listPreference = (ListPreference) findPreference("account");
+ // listPreference.setEntries(new String[] {"Hi","Hello"});
+
+ //listPreference.setEntryValues(new String[] {"Hey","Yo"});
+
// setup listener to be used by all EditTextPreferences
Preference.OnPreferenceChangeListener listener = new Preference.OnPreferenceChangeListener() {
@Override
@@ -50,7 +57,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
- String value = (String)newValue;
+ String value = (String) newValue;
if (value.contains(" ")) {
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(preference.getTitle() + " validation error");
@@ -66,6 +73,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
getPreferenceScreen().findPreference(RCDevice.ParameterKeys.SIGNALING_USERNAME).setOnPreferenceChangeListener(listener);
getPreferenceScreen().findPreference(RCDevice.ParameterKeys.SIGNALING_DOMAIN).setOnPreferenceChangeListener(listener);
+
+
/*
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@@ -94,4 +103,5 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
*/
}
+
}
\ No newline at end of file
diff --git a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SigninActivity.java b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SigninActivity.java
index aed229cc..46d3c814 100644
--- a/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SigninActivity.java
+++ b/Examples/restcomm-olympus/app/src/main/java/org/restcomm/android/olympus/SigninActivity.java
@@ -25,6 +25,9 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.database.SQLException;
+import android.database.sqlite.SQLiteDatabase;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
@@ -37,6 +40,7 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
+import android.widget.Toast;
import org.restcomm.android.sdk.RCDevice;
@@ -59,14 +63,20 @@ public class SigninActivity extends AppCompatActivity {
//SharedPreferences prefsGeneral = null;
+ DatabaseHelper dbHelper;
+ DatabaseManager dbManager;
+ SQLiteDatabase db;
+
@Override
- protected void onCreate(Bundle savedInstanceState)
- {
+ protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "%% onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signin);
+ dbHelper = new DatabaseHelper(this);
+ db = dbHelper.getWritableDatabase();
+
globalPreferences = new GlobalPreferences(getApplicationContext());
// Check if
//prefsGeneral = this.getSharedPreferences(PREFS_NAME, 0);
@@ -92,8 +102,7 @@ protected void onCreate(Bundle savedInstanceState)
startActivity(intent);
// needed to avoid extreme flashing when the App starts up without signing up
overridePendingTransition(0, 0);
- }
- else {
+ } else {
txtUsername = (EditText) findViewById(R.id.signin_username);
txtPassword = (EditText) findViewById(R.id.signin_password);
txtDomain = (EditText) findViewById(R.id.signin_domain);
@@ -101,8 +110,7 @@ protected void onCreate(Bundle savedInstanceState)
txtPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
- public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent)
- {
+ public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
@@ -113,8 +121,7 @@ public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent)
mSigninButton.setOnClickListener(new OnClickListener() {
@Override
- public void onClick(View view)
- {
+ public void onClick(View view) {
attemptLogin();
}
});
@@ -126,10 +133,35 @@ public void onClick(View view)
txtDomain.setText(prefs.getString(RCDevice.ParameterKeys.SIGNALING_DOMAIN, ""));
txtPassword.setText(prefs.getString(RCDevice.ParameterKeys.SIGNALING_PASSWORD, ""));
}
+
+ checkDatabase();
+ }
+
+ //TODO: Check if there is a way to save accounts in SharedPreferences instead of saving them in an SQLite DB, Till then leave issue #388
+
+ private void checkDatabase() {
+ String[] columnsAccounts = {
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_USERNAME,
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_PASSWORD,
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_DOMAIN
+
+ };
+ Toast.makeText(getApplicationContext(), "Welcome to Olympus!", Toast.LENGTH_SHORT).show();
+ try {
+ db.execSQL(DatabaseHelper.SQL_CREATE_ACCOUNTS_TABLE);
+ } catch (SQLException e) {
+
+ if (e.toString().contains("exists")) {
+
+ Toast.makeText(getApplicationContext(), "One or more than one accounts detected", Toast.LENGTH_SHORT).show();
+ }
+
+ }
+
+
}
- private void attemptLogin()
- {
+ private void attemptLogin() {
// Reset errors.
txtUsername.setError(null);
txtPassword.setError(null);
@@ -148,18 +180,15 @@ private void attemptLogin()
txtUsername.setError(getString(R.string.error_field_required));
focusView = txtUsername;
cancel = true;
- }
- else if (TextUtils.isEmpty(domain)) {
+ } else if (TextUtils.isEmpty(domain)) {
txtDomain.setError(getString(R.string.error_invalid_email));
focusView = txtDomain;
cancel = true;
- }
- else if (username.contains(" ")) {
+ } else if (username.contains(" ")) {
txtUsername.setError(getString(R.string.error_field_no_whitespace));
focusView = txtUsername;
cancel = true;
- }
- else if (domain.contains(" ")) {
+ } else if (domain.contains(" ")) {
txtDomain.setError(getString(R.string.error_field_no_whitespace));
focusView = txtDomain;
cancel = true;
@@ -169,13 +198,16 @@ else if (domain.contains(" ")) {
// There was an error; don't attempt login and focus the first
// form field with an error.
focusView.requestFocus();
- }
- else {
+ } else {
// note down the fact that we are signed up so that
globalPreferences.setSignedUp(true);
// values are valid let's update prefs
updatePrefs();
+ //Initialising Database manager
+ dbManager = new DatabaseManager();
+ //Saving the account details to accounts.db
+ addAccountDb(username, password, domain);
Intent intent = new Intent(this, MainActivity.class);
//intent.setAction(RCDevice.ACTION_OUTGOING_CALL);
//intent.putExtra(RCDevice.EXTRA_DID, sipuri);
@@ -185,8 +217,43 @@ else if (domain.contains(" ")) {
}
}
- private void updatePrefs()
- {
+ //Method added to check if an Account exists in the Table already
+ public boolean checkAccountExists(String username) {
+
+
+ String[] columnsAccounts = {
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_USERNAME,
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_PASSWORD,
+ DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_DOMAIN
+
+ };
+ String selection = DatabaseContract.AccountEntry.COLUMN_NAME_ACCOUNTS_USERNAME + " =?";
+ String[] selectionArgs = {username};
+ String limit = "1";
+
+ Cursor cursor = db.query(DatabaseContract.AccountEntry.TABLE_NAME_ACCOUNTS, columnsAccounts, selection, selectionArgs, null, null, null, limit);
+ boolean exists = (cursor.getCount() > 0);
+ return exists;
+
+
+ }
+
+ //Method to add the account into the table after checking
+ public void addAccountDb(String username, String password, String domain) {
+
+ if (checkAccountExists(username)) {
+
+ Toast.makeText(getApplicationContext(), "Hey, I recognise you!", Toast.LENGTH_SHORT).show();
+ } else {
+
+ dbManager.open(getApplicationContext());
+ dbManager.addAccount(username, password, domain);
+
+ }
+
+ }
+
+ private void updatePrefs() {
SharedPreferences.Editor prefEdit = prefs.edit();
prefEdit.putString(RCDevice.ParameterKeys.SIGNALING_USERNAME, txtUsername.getText().toString());
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xhdpi/custom_orange_button.xml b/Examples/restcomm-olympus/app/src/main/res/drawable-xhdpi/custom_orange_button.xml
new file mode 100644
index 00000000..f663cbcd
--- /dev/null
+++ b/Examples/restcomm-olympus/app/src/main/res/drawable-xhdpi/custom_orange_button.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/eight_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/eight_digit_new.png
new file mode 100644
index 00000000..6654a7c0
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/eight_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/five_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/five_digit_new.png
new file mode 100644
index 00000000..8a1a2ea0
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/five_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/four_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/four_digit_new.png
new file mode 100644
index 00000000..c9586d7d
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/four_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/hash_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/hash_digit_new.png
new file mode 100644
index 00000000..0b756183
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/hash_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/nine_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/nine_digit_new.png
new file mode 100644
index 00000000..a048687e
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/nine_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/one.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/one.png
new file mode 100644
index 00000000..6812007e
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/one.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/one_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/one_digit_new.png
new file mode 100644
index 00000000..12a7d552
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/one_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/seven_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/seven_digit_new.png
new file mode 100644
index 00000000..29866c0a
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/seven_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/six_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/six_digit_new.png
new file mode 100644
index 00000000..283d4992
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/six_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/star_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/star_digit_new.png
new file mode 100644
index 00000000..27dc264e
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/star_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/three_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/three_digit_new.png
new file mode 100644
index 00000000..5e196602
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/three_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/two_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/two_digit_new.png
new file mode 100644
index 00000000..42e934a1
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/two_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/zero_digit_new.png b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/zero_digit_new.png
new file mode 100644
index 00000000..0550dc42
Binary files /dev/null and b/Examples/restcomm-olympus/app/src/main/res/drawable-xxxhdpi/zero_digit_new.png differ
diff --git a/Examples/restcomm-olympus/app/src/main/res/layout/fragment_dialog_add_contact.xml b/Examples/restcomm-olympus/app/src/main/res/layout/fragment_dialog_add_contact.xml
index 4a3013d1..86a1b7c6 100644
--- a/Examples/restcomm-olympus/app/src/main/res/layout/fragment_dialog_add_contact.xml
+++ b/Examples/restcomm-olympus/app/src/main/res/layout/fragment_dialog_add_contact.xml
@@ -73,4 +73,16 @@
android:id="@+id/textView_sipuri"
android:layout_gravity="center_horizontal" />
+
+
\ No newline at end of file
diff --git a/Examples/restcomm-olympus/app/src/main/res/layout/fragment_keypad.xml b/Examples/restcomm-olympus/app/src/main/res/layout/fragment_keypad.xml
index 25419391..32ca1503 100755
--- a/Examples/restcomm-olympus/app/src/main/res/layout/fragment_keypad.xml
+++ b/Examples/restcomm-olympus/app/src/main/res/layout/fragment_keypad.xml
@@ -11,158 +11,164 @@
+ android:background="#EF222222"/>
+ android:src="@drawable/ic_clear_24dp"/>
+ android:layout_marginTop="70dp"
+ android:fontFamily=""
+ android:text="DTMF Keypad"
+ android:textColor="@color/colorDtmfColor"
+ android:textSize="30sp"/>
+ android:background="@android:color/transparent"
+ android:src="@drawable/one_digit_new"/>
+
+ android:src="@drawable/two_digit_new"/>
+
+ android:layout_toRightOf="@+id/imageButton_2"
+ android:background="@android:color/transparent"
+ android:src="@drawable/three_digit_new"/>
+ android:background="@android:color/transparent"
+ android:src="@drawable/four_digit_new"/>
+
+ android:layout_marginTop="30dp"
+ android:background="@android:color/transparent"
+ android:src="@drawable/five_digit_new"/>
+
+ android:layout_toRightOf="@+id/imageButton_5"
+ android:background="@android:color/transparent"
+ android:src="@drawable/six_digit_new"/>
+ android:background="@android:color/transparent"
+ android:src="@drawable/seven_digit_new"/>
+
+ android:layout_marginTop="30dp"
+ android:background="@android:color/transparent"
+ android:src="@drawable/eight_digit_new"/>
+
+ android:layout_toRightOf="@+id/imageButton_8"
+ android:background="@android:color/transparent"
+ android:src="@drawable/nine_digit_new"/>
+ android:background="@android:color/transparent"
+ android:src="@drawable/star_digit_new"/>
+
+ android:layout_marginTop="30dp"
+ android:background="@android:color/transparent"
+ android:src="@drawable/zero_digit_new"/>
+
+ android:layout_toRightOf="@+id/imageButton_0"
+ android:background="@android:color/transparent"
+ android:src="@drawable/hash_digit_new"/>
diff --git a/restcomm.android.sdk/src/main/java/org/restcomm/android/sdk/SignalingClient/SignalingClient.java b/restcomm.android.sdk/src/main/java/org/restcomm/android/sdk/SignalingClient/SignalingClient.java
index 852e1191..508c4c9a 100644
--- a/restcomm.android.sdk/src/main/java/org/restcomm/android/sdk/SignalingClient/SignalingClient.java
+++ b/restcomm.android.sdk/src/main/java/org/restcomm/android/sdk/SignalingClient/SignalingClient.java
@@ -56,7 +56,7 @@
* the reverse happens: a message is created from the Signaling thread to the UI thread and after it is received at handleMessage() the respective
* listener callback is used to notify the UI.
*/
-public class SignalingClient extends Handler {
+public class SignalingClient extends Handler {
/**
* Registration/configuration related interface callbacks that user of the API needs to implement