Code refactoring: renamed private variable to start with m (or s if static) and removed unused code

This commit is contained in:
Sylvain Berfini 2018-12-05 11:55:14 +01:00
parent 3494ae1180
commit 9300877d12
69 changed files with 2915 additions and 3053 deletions

View file

@ -108,7 +108,7 @@ import org.linphone.fragments.EmptyFragment;
import org.linphone.fragments.FragmentsAvailable; import org.linphone.fragments.FragmentsAvailable;
import org.linphone.fragments.StatusFragment; import org.linphone.fragments.StatusFragment;
import org.linphone.history.HistoryDetailFragment; import org.linphone.history.HistoryDetailFragment;
import org.linphone.history.HistoryListFragment; import org.linphone.history.HistoryFragment;
import org.linphone.mediastream.Log; import org.linphone.mediastream.Log;
import org.linphone.purchase.InAppPurchaseActivity; import org.linphone.purchase.InAppPurchaseActivity;
import org.linphone.recording.RecordingsFragment; import org.linphone.recording.RecordingsFragment;
@ -133,44 +133,42 @@ public class LinphoneActivity extends LinphoneGenericActivity
private static final int PERMISSIONS_READ_EXTERNAL_STORAGE_DEVICE_RINGTONE = 210; private static final int PERMISSIONS_READ_EXTERNAL_STORAGE_DEVICE_RINGTONE = 210;
private static final int PERMISSIONS_RECORD_AUDIO_ECHO_TESTER = 211; private static final int PERMISSIONS_RECORD_AUDIO_ECHO_TESTER = 211;
private static LinphoneActivity instance; private static LinphoneActivity sInstance;
public String mAddressWaitingToBeCalled;
private StatusFragment statusFragment; public String addressWaitingToBeCalled;
private TextView missedCalls, missedChats;
private RelativeLayout contacts, history, dialer, chat; private StatusFragment mStatusFragment;
private View contacts_selected, private TextView mMissedCalls, mMissedChats;
history_selected, private RelativeLayout mContacts, mHistory, mDialer, mChat;
dialer_selected, private View mContactsSelected, mHistorySelected, mDialerSelected, mChatSelected;
chat_selected,
record_selected;
private LinearLayout mTopBar; private LinearLayout mTopBar;
private TextView mTopBarTitle; private TextView mTopBarTitle;
private ImageView cancel; private ImageView mCancel;
private FragmentsAvailable pendingFragmentTransaction, currentFragment, leftFragment; private FragmentsAvailable mPendingFragmentTransaction, mCurrentFragment, mLeftFragment;
private Fragment fragment; private Fragment mFragment;
private List<FragmentsAvailable> fragmentsHistory; private List<FragmentsAvailable> mFragmentsHistory;
private Fragment.SavedState dialerSavedState; private Fragment.SavedState mDialerSavedState;
private boolean newProxyConfig; private boolean mNewProxyConfig;
private boolean emptyFragment = false; private boolean mEmptyFragment = false;
private boolean isTrialAccount = false; private boolean mIsTrialAccount = false;
private OrientationEventListener mOrientationHelper; private OrientationEventListener mOrientationHelper;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private LinearLayout mTabBar; private LinearLayout mTabBar;
private DrawerLayout sideMenu; private DrawerLayout mSideMenu;
private RelativeLayout sideMenuContent, quitLayout, defaultAccount; private RelativeLayout mSideMenuContent, mQuitLayout, mDefaultAccount;
private ListView accountsList, sideMenuItemList; private ListView mAccountsList, mSideMenuItemList;
private ImageView menu; private ImageView mMenu;
private List<MenuItem> sideMenuItems; private List<MenuItem> mSideMenuItems;
private boolean callTransfer = false; private boolean mCallTransfer = false;
private boolean isOnBackground = false; private boolean mIsOnBackground = false;
private int mAlwaysChangingPhoneAngle = -1; private int mAlwaysChangingPhoneAngle = -1;
public static final boolean isInstanciated() { public static final boolean isInstanciated() {
return instance != null; return sInstance != null;
} }
public static final LinphoneActivity instance() { public static final LinphoneActivity instance() {
if (instance != null) return instance; if (sInstance != null) return sInstance;
throw new RuntimeException("LinphoneActivity not instantiated yet"); throw new RuntimeException("LinphoneActivity not instantiated yet");
} }
@ -220,19 +218,19 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
setContentView(R.layout.main); setContentView(R.layout.main);
instance = this; sInstance = this;
fragmentsHistory = new ArrayList<>(); mFragmentsHistory = new ArrayList<>();
pendingFragmentTransaction = FragmentsAvailable.UNKNOW; mPendingFragmentTransaction = FragmentsAvailable.UNKNOW;
initButtons(); initButtons();
initSideMenu(); initSideMenu();
currentFragment = FragmentsAvailable.EMPTY; mCurrentFragment = FragmentsAvailable.EMPTY;
if (savedInstanceState == null) { if (savedInstanceState == null) {
changeCurrentFragment(FragmentsAvailable.DIALER, getIntent().getExtras()); changeCurrentFragment(FragmentsAvailable.DIALER, getIntent().getExtras());
} else { } else {
currentFragment = mCurrentFragment =
(FragmentsAvailable) savedInstanceState.getSerializable("currentFragment"); (FragmentsAvailable) savedInstanceState.getSerializable("mCurrentFragment");
} }
mListener = mListener =
@ -262,8 +260,8 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
} }
if (state.equals(RegistrationState.Failed) && newProxyConfig) { if (state.equals(RegistrationState.Failed) && mNewProxyConfig) {
newProxyConfig = false; mNewProxyConfig = false;
if (proxy.getError() == Reason.Forbidden) { if (proxy.getError() == Reason.Forbidden) {
// displayCustomToast(getString(R.string.error_bad_credentials), // displayCustomToast(getString(R.string.error_bad_credentials),
// Toast.LENGTH_LONG); // Toast.LENGTH_LONG);
@ -337,25 +335,25 @@ public class LinphoneActivity extends LinphoneGenericActivity
mTopBar = findViewById(R.id.top_bar); mTopBar = findViewById(R.id.top_bar);
mTopBarTitle = findViewById(R.id.top_bar_title); mTopBarTitle = findViewById(R.id.top_bar_title);
cancel = findViewById(R.id.cancel); mCancel = findViewById(R.id.cancel);
cancel.setOnClickListener(this); mCancel.setOnClickListener(this);
history = findViewById(R.id.history); mHistory = findViewById(R.id.history);
history.setOnClickListener(this); mHistory.setOnClickListener(this);
contacts = findViewById(R.id.contacts); mContacts = findViewById(R.id.contacts);
contacts.setOnClickListener(this); mContacts.setOnClickListener(this);
dialer = findViewById(R.id.dialer); mDialer = findViewById(R.id.dialer);
dialer.setOnClickListener(this); mDialer.setOnClickListener(this);
chat = findViewById(R.id.chat); mChat = findViewById(R.id.chat);
chat.setOnClickListener(this); mChat.setOnClickListener(this);
history_selected = findViewById(R.id.history_select); mHistorySelected = findViewById(R.id.history_select);
contacts_selected = findViewById(R.id.contacts_select); mContactsSelected = findViewById(R.id.contacts_select);
dialer_selected = findViewById(R.id.dialer_select); mDialerSelected = findViewById(R.id.dialer_select);
chat_selected = findViewById(R.id.chat_select); mChatSelected = findViewById(R.id.chat_select);
missedCalls = findViewById(R.id.missed_calls); mMissedCalls = findViewById(R.id.missed_calls);
missedChats = findViewById(R.id.missed_chats); mMissedChats = findViewById(R.id.missed_chats);
} }
public boolean isTablet() { public boolean isTablet() {
@ -375,119 +373,119 @@ public class LinphoneActivity extends LinphoneGenericActivity
return; return;
} }
if (statusFragment != null && !statusFragment.isVisible()) { if (mStatusFragment != null && !mStatusFragment.isVisible()) {
statusFragment.getView().setVisibility(View.VISIBLE); mStatusFragment.getView().setVisibility(View.VISIBLE);
} }
findViewById(R.id.status).setVisibility(View.VISIBLE); findViewById(R.id.status).setVisibility(View.VISIBLE);
} }
public void isNewProxyConfig() { public void isNewProxyConfig() {
newProxyConfig = true; mNewProxyConfig = true;
} }
public void popBackStack() { public void popBackStack() {
getFragmentManager().popBackStackImmediate(); getFragmentManager().popBackStackImmediate();
currentFragment = FragmentsAvailable.EMPTY; mCurrentFragment = FragmentsAvailable.EMPTY;
} }
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras) { private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras) {
if (newFragmentType == currentFragment if (newFragmentType == mCurrentFragment
&& newFragmentType != FragmentsAvailable.CHAT && newFragmentType != FragmentsAvailable.CHAT
&& newFragmentType != FragmentsAvailable.GROUP_CHAT) { && newFragmentType != FragmentsAvailable.GROUP_CHAT) {
return; return;
} }
if (currentFragment == FragmentsAvailable.DIALER) { if (mCurrentFragment == FragmentsAvailable.DIALER) {
try { try {
DialerFragment dialerFragment = DialerFragment.instance(); DialerFragment dialerFragment = DialerFragment.instance();
dialerSavedState = getFragmentManager().saveFragmentInstanceState(dialerFragment); mDialerSavedState = getFragmentManager().saveFragmentInstanceState(dialerFragment);
} catch (Exception e) { } catch (Exception e) {
} }
} }
fragment = null; mFragment = null;
switch (newFragmentType) { switch (newFragmentType) {
case HISTORY_LIST: case HISTORY_LIST:
fragment = new HistoryListFragment(); mFragment = new HistoryFragment();
break; break;
case HISTORY_DETAIL: case HISTORY_DETAIL:
fragment = new HistoryDetailFragment(); mFragment = new HistoryDetailFragment();
break; break;
case CONTACTS_LIST: case CONTACTS_LIST:
checkAndRequestWriteContactsPermission(); checkAndRequestWriteContactsPermission();
fragment = new ContactsListFragment(); mFragment = new ContactsListFragment();
break; break;
case CONTACT_DETAIL: case CONTACT_DETAIL:
fragment = new ContactDetailsFragment(); mFragment = new ContactDetailsFragment();
break; break;
case CONTACT_EDITOR: case CONTACT_EDITOR:
fragment = new ContactEditorFragment(); mFragment = new ContactEditorFragment();
break; break;
case DIALER: case DIALER:
fragment = new DialerFragment(); mFragment = new DialerFragment();
if (extras == null) { if (extras == null) {
fragment.setInitialSavedState(dialerSavedState); mFragment.setInitialSavedState(mDialerSavedState);
} }
break; break;
case SETTINGS: case SETTINGS:
fragment = new SettingsFragment(); mFragment = new SettingsFragment();
break; break;
case ACCOUNT_SETTINGS: case ACCOUNT_SETTINGS:
fragment = new AccountPreferencesFragment(); mFragment = new AccountPreferencesFragment();
break; break;
case ABOUT: case ABOUT:
fragment = new AboutFragment(); mFragment = new AboutFragment();
break; break;
case EMPTY: case EMPTY:
fragment = new EmptyFragment(); mFragment = new EmptyFragment();
break; break;
case CHAT_LIST: case CHAT_LIST:
fragment = new ChatRoomsFragment(); mFragment = new ChatRoomsFragment();
break; break;
case CREATE_CHAT: case CREATE_CHAT:
checkAndRequestWriteContactsPermission(); checkAndRequestWriteContactsPermission();
fragment = new ChatRoomCreationFragment(); mFragment = new ChatRoomCreationFragment();
break; break;
case INFO_GROUP_CHAT: case INFO_GROUP_CHAT:
fragment = new GroupInfoFragment(); mFragment = new GroupInfoFragment();
break; break;
case GROUP_CHAT: case GROUP_CHAT:
fragment = new ChatMessagesFragment(); mFragment = new ChatMessagesFragment();
break; break;
case MESSAGE_IMDN: case MESSAGE_IMDN:
if (getResources().getBoolean(R.bool.use_new_chat_bubbles_layout)) { if (getResources().getBoolean(R.bool.use_new_chat_bubbles_layout)) {
fragment = new ImdnFragment(); mFragment = new ImdnFragment();
} else { } else {
fragment = new ImdnOldFragment(); mFragment = new ImdnOldFragment();
} }
break; break;
case CONTACT_DEVICES: case CONTACT_DEVICES:
fragment = new DevicesFragment(); mFragment = new DevicesFragment();
break; break;
case RECORDING_LIST: case RECORDING_LIST:
fragment = new RecordingsFragment(); mFragment = new RecordingsFragment();
break; break;
default: default:
break; break;
} }
if (fragment != null) { if (mFragment != null) {
fragment.setArguments(extras); mFragment.setArguments(extras);
if (isTablet()) { if (isTablet()) {
changeFragmentForTablets(fragment, newFragmentType); changeFragmentForTablets(mFragment, newFragmentType);
switch (newFragmentType) { switch (newFragmentType) {
case HISTORY_LIST: case HISTORY_LIST:
((HistoryListFragment) fragment).displayFirstLog(); ((HistoryFragment) mFragment).displayFirstLog();
break; break;
case CONTACTS_LIST: case CONTACTS_LIST:
((ContactsListFragment) fragment).displayFirstContact(); ((ContactsListFragment) mFragment).displayFirstContact();
break; break;
case CHAT_LIST: case CHAT_LIST:
((ChatRoomsFragment) fragment).displayFirstChat(); ((ChatRoomsFragment) mFragment).displayFirstChat();
break; break;
} }
} else { } else {
changeFragment(fragment, newFragmentType); changeFragment(mFragment, newFragmentType);
} }
LinphoneUtils.hideKeyboard(this); LinphoneUtils.hideKeyboard(this);
} }
@ -513,7 +511,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
transaction.commitAllowingStateLoss(); transaction.commitAllowingStateLoss();
fm.executePendingTransactions(); fm.executePendingTransactions();
currentFragment = newFragmentType; mCurrentFragment = newFragmentType;
} }
private void changeFragmentForTablets( private void changeFragmentForTablets(
@ -525,38 +523,38 @@ public class LinphoneActivity extends LinphoneGenericActivity
hideStatusBar(); hideStatusBar();
} }
} }
emptyFragment = false; mEmptyFragment = false;
LinearLayout ll = findViewById(R.id.fragmentContainer2); LinearLayout ll = findViewById(R.id.fragmentContainer2);
FragmentTransaction transaction = getFragmentManager().beginTransaction(); FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (newFragmentType == FragmentsAvailable.EMPTY) { if (newFragmentType == FragmentsAvailable.EMPTY) {
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
emptyFragment = true; mEmptyFragment = true;
transaction.replace(R.id.fragmentContainer2, newFragment); transaction.replace(R.id.fragmentContainer2, newFragment);
transaction.commitAllowingStateLoss(); transaction.commitAllowingStateLoss();
getFragmentManager().executePendingTransactions(); getFragmentManager().executePendingTransactions();
} else { } else {
if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment) if (newFragmentType.shouldAddItselfToTheRightOf(mCurrentFragment)
|| newFragmentType.shouldAddItselfToTheRightOf(leftFragment)) { || newFragmentType.shouldAddItselfToTheRightOf(mLeftFragment)) {
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
if (newFragmentType == FragmentsAvailable.CONTACT_EDITOR) { if (newFragmentType == FragmentsAvailable.CONTACT_EDITOR) {
transaction.addToBackStack(newFragmentType.toString()); transaction.addToBackStack(newFragmentType.toString());
} }
transaction.replace(R.id.fragmentContainer2, newFragment); transaction.replace(R.id.fragmentContainer2, newFragment);
leftFragment = currentFragment; mLeftFragment = mCurrentFragment;
if (newFragmentType == FragmentsAvailable.GROUP_CHAT if (newFragmentType == FragmentsAvailable.GROUP_CHAT
&& leftFragment != FragmentsAvailable.CHAT_LIST) { && mLeftFragment != FragmentsAvailable.CHAT_LIST) {
leftFragment = FragmentsAvailable.CHAT_LIST; mLeftFragment = FragmentsAvailable.CHAT_LIST;
transaction.replace(R.id.fragmentContainer, new ChatRoomsFragment()); transaction.replace(R.id.fragmentContainer, new ChatRoomsFragment());
} }
} else { } else {
if (newFragmentType == FragmentsAvailable.EMPTY) { if (newFragmentType == FragmentsAvailable.EMPTY) {
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
transaction.replace(R.id.fragmentContainer2, new EmptyFragment()); transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
emptyFragment = true; mEmptyFragment = true;
} }
if (newFragmentType == FragmentsAvailable.DIALER if (newFragmentType == FragmentsAvailable.DIALER
@ -576,7 +574,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
transaction.commitAllowingStateLoss(); transaction.commitAllowingStateLoss();
getFragmentManager().executePendingTransactions(); getFragmentManager().executePendingTransactions();
currentFragment = newFragmentType; mCurrentFragment = newFragmentType;
if (newFragmentType == FragmentsAvailable.DIALER if (newFragmentType == FragmentsAvailable.DIALER
|| newFragmentType == FragmentsAvailable.SETTINGS || newFragmentType == FragmentsAvailable.SETTINGS
|| newFragmentType == FragmentsAvailable.CONTACTS_LIST || newFragmentType == FragmentsAvailable.CONTACTS_LIST
@ -589,7 +587,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
} }
fragmentsHistory.add(currentFragment); mFragmentsHistory.add(mCurrentFragment);
} }
} }
@ -624,7 +622,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2); Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null if (fragment2 != null
&& fragment2.isVisible() && fragment2.isVisible()
&& currentFragment == FragmentsAvailable.HISTORY_DETAIL) { && mCurrentFragment == FragmentsAvailable.HISTORY_DETAIL) {
HistoryDetailFragment historyDetailFragment = (HistoryDetailFragment) fragment2; HistoryDetailFragment historyDetailFragment = (HistoryDetailFragment) fragment2;
historyDetailFragment.changeDisplayedHistory( historyDetailFragment.changeDisplayedHistory(
sipUri, displayName, pictureUri, status, callTime, callDate); sipUri, displayName, pictureUri, status, callTime, callDate);
@ -659,7 +657,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2); Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null if (fragment2 != null
&& fragment2.isVisible() && fragment2.isVisible()
&& currentFragment == FragmentsAvailable.CONTACT_DETAIL) { && mCurrentFragment == FragmentsAvailable.CONTACT_DETAIL) {
ContactDetailsFragment contactFragment = (ContactDetailsFragment) fragment2; ContactDetailsFragment contactFragment = (ContactDetailsFragment) fragment2;
contactFragment.changeDisplayedContact(contact); contactFragment.changeDisplayedContact(contact);
} else { } else {
@ -741,7 +739,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
Bundle shareInfos, Bundle shareInfos,
boolean createGroupChat, boolean createGroupChat,
boolean isChatRoomEncrypted) { boolean isChatRoomEncrypted) {
if (currentFragment == FragmentsAvailable.INFO_GROUP_CHAT && isGoBack) { if (mCurrentFragment == FragmentsAvailable.INFO_GROUP_CHAT && isGoBack) {
getFragmentManager().popBackStackImmediate(); getFragmentManager().popBackStackImmediate();
getFragmentManager().popBackStackImmediate(); getFragmentManager().popBackStackImmediate();
} }
@ -777,8 +775,8 @@ public class LinphoneActivity extends LinphoneGenericActivity
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2); Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null if (fragment2 != null
&& fragment2.isVisible() && fragment2.isVisible()
&& currentFragment == FragmentsAvailable.GROUP_CHAT && mCurrentFragment == FragmentsAvailable.GROUP_CHAT
&& !emptyFragment) { && !mEmptyFragment) {
ChatMessagesFragment chatFragment = (ChatMessagesFragment) fragment2; ChatMessagesFragment chatFragment = (ChatMessagesFragment) fragment2;
chatFragment.changeDisplayedChat(sipUri); chatFragment.changeDisplayedChat(sipUri);
} else { } else {
@ -800,7 +798,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
boolean isGoBack, boolean isGoBack,
Bundle shareInfos, Bundle shareInfos,
boolean enableEncryption) { boolean enableEncryption) {
if (currentFragment == FragmentsAvailable.CREATE_CHAT && isGoBack) { if (mCurrentFragment == FragmentsAvailable.CREATE_CHAT && isGoBack) {
getFragmentManager().popBackStackImmediate(); getFragmentManager().popBackStackImmediate();
getFragmentManager().popBackStackImmediate(); getFragmentManager().popBackStackImmediate();
} }
@ -861,13 +859,13 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
} }
if (currentFragment == FragmentsAvailable.CHAT_LIST if (mCurrentFragment == FragmentsAvailable.CHAT_LIST
|| currentFragment == FragmentsAvailable.GROUP_CHAT) { || mCurrentFragment == FragmentsAvailable.GROUP_CHAT) {
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2); Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null if (fragment2 != null
&& fragment2.isVisible() && fragment2.isVisible()
&& currentFragment == FragmentsAvailable.GROUP_CHAT && mCurrentFragment == FragmentsAvailable.GROUP_CHAT
&& !emptyFragment) { && !mEmptyFragment) {
ChatMessagesFragment chatFragment = (ChatMessagesFragment) fragment2; ChatMessagesFragment chatFragment = (ChatMessagesFragment) fragment2;
chatFragment.changeDisplayedChat(sipUri); chatFragment.changeDisplayedChat(sipUri);
} else { } else {
@ -894,18 +892,18 @@ public class LinphoneActivity extends LinphoneGenericActivity
if (id == R.id.history) { if (id == R.id.history) {
changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null); changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null);
history_selected.setVisibility(View.VISIBLE); mHistorySelected.setVisibility(View.VISIBLE);
LinphoneManager.getLc().resetMissedCallsCount(); LinphoneManager.getLc().resetMissedCallsCount();
displayMissedCalls(0); displayMissedCalls(0);
} else if (id == R.id.contacts) { } else if (id == R.id.contacts) {
changeCurrentFragment(FragmentsAvailable.CONTACTS_LIST, null); changeCurrentFragment(FragmentsAvailable.CONTACTS_LIST, null);
contacts_selected.setVisibility(View.VISIBLE); mContactsSelected.setVisibility(View.VISIBLE);
} else if (id == R.id.dialer) { } else if (id == R.id.dialer) {
changeCurrentFragment(FragmentsAvailable.DIALER, null); changeCurrentFragment(FragmentsAvailable.DIALER, null);
dialer_selected.setVisibility(View.VISIBLE); mDialerSelected.setVisibility(View.VISIBLE);
} else if (id == R.id.chat) { } else if (id == R.id.chat) {
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null); changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
chat_selected.setVisibility(View.VISIBLE); mChatSelected.setVisibility(View.VISIBLE);
} else if (id == R.id.cancel) { } else if (id == R.id.cancel) {
hideTopBar(); hideTopBar();
displayDialer(); displayDialer();
@ -913,10 +911,10 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
private void resetSelection() { private void resetSelection() {
history_selected.setVisibility(View.GONE); mHistorySelected.setVisibility(View.GONE);
contacts_selected.setVisibility(View.GONE); mContactsSelected.setVisibility(View.GONE);
dialer_selected.setVisibility(View.GONE); mDialerSelected.setVisibility(View.GONE);
chat_selected.setVisibility(View.GONE); mChatSelected.setVisibility(View.GONE);
} }
public void hideTabBar(Boolean hide) { public void hideTabBar(Boolean hide) {
@ -943,7 +941,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
@SuppressWarnings("incomplete-switch") @SuppressWarnings("incomplete-switch")
public void selectMenu(FragmentsAvailable menuToSelect) { public void selectMenu(FragmentsAvailable menuToSelect) {
currentFragment = menuToSelect; mCurrentFragment = menuToSelect;
resetSelection(); resetSelection();
boolean hideBottomBar = boolean hideBottomBar =
getResources().getBoolean(R.bool.hide_bottom_bar_on_second_level_views); getResources().getBoolean(R.bool.hide_bottom_bar_on_second_level_views);
@ -951,24 +949,24 @@ public class LinphoneActivity extends LinphoneGenericActivity
switch (menuToSelect) { switch (menuToSelect) {
case HISTORY_LIST: case HISTORY_LIST:
hideTabBar(false); hideTabBar(false);
history_selected.setVisibility(View.VISIBLE); mHistorySelected.setVisibility(View.VISIBLE);
break; break;
case HISTORY_DETAIL: case HISTORY_DETAIL:
hideTabBar(hideBottomBar); hideTabBar(hideBottomBar);
history_selected.setVisibility(View.VISIBLE); mHistorySelected.setVisibility(View.VISIBLE);
break; break;
case CONTACTS_LIST: case CONTACTS_LIST:
hideTabBar(false); hideTabBar(false);
contacts_selected.setVisibility(View.VISIBLE); mContactsSelected.setVisibility(View.VISIBLE);
break; break;
case CONTACT_DETAIL: case CONTACT_DETAIL:
case CONTACT_EDITOR: case CONTACT_EDITOR:
hideTabBar(hideBottomBar); hideTabBar(hideBottomBar);
contacts_selected.setVisibility(View.VISIBLE); mContactsSelected.setVisibility(View.VISIBLE);
break; break;
case DIALER: case DIALER:
hideTabBar(false); hideTabBar(false);
dialer_selected.setVisibility(View.VISIBLE); mDialerSelected.setVisibility(View.VISIBLE);
break; break;
case SETTINGS: case SETTINGS:
case ACCOUNT_SETTINGS: case ACCOUNT_SETTINGS:
@ -981,7 +979,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
break; break;
case CHAT_LIST: case CHAT_LIST:
hideTabBar(false); hideTabBar(false);
chat_selected.setVisibility(View.VISIBLE); mChatSelected.setVisibility(View.VISIBLE);
break; break;
case CREATE_CHAT: case CREATE_CHAT:
case GROUP_CHAT: case GROUP_CHAT:
@ -990,7 +988,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
case CONTACT_DEVICES: case CONTACT_DEVICES:
case CHAT: case CHAT:
hideTabBar(hideBottomBar); hideTabBar(hideBottomBar);
chat_selected.setVisibility(View.VISIBLE); mChatSelected.setVisibility(View.VISIBLE);
break; break;
case RECORDING_LIST: case RECORDING_LIST:
hideTabBar(hideBottomBar); hideTabBar(hideBottomBar);
@ -1010,11 +1008,11 @@ public class LinphoneActivity extends LinphoneGenericActivity
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString("SipUri", ""); extras.putString("SipUri", "");
changeCurrentFragment(FragmentsAvailable.DIALER, extras); changeCurrentFragment(FragmentsAvailable.DIALER, extras);
dialer_selected.setVisibility(View.VISIBLE); mDialerSelected.setVisibility(View.VISIBLE);
} }
public void updateStatusFragment(StatusFragment fragment) { public void updateStatusFragment(StatusFragment fragment) {
statusFragment = fragment; mStatusFragment = fragment;
} }
public void displaySettings() { public void displaySettings() {
@ -1037,27 +1035,27 @@ public class LinphoneActivity extends LinphoneGenericActivity
public void displayMissedCalls(final int missedCallsCount) { public void displayMissedCalls(final int missedCallsCount) {
if (missedCallsCount > 0) { if (missedCallsCount > 0) {
missedCalls.setText(missedCallsCount + ""); mMissedCalls.setText(missedCallsCount + "");
missedCalls.setVisibility(View.VISIBLE); mMissedCalls.setVisibility(View.VISIBLE);
} else { } else {
if (LinphoneManager.isInstanciated()) LinphoneManager.getLc().resetMissedCallsCount(); if (LinphoneManager.isInstanciated()) LinphoneManager.getLc().resetMissedCallsCount();
missedCalls.clearAnimation(); mMissedCalls.clearAnimation();
missedCalls.setVisibility(View.GONE); mMissedCalls.setVisibility(View.GONE);
} }
} }
public void displayMissedChats(final int missedChatCount) { public void displayMissedChats(final int missedChatCount) {
if (missedChatCount > 0) { if (missedChatCount > 0) {
missedChats.setText(missedChatCount + ""); mMissedChats.setText(missedChatCount + "");
missedChats.setVisibility(View.VISIBLE); mMissedChats.setVisibility(View.VISIBLE);
} else { } else {
missedChats.clearAnimation(); mMissedChats.clearAnimation();
missedChats.setVisibility(View.GONE); mMissedChats.setVisibility(View.GONE);
} }
if (currentFragment == FragmentsAvailable.CHAT_LIST if (mCurrentFragment == FragmentsAvailable.CHAT_LIST
&& fragment != null && mFragment != null
&& fragment instanceof ChatRoomsFragment) { && mFragment instanceof ChatRoomsFragment) {
((ChatRoomsFragment) fragment).invalidate(); ((ChatRoomsFragment) mFragment).invalidate();
} }
} }
@ -1139,7 +1137,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
public Boolean isCallTransfer() { public Boolean isCallTransfer() {
return callTransfer; return mCallTransfer;
} }
private void initInCallMenuLayout() { private void initInCallMenuLayout() {
@ -1167,7 +1165,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
public FragmentsAvailable getCurrentFragment() { public FragmentsAvailable getCurrentFragment() {
return currentFragment; return mCurrentFragment;
} }
public void addContact(String displayName, String sipUri) { public void addContact(String displayName, String sipUri) {
@ -1201,29 +1199,29 @@ public class LinphoneActivity extends LinphoneGenericActivity
@Override @Override
protected void onPostResume() { protected void onPostResume() {
super.onPostResume(); super.onPostResume();
if (pendingFragmentTransaction != FragmentsAvailable.UNKNOW) { if (mPendingFragmentTransaction != FragmentsAvailable.UNKNOW) {
changeCurrentFragment(pendingFragmentTransaction, null); changeCurrentFragment(mPendingFragmentTransaction, null);
selectMenu(pendingFragmentTransaction); selectMenu(mPendingFragmentTransaction);
pendingFragmentTransaction = FragmentsAvailable.UNKNOW; mPendingFragmentTransaction = FragmentsAvailable.UNKNOW;
} }
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (getIntent() != null && getIntent().getExtras() != null) { if (getIntent() != null && getIntent().getExtras() != null) {
newProxyConfig = getIntent().getExtras().getBoolean("isNewProxyConfig"); mNewProxyConfig = getIntent().getExtras().getBoolean("isNewProxyConfig");
} }
if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) { if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
if (data.getExtras().getBoolean("Exit", false)) { if (data.getExtras().getBoolean("Exit", false)) {
quit(); quit();
} else { } else {
pendingFragmentTransaction = mPendingFragmentTransaction =
(FragmentsAvailable) data.getExtras().getSerializable("FragmentToDisplay"); (FragmentsAvailable) data.getExtras().getSerializable("FragmentToDisplay");
} }
} else if (resultCode == Activity.RESULT_FIRST_USER && requestCode == CALL_ACTIVITY) { } else if (resultCode == Activity.RESULT_FIRST_USER && requestCode == CALL_ACTIVITY) {
getIntent().putExtra("PreviousActivity", CALL_ACTIVITY); getIntent().putExtra("PreviousActivity", CALL_ACTIVITY);
callTransfer = data != null && data.getBooleanExtra("Transfer", false); mCallTransfer = data != null && data.getBooleanExtra("Transfer", false);
if (LinphoneManager.getLc().getCallsNb() > 0) { if (LinphoneManager.getLc().getCallsNb() > 0) {
initInCallMenuLayout(); initInCallMenuLayout();
} else { } else {
@ -1244,8 +1242,8 @@ public class LinphoneActivity extends LinphoneGenericActivity
if (lc != null) { if (lc != null) {
lc.removeListener(mListener); lc.removeListener(mListener);
} }
callTransfer = false; mCallTransfer = false;
isOnBackground = true; mIsOnBackground = true;
super.onPause(); super.onPause();
} }
@ -1383,9 +1381,9 @@ public class LinphoneActivity extends LinphoneGenericActivity
break; break;
case PERMISSIONS_RECORD_AUDIO_ECHO_CANCELLER: case PERMISSIONS_RECORD_AUDIO_ECHO_CANCELLER:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
((SettingsFragment) fragment).startEchoCancellerCalibration(); ((SettingsFragment) mFragment).startEchoCancellerCalibration();
} else { } else {
((SettingsFragment) fragment).echoCalibrationFail(); ((SettingsFragment) mFragment).echoCalibrationFail();
} }
break; break;
case PERMISSIONS_READ_EXTERNAL_STORAGE_DEVICE_RINGTONE: case PERMISSIONS_READ_EXTERNAL_STORAGE_DEVICE_RINGTONE:
@ -1396,7 +1394,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
break; break;
case PERMISSIONS_RECORD_AUDIO_ECHO_TESTER: case PERMISSIONS_RECORD_AUDIO_ECHO_TESTER:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
((SettingsFragment) fragment).startEchoTester(); ((SettingsFragment) mFragment).startEchoTester();
break; break;
} }
if (readContactsI >= 0 if (readContactsI >= 0
@ -1465,7 +1463,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
.firstTimeAskingForPermission(Manifest.permission.READ_CONTACTS) .firstTimeAskingForPermission(Manifest.permission.READ_CONTACTS)
|| ActivityCompat.shouldShowRequestPermissionRationale( || ActivityCompat.shouldShowRequestPermissionRationale(
this, Manifest.permission.READ_CONTACTS)) { this, Manifest.permission.READ_CONTACTS)) {
Log.i("[Permission] Asking for contacts"); Log.i("[Permission] Asking for mContacts");
permissionsList.add(Manifest.permission.READ_CONTACTS); permissionsList.add(Manifest.permission.READ_CONTACTS);
} }
} else { } else {
@ -1485,7 +1483,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
outState.putSerializable("currentFragment", currentFragment); outState.putSerializable("mCurrentFragment", mCurrentFragment);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@ -1509,10 +1507,10 @@ public class LinphoneActivity extends LinphoneGenericActivity
if (isTablet()) { if (isTablet()) {
// Prevent fragmentContainer2 to be visible when rotating the device // Prevent fragmentContainer2 to be visible when rotating the device
LinearLayout ll = findViewById(R.id.fragmentContainer2); LinearLayout ll = findViewById(R.id.fragmentContainer2);
if (currentFragment == FragmentsAvailable.DIALER if (mCurrentFragment == FragmentsAvailable.DIALER
|| currentFragment == FragmentsAvailable.ABOUT || mCurrentFragment == FragmentsAvailable.ABOUT
|| currentFragment == FragmentsAvailable.SETTINGS || mCurrentFragment == FragmentsAvailable.SETTINGS
|| currentFragment == FragmentsAvailable.ACCOUNT_SETTINGS) { || mCurrentFragment == FragmentsAvailable.ACCOUNT_SETTINGS) {
ll.setVisibility(View.GONE); ll.setVisibility(View.GONE);
} }
} }
@ -1556,12 +1554,12 @@ public class LinphoneActivity extends LinphoneGenericActivity
displayChat(null, null, intent.getStringExtra("fileShared")); displayChat(null, null, intent.getStringExtra("fileShared"));
intent.putExtra("fileShared", ""); intent.putExtra("fileShared", "");
} }
isOnBackground = false; mIsOnBackground = false;
if (intent != null) { if (intent != null) {
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
if (extras != null && extras.containsKey("SipUriOrNumber")) { if (extras != null && extras.containsKey("SipUriOrNumber")) {
mAddressWaitingToBeCalled = extras.getString("SipUriOrNumber"); addressWaitingToBeCalled = extras.getString("SipUriOrNumber");
intent.removeExtra("SipUriOrNumber"); intent.removeExtra("SipUriOrNumber");
goToDialerFragment(); goToDialerFragment();
} }
@ -1575,7 +1573,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
mOrientationHelper = null; mOrientationHelper = null;
} }
instance = null; sInstance = null;
super.onDestroy(); super.onDestroy();
unbindDrawables(findViewById(R.id.topLayout)); unbindDrawables(findViewById(R.id.topLayout));
@ -1598,8 +1596,8 @@ public class LinphoneActivity extends LinphoneGenericActivity
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
if (getCurrentFragment() == FragmentsAvailable.SETTINGS) { if (getCurrentFragment() == FragmentsAvailable.SETTINGS) {
if (fragment instanceof SettingsFragment) { if (mFragment instanceof SettingsFragment) {
((SettingsFragment) fragment).closePreferenceScreen(); ((SettingsFragment) mFragment).closePreferenceScreen();
} }
} }
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
@ -1625,7 +1623,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
if (CallActivity.isInstanciated()) { if (CallActivity.isInstanciated()) {
CallActivity.instance().startIncomingCallActivity(); CallActivity.instance().startIncomingCallActivity();
} else { } else {
mAddressWaitingToBeCalled = extras.getString("NumberToCall"); addressWaitingToBeCalled = extras.getString("NumberToCall");
goToDialerFragment(); goToDialerFragment();
} }
} else if (extras != null && extras.getBoolean("Transfer", false)) { } else if (extras != null && extras.getBoolean("Transfer", false)) {
@ -1647,7 +1645,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
} else { } else {
if (extras != null && extras.containsKey("SipUriOrNumber")) { if (extras != null && extras.containsKey("SipUriOrNumber")) {
mAddressWaitingToBeCalled = extras.getString("SipUriOrNumber"); addressWaitingToBeCalled = extras.getString("SipUriOrNumber");
goToDialerFragment(); goToDialerFragment();
} }
} }
@ -1668,12 +1666,12 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
public boolean isOnBackground() { public boolean isOnBackground() {
return isOnBackground; return mIsOnBackground;
} }
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
switch (currentFragment) { switch (mCurrentFragment) {
case DIALER: case DIALER:
case CONTACTS_LIST: case CONTACTS_LIST:
case HISTORY_LIST: case HISTORY_LIST:
@ -1708,63 +1706,63 @@ public class LinphoneActivity extends LinphoneGenericActivity
// SIDE MENU // SIDE MENU
public void openOrCloseSideMenu(boolean open) { public void openOrCloseSideMenu(boolean open) {
if (open) { if (open) {
sideMenu.openDrawer(sideMenuContent); mSideMenu.openDrawer(mSideMenuContent);
} else { } else {
sideMenu.closeDrawer(sideMenuContent); mSideMenu.closeDrawer(mSideMenuContent);
} }
} }
public void initSideMenu() { public void initSideMenu() {
sideMenu = findViewById(R.id.side_menu); mSideMenu = findViewById(R.id.side_menu);
sideMenuItems = new ArrayList<>(); mSideMenuItems = new ArrayList<>();
if (!getResources().getBoolean(R.bool.hide_assistant_from_side_menu)) { if (!getResources().getBoolean(R.bool.hide_assistant_from_side_menu)) {
sideMenuItems.add( mSideMenuItems.add(
new MenuItem( new MenuItem(
getResources().getString(R.string.menu_assistant), getResources().getString(R.string.menu_assistant),
R.drawable.menu_assistant)); R.drawable.menu_assistant));
} }
if (!getResources().getBoolean(R.bool.hide_settings_from_side_menu)) { if (!getResources().getBoolean(R.bool.hide_settings_from_side_menu)) {
sideMenuItems.add( mSideMenuItems.add(
new MenuItem( new MenuItem(
getResources().getString(R.string.menu_settings), getResources().getString(R.string.menu_settings),
R.drawable.menu_options)); R.drawable.menu_options));
} }
if (getResources().getBoolean(R.bool.enable_in_app_purchase)) { if (getResources().getBoolean(R.bool.enable_in_app_purchase)) {
sideMenuItems.add( mSideMenuItems.add(
new MenuItem( new MenuItem(
getResources().getString(R.string.inapp), R.drawable.menu_options)); getResources().getString(R.string.inapp), R.drawable.menu_options));
} }
sideMenuItems.add( mSideMenuItems.add(
new MenuItem( new MenuItem(
getResources().getString(R.string.menu_recordings), getResources().getString(R.string.menu_recordings),
R.drawable.menu_recordings)); R.drawable.menu_recordings));
sideMenuItems.add( mSideMenuItems.add(
new MenuItem(getResources().getString(R.string.menu_about), R.drawable.menu_about)); new MenuItem(getResources().getString(R.string.menu_about), R.drawable.menu_about));
sideMenuContent = findViewById(R.id.side_menu_content); mSideMenuContent = findViewById(R.id.side_menu_content);
sideMenuItemList = findViewById(R.id.item_list); mSideMenuItemList = findViewById(R.id.item_list);
menu = findViewById(R.id.side_menu_button); mMenu = findViewById(R.id.side_menu_button);
sideMenuItemList.setAdapter( mSideMenuItemList.setAdapter(
new MenuAdapter(this, R.layout.side_menu_item_cell, sideMenuItems)); new MenuAdapter(this, R.layout.side_menu_item_cell, mSideMenuItems));
sideMenuItemList.setOnItemClickListener( mSideMenuItemList.setOnItemClickListener(
new AdapterView.OnItemClickListener() { new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (sideMenuItemList if (mSideMenuItemList
.getAdapter() .getAdapter()
.getItem(i) .getItem(i)
.toString() .toString()
.equals(getString(R.string.menu_settings))) { .equals(getString(R.string.menu_settings))) {
LinphoneActivity.instance().displaySettings(); LinphoneActivity.instance().displaySettings();
} }
if (sideMenuItemList if (mSideMenuItemList
.getAdapter() .getAdapter()
.getItem(i) .getItem(i)
.toString() .toString()
.equals(getString(R.string.menu_about))) { .equals(getString(R.string.menu_about))) {
LinphoneActivity.instance().displayAbout(); LinphoneActivity.instance().displayAbout();
} }
if (sideMenuItemList if (mSideMenuItemList
.getAdapter() .getAdapter()
.getItem(i) .getItem(i)
.toString() .toString()
@ -1772,7 +1770,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
LinphoneActivity.instance().displayAssistant(); LinphoneActivity.instance().displayAssistant();
} }
if (getResources().getBoolean(R.bool.enable_in_app_purchase)) { if (getResources().getBoolean(R.bool.enable_in_app_purchase)) {
if (sideMenuItemList if (mSideMenuItemList
.getAdapter() .getAdapter()
.getItem(i) .getItem(i)
.toString() .toString()
@ -1780,7 +1778,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
LinphoneActivity.instance().displayInapp(); LinphoneActivity.instance().displayInapp();
} }
} }
if (sideMenuItemList if (mSideMenuItemList
.getAdapter() .getAdapter()
.getItem(i) .getItem(i)
.toString() .toString()
@ -1793,21 +1791,21 @@ public class LinphoneActivity extends LinphoneGenericActivity
initAccounts(); initAccounts();
menu.setOnClickListener( mMenu.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (sideMenu.isDrawerVisible(Gravity.LEFT)) { if (mSideMenu.isDrawerVisible(Gravity.LEFT)) {
sideMenu.closeDrawer(sideMenuContent); mSideMenu.closeDrawer(mSideMenuContent);
} else { } else {
sideMenu.openDrawer(sideMenuContent); mSideMenu.openDrawer(mSideMenuContent);
} }
} }
}); });
quitLayout = findViewById(R.id.side_menu_quit); mQuitLayout = findViewById(R.id.side_menu_quit);
quitLayout.setOnClickListener( mQuitLayout.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -1835,27 +1833,27 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
private void displayMainAccount() { private void displayMainAccount() {
defaultAccount.setVisibility(View.VISIBLE); mDefaultAccount.setVisibility(View.VISIBLE);
ImageView status = defaultAccount.findViewById(R.id.main_account_status); ImageView status = mDefaultAccount.findViewById(R.id.main_account_status);
TextView address = defaultAccount.findViewById(R.id.main_account_address); TextView address = mDefaultAccount.findViewById(R.id.main_account_address);
TextView displayName = defaultAccount.findViewById(R.id.main_account_display_name); TextView displayName = mDefaultAccount.findViewById(R.id.main_account_display_name);
ProxyConfig proxy = LinphoneManager.getLc().getDefaultProxyConfig(); ProxyConfig proxy = LinphoneManager.getLc().getDefaultProxyConfig();
if (proxy == null) { if (proxy == null) {
displayName.setText(getString(R.string.no_account)); displayName.setText(getString(R.string.no_account));
status.setVisibility(View.GONE); status.setVisibility(View.GONE);
address.setText(""); address.setText("");
statusFragment.resetAccountStatus(); mStatusFragment.resetAccountStatus();
LinphoneManager.getInstance().subscribeFriendList(false); LinphoneManager.getInstance().subscribeFriendList(false);
defaultAccount.setOnClickListener(null); mDefaultAccount.setOnClickListener(null);
} else { } else {
address.setText(proxy.getIdentityAddress().asStringUriOnly()); address.setText(proxy.getIdentityAddress().asStringUriOnly());
displayName.setText(LinphoneUtils.getAddressDisplayName(proxy.getIdentityAddress())); displayName.setText(LinphoneUtils.getAddressDisplayName(proxy.getIdentityAddress()));
status.setImageResource(getStatusIconResource(proxy.getState())); status.setImageResource(getStatusIconResource(proxy.getState()));
status.setVisibility(View.VISIBLE); status.setVisibility(View.VISIBLE);
defaultAccount.setOnClickListener( mDefaultAccount.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -1872,9 +1870,9 @@ public class LinphoneActivity extends LinphoneGenericActivity
public void refreshAccounts() { public void refreshAccounts() {
if (LinphoneManager.getLc().getProxyConfigList() != null if (LinphoneManager.getLc().getProxyConfigList() != null
&& LinphoneManager.getLc().getProxyConfigList().length > 1) { && LinphoneManager.getLc().getProxyConfigList().length > 1) {
accountsList.setVisibility(View.VISIBLE); mAccountsList.setVisibility(View.VISIBLE);
accountsList.setAdapter(new AccountsListAdapter()); mAccountsList.setAdapter(new AccountsListAdapter());
accountsList.setOnItemClickListener( mAccountsList.setOnItemClickListener(
new AdapterView.OnItemClickListener() { new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick( public void onItemClick(
@ -1887,14 +1885,14 @@ public class LinphoneActivity extends LinphoneGenericActivity
} }
}); });
} else { } else {
accountsList.setVisibility(View.GONE); mAccountsList.setVisibility(View.GONE);
} }
displayMainAccount(); displayMainAccount();
} }
private void initAccounts() { private void initAccounts() {
accountsList = findViewById(R.id.accounts_list); mAccountsList = findViewById(R.id.accounts_list);
defaultAccount = findViewById(R.id.default_account); mDefaultAccount = findViewById(R.id.default_account);
} }
// Inapp Purchase // Inapp Purchase
@ -1906,7 +1904,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
new XmlRpcListenerBase() { new XmlRpcListenerBase() {
@Override @Override
public void onTrialAccountFetched(boolean isTrial) { public void onTrialAccountFetched(boolean isTrial) {
isTrialAccount = isTrial; mIsTrialAccount = isTrial;
getExpirationAccount(); getExpirationAccount();
} }
@ -1972,7 +1970,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
+ getResources().getInteger(R.integer.time_between_inapp_notification); + getResources().getInteger(R.integer.time_between_inapp_notification);
LinphonePreferences.instance().setInappPopupTime(String.valueOf(newDate)); LinphonePreferences.instance().setInappPopupTime(String.valueOf(newDate));
} }
if (isTrialAccount) { if (mIsTrialAccount) {
LinphoneService.instance() LinphoneService.instance()
.getNotificationManager() .getNotificationManager()
.displayInappNotification( .displayInappNotification(

View file

@ -41,8 +41,8 @@ public class LinphoneLauncherActivity extends Activity {
private Handler mHandler; private Handler mHandler;
private ServiceWaitThread mServiceThread; private ServiceWaitThread mServiceThread;
private String addressToCall; private String mAddressToCall;
private Uri uriToResolve; private Uri mUriToResolve;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -60,23 +60,23 @@ public class LinphoneLauncherActivity extends Activity {
String action = intent.getAction(); String action = intent.getAction();
if (Intent.ACTION_CALL.equals(action)) { if (Intent.ACTION_CALL.equals(action)) {
if (intent.getData() != null) { if (intent.getData() != null) {
addressToCall = intent.getData().toString(); mAddressToCall = intent.getData().toString();
addressToCall = addressToCall.replace("%40", "@"); mAddressToCall = mAddressToCall.replace("%40", "@");
addressToCall = addressToCall.replace("%3A", ":"); mAddressToCall = mAddressToCall.replace("%3A", ":");
if (addressToCall.startsWith("sip:")) { if (mAddressToCall.startsWith("sip:")) {
addressToCall = addressToCall.substring("sip:".length()); mAddressToCall = mAddressToCall.substring("sip:".length());
} else if (addressToCall.startsWith("tel:")) { } else if (mAddressToCall.startsWith("tel:")) {
addressToCall = addressToCall.substring("tel:".length()); mAddressToCall = mAddressToCall.substring("tel:".length());
} }
} }
} else if (Intent.ACTION_VIEW.equals(action)) { } else if (Intent.ACTION_VIEW.equals(action)) {
if (LinphoneService.isReady()) { if (LinphoneService.isReady()) {
addressToCall = mAddressToCall =
ContactsManager.getInstance() ContactsManager.getInstance()
.getAddressOrNumberForAndroidContact( .getAddressOrNumberForAndroidContact(
getContentResolver(), intent.getData()); getContentResolver(), intent.getData());
} else { } else {
uriToResolve = intent.getData(); mUriToResolve = intent.getData();
} }
} }
} }
@ -153,22 +153,22 @@ public class LinphoneLauncherActivity extends Activity {
} }
} }
} }
if (uriToResolve != null) { if (mUriToResolve != null) {
addressToCall = mAddressToCall =
ContactsManager.getInstance() ContactsManager.getInstance()
.getAddressOrNumberForAndroidContact( .getAddressOrNumberForAndroidContact(
getContentResolver(), uriToResolve); getContentResolver(), mUriToResolve);
Log.i( Log.i(
"LinphoneLauncher", "LinphoneLauncher",
"Intent has uri to resolve : " + uriToResolve.toString()); "Intent has uri to resolve : " + mUriToResolve.toString());
uriToResolve = null; mUriToResolve = null;
} }
if (addressToCall != null) { if (mAddressToCall != null) {
newIntent.putExtra("SipUriOrNumber", addressToCall); newIntent.putExtra("SipUriOrNumber", mAddressToCall);
Log.i( Log.i(
"LinphoneLauncher", "LinphoneLauncher",
"Intent has address to call : " + addressToCall); "Intent has address to call : " + mAddressToCall);
addressToCall = null; mAddressToCall = null;
} }
startActivity(newIntent); startActivity(newIntent);
if (classToStart == LinphoneActivity.class if (classToStart == LinphoneActivity.class

View file

@ -126,8 +126,8 @@ import org.linphone.receivers.NetworkManager;
import org.linphone.receivers.OutgoingCallReceiver; import org.linphone.receivers.OutgoingCallReceiver;
import org.linphone.settings.LinphonePreferences; import org.linphone.settings.LinphonePreferences;
import org.linphone.utils.FileUtils; import org.linphone.utils.FileUtils;
import org.linphone.utils.LinphoneMediaScanner;
import org.linphone.utils.LinphoneUtils; import org.linphone.utils.LinphoneUtils;
import org.linphone.utils.MediaScanner;
import org.linphone.utils.MediaScannerListener; import org.linphone.utils.MediaScannerListener;
/** /**
@ -147,9 +147,13 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL; private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
private static final int dbStep = 4; private static final int dbStep = 4;
private static LinphoneManager instance;
private static LinphoneManager sInstance;
private static boolean sExited; private static boolean sExited;
public final String mConfigFile;
public String configFile;
public String wizardLoginViewDomain = null;
/** Called when the activity is first created. */ /** Called when the activity is first created. */
private final String mLPConfigXsd; private final String mLPConfigXsd;
@ -160,20 +164,19 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
private final String mCallLogDatabaseFile; private final String mCallLogDatabaseFile;
private final String mFriendsDatabaseFile; private final String mFriendsDatabaseFile;
private final String mUserCertsPath; private final String mUserCertsPath;
public String wizardLoginViewDomain = null;
private Context mServiceContext; private Context mServiceContext;
private AudioManager mAudioManager; private AudioManager mAudioManager;
private PowerManager mPowerManager; private PowerManager mPowerManager;
private Resources mR; private Resources mRessources;
private LinphonePreferences mPrefs; private LinphonePreferences mPrefs;
private Core mLc; private Core mCore;
private OpenH264DownloadHelper mCodecDownloader; private OpenH264DownloadHelper mCodecDownloader;
private OpenH264DownloadHelperListener mCodecListener; private OpenH264DownloadHelperListener mCodecListener;
private String basePath; private String mBasePath;
private boolean mAudioFocused; private boolean mAudioFocused;
private boolean echoTesterIsRunning; private boolean mEchoTesterIsRunning;
private boolean dozeModeEnabled; private boolean mDozeModeEnabled;
private boolean callGsmON; private boolean mCallGsmON;
private int mLastNetworkType = -1; private int mLastNetworkType = -1;
private ConnectivityManager mConnectivityManager; private ConnectivityManager mConnectivityManager;
private BroadcastReceiver mKeepAliveReceiver; private BroadcastReceiver mKeepAliveReceiver;
@ -188,35 +191,35 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
private IntentFilter mNetworkIntentFilter; private IntentFilter mNetworkIntentFilter;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private WakeLock mProximityWakelock; private WakeLock mProximityWakelock;
private AccountCreator accountCreator; private AccountCreator mAccountCreator;
private SensorManager mSensorManager; private SensorManager mSensorManager;
private Sensor mProximity; private Sensor mProximity;
private boolean mProximitySensingEnabled; private boolean mProximitySensingEnabled;
private boolean handsetON = false; private boolean mHandsetON = false;
private Address mCurrentChatRoomAddress; private Address mCurrentChatRoomAddress;
private Timer mTimer; private Timer mTimer;
private Map<String, Integer> mUnreadChatsPerRoom; private Map<String, Integer> mUnreadChatsPerRoom;
private LinphoneMediaScanner mMediaScanner; private MediaScanner mMediaScanner;
private Call ringingCall; private Call mRingingCall;
private MediaPlayer mRingerPlayer; private MediaPlayer mRingerPlayer;
private Vibrator mVibrator; private Vibrator mVibrator;
private boolean isRinging; private boolean mIsRinging;
protected LinphoneManager(final Context c) { protected LinphoneManager(Context c) {
mUnreadChatsPerRoom = new HashMap(); mUnreadChatsPerRoom = new HashMap();
sExited = false; sExited = false;
echoTesterIsRunning = false; mEchoTesterIsRunning = false;
mServiceContext = c; mServiceContext = c;
basePath = c.getFilesDir().getAbsolutePath(); mBasePath = c.getFilesDir().getAbsolutePath();
mLPConfigXsd = basePath + "/lpconfig.xsd"; mLPConfigXsd = mBasePath + "/lpconfig.xsd";
mLinphoneFactoryConfigFile = basePath + "/linphonerc"; mLinphoneFactoryConfigFile = mBasePath + "/linphonerc";
mConfigFile = basePath + "/.linphonerc"; configFile = mBasePath + "/.linphonerc";
mDynamicConfigFile = basePath + "/assistant_create.rc"; mDynamicConfigFile = mBasePath + "/assistant_create.rc";
mChatDatabaseFile = basePath + "/linphone-history.db"; mChatDatabaseFile = mBasePath + "/linphone-history.db";
mCallLogDatabaseFile = basePath + "/linphone-log-history.db"; mCallLogDatabaseFile = mBasePath + "/linphone-log-history.db";
mFriendsDatabaseFile = basePath + "/linphone-friends.db"; mFriendsDatabaseFile = mBasePath + "/linphone-friends.db";
mRingSoundFile = basePath + "/ringtone.mkv"; mRingSoundFile = mBasePath + "/ringtone.mkv";
mUserCertsPath = basePath + "/user-certs"; mUserCertsPath = mBasePath + "/user-certs";
mPrefs = LinphonePreferences.instance(); mPrefs = LinphonePreferences.instance();
mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE)); mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));
@ -226,7 +229,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
(ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
mSensorManager = (SensorManager) c.getSystemService(Context.SENSOR_SERVICE); mSensorManager = (SensorManager) c.getSystemService(Context.SENSOR_SERVICE);
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
mR = c.getResources(); mRessources = c.getResources();
File f = new File(mUserCertsPath); File f = new File(mUserCertsPath);
if (!f.exists()) { if (!f.exists()) {
@ -235,28 +238,28 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
} }
mMediaScanner = new LinphoneMediaScanner(c); mMediaScanner = new MediaScanner(c);
} }
public static final synchronized LinphoneManager createAndStart(Context c) { public static final synchronized LinphoneManager createAndStart(Context c) {
if (instance != null) { if (sInstance != null) {
Log.e( Log.e(
"Linphone Manager is already initialized ! Destroying it and creating a new one..."); "Linphone Manager is already initialized ! Destroying it and creating a new one...");
destroy(); destroy();
} }
instance = new LinphoneManager(c); sInstance = new LinphoneManager(c);
instance.startLibLinphone(c); sInstance.startLibLinphone(c);
instance.initOpenH264DownloadHelper(); sInstance.initOpenH264DownloadHelper();
// H264 codec Management - set to auto mode -> MediaCodec >= android 5.0 >= OpenH264 // H264 codec Management - set to auto mode -> MediaCodec >= android 5.0 >= OpenH264
H264Helper.setH264Mode(H264Helper.MODE_AUTO, getLc()); H264Helper.setH264Mode(H264Helper.MODE_AUTO, getLc());
return instance; return sInstance;
} }
public static final synchronized LinphoneManager getInstance() { public static final synchronized LinphoneManager getInstance() {
if (instance != null) return instance; if (sInstance != null) return sInstance;
if (sExited) { if (sExited) {
throw new RuntimeException( throw new RuntimeException(
@ -268,7 +271,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public static final synchronized Core getLc() { public static final synchronized Core getLc() {
return getInstance().mLc; return getInstance().mCore;
} }
public static Boolean isProximitySensorNearby(final SensorEvent event) { public static Boolean isProximitySensorNearby(final SensorEvent event) {
@ -291,8 +294,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public static void ContactsManagerDestroy() { public static void ContactsManagerDestroy() {
if (LinphoneManager.instance != null && LinphoneManager.instance.mServiceContext != null) if (LinphoneManager.sInstance != null && LinphoneManager.sInstance.mServiceContext != null)
LinphoneManager.instance LinphoneManager.sInstance
.mServiceContext .mServiceContext
.getContentResolver() .getContentResolver()
.unregisterContentObserver(ContactsManager.getInstance()); .unregisterContentObserver(ContactsManager.getInstance());
@ -304,28 +307,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public static synchronized void destroy() { public static synchronized void destroy() {
if (instance == null) return; if (sInstance == null) return;
instance.changeStatusToOffline(); sInstance.changeStatusToOffline();
instance.mMediaScanner.destroy(); sInstance.mMediaScanner.destroy();
sExited = true; sExited = true;
instance.destroyCore(); sInstance.destroyCore();
instance = null; sInstance = null;
}
public static String extractADisplayName(Resources r, Address address) {
if (address == null) return r.getString(R.string.unknown_incoming_call_name);
final String displayName = address.getDisplayName();
if (displayName != null) {
return displayName;
} else if (address.getUsername() != null) {
return address.getUsername();
} else {
String rms = address.toString();
if (rms != null && rms.length() > 1) return rms;
return r.getString(R.string.unknown_incoming_call_name);
}
} }
public static boolean reinviteWithVideo() { public static boolean reinviteWithVideo() {
@ -333,7 +320,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public static synchronized Core getLcIfManagerNotDestroyedOrNull() { public static synchronized Core getLcIfManagerNotDestroyedOrNull() {
if (sExited || instance == null) { if (sExited || sInstance == null) {
// Can occur if the UI thread play a posted event but in the meantime the // Can occur if the UI thread play a posted event but in the meantime the
// LinphoneManager was destroyed // LinphoneManager was destroyed
// Ex: stop call and quickly terminate application. // Ex: stop call and quickly terminate application.
@ -343,7 +330,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public static final boolean isInstanciated() { public static final boolean isInstanciated() {
return instance != null; return sInstance != null;
} }
private void routeAudioToSpeakerHelper(boolean speakerOn) { private void routeAudioToSpeakerHelper(boolean speakerOn) {
@ -522,17 +509,13 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
} }
public String getLPConfigXsdPath() {
return mLPConfigXsd;
}
public void newOutgoingCall(AddressType address) { public void newOutgoingCall(AddressType address) {
String to = address.getText().toString(); String to = address.getText().toString();
newOutgoingCall(to, address.getDisplayedName()); newOutgoingCall(to, address.getDisplayedName());
} }
public void newOutgoingCall(String to, String displayName) { public void newOutgoingCall(String to, String displayName) {
// if (mLc.inCall()) { // if (mCore.inCall()) {
// listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall(); // listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall();
// return; // return;
// } // }
@ -550,14 +533,14 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
Address lAddress; Address lAddress;
lAddress = mLc.interpretUrl(to); // InterpretUrl does normalizePhoneNumber lAddress = mCore.interpretUrl(to); // InterpretUrl does normalizePhoneNumber
if (lAddress == null) { if (lAddress == null) {
Log.e("Couldn't convert to String to Address : " + to); Log.e("Couldn't convert to String to Address : " + to);
return; return;
} }
ProxyConfig lpc = mLc.getDefaultProxyConfig(); ProxyConfig lpc = mCore.getDefaultProxyConfig();
if (mR.getBoolean(R.bool.forbid_self_call) if (mRessources.getBoolean(R.bool.forbid_self_call)
&& lpc != null && lpc != null
&& lAddress.asStringUriOnly().equals(lpc.getIdentityAddress())) { && lAddress.asStringUriOnly().equals(lpc.getIdentityAddress())) {
return; return;
@ -568,7 +551,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
!LinphoneUtils.isHighBandwidthConnection( !LinphoneUtils.isHighBandwidthConnection(
LinphoneService.instance().getApplicationContext()); LinphoneService.instance().getApplicationContext());
if (mLc.isNetworkReachable()) { if (mCore.isNetworkReachable()) {
if (Version.isVideoCapable()) { if (Version.isVideoCapable()) {
boolean prefVideoEnable = mPrefs.isVideoEnabled(); boolean prefVideoEnable = mPrefs.isVideoEnabled();
boolean prefInitiateWithVideo = mPrefs.shouldInitiateVideoCall(); boolean prefInitiateWithVideo = mPrefs.shouldInitiateVideoCall();
@ -615,7 +598,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
if (mServiceContext.getResources().getBoolean(R.bool.enable_call_notification)) if (mServiceContext.getResources().getBoolean(R.bool.enable_call_notification))
LinphoneService.instance() LinphoneService.instance()
.getNotificationManager() .getNotificationManager()
.displayCallNotification(mLc.getCurrentCall()); .displayCallNotification(mCore.getCurrentCall());
} }
} }
@ -632,16 +615,16 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public void terminateCall() { public void terminateCall() {
if (mLc.inCall()) { if (mCore.inCall()) {
mLc.terminateCall(mLc.getCurrentCall()); mCore.terminateCall(mCore.getCurrentCall());
} }
} }
public void initTunnelFromConf() { public void initTunnelFromConf() {
if (!mLc.tunnelAvailable()) return; if (!mCore.tunnelAvailable()) return;
NetworkInfo info = mConnectivityManager.getActiveNetworkInfo(); NetworkInfo info = mConnectivityManager.getActiveNetworkInfo();
Tunnel tunnel = mLc.getTunnel(); Tunnel tunnel = mCore.getTunnel();
tunnel.cleanServers(); tunnel.cleanServers();
TunnelConfig config = mPrefs.getTunnelConfig(); TunnelConfig config = mPrefs.getTunnelConfig();
if (config.getHost() != null) { if (config.getHost() != null) {
@ -671,20 +654,10 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
return false; return false;
} }
// public void loadConfig(){
// try {
// copyIfNotExist(R.raw.configrc, mConfigFile);
// } catch (Exception e){
// Log.w(e);
// }
// LinphonePreferences.instance().setRemoteProvisioningUrl("file://" + mConfigFile);
// getLc().getConfig().setInt("misc","transient_provisioning",1);
// }
private void manageTunnelServer(NetworkInfo info) { private void manageTunnelServer(NetworkInfo info) {
if (mLc == null) return; if (mCore == null) return;
if (!mLc.tunnelAvailable()) return; if (!mCore.tunnelAvailable()) return;
Tunnel tunnel = mLc.getTunnel(); Tunnel tunnel = mCore.getTunnel();
Log.i("Managing tunnel"); Log.i("Managing tunnel");
if (isTunnelNeeded(info)) { if (isTunnelNeeded(info)) {
@ -739,7 +712,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} catch (Exception e) { } catch (Exception e) {
Log.e(e); Log.e(e);
} }
mLc = null; mCore = null;
} }
} }
@ -753,9 +726,9 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
try { try {
copyAssetsFromPackage(); copyAssetsFromPackage();
// traces alway start with traces enable to not missed first initialization // traces alway start with traces enable to not missed first initialization
mLc = Factory.instance().createCore(mConfigFile, mLinphoneFactoryConfigFile, c); mCore = Factory.instance().createCore(configFile, mLinphoneFactoryConfigFile, c);
mLc.addListener(this); mCore.addListener(this);
mLc.start(); mCore.start();
TimerTask lTask = TimerTask lTask =
new TimerTask() { new TimerTask() {
@Override @Override
@ -764,8 +737,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
if (mLc != null) { if (mCore != null) {
mLc.iterate(); mCore.iterate();
} }
} }
}); });
@ -804,37 +777,37 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
private synchronized void initLiblinphone(Core lc) throws CoreException { private synchronized void initLiblinphone(Core lc) throws CoreException {
mLc = lc; mCore = lc;
mLc.setZrtpSecretsFile(basePath + "/zrtp_secrets"); mCore.setZrtpSecretsFile(mBasePath + "/zrtp_secrets");
String deviceName = LinphoneUtils.getDeviceName(mServiceContext); String deviceName = LinphoneUtils.getDeviceName(mServiceContext);
String appName = mServiceContext.getResources().getString(R.string.user_agent); String appName = mServiceContext.getResources().getString(R.string.user_agent);
String androidVersion = BuildConfig.VERSION_NAME; String androidVersion = BuildConfig.VERSION_NAME;
String userAgent = appName + "/" + androidVersion + " (" + deviceName + ") LinphoneSDK"; String userAgent = appName + "/" + androidVersion + " (" + deviceName + ") LinphoneSDK";
mLc.setUserAgent( mCore.setUserAgent(
userAgent, userAgent,
getString(R.string.linphone_sdk_version) getString(R.string.linphone_sdk_version)
+ " (" + " ("
+ getString(R.string.linphone_sdk_branch) + getString(R.string.linphone_sdk_branch)
+ ")"); + ")");
mLc.checkForUpdate(androidVersion); mCore.checkForUpdate(androidVersion);
mLc.setChatDatabasePath(mChatDatabaseFile); mCore.setChatDatabasePath(mChatDatabaseFile);
mLc.setCallLogsDatabasePath(mCallLogDatabaseFile); mCore.setCallLogsDatabasePath(mCallLogDatabaseFile);
mLc.setFriendsDatabasePath(mFriendsDatabaseFile); mCore.setFriendsDatabasePath(mFriendsDatabaseFile);
mLc.setUserCertificatesPath(mUserCertsPath); mCore.setUserCertificatesPath(mUserCertsPath);
// mLc.setCallErrorTone(Reason.NotFound, mErrorToneFile); // mCore.setCallErrorTone(Reason.NotFound, mErrorToneFile);
enableDeviceRingtone(mPrefs.isDeviceRingtoneEnabled()); enableDeviceRingtone(mPrefs.isDeviceRingtoneEnabled());
int availableCores = Runtime.getRuntime().availableProcessors(); int availableCores = Runtime.getRuntime().availableProcessors();
Log.w("MediaStreamer : " + availableCores + " cores detected and configured"); Log.w("MediaStreamer : " + availableCores + " cores detected and configured");
mLc.migrateLogsFromRcToDb(); mCore.migrateLogsFromRcToDb();
// Migrate existing linphone accounts to have conference factory uri set // Migrate existing linphone accounts to have conference factory uri set
for (ProxyConfig lpc : mLc.getProxyConfigList()) { for (ProxyConfig lpc : mCore.getProxyConfigList()) {
if (lpc.getConferenceFactoryUri() == null if (lpc.getConferenceFactoryUri() == null
&& lpc.getIdentityAddress() && lpc.getIdentityAddress()
.getDomain() .getDomain()
@ -877,7 +850,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
mDozeIntentFilter = new IntentFilter(); mDozeIntentFilter = new IntentFilter();
mDozeIntentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED); mDozeIntentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
mDozeReceiver = new DozeReceiver(); mDozeReceiver = new DozeReceiver();
dozeModeEnabled = mDozeModeEnabled =
((PowerManager) mServiceContext.getSystemService(Context.POWER_SERVICE)) ((PowerManager) mServiceContext.getSystemService(Context.POWER_SERVICE))
.isDeviceIdleMode(); .isDeviceIdleMode();
mServiceContext.registerReceiver(mDozeReceiver, mDozeIntentFilter); mServiceContext.registerReceiver(mDozeReceiver, mDozeIntentFilter);
@ -899,36 +872,36 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
resetCameraFromPreferences(); resetCameraFromPreferences();
accountCreator = mAccountCreator =
LinphoneManager.getLc() LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl()); .createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this); mAccountCreator.setListener(this);
callGsmON = false; mCallGsmON = false;
updateMissedChatCount(); updateMissedChatCount();
} }
public void setHandsetMode(Boolean on) { public void setHandsetMode(Boolean on) {
if (mLc.isIncomingInvitePending() && on) { if (mCore.isIncomingInvitePending() && on) {
handsetON = true; mHandsetON = true;
acceptCall(mLc.getCurrentCall()); acceptCall(mCore.getCurrentCall());
LinphoneActivity.instance().startIncallActivity(); LinphoneActivity.instance().startIncallActivity();
} else if (on && CallActivity.isInstanciated()) { } else if (on && CallActivity.isInstanciated()) {
handsetON = true; mHandsetON = true;
CallActivity.instance().setSpeakerEnabled(true); CallActivity.instance().setSpeakerEnabled(true);
CallActivity.instance().refreshInCallActions(); CallActivity.instance().refreshInCallActions();
} else if (!on) { } else if (!on) {
handsetON = false; mHandsetON = false;
LinphoneManager.getInstance().terminateCall(); LinphoneManager.getInstance().terminateCall();
} }
} }
public boolean isHansetModeOn() { public boolean isHansetModeOn() {
return handsetON; return mHandsetON;
} }
private void copyAssetsFromPackage() throws IOException { private void copyAssetsFromPackage() throws IOException {
copyIfNotExist(R.raw.linphonerc_default, mConfigFile); copyIfNotExist(R.raw.linphonerc_default, configFile);
copyFromPackage(R.raw.linphonerc_factory, new File(mLinphoneFactoryConfigFile).getName()); copyFromPackage(R.raw.linphonerc_factory, new File(mLinphoneFactoryConfigFile).getName());
copyIfNotExist(R.raw.lpconfig, mLPConfigXsd); copyIfNotExist(R.raw.lpconfig, mLPConfigXsd);
copyFromPackage(R.raw.assistant_create, new File(mDynamicConfigFile).getName()); copyFromPackage(R.raw.assistant_create, new File(mDynamicConfigFile).getName());
@ -943,7 +916,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
public void copyFromPackage(int ressourceId, String target) throws IOException { public void copyFromPackage(int ressourceId, String target) throws IOException {
FileOutputStream lOutputStream = mServiceContext.openFileOutput(target, 0); FileOutputStream lOutputStream = mServiceContext.openFileOutput(target, 0);
InputStream lInputStream = mR.openRawResource(ressourceId); InputStream lInputStream = mRessources.openRawResource(ressourceId);
int readByte; int readByte;
byte[] buff = new byte[8048]; byte[] buff = new byte[8048];
while ((readByte = lInputStream.read(buff)) != -1) { while ((readByte = lInputStream.read(buff)) != -1) {
@ -975,20 +948,20 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
if (networkInfo == null || !connected) { if (networkInfo == null || !connected) {
Log.i("No connectivity: setting network unreachable"); Log.i("No connectivity: setting network unreachable");
mLc.setNetworkReachable(false); mCore.setNetworkReachable(false);
} else if (dozeModeEnabled) { } else if (mDozeModeEnabled) {
Log.i("Doze Mode enabled: shutting down network"); Log.i("Doze Mode enabled: shutting down network");
mLc.setNetworkReachable(false); mCore.setNetworkReachable(false);
} else if (connected) { } else if (connected) {
manageTunnelServer(networkInfo); manageTunnelServer(networkInfo);
boolean wifiOnly = LinphonePreferences.instance().isWifiOnlyEnabled(); boolean wifiOnly = LinphonePreferences.instance().isWifiOnlyEnabled();
if (wifiOnly) { if (wifiOnly) {
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
mLc.setNetworkReachable(true); mCore.setNetworkReachable(true);
} else { } else {
Log.i("Wifi-only mode, setting network not reachable"); Log.i("Wifi-only mode, setting network not reachable");
mLc.setNetworkReachable(false); mCore.setNetworkReachable(false);
} }
} else { } else {
int curtype = networkInfo.getType(); int curtype = networkInfo.getType();
@ -998,14 +971,14 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
// make sure all current connections are destroyed. // make sure all current connections are destroyed.
// they will be re-created during setNetworkReachable(true). // they will be re-created during setNetworkReachable(true).
Log.i("Connectivity has changed."); Log.i("Connectivity has changed.");
mLc.setNetworkReachable(false); mCore.setNetworkReachable(false);
} }
mLc.setNetworkReachable(true); mCore.setNetworkReachable(true);
mLastNetworkType = curtype; mLastNetworkType = curtype;
} }
} }
if (mLc.isNetworkReachable()) { if (mCore.isNetworkReachable()) {
// When network isn't available, push informations might not be set. This should fix the // When network isn't available, push informations might not be set. This should fix the
// issue. // issue.
LinphonePreferences prefs = LinphonePreferences.instance(); LinphonePreferences prefs = LinphonePreferences.instance();
@ -1019,17 +992,17 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
// at 0 // at 0
if (LinphonePreferences.instance().isPushNotificationEnabled() if (LinphonePreferences.instance().isPushNotificationEnabled()
|| LinphonePreferences.instance().isBackgroundModeEnabled()) { || LinphonePreferences.instance().isBackgroundModeEnabled()) {
mLc.setNetworkReachable(false); mCore.setNetworkReachable(false);
} }
} }
mLc = null; mCore = null;
} }
public void dozeManager(boolean enable) { public void dozeManager(boolean enable) {
if (enable) { if (enable) {
Log.i("[Doze Mode]: register"); Log.i("[Doze Mode]: register");
mServiceContext.registerReceiver(mDozeReceiver, mDozeIntentFilter); mServiceContext.registerReceiver(mDozeReceiver, mDozeIntentFilter);
dozeModeEnabled = true; mDozeModeEnabled = true;
} else { } else {
Log.i("[Doze Mode]: unregister"); Log.i("[Doze Mode]: unregister");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@ -1039,7 +1012,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
e.printStackTrace(); e.printStackTrace();
} }
} }
dozeModeEnabled = false; mDozeModeEnabled = false;
} }
} }
@ -1079,12 +1052,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
@Override @Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {} public void onAccuracyChanged(Sensor sensor, int accuracy) {}
public LinphoneMediaScanner getMediaScanner() { public MediaScanner getMediaScanner() {
return mMediaScanner; return mMediaScanner;
} }
private String getString(int key) { private String getString(int key) {
return mR.getString(key); return mRessources.getString(key);
} }
/* Simple implementation as Android way seems very complicate: /* Simple implementation as Android way seems very complicate:
@ -1326,8 +1299,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
if (state == State.IncomingReceived && getCallGsmON()) { if (state == State.IncomingReceived && getCallGsmON()) {
if (mLc != null) { if (mCore != null) {
mLc.declineCall(call, Reason.Busy); mCore.declineCall(call, Reason.Busy);
} }
} else if (state == State.IncomingReceived } else if (state == State.IncomingReceived
&& (LinphonePreferences.instance().isAutoAnswerEnabled()) && (LinphonePreferences.instance().isAutoAnswerEnabled())
@ -1336,8 +1309,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
new TimerTask() { new TimerTask() {
@Override @Override
public void run() { public void run() {
if (mLc != null) { if (mCore != null) {
if (mLc.getCallsNb() > 0) { if (mCore.getCallsNb() > 0) {
acceptCall(call); acceptCall(call);
if (LinphoneManager.getInstance() != null) { if (LinphoneManager.getInstance() != null) {
LinphoneManager.getInstance().routeAudioToReceiver(); LinphoneManager.getInstance().routeAudioToReceiver();
@ -1352,22 +1325,22 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
mTimer.schedule(lTask, mPrefs.getAutoAnswerTime()); mTimer.schedule(lTask, mPrefs.getAutoAnswerTime());
} else if (state == State.IncomingReceived } else if (state == State.IncomingReceived
|| (state == State.IncomingEarlyMedia || (state == State.IncomingEarlyMedia
&& mR.getBoolean(R.bool.allow_ringing_while_early_media))) { && mRessources.getBoolean(R.bool.allow_ringing_while_early_media))) {
// Brighten screen for at least 10 seconds // Brighten screen for at least 10 seconds
if (mLc.getCallsNb() == 1) { if (mCore.getCallsNb() == 1) {
requestAudioFocus(STREAM_RING); requestAudioFocus(STREAM_RING);
ringingCall = call; mRingingCall = call;
startRinging(); startRinging();
// otherwise there is the beep // otherwise there is the beep
} }
} else if (call == ringingCall && isRinging) { } else if (call == mRingingCall && mIsRinging) {
// previous state was ringing, so stop ringing // previous state was ringing, so stop ringing
stopRinging(); stopRinging();
} }
if (state == State.Connected) { if (state == State.Connected) {
if (mLc.getCallsNb() == 1) { if (mCore.getCallsNb() == 1) {
// It is for incoming calls, because outgoing calls enter MODE_IN_COMMUNICATION // It is for incoming calls, because outgoing calls enter MODE_IN_COMMUNICATION
// immediately when they start. // immediately when they start.
// However, incoming call first use the MODE_RINGING to play the local ring. // However, incoming call first use the MODE_RINGING to play the local ring.
@ -1385,7 +1358,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
if (state == State.End || state == State.Error) { if (state == State.End || state == State.Error) {
if (mLc.getCallsNb() == 0) { if (mCore.getCallsNb() == 0) {
// Disabling proximity sensor // Disabling proximity sensor
enableProximitySensing(false); enableProximitySensing(false);
Context activity = getContext(); Context activity = getContext();
@ -1462,7 +1435,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL); int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL);
int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL); int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL);
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0); mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0);
mLc.startEchoCancellerCalibration(); mCore.startEchoCancellerCalibration();
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, oldVolume, 0); mAudioManager.setStreamVolume(STREAM_VOICE_CALL, oldVolume, 0);
} }
@ -1471,7 +1444,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
setAudioManagerInCallMode(); setAudioManagerInCallMode();
Log.i("Set audio mode on 'Voice Communication'"); Log.i("Set audio mode on 'Voice Communication'");
requestAudioFocus(STREAM_VOICE_CALL); requestAudioFocus(STREAM_VOICE_CALL);
int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL);
int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL); int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL);
int sampleRate = 44100; int sampleRate = 44100;
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0); mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0);
@ -1480,23 +1452,14 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
mAudioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); mAudioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
sampleRate = Integer.parseInt(sampleRateProperty); sampleRate = Integer.parseInt(sampleRateProperty);
} }
/*int status = */ mLc.startEchoTester(sampleRate); mCore.startEchoTester(sampleRate);
/*if (status > 0)*/ mEchoTesterIsRunning = true;
echoTesterIsRunning = true;
/*else {
echoTesterIsRunning = false;
routeAudioToReceiver();
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, oldVolume, 0);
((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);
Log.i("Set audio mode on 'Normal'");
}*/
return 1; return 1;
// return status;
} }
public int stopEchoTester() throws CoreException { public int stopEchoTester() throws CoreException {
echoTesterIsRunning = false; mEchoTesterIsRunning = false;
/*int status = */ mLc.stopEchoTester(); mCore.stopEchoTester();
routeAudioToReceiver(); routeAudioToReceiver();
((AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE)) ((AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE))
.setMode(AudioManager.MODE_NORMAL); .setMode(AudioManager.MODE_NORMAL);
@ -1505,7 +1468,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public boolean getEchoTesterStatus() { public boolean getEchoTesterStatus() {
return echoTesterIsRunning; return mEchoTesterIsRunning;
} }
private void requestAudioFocus(int stream) { private void requestAudioFocus(int stream) {
@ -1524,9 +1487,9 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
public void enableDeviceRingtone(boolean use) { public void enableDeviceRingtone(boolean use) {
if (use) { if (use) {
mLc.setRing(null); mCore.setRing(null);
} else { } else {
mLc.setRing(mRingSoundFile); mCore.setRing(mRingSoundFile);
} }
} }
@ -1537,7 +1500,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
return; return;
} }
if (mR.getBoolean(R.bool.allow_ringing_while_early_media)) { if (mRessources.getBoolean(R.bool.allow_ringing_while_early_media)) {
routeAudioToSpeaker(); // Need to be able to ear the ringtone during the early media routeAudioToSpeaker(); // Need to be able to ear the ringtone during the early media
} }
@ -1581,7 +1544,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} catch (Exception e) { } catch (Exception e) {
Log.e(e, "cannot handle incoming call"); Log.e(e, "cannot handle incoming call");
} }
isRinging = true; mIsRinging = true;
} }
private synchronized void stopRinging() { private synchronized void stopRinging() {
@ -1596,7 +1559,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
if (Hacks.needGalaxySAudioHack()) mAudioManager.setMode(AudioManager.MODE_NORMAL); if (Hacks.needGalaxySAudioHack()) mAudioManager.setMode(AudioManager.MODE_NORMAL);
isRinging = false; mIsRinging = false;
// You may need to call galaxys audio hack after this method // You may need to call galaxys audio hack after this method
if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
if (mServiceContext.getResources().getBoolean(R.bool.isTablet)) { if (mServiceContext.getResources().getBoolean(R.bool.isTablet)) {
@ -1610,7 +1573,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public boolean hasLinphoneAccount() { public boolean hasLinphoneAccount() {
for (ProxyConfig proxyConfig : mLc.getProxyConfigList()) { for (ProxyConfig proxyConfig : mCore.getProxyConfigList()) {
if (getString(R.string.default_domain) if (getString(R.string.default_domain)
.equals(proxyConfig.getIdentityAddress().getDomain())) { .equals(proxyConfig.getIdentityAddress().getDomain())) {
return true; return true;
@ -1621,7 +1584,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
/** @return false if already in video call. */ /** @return false if already in video call. */
public boolean addVideo() { public boolean addVideo() {
Call call = mLc.getCurrentCall(); Call call = mCore.getCurrentCall();
enableCamera(call, true); enableCamera(call, true);
return reinviteWithVideo(); return reinviteWithVideo();
} }
@ -1648,7 +1611,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public boolean acceptCallWithParams(Call call, CallParams params) { public boolean acceptCallWithParams(Call call, CallParams params) {
mLc.acceptCallWithParams(call, params); mCore.acceptCallWithParams(call, params);
return true; return true;
} }
@ -1661,7 +1624,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
if (nextVolume > maxVolume) nextVolume = maxVolume; if (nextVolume > maxVolume) nextVolume = maxVolume;
if (nextVolume < 0) nextVolume = 0; if (nextVolume < 0) nextVolume = 0;
mLc.setPlaybackGainDb((nextVolume - maxVolume) * dbStep); mCore.setPlaybackGainDb((nextVolume - maxVolume) * dbStep);
} else } else
// starting from ICS, volume must be adjusted by the application, at least for // starting from ICS, volume must be adjusted by the application, at least for
// STREAM_VOICE_CALL volume stream // STREAM_VOICE_CALL volume stream
@ -1674,13 +1637,13 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
public void isAccountWithAlias() { public void isAccountWithAlias() {
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
long now = new Timestamp(new Date().getTime()).getTime(); long now = new Timestamp(new Date().getTime()).getTime();
if (accountCreator != null && LinphonePreferences.instance().getLinkPopupTime() == null if (mAccountCreator != null && LinphonePreferences.instance().getLinkPopupTime() == null
|| Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) < now) { || Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) < now) {
accountCreator.setUsername( mAccountCreator.setUsername(
LinphonePreferences.instance() LinphonePreferences.instance()
.getAccountUsername( .getAccountUsername(
LinphonePreferences.instance().getDefaultAccountIndex())); LinphonePreferences.instance().getDefaultAccountIndex()));
accountCreator.isAccountExist(); mAccountCreator.isAccountExist();
} }
} else { } else {
LinphonePreferences.instance().setLinkPopupTime(null); LinphonePreferences.instance().setLinkPopupTime(null);
@ -1759,7 +1722,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public void setDozeModeEnabled(boolean b) { public void setDozeModeEnabled(boolean b) {
dozeModeEnabled = b; mDozeModeEnabled = b;
} }
public String getmDynamicConfigFile() { public String getmDynamicConfigFile() {
@ -1767,11 +1730,11 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} }
public boolean getCallGsmON() { public boolean getCallGsmON() {
return callGsmON; return mCallGsmON;
} }
public void setCallGsmON(boolean on) { public void setCallGsmON(boolean on) {
callGsmON = on; mCallGsmON = on;
} }
@Override @Override
@ -1994,7 +1957,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
public int getUnreadMessageCount() { public int getUnreadMessageCount() {
int count = 0; int count = 0;
for (ChatRoom room : mLc.getChatRooms()) { for (ChatRoom room : mCore.getChatRooms()) {
count += room.getUnreadMessagesCount(); count += room.getUnreadMessagesCount();
} }
return count; return count;

View file

@ -71,23 +71,25 @@ public final class LinphoneService extends Service {
*/ */
public static final String START_LINPHONE_LOGS = " ==== Phone information dump ===="; public static final String START_LINPHONE_LOGS = " ==== Phone information dump ====";
private static LinphoneService instance; private static LinphoneService sInstance;
public Handler mHandler = new Handler();
public Handler handler = new Handler();
private boolean mTestDelayElapsed = true; private boolean mTestDelayElapsed = true;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private WindowManager mWindowManager; private WindowManager mWindowManager;
private LinphoneOverlay mOverlay; private LinphoneOverlay mOverlay;
private Application.ActivityLifecycleCallbacks mActivityCallbacks; private Application.ActivityLifecycleCallbacks mActivityCallbacks;
private NotificationsManager mNotificationManager; private NotificationsManager mNotificationManager;
private String incomingReceivedActivityName; private String mIncomingReceivedActivityName;
private Class<? extends Activity> incomingReceivedActivity = LinphoneActivity.class; private Class<? extends Activity> mIncomingReceivedActivity = LinphoneActivity.class;
public static boolean isReady() { public static boolean isReady() {
return instance != null && instance.mTestDelayElapsed; return sInstance != null && sInstance.mTestDelayElapsed;
} }
public static LinphoneService instance() { public static LinphoneService instance() {
if (isReady()) return instance; if (isReady()) return sInstance;
throw new RuntimeException("LinphoneService not instantiated yet"); throw new RuntimeException("LinphoneService not instantiated yet");
} }
@ -97,7 +99,7 @@ public final class LinphoneService extends Service {
} }
public Class<? extends Activity> getIncomingReceivedActivity() { public Class<? extends Activity> getIncomingReceivedActivity() {
return incomingReceivedActivity; return mIncomingReceivedActivity;
} }
public void setCurrentlyDisplayedChatRoom(String address) { public void setCurrentlyDisplayedChatRoom(String address) {
@ -144,14 +146,14 @@ public final class LinphoneService extends Service {
Log.i("[Push Notification] LinphoneService started because of a push"); Log.i("[Push Notification] LinphoneService started because of a push");
} }
if (instance != null) { if (sInstance != null) {
Log.w("Attempt to start the LinphoneService but it is already running !"); Log.w("Attempt to start the LinphoneService but it is already running !");
return START_REDELIVER_INTENT; return START_REDELIVER_INTENT;
} }
LinphoneManager.createAndStart(this); LinphoneManager.createAndStart(this);
instance = this; // instance is ready once linphone manager has been created sInstance = this; // sInstance is ready once linphone manager has been created
mNotificationManager = new NotificationsManager(this); mNotificationManager = new NotificationsManager(this);
LinphoneManager.getLc() LinphoneManager.getLc()
.addListener( .addListener(
@ -160,7 +162,7 @@ public final class LinphoneService extends Service {
@Override @Override
public void onCallStateChanged( public void onCallStateChanged(
Core lc, Call call, Call.State state, String message) { Core lc, Call call, Call.State state, String message) {
if (instance == null) { if (sInstance == null) {
Log.i( Log.i(
"Service not ready, discarding call state change to ", "Service not ready, discarding call state change to ",
state.toString()); state.toString());
@ -224,7 +226,7 @@ public final class LinphoneService extends Service {
if (!mTestDelayElapsed) { if (!mTestDelayElapsed) {
// Only used when testing. Simulates a 5 seconds delay for launching service // Only used when testing. Simulates a 5 seconds delay for launching service
mHandler.postDelayed( handler.postDelayed(
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
@ -273,11 +275,11 @@ public final class LinphoneService extends Service {
dumpDeviceInformation(); dumpDeviceInformation();
dumpInstalledLinphoneInformation(); dumpInstalledLinphoneInformation();
incomingReceivedActivityName = mIncomingReceivedActivityName =
LinphonePreferences.instance().getActivityToLaunchOnIncomingReceived(); LinphonePreferences.instance().getActivityToLaunchOnIncomingReceived();
try { try {
incomingReceivedActivity = mIncomingReceivedActivity =
(Class<? extends Activity>) Class.forName(incomingReceivedActivityName); (Class<? extends Activity>) Class.forName(mIncomingReceivedActivityName);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
Log.e(e); Log.e(e);
} }
@ -371,7 +373,7 @@ public final class LinphoneService extends Service {
lc.removeListener(mListener); lc.removeListener(mListener);
} }
instance = null; sInstance = null;
LinphoneManager.destroy(); LinphoneManager.destroy();
// Make sure our notification is gone. // Make sure our notification is gone.
@ -389,10 +391,10 @@ public final class LinphoneService extends Service {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setActivityToLaunchOnIncomingReceived(String activityName) { public void setActivityToLaunchOnIncomingReceived(String activityName) {
try { try {
incomingReceivedActivity = (Class<? extends Activity>) Class.forName(activityName); mIncomingReceivedActivity = (Class<? extends Activity>) Class.forName(activityName);
incomingReceivedActivityName = activityName; mIncomingReceivedActivityName = activityName;
LinphonePreferences.instance() LinphonePreferences.instance()
.setActivityToLaunchOnIncomingReceived(incomingReceivedActivityName); .setActivityToLaunchOnIncomingReceived(mIncomingReceivedActivityName);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
Log.e(e); Log.e(e);
} }
@ -402,7 +404,7 @@ public final class LinphoneService extends Service {
// wakeup linphone // wakeup linphone
startActivity( startActivity(
new Intent() new Intent()
.setClass(this, incomingReceivedActivity) .setClass(this, mIncomingReceivedActivity)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} }
@ -464,7 +466,7 @@ public final class LinphoneService extends Service {
void startInactivityChecker() { void startInactivityChecker() {
if (mLastChecker != null) mLastChecker.cancel(); if (mLastChecker != null) mLastChecker.cancel();
LinphoneService.this.mHandler.postDelayed( LinphoneService.this.handler.postDelayed(
(mLastChecker = new InactivityChecker()), 2000); (mLastChecker = new InactivityChecker()), 2000);
} }

View file

@ -87,29 +87,35 @@ public class AssistantActivity extends Activity
AccountCreatorListener { AccountCreatorListener {
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201; private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
private static final int PERMISSIONS_REQUEST_CAMERA = 202; private static final int PERMISSIONS_REQUEST_CAMERA = 202;
private static AssistantActivity instance;
private static AssistantActivity sInstance;
public DialPlan country; public DialPlan country;
public String phone_number; public String phone_number;
public String email; public String email;
private ImageView back, cancel;
private AssistantFragmentsEnum currentFragment; private ImageView mBack, mCancel;
private AssistantFragmentsEnum lastFragment; private AssistantFragmentsEnum mCurrentFragment;
private AssistantFragmentsEnum firstFragment; private AssistantFragmentsEnum mLastFragment;
private Fragment fragment; private AssistantFragmentsEnum mFirstFragment;
private Fragment mFragment;
private LinphonePreferences mPrefs; private LinphonePreferences mPrefs;
private boolean accountCreated = false, newAccount = false, isLink = false, fromPref = false; private boolean mAccountCreated = false,
mNewAccount = false,
mIsLink = false,
mFromPref = false;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private Address address; private Address mAddress;
private StatusFragment status; private StatusFragment mStatus;
private ProgressDialog progress; private ProgressDialog mProgress;
private Dialog dialog; private Dialog mDialog;
private boolean remoteProvisioningInProgress; private boolean mRemoteProvisioningInProgress;
private boolean echoCancellerAlreadyDone; private boolean mEchoCancellerAlreadyDone;
private AccountCreator mAccountCreator; private AccountCreator mAccountCreator;
private CountryListAdapter countryListAdapter; private CountryListAdapter mCountryListAdapter;
public static AssistantActivity instance() { public static AssistantActivity instance() {
return instance; return sInstance;
} }
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -123,16 +129,16 @@ public class AssistantActivity extends Activity
initUI(); initUI();
if (getIntent().getBooleanExtra("LinkPhoneNumber", false)) { if (getIntent().getBooleanExtra("LinkPhoneNumber", false)) {
isLink = true; mIsLink = true;
if (getIntent().getBooleanExtra("FromPref", false)) fromPref = true; if (getIntent().getBooleanExtra("FromPref", false)) mFromPref = true;
displayCreateAccount(); displayCreateAccount();
} else { } else {
firstFragment = mFirstFragment =
getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment) getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment)
? AssistantFragmentsEnum.LINPHONE_LOGIN ? AssistantFragmentsEnum.LINPHONE_LOGIN
: AssistantFragmentsEnum.WELCOME; : AssistantFragmentsEnum.WELCOME;
if (firstFragment == AssistantFragmentsEnum.WELCOME) { if (mFirstFragment == AssistantFragmentsEnum.WELCOME) {
firstFragment = mFirstFragment =
getResources() getResources()
.getBoolean( .getBoolean(
R.bool.assistant_use_create_linphone_account_as_first_fragment) R.bool.assistant_use_create_linphone_account_as_first_fragment)
@ -142,21 +148,21 @@ public class AssistantActivity extends Activity
if (findViewById(R.id.fragment_container) != null) { if (findViewById(R.id.fragment_container) != null) {
if (savedInstanceState == null) { if (savedInstanceState == null) {
display(firstFragment); display(mFirstFragment);
} else { } else {
currentFragment = mCurrentFragment =
(AssistantFragmentsEnum) (AssistantFragmentsEnum)
savedInstanceState.getSerializable("CurrentFragment"); savedInstanceState.getSerializable("CurrentFragment");
} }
} }
} }
if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) { if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) {
echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller"); mEchoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller");
} else { } else {
echoCancellerAlreadyDone = false; mEchoCancellerAlreadyDone = false;
} }
mPrefs = LinphonePreferences.instance(); mPrefs = LinphonePreferences.instance();
status.enableSideMenu(false); mStatus.enableSideMenu(false);
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) { if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
mAccountCreator = mAccountCreator =
@ -165,14 +171,14 @@ public class AssistantActivity extends Activity
mAccountCreator.setListener(this); mAccountCreator.setListener(this);
} }
countryListAdapter = new CountryListAdapter(getApplicationContext()); mCountryListAdapter = new CountryListAdapter(getApplicationContext());
mListener = mListener =
new CoreListenerStub() { new CoreListenerStub() {
@Override @Override
public void onConfiguringStatus( public void onConfiguringStatus(
Core lc, final ConfiguringState state, String message) { Core lc, final ConfiguringState state, String message) {
if (progress != null) progress.dismiss(); if (mProgress != null) mProgress.dismiss();
if (state == ConfiguringState.Successful) { if (state == ConfiguringState.Successful) {
goToLinphoneActivity(); goToLinphoneActivity();
} else if (state == ConfiguringState.Failed) { } else if (state == ConfiguringState.Failed) {
@ -187,18 +193,18 @@ public class AssistantActivity extends Activity
@Override @Override
public void onRegistrationStateChanged( public void onRegistrationStateChanged(
Core lc, ProxyConfig cfg, RegistrationState state, String smessage) { Core lc, ProxyConfig cfg, RegistrationState state, String smessage) {
if (remoteProvisioningInProgress) { if (mRemoteProvisioningInProgress) {
if (progress != null) progress.dismiss(); if (mProgress != null) mProgress.dismiss();
if (state == RegistrationState.Ok) { if (state == RegistrationState.Ok) {
remoteProvisioningInProgress = false; mRemoteProvisioningInProgress = false;
success(); success();
} }
} else if (accountCreated && !newAccount) { } else if (mAccountCreated && !mNewAccount) {
if (address != null if (mAddress != null
&& address.asString() && mAddress.asString()
.equals(cfg.getIdentityAddress().asString())) { .equals(cfg.getIdentityAddress().asString())) {
if (state == RegistrationState.Ok) { if (state == RegistrationState.Ok) {
if (progress != null) progress.dismiss(); if (mProgress != null) mProgress.dismiss();
if (getResources() if (getResources()
.getBoolean(R.bool.use_phone_number_validation) .getBoolean(R.bool.use_phone_number_validation)
&& cfg.getDomain() && cfg.getDomain()
@ -210,20 +216,20 @@ public class AssistantActivity extends Activity
success(); success();
} }
} else if (state == RegistrationState.Failed) { } else if (state == RegistrationState.Failed) {
if (progress != null) progress.dismiss(); if (mProgress != null) mProgress.dismiss();
if (dialog == null || !dialog.isShowing()) { if (mDialog == null || !mDialog.isShowing()) {
dialog = createErrorDialog(cfg, smessage); mDialog = createErrorDialog(cfg, smessage);
dialog.setCancelable(false); mDialog.setCancelable(false);
dialog.show(); mDialog.show();
} }
} else if (!(state == RegistrationState.Progress)) { } else if (!(state == RegistrationState.Progress)) {
if (progress != null) progress.dismiss(); if (mProgress != null) mProgress.dismiss();
} }
} }
} }
} }
}; };
instance = this; sInstance = this;
} }
@Override @Override
@ -248,13 +254,13 @@ public class AssistantActivity extends Activity
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
outState.putSerializable("CurrentFragment", currentFragment); outState.putSerializable("CurrentFragment", mCurrentFragment);
outState.putBoolean("echoCanceller", echoCancellerAlreadyDone); outState.putBoolean("echoCanceller", mEchoCancellerAlreadyDone);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
public void updateStatusFragment(StatusFragment fragment) { public void updateStatusFragment(StatusFragment fragment) {
status = fragment; mStatus = fragment;
} }
private AccountCreator loadAccountCreator(ProxyConfig cfg) { private AccountCreator loadAccountCreator(ProxyConfig cfg) {
@ -274,10 +280,10 @@ public class AssistantActivity extends Activity
} }
private void initUI() { private void initUI() {
back = findViewById(R.id.back); mBack = findViewById(R.id.back);
back.setOnClickListener(this); mBack.setOnClickListener(this);
cancel = findViewById(R.id.assistant_cancel); mCancel = findViewById(R.id.assistant_cancel);
cancel.setOnClickListener(this); mCancel.setOnClickListener(this);
} }
private void changeFragment(Fragment newFragment) { private void changeFragment(Fragment newFragment) {
@ -309,11 +315,11 @@ public class AssistantActivity extends Activity
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (isLink) { if (mIsLink) {
return; return;
} }
boolean firstLaunch = LinphonePreferences.instance().isFirstLaunch(); boolean firstLaunch = LinphonePreferences.instance().isFirstLaunch();
if (currentFragment == firstFragment) { if (mCurrentFragment == mFirstFragment) {
LinphonePreferences.instance().firstLaunchSuccessful(); LinphonePreferences.instance().firstLaunchSuccessful();
if (getResources().getBoolean(R.bool.assistant_cancel_move_to_back)) { if (getResources().getBoolean(R.bool.assistant_cancel_move_to_back)) {
moveTaskToBack(true); moveTaskToBack(true);
@ -322,21 +328,21 @@ public class AssistantActivity extends Activity
if (firstLaunch) startActivity(new Intent().setClass(this, LinphoneActivity.class)); if (firstLaunch) startActivity(new Intent().setClass(this, LinphoneActivity.class));
finish(); finish();
} }
} else if (currentFragment == AssistantFragmentsEnum.LOGIN } else if (mCurrentFragment == AssistantFragmentsEnum.LOGIN
|| currentFragment == AssistantFragmentsEnum.LINPHONE_LOGIN || mCurrentFragment == AssistantFragmentsEnum.LINPHONE_LOGIN
|| currentFragment == AssistantFragmentsEnum.CREATE_ACCOUNT || mCurrentFragment == AssistantFragmentsEnum.CREATE_ACCOUNT
|| currentFragment == AssistantFragmentsEnum.REMOTE_PROVISIONING) { || mCurrentFragment == AssistantFragmentsEnum.REMOTE_PROVISIONING) {
displayMenu(); displayMenu();
} else if (currentFragment == AssistantFragmentsEnum.WELCOME) { } else if (mCurrentFragment == AssistantFragmentsEnum.WELCOME) {
if (firstLaunch) startActivity(new Intent().setClass(this, LinphoneActivity.class)); if (firstLaunch) startActivity(new Intent().setClass(this, LinphoneActivity.class));
finish(); finish();
} else if (currentFragment == AssistantFragmentsEnum.COUNTRY_CHOOSER) { } else if (mCurrentFragment == AssistantFragmentsEnum.COUNTRY_CHOOSER) {
if (lastFragment.equals(AssistantFragmentsEnum.LINPHONE_LOGIN)) { if (mLastFragment.equals(AssistantFragmentsEnum.LINPHONE_LOGIN)) {
displayLoginLinphone(null, null); displayLoginLinphone(null, null);
} else { } else {
displayCreateAccount(); displayCreateAccount();
} }
} else if (currentFragment == AssistantFragmentsEnum.QRCODE_READER) { } else if (mCurrentFragment == AssistantFragmentsEnum.QRCODE_READER) {
displayRemoteProvisioning(""); displayRemoteProvisioning("");
} }
} }
@ -421,9 +427,9 @@ public class AssistantActivity extends Activity
EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment(); EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment();
fragment.enableEcCalibrationResultSending(sendEcCalibrationResult); fragment.enableEcCalibrationResultSending(sendEcCalibrationResult);
changeFragment(fragment); changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.ECHO_CANCELLER_CALIBRATION; mCurrentFragment = AssistantFragmentsEnum.ECHO_CANCELLER_CALIBRATION;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
cancel.setEnabled(false); mCancel.setEnabled(false);
} else { } else {
checkAndRequestAudioPermission(); checkAndRequestAudioPermission();
} }
@ -442,7 +448,7 @@ public class AssistantActivity extends Activity
identity = identity.replace("?", accountCreator.getUsername()); identity = identity.replace("?", accountCreator.getUsername());
Address addr = Factory.instance().createAddress(identity); Address addr = Factory.instance().createAddress(identity);
addr.setDisplayName(accountCreator.getUsername()); addr.setDisplayName(accountCreator.getUsername());
address = addr; mAddress = addr;
proxyConfig.edit(); proxyConfig.edit();
proxyConfig.setIdentityAddress(addr); proxyConfig.setIdentityAddress(addr);
@ -479,10 +485,10 @@ public class AssistantActivity extends Activity
LinphoneManager.getInstance() LinphoneManager.getInstance()
.subscribeFriendList(getResources().getBoolean(R.bool.use_friendlist_subscription)); .subscribeFriendList(getResources().getBoolean(R.bool.use_friendlist_subscription));
if (!newAccount) { if (!mNewAccount) {
displayRegistrationInProgressDialog(); displayRegistrationInProgressDialog();
} }
accountCreated = true; mAccountCreated = true;
} }
public void linphoneLogIn(AccountCreator accountCreator) { public void linphoneLogIn(AccountCreator accountCreator) {
@ -521,52 +527,52 @@ public class AssistantActivity extends Activity
} }
public void displayMenu() { public void displayMenu() {
fragment = new WelcomeFragment(); mFragment = new WelcomeFragment();
changeFragment(fragment); changeFragment(mFragment);
country = null; country = null;
currentFragment = AssistantFragmentsEnum.WELCOME; mCurrentFragment = AssistantFragmentsEnum.WELCOME;
back.setVisibility(View.INVISIBLE); mBack.setVisibility(View.INVISIBLE);
} }
public void displayLoginGeneric() { public void displayLoginGeneric() {
fragment = new LoginFragment(); mFragment = new LoginFragment();
changeFragment(fragment); changeFragment(mFragment);
currentFragment = AssistantFragmentsEnum.LOGIN; mCurrentFragment = AssistantFragmentsEnum.LOGIN;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
} }
public void displayLoginLinphone(String username, String password) { public void displayLoginLinphone(String username, String password) {
fragment = new LinphoneLoginFragment(); mFragment = new LinphoneLoginFragment();
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString("Phone", null); extras.putString("Phone", null);
extras.putString("Dialcode", null); extras.putString("Dialcode", null);
extras.putString("Username", username); extras.putString("Username", username);
extras.putString("Password", password); extras.putString("Password", password);
fragment.setArguments(extras); mFragment.setArguments(extras);
changeFragment(fragment); changeFragment(mFragment);
currentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN; mCurrentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
} }
public void displayCreateAccount() { public void displayCreateAccount() {
fragment = new CreateAccountFragment(); mFragment = new CreateAccountFragment();
Bundle extra = new Bundle(); Bundle extra = new Bundle();
extra.putBoolean("LinkPhoneNumber", isLink); extra.putBoolean("LinkPhoneNumber", mIsLink);
extra.putBoolean("LinkFromPref", fromPref); extra.putBoolean("LinkFromPref", mFromPref);
fragment.setArguments(extra); mFragment.setArguments(extra);
changeFragment(fragment); changeFragment(mFragment);
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT; mCurrentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
} }
public void displayRemoteProvisioning(String url) { public void displayRemoteProvisioning(String url) {
fragment = new RemoteProvisioningFragment(); mFragment = new RemoteProvisioningFragment();
Bundle extra = new Bundle(); Bundle extra = new Bundle();
extra.putString("RemoteUrl", url); extra.putString("RemoteUrl", url);
fragment.setArguments(extra); mFragment.setArguments(extra);
changeFragment(fragment); changeFragment(mFragment);
currentFragment = AssistantFragmentsEnum.REMOTE_PROVISIONING; mCurrentFragment = AssistantFragmentsEnum.REMOTE_PROVISIONING;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
} }
public void displayQRCodeReader() { public void displayQRCodeReader() {
@ -574,19 +580,19 @@ public class AssistantActivity extends Activity
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
checkAndRequestVideoPermission(); checkAndRequestVideoPermission();
} else { } else {
fragment = new QrCodeFragment(); mFragment = new QrCodeFragment();
changeFragment(fragment); changeFragment(mFragment);
currentFragment = AssistantFragmentsEnum.QRCODE_READER; mCurrentFragment = AssistantFragmentsEnum.QRCODE_READER;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
} }
} }
public void displayCountryChooser() { public void displayCountryChooser() {
fragment = new CountryListFragment(); mFragment = new CountryListFragment();
changeFragment(fragment); changeFragment(mFragment);
lastFragment = currentFragment; mLastFragment = mCurrentFragment;
currentFragment = AssistantFragmentsEnum.COUNTRY_CHOOSER; mCurrentFragment = AssistantFragmentsEnum.COUNTRY_CHOOSER;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
} }
private void launchDownloadCodec() { private void launchDownloadCodec() {
@ -598,9 +604,9 @@ public class AssistantActivity extends Activity
&& !downloadHelper.isCodecFound()) { && !downloadHelper.isCodecFound()) {
CodecDownloaderFragment codecFragment = new CodecDownloaderFragment(); CodecDownloaderFragment codecFragment = new CodecDownloaderFragment();
changeFragment(codecFragment); changeFragment(codecFragment);
currentFragment = AssistantFragmentsEnum.DOWNLOAD_CODEC; mCurrentFragment = AssistantFragmentsEnum.DOWNLOAD_CODEC;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
cancel.setEnabled(false); mCancel.setEnabled(false);
} else goToLinphoneActivity(); } else goToLinphoneActivity();
} else { } else {
goToLinphoneActivity(); goToLinphoneActivity();
@ -611,13 +617,6 @@ public class AssistantActivity extends Activity
goToLinphoneActivity(); goToLinphoneActivity();
} }
public String getPhoneWithCountry() {
if (country == null || phone_number == null) return "";
String phoneNumberWithCountry =
country.getCountryCallingCode() + phone_number.replace("\\D", "");
return phoneNumberWithCountry;
}
public void saveCreatedAccount( public void saveCreatedAccount(
String username, String username,
String userid, String userid,
@ -632,7 +631,7 @@ public class AssistantActivity extends Activity
domain = LinphoneUtils.getDisplayableUsernameFromAddress(domain); domain = LinphoneUtils.getDisplayableUsernameFromAddress(domain);
String identity = "sip:" + username + "@" + domain; String identity = "sip:" + username + "@" + domain;
address = Factory.instance().createAddress(identity); mAddress = Factory.instance().createAddress(identity);
AccountBuilder builder = AccountBuilder builder =
new AccountBuilder(LinphoneManager.getLc()) new AccountBuilder(LinphoneManager.getLc())
@ -657,10 +656,10 @@ public class AssistantActivity extends Activity
try { try {
builder.saveNewAccount(); builder.saveNewAccount();
if (!newAccount) { if (!mNewAccount) {
displayRegistrationInProgressDialog(); displayRegistrationInProgressDialog();
} }
accountCreated = true; mAccountCreated = true;
} catch (CoreException e) { } catch (CoreException e) {
Log.e(e); Log.e(e);
} }
@ -668,37 +667,39 @@ public class AssistantActivity extends Activity
public void displayRegistrationInProgressDialog() { public void displayRegistrationInProgressDialog() {
if (LinphoneManager.getLc().isNetworkReachable()) { if (LinphoneManager.getLc().isNetworkReachable()) {
progress = ProgressDialog.show(this, null, null); mProgress = ProgressDialog.show(this, null, null);
Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE)); Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE));
d.setAlpha(200); d.setAlpha(200);
progress.getWindow() mProgress
.getWindow()
.setLayout( .setLayout(
WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT); WindowManager.LayoutParams.MATCH_PARENT);
progress.getWindow().setBackgroundDrawable(d); mProgress.getWindow().setBackgroundDrawable(d);
progress.setContentView(R.layout.progress_dialog); mProgress.setContentView(R.layout.progress_dialog);
progress.show(); mProgress.show();
} }
} }
public void displayRemoteProvisioningInProgressDialog() { public void displayRemoteProvisioningInProgressDialog() {
remoteProvisioningInProgress = true; mRemoteProvisioningInProgress = true;
progress = ProgressDialog.show(this, null, null); mProgress = ProgressDialog.show(this, null, null);
Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE)); Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE));
d.setAlpha(200); d.setAlpha(200);
progress.getWindow() mProgress
.getWindow()
.setLayout( .setLayout(
WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT); WindowManager.LayoutParams.MATCH_PARENT);
progress.getWindow().setBackgroundDrawable(d); mProgress.getWindow().setBackgroundDrawable(d);
progress.setContentView(R.layout.progress_dialog); mProgress.setContentView(R.layout.progress_dialog);
progress.show(); mProgress.show();
} }
public void displayAssistantConfirm(String username, String password, String email) { public void displayAssistantConfirm(String username, String password, String email) {
CreateAccountActivationFragment fragment = new CreateAccountActivationFragment(); CreateAccountActivationFragment fragment = new CreateAccountActivationFragment();
newAccount = true; mNewAccount = true;
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString("Username", username); extras.putString("Username", username);
extras.putString("Password", password); extras.putString("Password", password);
@ -706,38 +707,38 @@ public class AssistantActivity extends Activity
fragment.setArguments(extras); fragment.setArguments(extras);
changeFragment(fragment); changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_ACTIVATION; mCurrentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_ACTIVATION;
back.setVisibility(View.INVISIBLE); mBack.setVisibility(View.INVISIBLE);
} }
public void displayAssistantCodeConfirm( public void displayAssistantCodeConfirm(
String username, String phone, String dialcode, boolean recoverAccount) { String username, String phone, String dialcode, boolean recoverAccount) {
CreateAccountCodeActivationFragment fragment = new CreateAccountCodeActivationFragment(); CreateAccountCodeActivationFragment fragment = new CreateAccountCodeActivationFragment();
newAccount = true; mNewAccount = true;
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString("Username", username); extras.putString("Username", username);
extras.putString("Phone", phone); extras.putString("Phone", phone);
extras.putString("Dialcode", dialcode); extras.putString("Dialcode", dialcode);
extras.putBoolean("RecoverAccount", recoverAccount); extras.putBoolean("RecoverAccount", recoverAccount);
extras.putBoolean("LinkAccount", isLink); extras.putBoolean("LinkAccount", mIsLink);
fragment.setArguments(extras); fragment.setArguments(extras);
changeFragment(fragment); changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_CODE_ACTIVATION; mCurrentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_CODE_ACTIVATION;
back.setVisibility(View.INVISIBLE); mBack.setVisibility(View.INVISIBLE);
} }
public void displayAssistantLinphoneLogin(String phone, String dialcode) { public void displayAssistantLinphoneLogin(String phone, String dialcode) {
LinphoneLoginFragment fragment = new LinphoneLoginFragment(); LinphoneLoginFragment fragment = new LinphoneLoginFragment();
newAccount = true; mNewAccount = true;
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString("Phone", phone); extras.putString("Phone", phone);
extras.putString("Dialcode", dialcode); extras.putString("Dialcode", dialcode);
fragment.setArguments(extras); fragment.setArguments(extras);
changeFragment(fragment); changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN; mCurrentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN;
back.setVisibility(View.VISIBLE); mBack.setVisibility(View.VISIBLE);
} }
public void isAccountVerified(String username) { public void isAccountVerified(String username) {
@ -803,8 +804,8 @@ public class AssistantActivity extends Activity
if (lc != null) { if (lc != null) {
lc.addListener(mListener); lc.addListener(mListener);
} }
if (status != null) { if (mStatus != null) {
status.setCoreListener(); mStatus.setCoreListener();
} }
} }
@ -834,7 +835,7 @@ public class AssistantActivity extends Activity
if (status.equals(AccountCreator.Status.AccountExistWithAlias)) { if (status.equals(AccountCreator.Status.AccountExistWithAlias)) {
success(); success();
} else { } else {
isLink = true; mIsLink = true;
displayCreateAccount(); displayCreateAccount();
} }
if (mAccountCreator != null) mAccountCreator.setListener(null); if (mAccountCreator != null) mAccountCreator.setListener(null);
@ -877,13 +878,13 @@ public class AssistantActivity extends Activity
AccountCreator accountCreator, AccountCreator.Status status, String resp) {} AccountCreator accountCreator, AccountCreator.Status status, String resp) {}
public CountryListAdapter getCountryListAdapter() { public CountryListAdapter getCountryListAdapter() {
return countryListAdapter; return mCountryListAdapter;
} }
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
if (currentFragment == AssistantFragmentsEnum.QRCODE_READER) { if (mCurrentFragment == AssistantFragmentsEnum.QRCODE_READER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} }
} }
@ -902,7 +903,7 @@ public class AssistantActivity extends Activity
public CountryListAdapter(Context ctx) { public CountryListAdapter(Context ctx) {
context = ctx; context = ctx;
allCountries = Factory.instance().getDialPlans(); allCountries = Factory.instance().getDialPlans();
filteredCountries = new ArrayList<DialPlan>(Arrays.asList(allCountries)); filteredCountries = new ArrayList<>(Arrays.asList(allCountries));
} }
public void setInflater(LayoutInflater inf) { public void setInflater(LayoutInflater inf) {
@ -944,10 +945,10 @@ public class AssistantActivity extends Activity
DialPlan c = filteredCountries.get(position); DialPlan c = filteredCountries.get(position);
TextView name = (TextView) view.findViewById(R.id.country_name); TextView name = view.findViewById(R.id.country_name);
name.setText(c.getCountry()); name.setText(c.getCountry());
TextView dial_code = (TextView) view.findViewById(R.id.country_prefix); TextView dial_code = view.findViewById(R.id.country_prefix);
if (context != null) if (context != null)
dial_code.setText( dial_code.setText(
String.format( String.format(

View file

@ -37,28 +37,28 @@ import org.linphone.core.tools.OpenH264DownloadHelperListener;
public class CodecDownloaderFragment extends Fragment { public class CodecDownloaderFragment extends Fragment {
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private TextView question; private TextView mQuestion;
private TextView downloading; private TextView mDownloading;
private TextView downloaded; private TextView mDownloaded;
private Button yes; private Button mYes;
private Button no; private Button mNo;
private Button ok; private Button mOk;
private ProgressBar bar; private ProgressBar mProgressBar;
private TextView downloadingInfo; private TextView mDownloadingInfo;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.assistant_codec_downloader, container, false); final View view = inflater.inflate(R.layout.assistant_codec_downloader, container, false);
question = view.findViewById(R.id.question); mQuestion = view.findViewById(R.id.question);
downloading = view.findViewById(R.id.downloading); mDownloading = view.findViewById(R.id.downloading);
downloaded = view.findViewById(R.id.downloaded); mDownloaded = view.findViewById(R.id.downloaded);
yes = view.findViewById(R.id.answerYes); mYes = view.findViewById(R.id.answerYes);
no = view.findViewById(R.id.answerNo); mNo = view.findViewById(R.id.answerNo);
ok = view.findViewById(R.id.answerOk); mOk = view.findViewById(R.id.answerOk);
bar = view.findViewById(R.id.progressBar); mProgressBar = view.findViewById(R.id.progressBar);
downloadingInfo = view.findViewById(R.id.downloadingInfo); mDownloadingInfo = view.findViewById(R.id.downloadingInfo);
final OpenH264DownloadHelper codecDownloader = final OpenH264DownloadHelper codecDownloader =
LinphoneManager.getInstance().getOpenH264DownloadHelper(); LinphoneManager.getInstance().getOpenH264DownloadHelper();
@ -73,15 +73,15 @@ public class CodecDownloaderFragment extends Fragment {
public void run() { public void run() {
if (current <= max) { if (current <= max) {
hideAllItems(); hideAllItems();
downloadingInfo.setText(current + " / " + max); mDownloadingInfo.setText(current + " / " + max);
downloadingInfo.setVisibility(View.VISIBLE); mDownloadingInfo.setVisibility(View.VISIBLE);
downloading.setVisibility(View.VISIBLE); mDownloading.setVisibility(View.VISIBLE);
bar.setMax(max); mProgressBar.setMax(max);
bar.setProgress(current); mProgressBar.setProgress(current);
bar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE);
} else { } else {
hideAllItems(); hideAllItems();
downloaded.setVisibility(View.VISIBLE); mDownloaded.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT if (Build.VERSION.SDK_INT
>= Build.VERSION_CODES.LOLLIPOP_MR1) { >= Build.VERSION_CODES.LOLLIPOP_MR1) {
enabledH264(true); enabledH264(true);
@ -107,9 +107,9 @@ public class CodecDownloaderFragment extends Fragment {
@Override @Override
public void run() { public void run() {
hideAllItems(); hideAllItems();
downloaded.setText("Sorry an error has occurred."); mDownloaded.setText("Sorry an error has occurred.");
downloaded.setVisibility(View.VISIBLE); mDownloaded.setVisibility(View.VISIBLE);
ok.setVisibility(View.VISIBLE); mOk.setVisibility(View.VISIBLE);
enabledH264(false); enabledH264(false);
AssistantActivity.instance().endDownloadCodec(); AssistantActivity.instance().endDownloadCodec();
} }
@ -119,17 +119,17 @@ public class CodecDownloaderFragment extends Fragment {
codecDownloader.setOpenH264HelperListener(codecListener); codecDownloader.setOpenH264HelperListener(codecListener);
yes.setOnClickListener( mYes.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
hideAllItems(); hideAllItems();
bar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE);
codecDownloader.downloadCodec(); codecDownloader.downloadCodec();
} }
}); });
no.setOnClickListener( mNo.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -140,39 +140,40 @@ public class CodecDownloaderFragment extends Fragment {
hideAllItems(); hideAllItems();
if (savedInstanceState != null) { if (savedInstanceState != null) {
if (savedInstanceState.containsKey("question")) if (savedInstanceState.containsKey("mQuestion"))
question.setVisibility((Integer) savedInstanceState.getSerializable("question")); mQuestion.setVisibility((Integer) savedInstanceState.getSerializable("mQuestion"));
else question.setVisibility(View.VISIBLE); else mQuestion.setVisibility(View.VISIBLE);
if (savedInstanceState.containsKey("yes")) if (savedInstanceState.containsKey("mYes"))
yes.setVisibility((Integer) savedInstanceState.getSerializable("yes")); mYes.setVisibility((Integer) savedInstanceState.getSerializable("mYes"));
else yes.setVisibility(View.VISIBLE); else mYes.setVisibility(View.VISIBLE);
if (savedInstanceState.containsKey("no")) if (savedInstanceState.containsKey("mNo"))
no.setVisibility((Integer) savedInstanceState.getSerializable("no")); mNo.setVisibility((Integer) savedInstanceState.getSerializable("mNo"));
else no.setVisibility(View.VISIBLE); else mNo.setVisibility(View.VISIBLE);
if (savedInstanceState.containsKey("downloading")) if (savedInstanceState.containsKey("mDownloading"))
downloading.setVisibility( mDownloading.setVisibility(
(Integer) savedInstanceState.getSerializable("downloading")); (Integer) savedInstanceState.getSerializable("mDownloading"));
if (savedInstanceState.containsKey("downloaded")) if (savedInstanceState.containsKey("mDownloaded"))
downloaded.setVisibility( mDownloaded.setVisibility(
(Integer) savedInstanceState.getSerializable("downloaded")); (Integer) savedInstanceState.getSerializable("mDownloaded"));
if (savedInstanceState.containsKey("context_bar")) if (savedInstanceState.containsKey("context_bar"))
bar.setVisibility((Integer) savedInstanceState.getSerializable("context_bar")); mProgressBar.setVisibility(
(Integer) savedInstanceState.getSerializable("context_bar"));
if (savedInstanceState.containsKey("downloadingInfo")) if (savedInstanceState.containsKey("mDownloadingInfo"))
downloadingInfo.setVisibility( mDownloadingInfo.setVisibility(
(Integer) savedInstanceState.getSerializable("downloadingInfo")); (Integer) savedInstanceState.getSerializable("mDownloadingInfo"));
if (savedInstanceState.containsKey("ok")) if (savedInstanceState.containsKey("mOk"))
ok.setVisibility((Integer) savedInstanceState.getSerializable("ok")); mOk.setVisibility((Integer) savedInstanceState.getSerializable("mOk"));
} else { } else {
yes.setVisibility(View.VISIBLE); mYes.setVisibility(View.VISIBLE);
question.setVisibility(View.VISIBLE); mQuestion.setVisibility(View.VISIBLE);
no.setVisibility(View.VISIBLE); mNo.setVisibility(View.VISIBLE);
} }
return view; return view;
@ -180,28 +181,30 @@ public class CodecDownloaderFragment extends Fragment {
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
if (question != null) outState.putSerializable("question", question.getVisibility()); if (mQuestion != null) outState.putSerializable("mQuestion", mQuestion.getVisibility());
if (downloading != null) if (mDownloading != null)
outState.putSerializable("downloading", downloading.getVisibility()); outState.putSerializable("mDownloading", mDownloading.getVisibility());
if (downloaded != null) outState.putSerializable("downloaded", downloaded.getVisibility()); if (mDownloaded != null)
if (yes != null) outState.putSerializable("yes", yes.getVisibility()); outState.putSerializable("mDownloaded", mDownloaded.getVisibility());
if (no != null) outState.putSerializable("no", no.getVisibility()); if (mYes != null) outState.putSerializable("mYes", mYes.getVisibility());
if (ok != null) outState.putSerializable("ok", ok.getVisibility()); if (mNo != null) outState.putSerializable("mNo", mNo.getVisibility());
if (bar != null) outState.putSerializable("context_bar", bar.getVisibility()); if (mOk != null) outState.putSerializable("mOk", mOk.getVisibility());
if (downloadingInfo != null) if (mProgressBar != null)
outState.putSerializable("downloadingInfo", downloadingInfo.getVisibility()); outState.putSerializable("context_bar", mProgressBar.getVisibility());
if (mDownloadingInfo != null)
outState.putSerializable("mDownloadingInfo", mDownloadingInfo.getVisibility());
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
private void hideAllItems() { private void hideAllItems() {
if (question != null) question.setVisibility(View.INVISIBLE); if (mQuestion != null) mQuestion.setVisibility(View.INVISIBLE);
if (downloading != null) downloading.setVisibility(View.INVISIBLE); if (mDownloading != null) mDownloading.setVisibility(View.INVISIBLE);
if (downloaded != null) downloaded.setVisibility(View.INVISIBLE); if (mDownloaded != null) mDownloaded.setVisibility(View.INVISIBLE);
if (yes != null) yes.setVisibility(View.INVISIBLE); if (mYes != null) mYes.setVisibility(View.INVISIBLE);
if (no != null) no.setVisibility(View.INVISIBLE); if (mNo != null) mNo.setVisibility(View.INVISIBLE);
if (ok != null) ok.setVisibility(View.INVISIBLE); if (mOk != null) mOk.setVisibility(View.INVISIBLE);
if (bar != null) bar.setVisibility(View.INVISIBLE); if (mProgressBar != null) mProgressBar.setVisibility(View.INVISIBLE);
if (downloadingInfo != null) downloadingInfo.setVisibility(View.INVISIBLE); if (mDownloadingInfo != null) mDownloadingInfo.setVisibility(View.INVISIBLE);
} }
private void enabledH264(boolean enable) { private void enabledH264(boolean enable) {

View file

@ -35,28 +35,28 @@ import org.linphone.core.DialPlan;
public class CountryListFragment extends Fragment public class CountryListFragment extends Fragment
implements AdapterView.OnItemClickListener, View.OnClickListener { implements AdapterView.OnItemClickListener, View.OnClickListener {
private ListView list; private ListView mList;
private EditText search; private EditText mSearch;
private ImageView clearSearchField; private ImageView mClearSearchField;
private AssistantActivity.CountryListAdapter adapter; private AssistantActivity.CountryListAdapter mAdapter;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_country_list, container, false); View view = inflater.inflate(R.layout.assistant_country_list, container, false);
adapter = AssistantActivity.instance().getCountryListAdapter(); mAdapter = AssistantActivity.instance().getCountryListAdapter();
adapter.setInflater(inflater); mAdapter.setInflater(inflater);
search = view.findViewById(R.id.search_country); mSearch = view.findViewById(R.id.search_country);
clearSearchField = view.findViewById(R.id.clearSearchField); mClearSearchField = view.findViewById(R.id.clearSearchField);
clearSearchField.setOnClickListener(this); mClearSearchField.setOnClickListener(this);
list = view.findViewById(R.id.countryList); mList = view.findViewById(R.id.countryList);
list.setAdapter(adapter); mList.setAdapter(mAdapter);
list.setOnItemClickListener(this); mList.setOnItemClickListener(this);
search.addTextChangedListener( mSearch.addTextChangedListener(
new TextWatcher() { new TextWatcher() {
@Override @Override
public void beforeTextChanged( public void beforeTextChanged(
@ -64,13 +64,13 @@ public class CountryListFragment extends Fragment
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s); mAdapter.getFilter().filter(s);
} }
@Override @Override
public void afterTextChanged(Editable s) {} public void afterTextChanged(Editable s) {}
}); });
search.setText(""); mSearch.setText("");
return view; return view;
} }
@ -85,7 +85,7 @@ public class CountryListFragment extends Fragment
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.clearSearchField) { if (v.getId() == R.id.clearSearchField) {
search.setText(""); mSearch.setText("");
} }
} }
} }

View file

@ -35,10 +35,10 @@ import org.linphone.settings.LinphonePreferences;
public class CreateAccountActivationFragment extends Fragment public class CreateAccountActivationFragment extends Fragment
implements OnClickListener, AccountCreatorListener { implements OnClickListener, AccountCreatorListener {
private String username, password; private String mUsername, mPassword;
private Button checkAccount; private Button mCheckAccount;
private TextView email; private TextView mEmail;
private AccountCreator accountCreator; private AccountCreator mAccountCreator;
@Override @Override
public View onCreateView( public View onCreateView(
@ -47,22 +47,22 @@ public class CreateAccountActivationFragment extends Fragment
inflater.inflate( inflater.inflate(
R.layout.assistant_account_creation_email_activation, container, false); R.layout.assistant_account_creation_email_activation, container, false);
accountCreator = mAccountCreator =
LinphoneManager.getLc() LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl()); .createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this); mAccountCreator.setListener(this);
username = getArguments().getString("Username"); mUsername = getArguments().getString("Username");
password = getArguments().getString("Password"); mPassword = getArguments().getString("Password");
accountCreator.setUsername(username); mAccountCreator.setUsername(mUsername);
accountCreator.setPassword(password); mAccountCreator.setPassword(mPassword);
email = view.findViewById(R.id.send_email); mEmail = view.findViewById(R.id.send_email);
email.setText(getArguments().getString("Email")); mEmail.setText(getArguments().getString("Email"));
checkAccount = view.findViewById(R.id.assistant_check); mCheckAccount = view.findViewById(R.id.assistant_check);
checkAccount.setOnClickListener(this); mCheckAccount.setOnClickListener(this);
return view; return view;
} }
@ -70,8 +70,8 @@ public class CreateAccountActivationFragment extends Fragment
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
if (id == R.id.assistant_check) { if (id == R.id.assistant_check) {
checkAccount.setEnabled(false); mCheckAccount.setEnabled(false);
accountCreator.isAccountActivated(); mAccountCreator.isAccountActivated();
} }
} }
@ -109,7 +109,7 @@ public class CreateAccountActivationFragment extends Fragment
.show(); .show();
} else if (status.equals(AccountCreator.Status.AccountActivated)) { } else if (status.equals(AccountCreator.Status.AccountActivated)) {
AssistantActivity.instance().linphoneLogIn(accountCreator); AssistantActivity.instance().linphoneLogIn(accountCreator);
AssistantActivity.instance().isAccountVerified(username); AssistantActivity.instance().isAccountVerified(mUsername);
} else { } else {
Toast.makeText( Toast.makeText(
getActivity(), getActivity(),
@ -117,7 +117,7 @@ public class CreateAccountActivationFragment extends Fragment
Toast.LENGTH_LONG) Toast.LENGTH_LONG)
.show(); .show();
} }
checkAccount.setEnabled(true); mCheckAccount.setEnabled(true);
} }
@Override @Override

View file

@ -39,14 +39,14 @@ import org.linphone.settings.LinphonePreferences;
public class CreateAccountCodeActivationFragment extends Fragment public class CreateAccountCodeActivationFragment extends Fragment
implements AccountCreatorListener { implements AccountCreatorListener {
private String username, phone, dialcode; private String mUsername, mPhone, mDialcode;
private TextView title, phonenumber; private TextView mTitle, mPhonenumber;
private EditText code; private EditText mCode;
private boolean recoverAccount = false, linkAccount = false; private boolean mRecoverAccount = false, mLinkAccount = false;
private int code_length, accountNumber; private int mCodeLength, mAccountNumber;
private ImageView back; private ImageView mBack;
private Button checkAccount; private Button mCheckAccount;
private AccountCreator accountCreator; private AccountCreator mAccountCreator;
@Override @Override
public View onCreateView( public View onCreateView(
@ -55,36 +55,36 @@ public class CreateAccountCodeActivationFragment extends Fragment
inflater.inflate( inflater.inflate(
R.layout.assistant_account_creation_code_activation, container, false); R.layout.assistant_account_creation_code_activation, container, false);
username = getArguments().getString("Username"); mUsername = getArguments().getString("Username");
phone = getArguments().getString("Phone"); mPhone = getArguments().getString("Phone");
dialcode = getArguments().getString("Dialcode"); mDialcode = getArguments().getString("Dialcode");
recoverAccount = getArguments().getBoolean("RecoverAccount"); mRecoverAccount = getArguments().getBoolean("RecoverAccount");
linkAccount = getArguments().getBoolean("LinkAccount"); mLinkAccount = getArguments().getBoolean("LinkAccount");
accountNumber = getArguments().getInt("AccountNumber"); mAccountNumber = getArguments().getInt("AccountNumber");
code_length = LinphonePreferences.instance().getCodeLength(); mCodeLength = LinphonePreferences.instance().getCodeLength();
accountCreator = mAccountCreator =
LinphoneManager.getLc() LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl()); .createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this); mAccountCreator.setListener(this);
accountCreator.setUsername(username); mAccountCreator.setUsername(mUsername);
accountCreator.setPhoneNumber(phone, dialcode); mAccountCreator.setPhoneNumber(mPhone, mDialcode);
back = view.findViewById(R.id.back); mBack = view.findViewById(R.id.back);
if (back != null) back.setVisibility(Button.INVISIBLE); if (mBack != null) mBack.setVisibility(Button.INVISIBLE);
title = view.findViewById(R.id.title_account_activation); mTitle = view.findViewById(R.id.title_account_activation);
if (linkAccount) { if (mLinkAccount) {
title.setText(getString(R.string.assistant_link_account)); mTitle.setText(getString(R.string.assistant_link_account));
} else if (recoverAccount) { } else if (mRecoverAccount) {
title.setText(getString(R.string.assistant_linphone_account)); mTitle.setText(getString(R.string.assistant_linphone_account));
} }
phonenumber = view.findViewById(R.id.send_phone_number); mPhonenumber = view.findViewById(R.id.send_phone_number);
phonenumber.setText(accountCreator.getPhoneNumber()); mPhonenumber.setText(mAccountCreator.getPhoneNumber());
code = view.findViewById(R.id.assistant_code); mCode = view.findViewById(R.id.assistant_code);
code.addTextChangedListener( mCode.addTextChangedListener(
new TextWatcher() { new TextWatcher() {
@Override @Override
public void beforeTextChanged( public void beforeTextChanged(
@ -95,23 +95,23 @@ public class CreateAccountCodeActivationFragment extends Fragment
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (s.length() == code_length) { if (s.length() == mCodeLength) {
checkAccount.setEnabled(true); mCheckAccount.setEnabled(true);
} else { } else {
checkAccount.setEnabled(false); mCheckAccount.setEnabled(false);
} }
} }
}); });
checkAccount = view.findViewById(R.id.assistant_check); mCheckAccount = view.findViewById(R.id.assistant_check);
checkAccount.setEnabled(false); mCheckAccount.setEnabled(false);
checkAccount.setOnClickListener( mCheckAccount.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
checkAccount.setEnabled(false); mCheckAccount.setEnabled(false);
accountCreator.setActivationCode(code.getText().toString()); mAccountCreator.setActivationCode(mCode.getText().toString());
if (linkAccount) { if (mLinkAccount) {
linkAccount(); linkAccount();
} else { } else {
activateAccount(); activateAccount();
@ -123,17 +123,17 @@ public class CreateAccountCodeActivationFragment extends Fragment
} }
private void linkAccount() { private void linkAccount() {
accountCreator.setUsername( mAccountCreator.setUsername(
LinphonePreferences.instance().getAccountUsername(accountNumber)); LinphonePreferences.instance().getAccountUsername(mAccountNumber));
accountCreator.setHa1(LinphonePreferences.instance().getAccountHa1(accountNumber)); mAccountCreator.setHa1(LinphonePreferences.instance().getAccountHa1(mAccountNumber));
accountCreator.activateAlias(); mAccountCreator.activateAlias();
} }
private void activateAccount() { private void activateAccount() {
if (accountCreator.getUsername() == null) { if (mAccountCreator.getUsername() == null) {
accountCreator.setUsername(accountCreator.getPhoneNumber()); mAccountCreator.setUsername(mAccountCreator.getPhoneNumber());
} }
accountCreator.activateAccount(); mAccountCreator.activateAccount();
} }
@Override @Override
@ -151,17 +151,17 @@ public class CreateAccountCodeActivationFragment extends Fragment
return; return;
} }
if (status.equals(AccountCreator.Status.AccountActivated)) { if (status.equals(AccountCreator.Status.AccountActivated)) {
checkAccount.setEnabled(true); mCheckAccount.setEnabled(true);
if (accountCreator.getUsername() != null) { if (accountCreator.getUsername() != null) {
AssistantActivity.instance().linphoneLogIn(accountCreator); AssistantActivity.instance().linphoneLogIn(accountCreator);
if (!recoverAccount) { if (!mRecoverAccount) {
AssistantActivity.instance().isAccountVerified(accountCreator.getUsername()); AssistantActivity.instance().isAccountVerified(accountCreator.getUsername());
} else { } else {
AssistantActivity.instance().success(); AssistantActivity.instance().success();
} }
} else { } else {
AssistantActivity.instance().linphoneLogIn(accountCreator); AssistantActivity.instance().linphoneLogIn(accountCreator);
if (!recoverAccount) { if (!mRecoverAccount) {
AssistantActivity.instance().isAccountVerified(accountCreator.getPhoneNumber()); AssistantActivity.instance().isAccountVerified(accountCreator.getPhoneNumber());
} else { } else {
AssistantActivity.instance().success(); AssistantActivity.instance().success();
@ -179,7 +179,7 @@ public class CreateAccountCodeActivationFragment extends Fragment
getString(R.string.assistant_error_confirmation_code), getString(R.string.assistant_error_confirmation_code),
Toast.LENGTH_LONG) Toast.LENGTH_LONG)
.show(); .show();
AssistantActivity.instance().displayAssistantLinphoneLogin(phone, dialcode); AssistantActivity.instance().displayAssistantLinphoneLogin(mPhone, mDialcode);
} }
} }
@ -196,7 +196,7 @@ public class CreateAccountCodeActivationFragment extends Fragment
if (status.equals(AccountCreator.Status.AccountActivated)) { if (status.equals(AccountCreator.Status.AccountActivated)) {
LinphonePreferences.instance() LinphonePreferences.instance()
.setPrefix( .setPrefix(
accountNumber, mAccountNumber,
org.linphone.core.Utils.getPrefixFromE164( org.linphone.core.Utils.getPrefixFromE164(
accountCreator.getPhoneNumber())); accountCreator.getPhoneNumber()));
LinphonePreferences.instance().setLinkPopupTime(""); LinphonePreferences.instance().setLinkPopupTime("");

View file

@ -55,82 +55,83 @@ import org.linphone.utils.LinphoneUtils;
public class CreateAccountFragment extends Fragment public class CreateAccountFragment extends Fragment
implements CompoundButton.OnCheckedChangeListener, OnClickListener, AccountCreatorListener { implements CompoundButton.OnCheckedChangeListener, OnClickListener, AccountCreatorListener {
private final Pattern UPPER_CASE_REGEX = Pattern.compile("[A-Z]"); private final Pattern UPPER_CASE_REGEX = Pattern.compile("[A-Z]");
private EditText phoneNumberEdit,
usernameEdit, private EditText mPhoneNumberEdit,
passwordEdit, mUsernameEdit,
passwordConfirmEdit, mPasswordEdit,
emailEdit, mPasswordConfirmEdit,
dialCode; mEmailEdit,
private TextView phoneNumberError, mDialCode;
passwordError, private TextView mPhoneNumberError,
passwordConfirmError, mPasswordError,
emailError, mPasswordConfirmError,
assisstantTitle, mEmailError,
sipUri, mAssisstantTitle,
skip, mSipUri,
instruction; mSkip,
private ImageView phoneNumberInfo; mInstruction;
private boolean passwordOk = false; private ImageView mPhoneNumberInfo;
private boolean emailOk = false; private boolean mPasswordOk = false;
private boolean confirmPasswordOk = false; private boolean mEmailOk = false;
private boolean linkAccount = false; private boolean mConfirmPasswordOk = false;
private Button createAccount, selectCountry; private boolean mLinkAccount = false;
private CheckBox useUsername, useEmail; private Button mCreateAccount, mSelectCountry;
private String addressSip = ""; private CheckBox mUseUsername, mUseEmail;
private int countryCode; private String mAddressSip = "";
private LinearLayout phoneNumberLayout, private int mCountryCode;
usernameLayout, private LinearLayout mPhoneNumberLayout,
emailLayout, mUsernameLayout,
passwordLayout, mEmailLayout,
passwordConfirmLayout; mPasswordLayout,
private AccountCreator accountCreator; mPasswordConfirmLayout;
private AccountCreator mAccountCreator;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_account_creation, container, false); View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
// Initialize accountCreator // Initialize mAccountCreator
accountCreator = mAccountCreator =
LinphoneManager.getLc() LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl()); .createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this); mAccountCreator.setListener(this);
instruction = view.findViewById(R.id.message_create_account); mInstruction = view.findViewById(R.id.message_create_account);
createAccount = view.findViewById(R.id.assistant_create); mCreateAccount = view.findViewById(R.id.assistant_create);
phoneNumberLayout = view.findViewById(R.id.phone_number_layout); mPhoneNumberLayout = view.findViewById(R.id.phone_number_layout);
usernameLayout = view.findViewById(R.id.username_layout); mUsernameLayout = view.findViewById(R.id.username_layout);
emailLayout = view.findViewById(R.id.email_layout); mEmailLayout = view.findViewById(R.id.email_layout);
passwordLayout = view.findViewById(R.id.password_layout); mPasswordLayout = view.findViewById(R.id.password_layout);
passwordConfirmLayout = view.findViewById(R.id.password_confirm_layout); mPasswordConfirmLayout = view.findViewById(R.id.password_confirm_layout);
useUsername = view.findViewById(R.id.use_username); mUseUsername = view.findViewById(R.id.use_username);
useEmail = view.findViewById(R.id.use_email); mUseEmail = view.findViewById(R.id.use_email);
usernameEdit = view.findViewById(R.id.username); mUsernameEdit = view.findViewById(R.id.username);
phoneNumberError = view.findViewById(R.id.phone_number_error); mPhoneNumberError = view.findViewById(R.id.phone_number_error);
phoneNumberEdit = view.findViewById(R.id.phone_number); mPhoneNumberEdit = view.findViewById(R.id.phone_number);
sipUri = view.findViewById(R.id.sip_uri); mSipUri = view.findViewById(R.id.sip_uri);
phoneNumberInfo = view.findViewById(R.id.info_phone_number); mPhoneNumberInfo = view.findViewById(R.id.info_phone_number);
selectCountry = view.findViewById(R.id.select_country); mSelectCountry = view.findViewById(R.id.select_country);
dialCode = view.findViewById(R.id.dial_code); mDialCode = view.findViewById(R.id.dial_code);
assisstantTitle = view.findViewById(R.id.assistant_title); mAssisstantTitle = view.findViewById(R.id.assistant_title);
passwordError = view.findViewById(R.id.password_error); mPasswordError = view.findViewById(R.id.password_error);
passwordEdit = view.findViewById(R.id.password); mPasswordEdit = view.findViewById(R.id.password);
passwordConfirmError = view.findViewById(R.id.confirm_password_error); mPasswordConfirmError = view.findViewById(R.id.confirm_password_error);
passwordConfirmEdit = view.findViewById(R.id.confirm_password); mPasswordConfirmEdit = view.findViewById(R.id.confirm_password);
emailError = view.findViewById(R.id.email_error); mEmailError = view.findViewById(R.id.email_error);
emailEdit = view.findViewById(R.id.email); mEmailEdit = view.findViewById(R.id.email);
skip = view.findViewById(R.id.assistant_skip); mSkip = view.findViewById(R.id.assistant_skip);
// Phone number // Phone number
if (getResources().getBoolean(R.bool.use_phone_number_validation)) { if (getResources().getBoolean(R.bool.use_phone_number_validation)) {
@ -142,21 +143,21 @@ public class CreateAccountFragment extends Fragment
.getApplicationContext() .getApplicationContext()
.getSystemService(Context.TELEPHONY_SERVICE); .getSystemService(Context.TELEPHONY_SERVICE);
String countryIso = tm.getNetworkCountryIso(); String countryIso = tm.getNetworkCountryIso();
countryCode = org.linphone.core.Utils.getCccFromIso(countryIso.toUpperCase()); mCountryCode = org.linphone.core.Utils.getCccFromIso(countryIso.toUpperCase());
phoneNumberLayout.setVisibility(View.VISIBLE); mPhoneNumberLayout.setVisibility(View.VISIBLE);
phoneNumberInfo.setOnClickListener(this); mPhoneNumberInfo.setOnClickListener(this);
selectCountry.setOnClickListener(this); mSelectCountry.setOnClickListener(this);
String previousPhone = AssistantActivity.instance().phone_number; String previousPhone = AssistantActivity.instance().phone_number;
if (previousPhone != null) { if (previousPhone != null) {
phoneNumberEdit.setText(previousPhone); mPhoneNumberEdit.setText(previousPhone);
} }
DialPlan c = AssistantActivity.instance().country; DialPlan c = AssistantActivity.instance().country;
if (c != null) { if (c != null) {
selectCountry.setText(c.getCountry()); mSelectCountry.setText(c.getCountry());
dialCode.setText( mDialCode.setText(
c.getCountryCallingCode().contains("+") c.getCountryCallingCode().contains("+")
? c.getCountryCallingCode() ? c.getCountryCallingCode()
: "+" + c.getCountryCallingCode()); : "+" + c.getCountryCallingCode());
@ -164,10 +165,10 @@ public class CreateAccountFragment extends Fragment
c = c =
AssistantActivity.instance() AssistantActivity.instance()
.getCountryListAdapter() .getCountryListAdapter()
.getCountryFromCountryCode(String.valueOf(countryCode)); .getCountryFromCountryCode(String.valueOf(mCountryCode));
if (c != null) { if (c != null) {
selectCountry.setText(c.getCountry()); mSelectCountry.setText(c.getCountry());
dialCode.setText( mDialCode.setText(
c.getCountryCallingCode().contains("+") c.getCountryCallingCode().contains("+")
? c.getCountryCallingCode() ? c.getCountryCallingCode()
: "+" + c.getCountryCallingCode()); : "+" + c.getCountryCallingCode());
@ -176,18 +177,18 @@ public class CreateAccountFragment extends Fragment
// Allow user to enter a username instead use the phone number as username // Allow user to enter a username instead use the phone number as username
if (getResources().getBoolean(R.bool.assistant_allow_username)) { if (getResources().getBoolean(R.bool.assistant_allow_username)) {
useUsername.setVisibility(View.VISIBLE); mUseUsername.setVisibility(View.VISIBLE);
useUsername.setOnCheckedChangeListener(this); mUseUsername.setOnCheckedChangeListener(this);
} }
addPhoneNumberHandler(phoneNumberEdit, null); addPhoneNumberHandler(mPhoneNumberEdit, null);
addPhoneNumberHandler(dialCode, null); addPhoneNumberHandler(mDialCode, null);
} }
// Password & email address // Password & email address
if (getResources().getBoolean(R.bool.isTablet) if (getResources().getBoolean(R.bool.isTablet)
|| !getResources().getBoolean(R.bool.use_phone_number_validation)) { || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
useEmail.setVisibility(View.VISIBLE); mUseEmail.setVisibility(View.VISIBLE);
useEmail.setOnCheckedChangeListener(this); mUseEmail.setOnCheckedChangeListener(this);
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) { if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
Account[] accounts = Account[] accounts =
@ -196,55 +197,55 @@ public class CreateAccountFragment extends Fragment
for (Account account : accounts) { for (Account account : accounts) {
if (isEmailCorrect(account.name)) { if (isEmailCorrect(account.name)) {
String possibleEmail = account.name; String possibleEmail = account.name;
emailEdit.setText(possibleEmail); mEmailEdit.setText(possibleEmail);
accountCreator.setEmail(possibleEmail); mAccountCreator.setEmail(possibleEmail);
emailOk = true; mEmailOk = true;
break; break;
} }
} }
} }
addPasswordHandler(passwordEdit, null); addPasswordHandler(mPasswordEdit, null);
addConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null); addConfirmPasswordHandler(mPasswordEdit, mPasswordConfirmEdit, null);
addEmailHandler(emailEdit, null); addEmailHandler(mEmailEdit, null);
} }
// Hide phone number and display username/email/password // Hide phone number and display username/email/password
if (!getResources().getBoolean(R.bool.use_phone_number_validation)) { if (!getResources().getBoolean(R.bool.use_phone_number_validation)) {
useEmail.setVisibility(View.GONE); mUseEmail.setVisibility(View.GONE);
useUsername.setVisibility(View.GONE); mUseUsername.setVisibility(View.GONE);
usernameLayout.setVisibility(View.VISIBLE); mUsernameLayout.setVisibility(View.VISIBLE);
passwordLayout.setVisibility(View.VISIBLE); mPasswordLayout.setVisibility(View.VISIBLE);
passwordConfirmLayout.setVisibility(View.VISIBLE); mPasswordConfirmLayout.setVisibility(View.VISIBLE);
emailLayout.setVisibility(View.VISIBLE); mEmailLayout.setVisibility(View.VISIBLE);
} }
// Link account with phone number // Link account with phone number
if (getArguments().getBoolean("LinkPhoneNumber")) { if (getArguments().getBoolean("LinkPhoneNumber")) {
linkAccount = true; mLinkAccount = true;
useEmail.setVisibility(View.GONE); mUseEmail.setVisibility(View.GONE);
useUsername.setVisibility(View.GONE); mUseUsername.setVisibility(View.GONE);
usernameLayout.setVisibility(View.GONE); mUsernameLayout.setVisibility(View.GONE);
passwordLayout.setVisibility(View.GONE); mPasswordLayout.setVisibility(View.GONE);
passwordConfirmLayout.setVisibility(View.GONE); mPasswordConfirmLayout.setVisibility(View.GONE);
emailLayout.setVisibility(View.GONE); mEmailLayout.setVisibility(View.GONE);
skip.setVisibility(View.VISIBLE); mSkip.setVisibility(View.VISIBLE);
skip.setOnClickListener(this); mSkip.setOnClickListener(this);
createAccount.setText(getResources().getString(R.string.link_account)); mCreateAccount.setText(getResources().getString(R.string.link_account));
assisstantTitle.setText(getResources().getString(R.string.link_account)); mAssisstantTitle.setText(getResources().getString(R.string.link_account));
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
accountCreator.setLanguage(Locale.getDefault().toLanguageTag()); mAccountCreator.setLanguage(Locale.getDefault().toLanguageTag());
} }
addUsernameHandler(usernameEdit, null); addUsernameHandler(mUsernameEdit, null);
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
createAccount.setOnClickListener(this); mCreateAccount.setOnClickListener(this);
return view; return view;
} }
@ -252,12 +253,12 @@ public class CreateAccountFragment extends Fragment
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
accountCreator.setListener(null); mAccountCreator.setListener(null);
} }
private String getUsername() { private String getUsername() {
if (usernameEdit != null) { if (mUsernameEdit != null) {
String username = usernameEdit.getText().toString(); String username = mUsernameEdit.getText().toString();
return username.toLowerCase(Locale.getDefault()); return username.toLowerCase(Locale.getDefault());
} }
return null; return null;
@ -267,42 +268,42 @@ public class CreateAccountFragment extends Fragment
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.getId() == R.id.use_username) { if (buttonView.getId() == R.id.use_username) {
if (isChecked) { if (isChecked) {
usernameLayout.setVisibility(View.VISIBLE); mUsernameLayout.setVisibility(View.VISIBLE);
onTextChanged2(); onTextChanged2();
} else { } else {
usernameLayout.setVisibility(View.GONE); mUsernameLayout.setVisibility(View.GONE);
accountCreator.setUsername(null); mAccountCreator.setUsername(null);
onTextChanged2(); onTextChanged2();
} }
} else if (buttonView.getId() == R.id.use_email) { } else if (buttonView.getId() == R.id.use_email) {
if (isChecked) { if (isChecked) {
dialCode.setBackgroundResource(R.drawable.resizable_textfield); mDialCode.setBackgroundResource(R.drawable.resizable_textfield);
phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield); mPhoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
useUsername.setEnabled(false); mUseUsername.setEnabled(false);
dialCode.setEnabled(false); mDialCode.setEnabled(false);
selectCountry.setEnabled(false); mSelectCountry.setEnabled(false);
phoneNumberEdit.setEnabled(false); mPhoneNumberEdit.setEnabled(false);
emailLayout.setVisibility(View.VISIBLE); mEmailLayout.setVisibility(View.VISIBLE);
passwordLayout.setVisibility(View.VISIBLE); mPasswordLayout.setVisibility(View.VISIBLE);
passwordConfirmLayout.setVisibility(View.VISIBLE); mPasswordConfirmLayout.setVisibility(View.VISIBLE);
usernameLayout.setVisibility(View.VISIBLE); mUsernameLayout.setVisibility(View.VISIBLE);
useUsername.setVisibility(CheckBox.GONE); mUseUsername.setVisibility(CheckBox.GONE);
phoneNumberLayout.setVisibility(LinearLayout.GONE); mPhoneNumberLayout.setVisibility(LinearLayout.GONE);
instruction.setText(getString(R.string.assistant_create_account_part_email)); mInstruction.setText(getString(R.string.assistant_create_account_part_email));
} else { } else {
if (!useUsername.isChecked()) { if (!mUseUsername.isChecked()) {
usernameLayout.setVisibility(View.GONE); mUsernameLayout.setVisibility(View.GONE);
} }
useUsername.setEnabled(true); mUseUsername.setEnabled(true);
dialCode.setEnabled(true); mDialCode.setEnabled(true);
selectCountry.setEnabled(true); mSelectCountry.setEnabled(true);
phoneNumberEdit.setEnabled(true); mPhoneNumberEdit.setEnabled(true);
emailLayout.setVisibility(View.GONE); mEmailLayout.setVisibility(View.GONE);
passwordLayout.setVisibility(View.GONE); mPasswordLayout.setVisibility(View.GONE);
passwordConfirmLayout.setVisibility(View.GONE); mPasswordConfirmLayout.setVisibility(View.GONE);
useUsername.setVisibility(CheckBox.VISIBLE); mUseUsername.setVisibility(CheckBox.VISIBLE);
phoneNumberLayout.setVisibility(LinearLayout.VISIBLE); mPhoneNumberLayout.setVisibility(LinearLayout.VISIBLE);
instruction.setText(getString(R.string.assistant_create_account_part_1)); mInstruction.setText(getString(R.string.assistant_create_account_part_1));
} }
} }
} }
@ -319,7 +320,7 @@ public class CreateAccountFragment extends Fragment
AssistantActivity.instance().success(); AssistantActivity.instance().success();
} }
} else if (id == R.id.info_phone_number) { } else if (id == R.id.info_phone_number) {
if (linkAccount) { if (mLinkAccount) {
new AlertDialog.Builder(getActivity()) new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.phone_number_info_title)) .setTitle(getString(R.string.phone_number_info_title))
.setMessage( .setMessage(
@ -336,22 +337,22 @@ public class CreateAccountFragment extends Fragment
.show(); .show();
} }
} else if (id == R.id.assistant_create) { } else if (id == R.id.assistant_create) {
createAccount.setEnabled(false); mCreateAccount.setEnabled(false);
if (linkAccount) { if (mLinkAccount) {
addAlias(); addAlias();
} else { } else {
if (useEmail.isChecked()) accountCreator.setPhoneNumber(null, null); if (mUseEmail.isChecked()) mAccountCreator.setPhoneNumber(null, null);
if (!getResources().getBoolean(R.bool.isTablet) || getUsername().length() > 0) { if (!getResources().getBoolean(R.bool.isTablet) || getUsername().length() > 0) {
LinphoneManager.getLc() LinphoneManager.getLc()
.getConfig() .getConfig()
.loadFromXmlFile(LinphoneManager.getInstance().getmDynamicConfigFile()); .loadFromXmlFile(LinphoneManager.getInstance().getmDynamicConfigFile());
accountCreator.isAccountExist(); mAccountCreator.isAccountExist();
} else { } else {
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForUsernameStatus( LinphoneUtils.errorForUsernameStatus(
AccountCreator.UsernameStatus.TooShort), AccountCreator.UsernameStatus.TooShort),
AssistantActivity.instance()); AssistantActivity.instance());
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
} }
} }
} }
@ -367,88 +368,90 @@ public class CreateAccountFragment extends Fragment
} }
private void addAlias() { private void addAlias() {
accountCreator.setUsername( mAccountCreator.setUsername(
LinphonePreferences.instance() LinphonePreferences.instance()
.getAccountUsername( .getAccountUsername(
LinphonePreferences.instance().getDefaultAccountIndex())); LinphonePreferences.instance().getDefaultAccountIndex()));
int status = int status =
accountCreator.setPhoneNumber( mAccountCreator.setPhoneNumber(
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
LinphoneUtils.getCountryCode(dialCode)); LinphoneUtils.getCountryCode(mDialCode));
boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt(); boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt();
if (isOk) { if (isOk) {
accountCreator.linkAccount(); mAccountCreator.linkAccount();
} else { } else {
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForPhoneNumberStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForPhoneNumberStatus(status), AssistantActivity.instance());
LinphoneUtils.displayError( LinphoneUtils.displayError(
isOk, phoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status)); isOk, mPhoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status));
} }
} }
private void createAccount() { private void createAccount() {
if ((getResources().getBoolean(R.bool.isTablet) if ((getResources().getBoolean(R.bool.isTablet)
|| !getResources().getBoolean(R.bool.use_phone_number_validation)) || !getResources().getBoolean(R.bool.use_phone_number_validation))
&& useEmail.isChecked()) { && mUseEmail.isChecked()) {
AccountCreator.EmailStatus emailStatus; AccountCreator.EmailStatus emailStatus;
AccountCreator.PasswordStatus passwordStatus; AccountCreator.PasswordStatus passwordStatus;
passwordStatus = accountCreator.setPassword(passwordEdit.getText().toString()); passwordStatus = mAccountCreator.setPassword(mPasswordEdit.getText().toString());
emailStatus = accountCreator.setEmail(emailEdit.getText().toString()); emailStatus = mAccountCreator.setEmail(mEmailEdit.getText().toString());
if (!emailOk) { if (!mEmailOk) {
LinphoneUtils.displayError( LinphoneUtils.displayError(
false, emailError, LinphoneUtils.errorForEmailStatus(emailStatus)); false, mEmailError, LinphoneUtils.errorForEmailStatus(emailStatus));
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForEmailStatus(emailStatus), LinphoneUtils.errorForEmailStatus(emailStatus),
AssistantActivity.instance()); AssistantActivity.instance());
} else if (!passwordOk) { } else if (!mPasswordOk) {
LinphoneUtils.displayError( LinphoneUtils.displayError(
false, passwordError, LinphoneUtils.errorForPasswordStatus(passwordStatus)); false,
mPasswordError,
LinphoneUtils.errorForPasswordStatus(passwordStatus));
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForPasswordStatus(passwordStatus), LinphoneUtils.errorForPasswordStatus(passwordStatus),
AssistantActivity.instance()); AssistantActivity.instance());
} else if (!confirmPasswordOk) { } else if (!mConfirmPasswordOk) {
String msg; String msg;
if (passwordConfirmEdit if (mPasswordConfirmEdit
.getText() .getText()
.toString() .toString()
.equals(passwordEdit.getText().toString())) { .equals(mPasswordEdit.getText().toString())) {
msg = getString(R.string.wizard_password_incorrect); msg = getString(R.string.wizard_password_incorrect);
} else { } else {
msg = getString(R.string.wizard_passwords_unmatched); msg = getString(R.string.wizard_passwords_unmatched);
} }
LinphoneUtils.displayError(false, passwordError, msg); LinphoneUtils.displayError(false, mPasswordError, msg);
LinphoneUtils.displayErrorAlert(msg, AssistantActivity.instance()); LinphoneUtils.displayErrorAlert(msg, AssistantActivity.instance());
} else { } else {
accountCreator.createAccount(); mAccountCreator.createAccount();
} }
} else { } else {
if (phoneNumberEdit.length() > 0 || dialCode.length() > 1) { if (mPhoneNumberEdit.length() > 0 || mDialCode.length() > 1) {
int phoneStatus; int phoneStatus;
boolean isOk; boolean isOk;
phoneStatus = phoneStatus =
accountCreator.setPhoneNumber( mAccountCreator.setPhoneNumber(
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
LinphoneUtils.getCountryCode(dialCode)); LinphoneUtils.getCountryCode(mDialCode));
isOk = phoneStatus == AccountCreator.PhoneNumberStatus.Ok.toInt(); isOk = phoneStatus == AccountCreator.PhoneNumberStatus.Ok.toInt();
if (!useUsername.isChecked() && accountCreator.getUsername() == null) { if (!mUseUsername.isChecked() && mAccountCreator.getUsername() == null) {
accountCreator.setUsername(accountCreator.getPhoneNumber()); mAccountCreator.setUsername(mAccountCreator.getPhoneNumber());
} else { } else {
accountCreator.setUsername(usernameEdit.getText().toString()); mAccountCreator.setUsername(mUsernameEdit.getText().toString());
accountCreator.setPhoneNumber( mAccountCreator.setPhoneNumber(
phoneNumberEdit.getText().toString(), dialCode.getText().toString()); mPhoneNumberEdit.getText().toString(), mDialCode.getText().toString());
} }
if (isOk) { if (isOk) {
accountCreator.createAccount(); mAccountCreator.createAccount();
} else { } else {
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForPhoneNumberStatus(phoneStatus), LinphoneUtils.errorForPhoneNumberStatus(phoneStatus),
AssistantActivity.instance()); AssistantActivity.instance());
LinphoneUtils.displayError( LinphoneUtils.displayError(
isOk, isOk,
phoneNumberError, mPhoneNumberError,
LinphoneUtils.errorForPhoneNumberStatus(phoneStatus)); LinphoneUtils.errorForPhoneNumberStatus(phoneStatus));
} }
} else { } else {
@ -457,93 +460,93 @@ public class CreateAccountFragment extends Fragment
AssistantActivity.instance()); AssistantActivity.instance());
} }
} }
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
} }
private int getPhoneNumberStatus() { private int getPhoneNumberStatus() {
int status = int status =
accountCreator.setPhoneNumber( mAccountCreator.setPhoneNumber(
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
LinphoneUtils.getCountryCode(dialCode)); LinphoneUtils.getCountryCode(mDialCode));
addressSip = accountCreator.getPhoneNumber(); mAddressSip = mAccountCreator.getPhoneNumber();
return status; return status;
} }
public void onTextChanged2() { public void onTextChanged2() {
String msg = ""; String msg = "";
accountCreator.setUsername(getUsername()); mAccountCreator.setUsername(getUsername());
if (!useEmail.isChecked() if (!mUseEmail.isChecked()
&& getResources().getBoolean(R.bool.use_phone_number_validation)) { && getResources().getBoolean(R.bool.use_phone_number_validation)) {
int status = getPhoneNumberStatus(); int status = getPhoneNumberStatus();
boolean isOk = (status == AccountCreator.PhoneNumberStatus.Ok.toInt()); boolean isOk = (status == AccountCreator.PhoneNumberStatus.Ok.toInt());
LinphoneUtils.displayError( LinphoneUtils.displayError(
isOk, phoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status)); isOk, mPhoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status));
// Username or phone number // Username or phone number
if (getResources().getBoolean(R.bool.assistant_allow_username) if (getResources().getBoolean(R.bool.assistant_allow_username)
&& useUsername.isChecked()) { && mUseUsername.isChecked()) {
addressSip = getUsername(); mAddressSip = getUsername();
} }
if (!isOk) { if (!isOk) {
if (status == AccountCreator.PhoneNumberStatus.InvalidCountryCode.toInt()) { if (status == AccountCreator.PhoneNumberStatus.InvalidCountryCode.toInt()) {
dialCode.setBackgroundResource(R.drawable.resizable_textfield_error); mDialCode.setBackgroundResource(R.drawable.resizable_textfield_error);
phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield); mPhoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
} else { } else {
dialCode.setBackgroundResource(R.drawable.resizable_textfield); mDialCode.setBackgroundResource(R.drawable.resizable_textfield);
phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield_error); mPhoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield_error);
} }
} else { } else {
dialCode.setBackgroundResource(R.drawable.resizable_textfield); mDialCode.setBackgroundResource(R.drawable.resizable_textfield);
phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield); mPhoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
if (!linkAccount && addressSip.length() > 0) { if (!mLinkAccount && mAddressSip.length() > 0) {
msg = msg =
getResources() getResources()
.getString( .getString(
R.string R.string
.assistant_create_account_phone_number_address) .assistant_create_account_phone_number_address)
+ " <" + " <"
+ addressSip + mAddressSip
+ "@" + "@"
+ getResources().getString(R.string.default_domain) + getResources().getString(R.string.default_domain)
+ ">"; + ">";
} }
} }
} else { } else {
addressSip = getUsername(); mAddressSip = getUsername();
if (addressSip.length() > 0) { if (mAddressSip.length() > 0) {
msg = msg =
getResources() getResources()
.getString( .getString(
R.string R.string
.assistant_create_account_phone_number_address) .assistant_create_account_phone_number_address)
+ " <sip:" + " <sip:"
+ addressSip + mAddressSip
+ "@" + "@"
+ getResources().getString(R.string.default_domain) + getResources().getString(R.string.default_domain)
+ ">"; + ">";
} }
} }
sipUri.setText(msg); mSipUri.setText(msg);
} }
private void addPhoneNumberHandler(final EditText field, final ImageView icon) { private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
field.addTextChangedListener( field.addTextChangedListener(
new TextWatcher() { new TextWatcher() {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (field.equals(dialCode)) { if (field.equals(mDialCode)) {
DialPlan c = DialPlan c =
AssistantActivity.instance() AssistantActivity.instance()
.getCountryListAdapter() .getCountryListAdapter()
.getCountryFromCountryCode( .getCountryFromCountryCode(
dialCode.getText().toString()); mDialCode.getText().toString());
if (c != null) { if (c != null) {
AssistantActivity.instance().country = c; AssistantActivity.instance().country = c;
selectCountry.setText(c.getCountry()); mSelectCountry.setText(c.getCountry());
} else { } else {
selectCountry.setText(R.string.select_your_country); mSelectCountry.setText(R.string.select_your_country);
} }
} }
} }
@ -585,15 +588,17 @@ public class CreateAccountFragment extends Fragment
field.addTextChangedListener( field.addTextChangedListener(
new TextWatcher() { new TextWatcher() {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
emailOk = false; mEmailOk = false;
AccountCreator.EmailStatus status = AccountCreator.EmailStatus status =
accountCreator.setEmail(field.getText().toString()); mAccountCreator.setEmail(field.getText().toString());
if (status.equals(AccountCreator.EmailStatus.Ok)) { if (status.equals(AccountCreator.EmailStatus.Ok)) {
emailOk = true; mEmailOk = true;
LinphoneUtils.displayError(emailOk, emailError, ""); LinphoneUtils.displayError(mEmailOk, mEmailError, "");
} else { } else {
LinphoneUtils.displayError( LinphoneUtils.displayError(
emailOk, emailError, LinphoneUtils.errorForEmailStatus(status)); mEmailOk,
mEmailError,
LinphoneUtils.errorForEmailStatus(status));
} }
} }
@ -608,16 +613,16 @@ public class CreateAccountFragment extends Fragment
TextWatcher passwordListener = TextWatcher passwordListener =
new TextWatcher() { new TextWatcher() {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
passwordOk = false; mPasswordOk = false;
AccountCreator.PasswordStatus status = AccountCreator.PasswordStatus status =
accountCreator.setPassword(field1.getText().toString()); mAccountCreator.setPassword(field1.getText().toString());
if (isPasswordCorrect(field1.getText().toString())) { if (isPasswordCorrect(field1.getText().toString())) {
passwordOk = true; mPasswordOk = true;
LinphoneUtils.displayError(passwordOk, passwordError, ""); LinphoneUtils.displayError(mPasswordOk, mPasswordError, "");
} else { } else {
LinphoneUtils.displayError( LinphoneUtils.displayError(
passwordOk, mPasswordOk,
passwordError, mPasswordError,
LinphoneUtils.errorForPasswordStatus(status)); LinphoneUtils.errorForPasswordStatus(status));
} }
} }
@ -636,22 +641,22 @@ public class CreateAccountFragment extends Fragment
TextWatcher passwordListener = TextWatcher passwordListener =
new TextWatcher() { new TextWatcher() {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
confirmPasswordOk = false; mConfirmPasswordOk = false;
if (field1.getText().toString().equals(field2.getText().toString())) { if (field1.getText().toString().equals(field2.getText().toString())) {
confirmPasswordOk = true; mConfirmPasswordOk = true;
if (!isPasswordCorrect(field1.getText().toString())) { if (!isPasswordCorrect(field1.getText().toString())) {
LinphoneUtils.displayError( LinphoneUtils.displayError(
passwordOk, mPasswordOk,
passwordError, mPasswordError,
getString(R.string.wizard_password_incorrect)); getString(R.string.wizard_password_incorrect));
} else { } else {
LinphoneUtils.displayError( LinphoneUtils.displayError(
confirmPasswordOk, passwordConfirmError, ""); mConfirmPasswordOk, mPasswordConfirmError, "");
} }
} else { } else {
LinphoneUtils.displayError( LinphoneUtils.displayError(
confirmPasswordOk, mConfirmPasswordOk,
passwordConfirmError, mPasswordConfirmError,
getString(R.string.wizard_passwords_unmatched)); getString(R.string.wizard_passwords_unmatched));
} }
} }
@ -668,8 +673,8 @@ public class CreateAccountFragment extends Fragment
@Override @Override
public void onIsAccountExist(AccountCreator accountCreator, final Status status, String resp) { public void onIsAccountExist(AccountCreator accountCreator, final Status status, String resp) {
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) { if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
if (useEmail.isChecked()) { if (mUseEmail.isChecked()) {
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForStatus(status), AssistantActivity.instance());
} else { } else {
@ -686,23 +691,23 @@ public class CreateAccountFragment extends Fragment
@Override @Override
public void onCreateAccount(AccountCreator accountCreator, Status status, String resp) { public void onCreateAccount(AccountCreator accountCreator, Status status, String resp) {
if (status.equals(Status.AccountCreated)) { if (status.equals(Status.AccountCreated)) {
if (useEmail.isChecked() if (mUseEmail.isChecked()
|| !getResources().getBoolean(R.bool.use_phone_number_validation)) { || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
AssistantActivity.instance() AssistantActivity.instance()
.displayAssistantConfirm( .displayAssistantConfirm(
getUsername(), getUsername(),
passwordEdit.getText().toString(), mPasswordEdit.getText().toString(),
emailEdit.getText().toString()); mEmailEdit.getText().toString());
} else { } else {
AssistantActivity.instance() AssistantActivity.instance()
.displayAssistantCodeConfirm( .displayAssistantCodeConfirm(
getUsername(), getUsername(),
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
LinphoneUtils.getCountryCode(dialCode), LinphoneUtils.getCountryCode(mDialCode),
false); false);
} }
} else { } else {
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForStatus(status), AssistantActivity.instance());
} }
@ -720,8 +725,8 @@ public class CreateAccountFragment extends Fragment
AssistantActivity.instance() AssistantActivity.instance()
.displayAssistantCodeConfirm( .displayAssistantCodeConfirm(
getUsername(), getUsername(),
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
LinphoneUtils.getCountryCode(dialCode), LinphoneUtils.getCountryCode(mDialCode),
false); false);
} }
} }
@ -735,8 +740,8 @@ public class CreateAccountFragment extends Fragment
AssistantActivity.instance() AssistantActivity.instance()
.displayAssistantCodeConfirm( .displayAssistantCodeConfirm(
getUsername(), getUsername(),
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
LinphoneUtils.getCountryCode(dialCode), LinphoneUtils.getCountryCode(mDialCode),
false); false);
} }
} }
@ -749,12 +754,12 @@ public class CreateAccountFragment extends Fragment
if (status.equals(Status.AccountNotActivated)) { if (status.equals(Status.AccountNotActivated)) {
if (getResources().getBoolean(R.bool.isTablet) if (getResources().getBoolean(R.bool.isTablet)
|| !getResources().getBoolean(R.bool.use_phone_number_validation)) { || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
// accountCreator.activateAccount(); // Resend email TODO // mAccountCreator.activateAccount(); // Resend email TODO
} else { } else {
accountCreator.recoverAccount(); // Resend SMS accountCreator.recoverAccount(); // Resend SMS
} }
} else { } else {
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForStatus(status), AssistantActivity.instance());
} }
@ -769,11 +774,11 @@ public class CreateAccountFragment extends Fragment
AssistantActivity.instance() AssistantActivity.instance()
.displayAssistantCodeConfirm( .displayAssistantCodeConfirm(
getUsername(), getUsername(),
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
dialCode.getText().toString(), mDialCode.getText().toString(),
false); false);
} else { } else {
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
// SMS error // SMS error
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
getString(R.string.request_failed), AssistantActivity.instance()); getString(R.string.request_failed), AssistantActivity.instance());
@ -789,18 +794,18 @@ public class CreateAccountFragment extends Fragment
return; return;
} }
if (status.equals(Status.AliasIsAccount) || status.equals(Status.AliasExist)) { if (status.equals(Status.AliasIsAccount) || status.equals(Status.AliasExist)) {
if (accountCreator.getPhoneNumber() != null if (mAccountCreator.getPhoneNumber() != null
&& accountCreator.getUsername() != null && mAccountCreator.getUsername() != null
&& accountCreator.getPhoneNumber().compareTo(accountCreator.getUsername()) && mAccountCreator.getPhoneNumber().compareTo(mAccountCreator.getUsername())
== 0) { == 0) {
accountCreator.isAccountActivated(); mAccountCreator.isAccountActivated();
} else { } else {
createAccount.setEnabled(true); mCreateAccount.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForStatus(status), AssistantActivity.instance());
} }
} else { } else {
accountCreator.isAccountActivated(); mAccountCreator.isAccountActivated();
} }
} }

View file

@ -43,9 +43,9 @@ public class EchoCancellerCalibrationFragment extends Fragment implements XmlRpc
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private boolean mSendEcCalibrationResult = false; private boolean mSendEcCalibrationResult = false;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private XmlRpcSession xmlRpcSession; private XmlRpcSession mXmlRpcSession;
private XmlRpcRequest xmlRpcRequest; private XmlRpcRequest mXmlRpcRequest;
private Runnable runFinished; private Runnable mRunFinished;
@Override @Override
public View onCreateView( public View onCreateView(
@ -66,19 +66,19 @@ public class EchoCancellerCalibrationFragment extends Fragment implements XmlRpc
} }
} }
}; };
runFinished = mRunFinished =
new Runnable() { new Runnable() {
public void run() { public void run() {
AssistantActivity.instance().isEchoCalibrationFinished(); AssistantActivity.instance().isEchoCalibrationFinished();
} }
}; };
xmlRpcSession = mXmlRpcSession =
LinphoneManager.getLcIfManagerNotDestroyedOrNull() LinphoneManager.getLcIfManagerNotDestroyedOrNull()
.createXmlRpcSession(LinphonePreferences.instance().getXmlrpcUrl()); .createXmlRpcSession(LinphonePreferences.instance().getXmlrpcUrl());
xmlRpcRequest = mXmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.None, "add_ec_calibration_result"); mXmlRpcSession.createRequest(XmlRpcArgType.None, "add_ec_calibration_result");
xmlRpcRequest.setListener(this); mXmlRpcRequest.setListener(this);
try { try {
LinphoneManager.getLc().addListener(mListener); LinphoneManager.getLc().addListener(mListener);
@ -96,7 +96,7 @@ public class EchoCancellerCalibrationFragment extends Fragment implements XmlRpc
@Override @Override
public void onResponse(XmlRpcRequest request) { public void onResponse(XmlRpcRequest request) {
mHandler.post(runFinished); mHandler.post(mRunFinished);
} }
private void sendEcCalibrationResult(EcCalibratorStatus status, int delayMs) { private void sendEcCalibrationResult(EcCalibratorStatus status, int delayMs) {
@ -113,11 +113,11 @@ public class EchoCancellerCalibrationFragment extends Fragment implements XmlRpc
+ "ms" + "ms"
+ " hasBuiltInEchoCanceler " + " hasBuiltInEchoCanceler "
+ hasBuiltInEchoCanceler); + hasBuiltInEchoCanceler);
xmlRpcRequest.addStringArg(Build.MANUFACTURER); mXmlRpcRequest.addStringArg(Build.MANUFACTURER);
xmlRpcRequest.addStringArg(Build.MODEL); mXmlRpcRequest.addStringArg(Build.MODEL);
xmlRpcRequest.addStringArg(status.toString()); mXmlRpcRequest.addStringArg(status.toString());
xmlRpcRequest.addIntArg(delayMs); mXmlRpcRequest.addIntArg(delayMs);
xmlRpcRequest.addIntArg(hasBuiltInEchoCanceler ? 1 : 0); mXmlRpcRequest.addIntArg(hasBuiltInEchoCanceler ? 1 : 0);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(mXmlRpcRequest);
} }
} }

View file

@ -53,75 +53,75 @@ public class LinphoneLoginFragment extends Fragment
OnClickListener, OnClickListener,
TextWatcher, TextWatcher,
AccountCreatorListener { AccountCreatorListener {
private EditText login, password, phoneNumberEdit, dialCode; private EditText mLogin, mPassword, mPhoneNumberEdit, mDialCode;
private Button apply, selectCountry; private Button mApply, mSelectCountry;
private CheckBox useUsername; private CheckBox mUseUsername;
private LinearLayout phoneNumberLayout, usernameLayout, passwordLayout; private LinearLayout mPhoneNumberLayout, mUsernameLayout, mPasswordLayout;
private TextView forgotPassword, messagePhoneNumber, phoneNumberError; private TextView mForgotPassword, mMessagePhoneNumber, mPhoneNumberError;
private Boolean recoverAccount; private Boolean mRecoverAccount;
private AccountCreator accountCreator; private AccountCreator mAccountCreator;
private int countryCode; private int mCountryCode;
private String phone, dialcode, username, pwd; private String mPhone, mDialcode, mUsername, mPwd;
private ImageView phoneNumberInfo; private ImageView mPhoneNumberInfo;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_linphone_login, container, false); View view = inflater.inflate(R.layout.assistant_linphone_login, container, false);
accountCreator = mAccountCreator =
LinphoneManager.getLc() LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl()); .createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this); mAccountCreator.setListener(this);
String url = "http://linphone.org/free-sip-service.html&action=recover"; String url = "http://linphone.org/free-sip-service.html&action=recover";
login = view.findViewById(R.id.assistant_username); mLogin = view.findViewById(R.id.assistant_username);
login.addTextChangedListener(this); mLogin.addTextChangedListener(this);
recoverAccount = true; mRecoverAccount = true;
dialCode = view.findViewById(R.id.dial_code); mDialCode = view.findViewById(R.id.dial_code);
phoneNumberEdit = view.findViewById(R.id.phone_number); mPhoneNumberEdit = view.findViewById(R.id.phone_number);
phoneNumberLayout = view.findViewById(R.id.phone_number_layout); mPhoneNumberLayout = view.findViewById(R.id.phone_number_layout);
phoneNumberError = view.findViewById(R.id.phone_number_error_2); mPhoneNumberError = view.findViewById(R.id.phone_number_error_2);
phoneNumberInfo = view.findViewById(R.id.info_phone_number); mPhoneNumberInfo = view.findViewById(R.id.info_phone_number);
useUsername = view.findViewById(R.id.use_username); mUseUsername = view.findViewById(R.id.use_username);
usernameLayout = view.findViewById(R.id.username_layout); mUsernameLayout = view.findViewById(R.id.username_layout);
passwordLayout = view.findViewById(R.id.password_layout); mPasswordLayout = view.findViewById(R.id.password_layout);
password = view.findViewById(R.id.assistant_password); mPassword = view.findViewById(R.id.assistant_password);
messagePhoneNumber = view.findViewById(R.id.message_phone_number); mMessagePhoneNumber = view.findViewById(R.id.message_phone_number);
forgotPassword = view.findViewById(R.id.forgot_password); mForgotPassword = view.findViewById(R.id.forgot_password);
selectCountry = view.findViewById(R.id.select_country); mSelectCountry = view.findViewById(R.id.select_country);
apply = view.findViewById(R.id.assistant_apply); mApply = view.findViewById(R.id.assistant_apply);
apply.setEnabled(true); mApply.setEnabled(true);
apply.setOnClickListener(this); mApply.setOnClickListener(this);
// Phone number // Phone number
if (getResources().getBoolean(R.bool.use_phone_number_validation)) { if (getResources().getBoolean(R.bool.use_phone_number_validation)) {
messagePhoneNumber.setText(getString(R.string.assistant_create_account_part_1)); mMessagePhoneNumber.setText(getString(R.string.assistant_create_account_part_1));
phone = getArguments().getString("Phone"); mPhone = getArguments().getString("Phone");
dialcode = getArguments().getString("Dialcode"); mDialcode = getArguments().getString("Dialcode");
getActivity().getApplicationContext(); getActivity().getApplicationContext();
// Automatically get the country code from the phone // Automatically get the country code from the mPhone
TelephonyManager tm = TelephonyManager tm =
(TelephonyManager) (TelephonyManager)
getActivity() getActivity()
.getApplicationContext() .getApplicationContext()
.getSystemService(Context.TELEPHONY_SERVICE); .getSystemService(Context.TELEPHONY_SERVICE);
String countryIso = tm.getNetworkCountryIso(); String countryIso = tm.getNetworkCountryIso();
countryCode = org.linphone.core.Utils.getCccFromIso(countryIso.toUpperCase()); mCountryCode = org.linphone.core.Utils.getCccFromIso(countryIso.toUpperCase());
DialPlan c = AssistantActivity.instance().country; DialPlan c = AssistantActivity.instance().country;
if (c != null) { if (c != null) {
selectCountry.setText(c.getCountry()); mSelectCountry.setText(c.getCountry());
dialCode.setText( mDialCode.setText(
c.getCountryCallingCode().contains("+") c.getCountryCallingCode().contains("+")
? c.getCountryCallingCode() ? c.getCountryCallingCode()
: "+" + c.getCountryCallingCode()); : "+" + c.getCountryCallingCode());
@ -129,114 +129,114 @@ public class LinphoneLoginFragment extends Fragment
c = c =
AssistantActivity.instance() AssistantActivity.instance()
.getCountryListAdapter() .getCountryListAdapter()
.getCountryFromCountryCode(String.valueOf(countryCode)); .getCountryFromCountryCode(String.valueOf(mCountryCode));
if (c != null) { if (c != null) {
selectCountry.setText(c.getCountry()); mSelectCountry.setText(c.getCountry());
dialCode.setText( mDialCode.setText(
c.getCountryCallingCode().contains("+") c.getCountryCallingCode().contains("+")
? c.getCountryCallingCode() ? c.getCountryCallingCode()
: "+" + c.getCountryCallingCode()); : "+" + c.getCountryCallingCode());
} }
} }
phoneNumberLayout.setVisibility(View.VISIBLE); mPhoneNumberLayout.setVisibility(View.VISIBLE);
selectCountry.setOnClickListener(this); mSelectCountry.setOnClickListener(this);
phoneNumberInfo.setOnClickListener(this); mPhoneNumberInfo.setOnClickListener(this);
String previousPhone = AssistantActivity.instance().phone_number; String previousPhone = AssistantActivity.instance().phone_number;
if (previousPhone != null) { if (previousPhone != null) {
phoneNumberEdit.setText(previousPhone); mPhoneNumberEdit.setText(previousPhone);
} }
// Allow user to enter a username instead use the phone number as username // Allow user to enter a mUsername instead use the mPhone number as mUsername
if (getResources().getBoolean(R.bool.assistant_allow_username)) { if (getResources().getBoolean(R.bool.assistant_allow_username)) {
useUsername.setVisibility(View.VISIBLE); mUseUsername.setVisibility(View.VISIBLE);
useUsername.setOnCheckedChangeListener(this); mUseUsername.setOnCheckedChangeListener(this);
} }
if (phone != null) phoneNumberEdit.setText(phone); if (mPhone != null) mPhoneNumberEdit.setText(mPhone);
if (dialcode != null) dialCode.setText("+" + dialcode); if (mDialcode != null) mDialCode.setText("+" + mDialcode);
} }
if (getResources().getBoolean(R.bool.assistant_allow_username)) { if (getResources().getBoolean(R.bool.assistant_allow_username)) {
useUsername.setVisibility(View.VISIBLE); mUseUsername.setVisibility(View.VISIBLE);
useUsername.setOnCheckedChangeListener(this); mUseUsername.setOnCheckedChangeListener(this);
password.addTextChangedListener(this); mPassword.addTextChangedListener(this);
forgotPassword.setText( mForgotPassword.setText(
Html.fromHtml( Html.fromHtml(
"<a href=\"" "<a href=\""
+ url + url
+ "\"'>" + "\"'>"
+ getString(R.string.forgot_password) + getString(R.string.forgot_password)
+ "</a>")); + "</a>"));
forgotPassword.setMovementMethod(LinkMovementMethod.getInstance()); mForgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
} }
// Hide phone number and display username/email/password // Hide mPhone number and display mUsername/email/mPassword
if (!getResources().getBoolean(R.bool.use_phone_number_validation)) { if (!getResources().getBoolean(R.bool.use_phone_number_validation)) {
phoneNumberLayout.setVisibility(View.GONE); mPhoneNumberLayout.setVisibility(View.GONE);
useUsername.setVisibility(View.GONE); mUseUsername.setVisibility(View.GONE);
usernameLayout.setVisibility(View.VISIBLE); mUsernameLayout.setVisibility(View.VISIBLE);
passwordLayout.setVisibility(View.VISIBLE); mPasswordLayout.setVisibility(View.VISIBLE);
} }
// When we come from generic login fragment // When we come from generic mLogin fragment
username = getArguments().getString("Username"); mUsername = getArguments().getString("Username");
pwd = getArguments().getString("Password"); mPwd = getArguments().getString("Password");
if (username != null && pwd != null) { if (mUsername != null && mPwd != null) {
useUsername.setChecked(true); mUseUsername.setChecked(true);
onCheckedChanged(useUsername, true); onCheckedChanged(mUseUsername, true);
login.setText(username); mLogin.setText(mUsername);
password.setText(pwd); mPassword.setText(mPwd);
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
accountCreator.setLanguage(Locale.getDefault().toLanguageTag()); mAccountCreator.setLanguage(Locale.getDefault().toLanguageTag());
} }
addPhoneNumberHandler(dialCode, null); addPhoneNumberHandler(mDialCode, null);
addPhoneNumberHandler(phoneNumberEdit, null); addPhoneNumberHandler(mPhoneNumberEdit, null);
return view; return view;
} }
public void linphoneLogIn() { public void linphoneLogIn() {
if (login.getText() == null if (mLogin.getText() == null
|| login.length() == 0 || mLogin.length() == 0
|| password.getText() == null || mPassword.getText() == null
|| password.length() == 0) { || mPassword.length() == 0) {
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
getString(R.string.first_launch_no_login_password), getString(R.string.first_launch_no_login_password),
AssistantActivity.instance()); AssistantActivity.instance());
apply.setEnabled(true); mApply.setEnabled(true);
return; return;
} }
accountCreator.setUsername(login.getText().toString()); mAccountCreator.setUsername(mLogin.getText().toString());
accountCreator.setPassword(password.getText().toString()); mAccountCreator.setPassword(mPassword.getText().toString());
accountCreator.isAccountExist(); mAccountCreator.isAccountExist();
} }
private int getPhoneNumberStatus() { private int getPhoneNumberStatus() {
return accountCreator.setPhoneNumber( return mAccountCreator.setPhoneNumber(
phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode)); mPhoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(mDialCode));
} }
private void addPhoneNumberHandler(final EditText field, final ImageView icon) { private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
field.addTextChangedListener( field.addTextChangedListener(
new TextWatcher() { new TextWatcher() {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (field.equals(dialCode)) { if (field.equals(mDialCode)) {
DialPlan c = DialPlan c =
AssistantActivity.instance() AssistantActivity.instance()
.getCountryListAdapter() .getCountryListAdapter()
.getCountryFromCountryCode( .getCountryFromCountryCode(
dialCode.getText().toString()); mDialCode.getText().toString());
if (c != null) { if (c != null) {
AssistantActivity.instance().country = c; AssistantActivity.instance().country = c;
selectCountry.setText(c.getCountry()); mSelectCountry.setText(c.getCountry());
} else { } else {
selectCountry.setText(R.string.select_your_country); mSelectCountry.setText(R.string.select_your_country);
} }
} }
} }
@ -253,16 +253,16 @@ public class LinphoneLoginFragment extends Fragment
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (useUsername != null && useUsername.isChecked()) recoverAccount = false; if (mUseUsername != null && mUseUsername.isChecked()) mRecoverAccount = false;
else recoverAccount = true; else mRecoverAccount = true;
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
if (id == R.id.assistant_apply) { if (id == R.id.assistant_apply) {
apply.setEnabled(false); mApply.setEnabled(false);
if (recoverAccount) { if (mRecoverAccount) {
recoverAccount(); recoverAccount();
} else { } else {
linphoneLogIn(); linphoneLogIn();
@ -278,24 +278,24 @@ public class LinphoneLoginFragment extends Fragment
} }
private void recoverAccount() { private void recoverAccount() {
if (phoneNumberEdit.length() > 0 || dialCode.length() > 1) { if (mPhoneNumberEdit.length() > 0 || mDialCode.length() > 1) {
int status = getPhoneNumberStatus(); int status = getPhoneNumberStatus();
boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt(); boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt();
if (isOk) { if (isOk) {
LinphoneManager.getLc() LinphoneManager.getLc()
.getConfig() .getConfig()
.loadFromXmlFile(LinphoneManager.getInstance().getmDynamicConfigFile()); .loadFromXmlFile(LinphoneManager.getInstance().getmDynamicConfigFile());
accountCreator.isAliasUsed(); mAccountCreator.isAliasUsed();
} else { } else {
apply.setEnabled(true); mApply.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForPhoneNumberStatus(status), LinphoneUtils.errorForPhoneNumberStatus(status),
AssistantActivity.instance()); AssistantActivity.instance());
LinphoneUtils.displayError( LinphoneUtils.displayError(
isOk, phoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status)); isOk, mPhoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status));
} }
} else { } else {
apply.setEnabled(true); mApply.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
getString(R.string.assistant_create_account_part_1), getString(R.string.assistant_create_account_part_1),
AssistantActivity.instance()); AssistantActivity.instance());
@ -309,20 +309,20 @@ public class LinphoneLoginFragment extends Fragment
int status = getPhoneNumberStatus(); int status = getPhoneNumberStatus();
boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt(); boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt();
LinphoneUtils.displayError( LinphoneUtils.displayError(
isOk, phoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status)); isOk, mPhoneNumberError, LinphoneUtils.errorForPhoneNumberStatus(status));
if (!isOk) { if (!isOk) {
if ((1 == (status & AccountCreator.PhoneNumberStatus.InvalidCountryCode.toInt()))) { if ((1 == (status & AccountCreator.PhoneNumberStatus.InvalidCountryCode.toInt()))) {
dialCode.setBackgroundResource(R.drawable.resizable_textfield_error); mDialCode.setBackgroundResource(R.drawable.resizable_textfield_error);
phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield); mPhoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
} else { } else {
dialCode.setBackgroundResource(R.drawable.resizable_textfield); mDialCode.setBackgroundResource(R.drawable.resizable_textfield);
phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield_error); mPhoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield_error);
} }
} else { } else {
accountCreator.setPhoneNumber( mAccountCreator.setPhoneNumber(
phoneNumberEdit.getText().toString(), dialCode.getText().toString()); mPhoneNumberEdit.getText().toString(), mDialCode.getText().toString());
dialCode.setBackgroundResource(R.drawable.resizable_textfield); mDialCode.setBackgroundResource(R.drawable.resizable_textfield);
phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield); mPhoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
} }
} }
@ -338,19 +338,19 @@ public class LinphoneLoginFragment extends Fragment
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.getId() == R.id.use_username) { if (buttonView.getId() == R.id.use_username) {
if (isChecked) { if (isChecked) {
usernameLayout.setVisibility(View.VISIBLE); mUsernameLayout.setVisibility(View.VISIBLE);
passwordLayout.setVisibility(View.VISIBLE); mPasswordLayout.setVisibility(View.VISIBLE);
phoneNumberEdit.setVisibility(EditText.GONE); mPhoneNumberEdit.setVisibility(EditText.GONE);
phoneNumberLayout.setVisibility(LinearLayout.GONE); mPhoneNumberLayout.setVisibility(LinearLayout.GONE);
messagePhoneNumber.setText(getString(R.string.assistant_linphone_login_desc)); mMessagePhoneNumber.setText(getString(R.string.assistant_linphone_login_desc));
recoverAccount = false; mRecoverAccount = false;
} else { } else {
usernameLayout.setVisibility(View.GONE); mUsernameLayout.setVisibility(View.GONE);
passwordLayout.setVisibility(View.GONE); mPasswordLayout.setVisibility(View.GONE);
phoneNumberEdit.setVisibility(EditText.VISIBLE); mPhoneNumberEdit.setVisibility(EditText.VISIBLE);
phoneNumberLayout.setVisibility(LinearLayout.VISIBLE); mPhoneNumberLayout.setVisibility(LinearLayout.VISIBLE);
messagePhoneNumber.setText(getString(R.string.assistant_create_account_part_1)); mMessagePhoneNumber.setText(getString(R.string.assistant_create_account_part_1));
recoverAccount = true; mRecoverAccount = true;
} }
} }
} }
@ -359,7 +359,7 @@ public class LinphoneLoginFragment extends Fragment
public void onIsAccountExist( public void onIsAccountExist(
AccountCreator accountCreator, AccountCreator.Status status, String resp) { AccountCreator accountCreator, AccountCreator.Status status, String resp) {
if (AssistantActivity.instance() == null) { if (AssistantActivity.instance() == null) {
apply.setEnabled(true); mApply.setEnabled(true);
return; return;
} }
if (status.equals(AccountCreator.Status.AccountExist) if (status.equals(AccountCreator.Status.AccountExist)
@ -369,7 +369,7 @@ public class LinphoneLoginFragment extends Fragment
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForStatus(status), AssistantActivity.instance());
} }
apply.setEnabled(true); mApply.setEnabled(true);
} }
@Override @Override
@ -396,20 +396,20 @@ public class LinphoneLoginFragment extends Fragment
public void onRecoverAccount( public void onRecoverAccount(
AccountCreator accountCreator, AccountCreator.Status status, String resp) { AccountCreator accountCreator, AccountCreator.Status status, String resp) {
if (AssistantActivity.instance() == null) { if (AssistantActivity.instance() == null) {
apply.setEnabled(true); mApply.setEnabled(true);
return; return;
} }
if (status.equals(AccountCreator.Status.ServerError)) { if (status.equals(AccountCreator.Status.ServerError)) {
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(AccountCreator.Status.RequestFailed), LinphoneUtils.errorForStatus(AccountCreator.Status.RequestFailed),
AssistantActivity.instance()); AssistantActivity.instance());
apply.setEnabled(true); mApply.setEnabled(true);
} else { } else {
AssistantActivity.instance() AssistantActivity.instance()
.displayAssistantCodeConfirm( .displayAssistantCodeConfirm(
accountCreator.getUsername(), accountCreator.getUsername(),
phoneNumberEdit.getText().toString(), mPhoneNumberEdit.getText().toString(),
LinphoneUtils.getCountryCode(dialCode), LinphoneUtils.getCountryCode(mDialCode),
true); true);
} }
} }
@ -422,14 +422,14 @@ public class LinphoneLoginFragment extends Fragment
public void onIsAliasUsed( public void onIsAliasUsed(
AccountCreator accountCreator, AccountCreator.Status status, String resp) { AccountCreator accountCreator, AccountCreator.Status status, String resp) {
if (AssistantActivity.instance() == null) { if (AssistantActivity.instance() == null) {
apply.setEnabled(true); mApply.setEnabled(true);
return; return;
} }
if (status.equals(AccountCreator.Status.AliasIsAccount) if (status.equals(AccountCreator.Status.AliasIsAccount)
|| status.equals(AccountCreator.Status.AliasExist)) { || status.equals(AccountCreator.Status.AliasExist)) {
accountCreator.recoverAccount(); accountCreator.recoverAccount();
} else { } else {
apply.setEnabled(true); mApply.setEnabled(true);
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForStatus(status), AssistantActivity.instance());
} }

View file

@ -34,29 +34,29 @@ import org.linphone.R;
import org.linphone.core.TransportType; import org.linphone.core.TransportType;
public class LoginFragment extends Fragment implements OnClickListener, TextWatcher { public class LoginFragment extends Fragment implements OnClickListener, TextWatcher {
private EditText login, userid, password, domain, displayName; private EditText mLogin, mUserid, mPassword, mDomain, mDisplayName;
private RadioGroup transports; private RadioGroup mTransports;
private Button apply; private Button mApply;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_login, container, false); View view = inflater.inflate(R.layout.assistant_login, container, false);
login = view.findViewById(R.id.assistant_username); mLogin = view.findViewById(R.id.assistant_username);
login.addTextChangedListener(this); mLogin.addTextChangedListener(this);
displayName = view.findViewById(R.id.assistant_display_name); mDisplayName = view.findViewById(R.id.assistant_display_name);
displayName.addTextChangedListener(this); mDisplayName.addTextChangedListener(this);
userid = view.findViewById(R.id.assistant_userid); mUserid = view.findViewById(R.id.assistant_userid);
userid.addTextChangedListener(this); mUserid.addTextChangedListener(this);
password = view.findViewById(R.id.assistant_password); mPassword = view.findViewById(R.id.assistant_password);
password.addTextChangedListener(this); mPassword.addTextChangedListener(this);
domain = view.findViewById(R.id.assistant_domain); mDomain = view.findViewById(R.id.assistant_domain);
domain.addTextChangedListener(this); mDomain.addTextChangedListener(this);
transports = view.findViewById(R.id.assistant_transports); mTransports = view.findViewById(R.id.assistant_transports);
apply = view.findViewById(R.id.assistant_apply); mApply = view.findViewById(R.id.assistant_apply);
apply.setEnabled(false); mApply.setEnabled(false);
apply.setOnClickListener(this); mApply.setOnClickListener(this);
return view; return view;
} }
@ -66,12 +66,12 @@ public class LoginFragment extends Fragment implements OnClickListener, TextWatc
int id = v.getId(); int id = v.getId();
if (id == R.id.assistant_apply) { if (id == R.id.assistant_apply) {
if (login.getText() == null if (mLogin.getText() == null
|| login.length() == 0 || mLogin.length() == 0
|| password.getText() == null || mPassword.getText() == null
|| password.length() == 0 || mPassword.length() == 0
|| domain.getText() == null || mDomain.getText() == null
|| domain.length() == 0) { || mDomain.length() == 0) {
Toast.makeText( Toast.makeText(
getActivity(), getActivity(),
getString(R.string.first_launch_no_login_password), getString(R.string.first_launch_no_login_password),
@ -81,29 +81,29 @@ public class LoginFragment extends Fragment implements OnClickListener, TextWatc
} }
TransportType transport; TransportType transport;
if (transports.getCheckedRadioButtonId() == R.id.transport_udp) { if (mTransports.getCheckedRadioButtonId() == R.id.transport_udp) {
transport = TransportType.Udp; transport = TransportType.Udp;
} else { } else {
if (transports.getCheckedRadioButtonId() == R.id.transport_tcp) { if (mTransports.getCheckedRadioButtonId() == R.id.transport_tcp) {
transport = TransportType.Tcp; transport = TransportType.Tcp;
} else { } else {
transport = TransportType.Tls; transport = TransportType.Tls;
} }
} }
if (domain.getText().toString().compareTo(getString(R.string.default_domain)) == 0) { if (mDomain.getText().toString().compareTo(getString(R.string.default_domain)) == 0) {
AssistantActivity.instance() AssistantActivity.instance()
.displayLoginLinphone( .displayLoginLinphone(
login.getText().toString(), password.getText().toString()); mLogin.getText().toString(), mPassword.getText().toString());
} else { } else {
AssistantActivity.instance() AssistantActivity.instance()
.genericLogIn( .genericLogIn(
login.getText().toString(), mLogin.getText().toString(),
userid.getText().toString(), mUserid.getText().toString(),
password.getText().toString(), mPassword.getText().toString(),
displayName.getText().toString(), mDisplayName.getText().toString(),
null, null,
domain.getText().toString(), mDomain.getText().toString(),
transport); transport);
} }
} }
@ -114,10 +114,10 @@ public class LoginFragment extends Fragment implements OnClickListener, TextWatc
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
apply.setEnabled( mApply.setEnabled(
!login.getText().toString().isEmpty() !mLogin.getText().toString().isEmpty()
&& !password.getText().toString().isEmpty() && !mPassword.getText().toString().isEmpty()
&& !domain.getText().toString().isEmpty()); && !mDomain.getText().toString().isEmpty());
} }
@Override @Override

View file

@ -42,22 +42,22 @@ import org.linphone.settings.LinphonePreferences;
public class RemoteProvisioningActivity extends Activity { public class RemoteProvisioningActivity extends Activity {
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private String configUriParam = null; private String mConfigUriParam = null;
private ProgressBar spinner; private ProgressBar mSpinner;
private CoreListenerStub mListener; private CoreListenerStub mListener;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.remote_provisioning); setContentView(R.layout.remote_provisioning);
spinner = findViewById(R.id.spinner); mSpinner = findViewById(R.id.spinner);
mListener = mListener =
new CoreListenerStub() { new CoreListenerStub() {
@Override @Override
public void onConfiguringStatus( public void onConfiguringStatus(
Core lc, final ConfiguringState state, String message) { Core lc, final ConfiguringState state, String message) {
if (spinner != null) spinner.setVisibility(View.GONE); if (mSpinner != null) mSpinner.setVisibility(View.GONE);
if (state == ConfiguringState.Successful) { if (state == ConfiguringState.Successful) {
goToLinphoneActivity(); goToLinphoneActivity();
} else if (state == ConfiguringState.Failed) { } else if (state == ConfiguringState.Failed) {
@ -113,18 +113,19 @@ public class RemoteProvisioningActivity extends Activity {
if (openUri != null) { if (openUri != null) {
// We expect something like // We expect something like
// linphone-config://http://linphone.org/config.xml // linphone-config://http://linphone.org/config.xml
configUriParam = mConfigUriParam =
openUri.getEncodedSchemeSpecificPart() openUri.getEncodedSchemeSpecificPart()
.substring(2); // Removes the linphone-config:// .substring(2); // Removes the linphone-config://
try { try {
configUriParam = URLDecoder.decode(configUriParam, "UTF-8"); mConfigUriParam =
URLDecoder.decode(mConfigUriParam, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
Log.e(e); Log.e(e);
} }
Log.d("Using config uri: " + configUriParam); Log.d("Using config uri: " + mConfigUriParam);
} }
if (configUriParam == null) { if (mConfigUriParam == null) {
if (!LinphonePreferences.instance() if (!LinphonePreferences.instance()
.isFirstRemoteProvisioning()) { .isFirstRemoteProvisioning()) {
mHandler.post( mHandler.post(
@ -167,7 +168,7 @@ public class RemoteProvisioningActivity extends Activity {
@Override @Override
public void run() { public void run() {
setRemoteProvisioningAddressAndRestart( setRemoteProvisioningAddressAndRestart(
configUriParam); mConfigUriParam);
} }
}); });
} }
@ -185,7 +186,7 @@ public class RemoteProvisioningActivity extends Activity {
R.string.accept, R.string.accept,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
setRemoteProvisioningAddressAndRestart(configUriParam); setRemoteProvisioningAddressAndRestart(mConfigUriParam);
} }
}) })
.setNegativeButton( .setNegativeButton(
@ -199,7 +200,7 @@ public class RemoteProvisioningActivity extends Activity {
} }
private void setRemoteProvisioningAddressAndRestart(final String configUri) { private void setRemoteProvisioningAddressAndRestart(final String configUri) {
if (spinner != null) spinner.setVisibility(View.VISIBLE); if (mSpinner != null) mSpinner.setVisibility(View.VISIBLE);
LinphonePreferences.instance().setContext(this); // Needed, else the next call will crash LinphonePreferences.instance().setContext(this); // Needed, else the next call will crash
LinphonePreferences.instance().setRemoteProvisioningUrl(configUri); LinphonePreferences.instance().setRemoteProvisioningUrl(configUri);

View file

@ -35,8 +35,8 @@ import org.linphone.xmlrpc.XmlRpcHelper;
import org.linphone.xmlrpc.XmlRpcListenerBase; import org.linphone.xmlrpc.XmlRpcListenerBase;
public class RemoteProvisioningLoginActivity extends Activity implements OnClickListener { public class RemoteProvisioningLoginActivity extends Activity implements OnClickListener {
private EditText login, password, domain; private EditText mLogin, mPassword, mDomain;
private Button connect; private Button mConnect;
private CoreListenerStub mListener; private CoreListenerStub mListener;
@Override @Override
@ -44,17 +44,17 @@ public class RemoteProvisioningLoginActivity extends Activity implements OnClick
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.assistant_remote_provisioning_login); setContentView(R.layout.assistant_remote_provisioning_login);
login = findViewById(R.id.assistant_username); mLogin = findViewById(R.id.assistant_username);
password = findViewById(R.id.assistant_password); mPassword = findViewById(R.id.assistant_password);
domain = findViewById(R.id.assistant_domain); mDomain = findViewById(R.id.assistant_domain);
connect = findViewById(R.id.assistant_connect); mConnect = findViewById(R.id.assistant_connect);
connect.setOnClickListener(this); mConnect.setOnClickListener(this);
String defaultDomain = getIntent().getStringExtra("Domain"); String defaultDomain = getIntent().getStringExtra("Domain");
if (defaultDomain != null) { if (defaultDomain != null) {
domain.setText(defaultDomain); mDomain.setText(defaultDomain);
domain.setEnabled(false); mDomain.setEnabled(false);
} }
mListener = mListener =
@ -132,9 +132,9 @@ public class RemoteProvisioningLoginActivity extends Activity implements OnClick
} }
if (id == R.id.assistant_connect) { if (id == R.id.assistant_connect) {
storeAccount( storeAccount(
login.getText().toString(), mLogin.getText().toString(),
password.getText().toString(), mPassword.getText().toString(),
domain.getText().toString()); mDomain.getText().toString());
} }
} }

View file

@ -28,35 +28,35 @@ import android.widget.Button;
import org.linphone.R; import org.linphone.R;
public class WelcomeFragment extends Fragment implements OnClickListener { public class WelcomeFragment extends Fragment implements OnClickListener {
private Button createAccount, logLinphoneAccount, logGenericAccount, remoteProvisioning; private Button mCreateAccount, mLogLinphoneAccount, mLogGenericAccount, mRemoteProvisioning;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_welcome, container, false); View view = inflater.inflate(R.layout.assistant_welcome, container, false);
createAccount = view.findViewById(R.id.create_account); mCreateAccount = view.findViewById(R.id.create_account);
createAccount.setOnClickListener(this); mCreateAccount.setOnClickListener(this);
logLinphoneAccount = view.findViewById(R.id.login_linphone); mLogLinphoneAccount = view.findViewById(R.id.login_linphone);
if (getResources().getBoolean(R.bool.hide_linphone_accounts_in_assistant)) { if (getResources().getBoolean(R.bool.hide_linphone_accounts_in_assistant)) {
logLinphoneAccount.setVisibility(View.GONE); mLogLinphoneAccount.setVisibility(View.GONE);
} else { } else {
logLinphoneAccount.setOnClickListener(this); mLogLinphoneAccount.setOnClickListener(this);
} }
logGenericAccount = view.findViewById(R.id.login_generic); mLogGenericAccount = view.findViewById(R.id.login_generic);
if (getResources().getBoolean(R.bool.hide_generic_accounts_in_assistant)) { if (getResources().getBoolean(R.bool.hide_generic_accounts_in_assistant)) {
logGenericAccount.setVisibility(View.GONE); mLogGenericAccount.setVisibility(View.GONE);
} else { } else {
logGenericAccount.setOnClickListener(this); mLogGenericAccount.setOnClickListener(this);
} }
remoteProvisioning = view.findViewById(R.id.remote_provisioning); mRemoteProvisioning = view.findViewById(R.id.remote_provisioning);
if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_assistant)) { if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_assistant)) {
remoteProvisioning.setVisibility(View.GONE); mRemoteProvisioning.setVisibility(View.GONE);
} else { } else {
remoteProvisioning.setOnClickListener(this); mRemoteProvisioning.setOnClickListener(this);
} }
return view; return view;

View file

@ -28,7 +28,7 @@ public class BandwidthManager {
public static final int LOW_RESOLUTION = 1; public static final int LOW_RESOLUTION = 1;
public static final int LOW_BANDWIDTH = 2; public static final int LOW_BANDWIDTH = 2;
private static BandwidthManager instance; private static BandwidthManager sInstance;
private int currentProfile = HIGH_RESOLUTION; private int currentProfile = HIGH_RESOLUTION;
@ -40,8 +40,8 @@ public class BandwidthManager {
} }
public static final synchronized BandwidthManager getInstance() { public static final synchronized BandwidthManager getInstance() {
if (instance == null) instance = new BandwidthManager(); if (sInstance == null) sInstance = new BandwidthManager();
return instance; return sInstance;
} }
public void updateWithProfileSettings(Core lc, CallParams callParams) { public void updateWithProfileSettings(Core lc, CallParams callParams) {

File diff suppressed because it is too large Load diff

View file

@ -27,8 +27,6 @@ import android.view.ViewGroup;
import org.linphone.R; import org.linphone.R;
public class CallAudioFragment extends Fragment { public class CallAudioFragment extends Fragment {
private CallActivity incallActvityInstance;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -39,14 +37,11 @@ public class CallAudioFragment extends Fragment {
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
incallActvityInstance = (CallActivity) getActivity(); CallActivity incallActvityInstance = (CallActivity) getActivity();
if (incallActvityInstance != null) { if (incallActvityInstance != null) {
incallActvityInstance.bindAudioFragment(this); incallActvityInstance.bindAudioFragment(this);
} // Just to be sure we have incall controls
// Just to be sure we have incall controls
if (incallActvityInstance != null) {
incallActvityInstance.removeCallbacks(); incallActvityInstance.removeCallbacks();
} }
} }

View file

@ -29,7 +29,6 @@ import android.os.Bundle;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
@ -54,25 +53,23 @@ import org.linphone.views.CallIncomingButtonListener;
import org.linphone.views.CallIncomingDeclineButton; import org.linphone.views.CallIncomingDeclineButton;
public class CallIncomingActivity extends LinphoneGenericActivity { public class CallIncomingActivity extends LinphoneGenericActivity {
private static CallIncomingActivity instance; private static CallIncomingActivity sInstance;
private TextView name, number; private TextView mName, mNumber;
private ImageView contactPicture, acceptIcon; private ImageView mContactPicture, mAcceptIcon;
private CallIncomingAnswerButton accept; private CallIncomingAnswerButton mAccept;
private CallIncomingDeclineButton decline; private CallIncomingDeclineButton mDecline;
private Call mCall; private Call mCall;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private LinearLayout acceptUnlock; private boolean mAlreadyAcceptedOrDeniedCall;
private LinearLayout declineUnlock;
private boolean alreadyAcceptedOrDeniedCall;
private KeyguardManager mKeyguardManager; private KeyguardManager mKeyguardManager;
public static CallIncomingActivity instance() { public static CallIncomingActivity instance() {
return instance; return sInstance;
} }
public static boolean isInstanciated() { public static boolean isInstanciated() {
return instance != null; return sInstance != null;
} }
@Override @Override
@ -86,9 +83,9 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.call_incoming); setContentView(R.layout.call_incoming);
name = findViewById(R.id.contact_name); mName = findViewById(R.id.contact_name);
number = findViewById(R.id.contact_number); mNumber = findViewById(R.id.contact_number);
contactPicture = findViewById(R.id.contact_picture); mContactPicture = findViewById(R.id.contact_picture);
// set this flag so this activity will stay in front of the keyguard // set this flag so this activity will stay in front of the keyguard
int flags = int flags =
@ -97,12 +94,9 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
getWindow().addFlags(flags); getWindow().addFlags(flags);
acceptUnlock = findViewById(R.id.acceptUnlock); mAccept = findViewById(R.id.answer_button);
declineUnlock = findViewById(R.id.declineUnlock); mDecline = findViewById(R.id.decline_button);
mAcceptIcon = findViewById(R.id.acceptIcon);
accept = findViewById(R.id.answer_button);
decline = findViewById(R.id.decline_button);
acceptIcon = findViewById(R.id.acceptIcon);
lookupCurrentCall(); lookupCurrentCall();
if (LinphonePreferences.instance() != null if (LinphonePreferences.instance() != null
@ -110,7 +104,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
&& mCall.getRemoteParams() != null && mCall.getRemoteParams() != null
&& LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests() && LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()
&& mCall.getRemoteParams().videoEnabled()) { && mCall.getRemoteParams().videoEnabled()) {
acceptIcon.setImageResource(R.drawable.call_video_start); mAcceptIcon.setImageResource(R.drawable.call_video_start);
} }
mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
@ -119,22 +113,22 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
.getBoolean( .getBoolean(
R.bool.do_not_use_sliders_to_answer_hangup_call_if_phone_unlocked); R.bool.do_not_use_sliders_to_answer_hangup_call_if_phone_unlocked);
if (doNotUseSliders && !mKeyguardManager.inKeyguardRestrictedInputMode()) { if (doNotUseSliders && !mKeyguardManager.inKeyguardRestrictedInputMode()) {
accept.setSliderMode(false); mAccept.setSliderMode(false);
decline.setSliderMode(false); mDecline.setSliderMode(false);
} else { } else {
accept.setSliderMode(true); mAccept.setSliderMode(true);
decline.setSliderMode(true); mDecline.setSliderMode(true);
accept.setDeclineButton(decline); mAccept.setDeclineButton(mDecline);
decline.setAnswerButton(accept); mDecline.setAnswerButton(mAccept);
} }
accept.setListener( mAccept.setListener(
new CallIncomingButtonListener() { new CallIncomingButtonListener() {
@Override @Override
public void onAction() { public void onAction() {
answer(); answer();
} }
}); });
decline.setListener( mDecline.setListener(
new CallIncomingButtonListener() { new CallIncomingButtonListener() {
@Override @Override
public void onAction() { public void onAction() {
@ -166,19 +160,19 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
}; };
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
instance = this; sInstance = this;
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
instance = this; sInstance = this;
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) { if (lc != null) {
lc.addListener(mListener); lc.addListener(mListener);
} }
alreadyAcceptedOrDeniedCall = false; mAlreadyAcceptedOrDeniedCall = false;
mCall = null; mCall = null;
// Only one call ringing at a time is allowed // Only one call ringing at a time is allowed
@ -194,12 +188,12 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address); LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address);
if (contact != null) { if (contact != null) {
ImageUtils.setImagePictureFromUri( ImageUtils.setImagePictureFromUri(
this, contactPicture, contact.getPhotoUri(), contact.getThumbnailUri()); this, mContactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
name.setText(contact.getFullName()); mName.setText(contact.getFullName());
} else { } else {
name.setText(LinphoneUtils.getAddressDisplayName(address)); mName.setText(LinphoneUtils.getAddressDisplayName(address));
} }
number.setText(address.asStringUriOnly()); mNumber.setText(address.asStringUriOnly());
} }
@Override @Override
@ -220,7 +214,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
instance = null; sInstance = null;
} }
@Override @Override
@ -245,20 +239,20 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
} }
private void decline() { private void decline() {
if (alreadyAcceptedOrDeniedCall) { if (mAlreadyAcceptedOrDeniedCall) {
return; return;
} }
alreadyAcceptedOrDeniedCall = true; mAlreadyAcceptedOrDeniedCall = true;
LinphoneManager.getLc().terminateCall(mCall); LinphoneManager.getLc().terminateCall(mCall);
finish(); finish();
} }
private void answer() { private void answer() {
if (alreadyAcceptedOrDeniedCall) { if (mAlreadyAcceptedOrDeniedCall) {
return; return;
} }
alreadyAcceptedOrDeniedCall = true; mAlreadyAcceptedOrDeniedCall = true;
if (!LinphoneManager.getInstance().acceptCall(mCall)) { if (!LinphoneManager.getInstance().acceptCall(mCall)) {
// the above method takes care of Samsung Galaxy S // the above method takes care of Samsung Galaxy S

View file

@ -32,16 +32,16 @@ import org.linphone.utils.LinphoneUtils;
/** Handle call updating, reinvites. */ /** Handle call updating, reinvites. */
public class CallManager { public class CallManager {
private static CallManager instance; private static CallManager sInstance;
public static final synchronized CallManager getInstance() {
if (sInstance == null) sInstance = new CallManager();
return sInstance;
}
private CallManager() {} private CallManager() {}
public static final synchronized CallManager getInstance() { private BandwidthManager getBandwidthManager() {
if (instance == null) instance = new CallManager();
return instance;
}
private BandwidthManager bm() {
return BandwidthManager.getInstance(); return BandwidthManager.getInstance();
} }
@ -57,7 +57,7 @@ public class CallManager {
Core lc = LinphoneManager.getLc(); Core lc = LinphoneManager.getLc();
CallParams params = lc.createCallParams(null); CallParams params = lc.createCallParams(null);
bm().updateWithProfileSettings(lc, params); getBandwidthManager().updateWithProfileSettings(lc, params);
if (videoEnabled && params.videoEnabled()) { if (videoEnabled && params.videoEnabled()) {
params.enableVideo(true); params.enableVideo(true);
@ -96,7 +96,7 @@ public class CallManager {
if (params.videoEnabled()) return false; if (params.videoEnabled()) return false;
// Check if video possible regarding bandwidth limitations // Check if video possible regarding bandwidth limitations
bm().updateWithProfileSettings(lc, params); getBandwidthManager().updateWithProfileSettings(lc, params);
// Abort if not enough bandwidth... // Abort if not enough bandwidth...
if (!params.videoEnabled()) { if (!params.videoEnabled()) {
@ -121,7 +121,7 @@ public class CallManager {
return; return;
} }
CallParams params = lc.createCallParams(lCall); CallParams params = lc.createCallParams(lCall);
bm().updateWithProfileSettings(lc, params); getBandwidthManager().updateWithProfileSettings(lc, params);
lc.updateCall(lCall, null); lc.updateCall(lCall, null);
} }
} }

View file

@ -53,20 +53,20 @@ import org.linphone.utils.LinphoneGenericActivity;
import org.linphone.utils.LinphoneUtils; import org.linphone.utils.LinphoneUtils;
public class CallOutgoingActivity extends LinphoneGenericActivity implements OnClickListener { public class CallOutgoingActivity extends LinphoneGenericActivity implements OnClickListener {
private static CallOutgoingActivity instance; private static CallOutgoingActivity sInstance;
private TextView name, number; private TextView mName, mNumber;
private ImageView contactPicture, micro, speaker, hangUp; private ImageView mContactPicture, mMicro, mSpeaker, mHangUp;
private Call mCall; private Call mCall;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private boolean isMicMuted, isSpeakerEnabled; private boolean mIsMicMuted, mIsSpeakerEnabled;
public static CallOutgoingActivity instance() { public static CallOutgoingActivity instance() {
return instance; return sInstance;
} }
public static boolean isInstanciated() { public static boolean isInstanciated() {
return instance != null; return sInstance != null;
} }
@Override @Override
@ -80,17 +80,17 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.call_outgoing); setContentView(R.layout.call_outgoing);
name = findViewById(R.id.contact_name); mName = findViewById(R.id.contact_name);
number = findViewById(R.id.contact_number); mNumber = findViewById(R.id.contact_number);
contactPicture = findViewById(R.id.contact_picture); mContactPicture = findViewById(R.id.contact_picture);
isMicMuted = false; mIsMicMuted = false;
isSpeakerEnabled = false; mIsSpeakerEnabled = false;
micro = findViewById(R.id.micro); mMicro = findViewById(R.id.micro);
micro.setOnClickListener(this); mMicro.setOnClickListener(this);
speaker = findViewById(R.id.speaker); mSpeaker = findViewById(R.id.speaker);
speaker.setOnClickListener(this); mSpeaker.setOnClickListener(this);
// set this flag so this activity will stay in front of the keyguard // set this flag so this activity will stay in front of the keyguard
int flags = int flags =
@ -99,8 +99,8 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
getWindow().addFlags(flags); getWindow().addFlags(flags);
hangUp = findViewById(R.id.outgoing_hang_up); mHangUp = findViewById(R.id.outgoing_hang_up);
hangUp.setOnClickListener(this); mHangUp.setOnClickListener(this);
mListener = mListener =
new CoreListenerStub() { new CoreListenerStub() {
@ -156,13 +156,13 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
} }
} }
}; };
instance = this; sInstance = this;
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
instance = this; sInstance = this;
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) { if (lc != null) {
lc.addListener(mListener); lc.addListener(mListener);
@ -200,12 +200,12 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address); LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address);
if (contact != null) { if (contact != null) {
ImageUtils.setImagePictureFromUri( ImageUtils.setImagePictureFromUri(
this, contactPicture, contact.getPhotoUri(), contact.getThumbnailUri()); this, mContactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
name.setText(contact.getFullName()); mName.setText(contact.getFullName());
} else { } else {
name.setText(LinphoneUtils.getAddressDisplayName(address)); mName.setText(LinphoneUtils.getAddressDisplayName(address));
} }
number.setText(address.asStringUriOnly()); mNumber.setText(address.asStringUriOnly());
} }
@Override @Override
@ -226,7 +226,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
instance = null; sInstance = null;
} }
@Override @Override
@ -234,22 +234,22 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
int id = v.getId(); int id = v.getId();
if (id == R.id.micro) { if (id == R.id.micro) {
isMicMuted = !isMicMuted; mIsMicMuted = !mIsMicMuted;
if (isMicMuted) { if (mIsMicMuted) {
micro.setImageResource(R.drawable.micro_selected); mMicro.setImageResource(R.drawable.micro_selected);
} else { } else {
micro.setImageResource(R.drawable.micro_default); mMicro.setImageResource(R.drawable.micro_default);
} }
LinphoneManager.getLc().enableMic(!isMicMuted); LinphoneManager.getLc().enableMic(!mIsMicMuted);
} }
if (id == R.id.speaker) { if (id == R.id.speaker) {
isSpeakerEnabled = !isSpeakerEnabled; mIsSpeakerEnabled = !mIsSpeakerEnabled;
if (isSpeakerEnabled) { if (mIsSpeakerEnabled) {
speaker.setImageResource(R.drawable.speaker_selected); mSpeaker.setImageResource(R.drawable.speaker_selected);
} else { } else {
speaker.setImageResource(R.drawable.speaker_default); mSpeaker.setImageResource(R.drawable.speaker_default);
} }
LinphoneManager.getInstance().enableSpeaker(isSpeakerEnabled); LinphoneManager.getInstance().enableSpeaker(mIsSpeakerEnabled);
} }
if (id == R.id.outgoing_hang_up) { if (id == R.id.outgoing_hang_up) {
decline(); decline();

View file

@ -52,8 +52,8 @@ public class CallVideoFragment extends Fragment
private float mZoomFactor = 1.f; private float mZoomFactor = 1.f;
private float mZoomCenterX, mZoomCenterY; private float mZoomCenterX, mZoomCenterY;
private CompatibilityScaleGestureDetector mScaleDetector; private CompatibilityScaleGestureDetector mScaleDetector;
private CallActivity inCallActivity; private CallActivity mInCallActivity;
private int previewX, previewY; private int mPreviewX, mPreviewY;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
// Warning useless because value is ignored and automatically set by new APIs. // Warning useless because value is ignored and automatically set by new APIs.
@ -81,8 +81,8 @@ public class CallVideoFragment extends Fragment
} }
mGestureDetector.onTouchEvent(event); mGestureDetector.onTouchEvent(event);
if (inCallActivity != null) { if (mInCallActivity != null) {
inCallActivity.displayVideoCallControlsIfHidden(); mInCallActivity.displayVideoCallControlsIfHidden();
} }
return true; return true;
} }
@ -94,8 +94,8 @@ public class CallVideoFragment extends Fragment
public boolean onTouch(View view, MotionEvent motionEvent) { public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) { switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
previewX = (int) motionEvent.getX(); mPreviewX = (int) motionEvent.getX();
previewY = (int) motionEvent.getY(); mPreviewY = (int) motionEvent.getY();
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
int x = (int) motionEvent.getX(); int x = (int) motionEvent.getX();
@ -108,8 +108,8 @@ public class CallVideoFragment extends Fragment
0); // Clears the rule, as there is no removeRule until API 0); // Clears the rule, as there is no removeRule until API
// 17. // 17.
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
int left = lp.leftMargin + (x - previewX); int left = lp.leftMargin + (x - mPreviewX);
int top = lp.topMargin + (y - previewY); int top = lp.topMargin + (y - mPreviewY);
lp.leftMargin = left; lp.leftMargin = left;
lp.topMargin = top; lp.topMargin = top;
view.setLayoutParams(lp); view.setLayoutParams(lp);
@ -124,9 +124,9 @@ public class CallVideoFragment extends Fragment
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
inCallActivity = (CallActivity) getActivity(); mInCallActivity = (CallActivity) getActivity();
if (inCallActivity != null) { if (mInCallActivity != null) {
inCallActivity.bindVideoFragment(this); mInCallActivity.bindVideoFragment(this);
} }
} }
@ -206,8 +206,8 @@ public class CallVideoFragment extends Fragment
LinphoneService.instance().destroyOverlay(); LinphoneService.instance().destroyOverlay();
} }
mGestureDetector = new GestureDetector(inCallActivity, this); mGestureDetector = new GestureDetector(mInCallActivity, this);
mScaleDetector = new CompatibilityScaleGestureDetector(inCallActivity); mScaleDetector = new CompatibilityScaleGestureDetector(mInCallActivity);
mScaleDetector.setOnScaleListener(this); mScaleDetector.setOnScaleListener(this);
resizePreview(); resizePreview();
@ -307,7 +307,7 @@ public class CallVideoFragment extends Fragment
@Override @Override
public void onDestroy() { public void onDestroy() {
inCallActivity = null; mInCallActivity = null;
mCaptureView = null; mCaptureView = null;
if (mVideoView != null) { if (mVideoView != null) {

View file

@ -35,7 +35,6 @@ import org.linphone.core.ChatMessage;
public class ChatMessageOldViewHolder extends RecyclerView.ViewHolder public class ChatMessageOldViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener { implements View.OnClickListener {
public String messageId; public String messageId;
public Context mContext;
public ChatMessage message; public ChatMessage message;
public LinearLayout eventLayout; public LinearLayout eventLayout;
public TextView eventMessage; public TextView eventMessage;
@ -63,6 +62,8 @@ public class ChatMessageOldViewHolder extends RecyclerView.ViewHolder
public Button openFileButton; public Button openFileButton;
public CheckBox delete; public CheckBox delete;
private Context mContext;
private ChatMessageViewHolderClickListener mListener; private ChatMessageViewHolderClickListener mListener;
public ChatMessageOldViewHolder( public ChatMessageOldViewHolder(

View file

@ -61,8 +61,6 @@ import org.linphone.views.BitmapWorkerTask;
import org.linphone.views.ContactAvatar; import org.linphone.views.ContactAvatar;
public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private Context mContext;
public ChatMessage message; public ChatMessage message;
public LinearLayout eventLayout; public LinearLayout eventLayout;
@ -85,6 +83,8 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
public CheckBox deleteEvent; public CheckBox deleteEvent;
public CheckBox deleteMessage; public CheckBox deleteMessage;
private Context mContext;
private ChatMessageViewHolderClickListener mListener; private ChatMessageViewHolderClickListener mListener;
public ChatMessageViewHolder( public ChatMessageViewHolder(

View file

@ -45,8 +45,9 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder
public TextView unreadMessages; public TextView unreadMessages;
public CheckBox delete; public CheckBox delete;
public RelativeLayout avatarLayout; public RelativeLayout avatarLayout;
public Context mContext; public ChatRoom room;
public ChatRoom mRoom;
private Context mContext;
private ClickListener mListener; private ClickListener mListener;
public ChatRoomViewHolder(Context context, View itemView, ClickListener listener) { public ChatRoomViewHolder(Context context, View itemView, ClickListener listener) {
@ -66,8 +67,8 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder
} }
public void bindChatRoom(ChatRoom room) { public void bindChatRoom(ChatRoom room) {
mRoom = room; this.room = room;
ChatMessage lastMessage = mRoom.getLastMessageInHistory(); ChatMessage lastMessage = this.room.getLastMessageInHistory();
if (lastMessage != null) { if (lastMessage != null) {
String messageContent = ""; String messageContent = "";
@ -78,20 +79,20 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder
messageContent = c.getStringBuffer() + " " + messageContent; messageContent = c.getStringBuffer() + " " + messageContent;
} }
} }
lastMessageView.setText(getSender(mRoom) + messageContent); lastMessageView.setText(getSender(this.room) + messageContent);
date.setText( date.setText(
LinphoneUtils.timestampToHumanDate( LinphoneUtils.timestampToHumanDate(
mContext, mContext,
mRoom.getLastUpdateTime(), this.room.getLastUpdateTime(),
R.string.messages_list_date_format)); R.string.messages_list_date_format));
} else { } else {
date.setText(""); date.setText("");
lastMessageView.setText(""); lastMessageView.setText("");
} }
displayName.setText(getContact(mRoom)); displayName.setText(getContact(this.room));
unreadMessages.setText(String.valueOf(mRoom.getUnreadMessagesCount())); unreadMessages.setText(String.valueOf(this.room.getUnreadMessagesCount()));
getAvatar(mRoom); getAvatar(this.room);
} }
public void onClick(View v) { public void onClick(View v) {

View file

@ -24,16 +24,16 @@ import androidx.recyclerview.widget.RecyclerView;
public abstract class ChatScrollListener extends RecyclerView.OnScrollListener { public abstract class ChatScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position // The minimum amount of items to have below your current scroll position
// before loading more. // before mLoading more.
private int visibleThreshold = 5; private int mVisibleThreshold = 5;
// The current offset index of data you have loaded // The current offset index of data you have loaded
private int currentPage = 0; private int mCurrentPage = 0;
// The total number of items in the dataset after the last load // The total number of items in the dataset after the last load
private int previousTotalItemCount = 0; private int mPreviousTotalItemCount = 0;
// True if we are still waiting for the last set of data to load. // True if we are still waiting for the last set of data to load.
private boolean loading = true; private boolean mLoading = true;
// Sets the starting page index // Sets the starting page index
private int startingPageIndex = 0; private int mStartingPageIndex = 0;
private LinearLayoutManager mLayoutManager; private LinearLayoutManager mLayoutManager;
@ -41,18 +41,6 @@ public abstract class ChatScrollListener extends RecyclerView.OnScrollListener {
mLayoutManager = layoutManager; mLayoutManager = layoutManager;
} }
public int getLastVisibleItem(int[] lastVisibleItemPositions) {
int maxSize = 0;
for (int i = 0; i < lastVisibleItemPositions.length; i++) {
if (i == 0) {
maxSize = lastVisibleItemPositions[i];
} else if (lastVisibleItemPositions[i] > maxSize) {
maxSize = lastVisibleItemPositions[i];
}
}
return maxSize;
}
// This happens many times a second during a scroll, so be wary of the code you place here. // This happens many times a second during a scroll, so be wary of the code you place here.
// We are given a few useful parameters to help us work out if we need to load some more data, // We are given a few useful parameters to help us work out if we need to load some more data,
// but first we check if we are waiting for the previous load to finish. // but first we check if we are waiting for the previous load to finish.
@ -65,39 +53,32 @@ public abstract class ChatScrollListener extends RecyclerView.OnScrollListener {
// If the total item count is zero and the previous isn't, assume the // If the total item count is zero and the previous isn't, assume the
// list is invalidated and should be reset back to initial state // list is invalidated and should be reset back to initial state
if (totalItemCount < previousTotalItemCount) { if (totalItemCount < mPreviousTotalItemCount) {
this.currentPage = this.startingPageIndex; this.mCurrentPage = this.mStartingPageIndex;
this.previousTotalItemCount = totalItemCount; this.mPreviousTotalItemCount = totalItemCount;
if (totalItemCount == 0) { if (totalItemCount == 0) {
this.loading = true; this.mLoading = true;
} }
} }
// If its still loading, we check to see if the dataset count has // If its still mLoading, we check to see if the dataset count has
// changed, if so we conclude it has finished loading and update the current page // changed, if so we conclude it has finished mLoading and update the current page
// number and total item count. // number and total item count.
if (loading && (totalItemCount > previousTotalItemCount)) { if (mLoading && (totalItemCount > mPreviousTotalItemCount)) {
loading = false; mLoading = false;
previousTotalItemCount = totalItemCount; mPreviousTotalItemCount = totalItemCount;
} }
// If it isnt currently loading, we check to see if we have breached // If it isnt currently mLoading, we check to see if we have breached
// the visibleThreshold and need to reload more data. // the mVisibleThreshold and need to reload more data.
// If we do need to reload some more data, we execute onLoadMore to fetch the data. // If we do need to reload some more data, we execute onLoadMore to fetch the data.
// threshold should reflect how many total columns there are too // threshold should reflect how many total columns there are too
if (!loading && (lastVisibleItemPosition + visibleThreshold) > totalItemCount) { if (!mLoading && (lastVisibleItemPosition + mVisibleThreshold) > totalItemCount) {
currentPage++; mCurrentPage++;
onLoadMore(currentPage, totalItemCount, view); onLoadMore(mCurrentPage, totalItemCount, view);
loading = true; mLoading = true;
} }
} }
// Call this method whenever performing new searches // Defines the process for actually mLoading more data based on page
public void resetState() {
this.currentPage = this.startingPageIndex;
this.previousTotalItemCount = 0;
this.loading = true;
}
// Defines the process for actually loading more data based on page
public abstract void onLoadMore(int page, int totalItemsCount, RecyclerView view); public abstract void onLoadMore(int page, int totalItemsCount, RecyclerView view);
} }

View file

@ -22,10 +22,6 @@ package org.linphone.chat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,25 +33,7 @@ import org.linphone.core.ChatRoom;
import org.linphone.core.Participant; import org.linphone.core.Participant;
import org.linphone.views.ContactAvatar; import org.linphone.views.ContactAvatar;
public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.ViewHolder> { public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoViewHolder> {
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView name;
public RelativeLayout avatarLayout;
public ImageView delete;
public LinearLayout isAdmin;
public LinearLayout isNotAdmin;
public ViewHolder(View view) {
super(view);
name = view.findViewById(R.id.name);
avatarLayout = view.findViewById(R.id.avatar_layout);
delete = view.findViewById(R.id.delete);
isAdmin = view.findViewById(R.id.isAdminLayout);
isNotAdmin = view.findViewById(R.id.isNotAdminLayout);
}
}
private List<ContactAddress> mItems; private List<ContactAddress> mItems;
private View.OnClickListener mDeleteListener; private View.OnClickListener mDeleteListener;
private boolean mHideAdminFeatures; private boolean mHideAdminFeatures;
@ -69,15 +47,15 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
@NonNull @NonNull
@Override @Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public GroupInfoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = View v =
LayoutInflater.from(parent.getContext()) LayoutInflater.from(parent.getContext())
.inflate(R.layout.chat_infos_cell, parent, false); .inflate(R.layout.chat_infos_cell, parent, false);
return new ViewHolder(v); return new GroupInfoViewHolder(v);
} }
@Override @Override
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { public void onBindViewHolder(@NonNull final GroupInfoViewHolder holder, int position) {
final ContactAddress ca = (ContactAddress) getItem(position); final ContactAddress ca = (ContactAddress) getItem(position);
LinphoneContact c = ca.getContact(); LinphoneContact c = ca.getContact();

View file

@ -0,0 +1,45 @@
package org.linphone.chat;
/*
GroupInfoViewHolder.java
Copyright (C) 2018 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import org.linphone.R;
public class GroupInfoViewHolder extends RecyclerView.ViewHolder {
public TextView name;
public RelativeLayout avatarLayout;
public ImageView delete;
public LinearLayout isAdmin;
public LinearLayout isNotAdmin;
public GroupInfoViewHolder(View view) {
super(view);
name = view.findViewById(R.id.name);
avatarLayout = view.findViewById(R.id.avatar_layout);
delete = view.findViewById(R.id.delete);
isAdmin = view.findViewById(R.id.isAdminLayout);
isNotAdmin = view.findViewById(R.id.isNotAdminLayout);
}
}

View file

@ -26,14 +26,14 @@ import org.linphone.core.Factory;
import org.linphone.core.SearchResult; import org.linphone.core.SearchResult;
public class ContactAddress implements Serializable { public class ContactAddress implements Serializable {
private LinphoneContact contact; private LinphoneContact mContact;
private SearchResult result; private SearchResult mResult;
private String address; private String mAddress;
private String phoneNumber; private String mPhoneNumber;
private boolean isLinphoneContact; private boolean mIsLinphoneContact;
private boolean isSelect = false; private boolean mIsSelect = false;
private boolean isAdmin = false; private boolean mIsAdmin = false;
private transient View view; private transient View mView;
public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC) { public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC) {
init(c, a, pn, isLC); init(c, a, pn, isLC);
@ -41,56 +41,58 @@ public class ContactAddress implements Serializable {
public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC, boolean isAdmin) { public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC, boolean isAdmin) {
init(c, a, pn, isLC); init(c, a, pn, isLC);
this.isAdmin = isAdmin; mIsAdmin = isAdmin;
} }
public boolean isAdmin() { public boolean isAdmin() {
return isAdmin; return mIsAdmin;
} }
public void setAdmin(boolean admin) { public void setAdmin(boolean admin) {
isAdmin = admin; mIsAdmin = admin;
} }
public boolean isSelect() { public boolean isSelect() {
return isSelect; return mIsSelect;
} }
public void setSelect(boolean select) { public void setSelect(boolean select) {
isSelect = select; mIsSelect = select;
} }
public View getView() { public View getView() {
return view; return mView;
} }
public void setView(View v) { public void setView(View v) {
view = v; mView = v;
} }
public LinphoneContact getContact() { public LinphoneContact getContact() {
return contact; return mContact;
} }
public SearchResult getResult() { public SearchResult getResult() {
return result; return mResult;
} }
public void setResult(SearchResult result) { public void setResult(SearchResult result) {
this.result = result; this.mResult = result;
} }
public String getAddressAsDisplayableString() { public String getAddressAsDisplayableString() {
Address addr = getAddress(); Address addr = getAddress();
if (addr != null && addr.getUsername() != null) return addr.asStringUriOnly(); if (addr != null && addr.getUsername() != null) return addr.asStringUriOnly();
return address; return mAddress;
} }
public Address getAddress() { public Address getAddress() {
String presence = String presence =
contact.getPresenceModelForUriOrTel( mContact.getPresenceModelForUriOrTel(
(phoneNumber != null && !phoneNumber.isEmpty()) ? phoneNumber : address); (mPhoneNumber != null && !mPhoneNumber.isEmpty())
Address addr = Factory.instance().createAddress(presence != null ? presence : address); ? mPhoneNumber
: mAddress);
Address addr = Factory.instance().createAddress(presence != null ? presence : mAddress);
// Remove the user=phone URI param if existing, it will break everything otherwise // Remove the user=phone URI param if existing, it will break everything otherwise
if (addr.hasUriParam("user")) { if (addr.hasUriParam("user")) {
addr.removeUriParam("user"); addr.removeUriParam("user");
@ -99,8 +101,8 @@ public class ContactAddress implements Serializable {
} }
public String getDisplayName() { public String getDisplayName() {
if (address != null) { if (mAddress != null) {
Address addr = Factory.instance().createAddress(address); Address addr = Factory.instance().createAddress(mAddress);
if (addr != null) { if (addr != null) {
return addr.getDisplayName(); return addr.getDisplayName();
} }
@ -109,8 +111,8 @@ public class ContactAddress implements Serializable {
} }
public String getUsername() { public String getUsername() {
if (address != null) { if (mAddress != null) {
Address addr = Factory.instance().createAddress(address); Address addr = Factory.instance().createAddress(mAddress);
if (addr != null) { if (addr != null) {
return addr.getUsername(); return addr.getUsername();
} }
@ -119,18 +121,18 @@ public class ContactAddress implements Serializable {
} }
public String getPhoneNumber() { public String getPhoneNumber() {
return phoneNumber; return mPhoneNumber;
} }
public boolean isLinphoneContact() { public boolean isLinphoneContact() {
return isLinphoneContact; return mIsLinphoneContact;
} }
private void init(LinphoneContact c, String a, String pn, boolean isLC) { private void init(LinphoneContact c, String a, String pn, boolean isLC) {
contact = c; mContact = c;
address = a; mAddress = a;
phoneNumber = pn; mPhoneNumber = pn;
isLinphoneContact = isLC; mIsLinphoneContact = isLC;
} }
@Override @Override

View file

@ -52,17 +52,17 @@ import org.linphone.utils.ImageUtils;
import org.linphone.utils.LinphoneUtils; import org.linphone.utils.LinphoneUtils;
public class ContactDetailsFragment extends Fragment implements OnClickListener { public class ContactDetailsFragment extends Fragment implements OnClickListener {
private LinphoneContact contact; private LinphoneContact mContact;
private ImageView editContact, deleteContact, back; private ImageView mEditContact, mDeleteContact, mBack;
private TextView organization; private TextView mOrganization;
private RelativeLayout mWaitLayout; private RelativeLayout mWaitLayout;
private LayoutInflater inflater; private LayoutInflater mInflater;
private View view; private View mView;
private boolean displayChatAddressOnly = false; private boolean mDisplayChatAddressOnly = false;
private ChatRoom mChatRoom; private ChatRoom mChatRoom;
private ChatRoomListenerStub mChatRoomCreationListener; private ChatRoomListenerStub mChatRoomCreationListener;
private OnClickListener dialListener = private OnClickListener mDialListener =
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -70,12 +70,12 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
String tag = (String) v.getTag(); String tag = (String) v.getTag();
LinphoneActivity.instance() LinphoneActivity.instance()
.setAddresGoToDialerAndCall( .setAddresGoToDialerAndCall(
tag, contact.getFullName(), contact.getPhotoUri()); tag, mContact.getFullName(), mContact.getPhotoUri());
} }
} }
}; };
private OnClickListener chatListener = private OnClickListener mChatListener =
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -124,38 +124,38 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
contact = (LinphoneContact) getArguments().getSerializable("Contact"); mContact = (LinphoneContact) getArguments().getSerializable("Contact");
this.inflater = inflater; this.mInflater = inflater;
view = inflater.inflate(R.layout.contact, container, false); mView = inflater.inflate(R.layout.contact, container, false);
if (getArguments() != null) { if (getArguments() != null) {
displayChatAddressOnly = getArguments().getBoolean("ChatAddressOnly"); mDisplayChatAddressOnly = getArguments().getBoolean("ChatAddressOnly");
} }
mWaitLayout = view.findViewById(R.id.waitScreen); mWaitLayout = mView.findViewById(R.id.waitScreen);
mWaitLayout.setVisibility(View.GONE); mWaitLayout.setVisibility(View.GONE);
editContact = view.findViewById(R.id.editContact); mEditContact = mView.findViewById(R.id.editContact);
editContact.setOnClickListener(this); mEditContact.setOnClickListener(this);
deleteContact = view.findViewById(R.id.deleteContact); mDeleteContact = mView.findViewById(R.id.deleteContact);
deleteContact.setOnClickListener(this); mDeleteContact.setOnClickListener(this);
organization = view.findViewById(R.id.contactOrganization); mOrganization = mView.findViewById(R.id.contactOrganization);
boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization); boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization);
String org = contact.getOrganization(); String org = mContact.getOrganization();
if (org != null && !org.isEmpty() && isOrgVisible) { if (org != null && !org.isEmpty() && isOrgVisible) {
organization.setText(org); mOrganization.setText(org);
} else { } else {
organization.setVisibility(View.GONE); mOrganization.setVisibility(View.GONE);
} }
back = view.findViewById(R.id.back); mBack = mView.findViewById(R.id.back);
if (getResources().getBoolean(R.bool.isTablet)) { if (getResources().getBoolean(R.bool.isTablet)) {
back.setVisibility(View.INVISIBLE); mBack.setVisibility(View.INVISIBLE);
} else { } else {
back.setOnClickListener(this); mBack.setOnClickListener(this);
} }
mChatRoomCreationListener = mChatRoomCreationListener =
@ -177,7 +177,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
} }
}; };
return view; return mView;
} }
@Override @Override
@ -189,30 +189,31 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
} }
public void changeDisplayedContact(LinphoneContact newContact) { public void changeDisplayedContact(LinphoneContact newContact) {
contact = newContact; mContact = newContact;
displayContact(inflater, view); displayContact(mInflater, mView);
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private void displayContact(LayoutInflater inflater, View view) { private void displayContact(LayoutInflater inflater, View view) {
ImageView contactPicture = view.findViewById(R.id.contact_picture); ImageView contactPicture = view.findViewById(R.id.contact_picture);
if (contact.hasPhoto()) { if (mContact.hasPhoto()) {
ImageUtils.setImagePictureFromUri( ImageUtils.setImagePictureFromUri(
getActivity(), getActivity(),
contactPicture, contactPicture,
contact.getPhotoUri(), mContact.getPhotoUri(),
contact.getThumbnailUri()); mContact.getThumbnailUri());
} else { } else {
contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap()); contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
} }
TextView contactName = view.findViewById(R.id.contact_name); TextView contactName = view.findViewById(R.id.contact_name);
contactName.setText(contact.getFullName()); contactName.setText(mContact.getFullName());
organization.setText((contact.getOrganization() != null) ? contact.getOrganization() : ""); mOrganization.setText(
(mContact.getOrganization() != null) ? mContact.getOrganization() : "");
TableLayout controls = view.findViewById(R.id.controls); TableLayout controls = view.findViewById(R.id.controls);
controls.removeAllViews(); controls.removeAllViews();
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) { for (LinphoneNumberOrAddress noa : mContact.getNumbersOrAddresses()) {
boolean skip = false; boolean skip = false;
View v = inflater.inflate(R.layout.contact_control_row, null); View v = inflater.inflate(R.layout.contact_control_row, null);
@ -242,8 +243,8 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
} }
v.findViewById(R.id.friendLinphone).setVisibility(View.GONE); v.findViewById(R.id.friendLinphone).setVisibility(View.GONE);
if (contact.getFriend() != null) { if (mContact.getFriend() != null) {
PresenceModel pm = contact.getFriend().getPresenceModelForUriOrTel(noa.getValue()); PresenceModel pm = mContact.getFriend().getPresenceModelForUriOrTel(noa.getValue());
if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) { if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE); v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE);
} else { } else {
@ -275,9 +276,9 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
}); });
} }
String contactAddress = contact.getPresenceModelForUriOrTel(noa.getValue()); String contactAddress = mContact.getPresenceModelForUriOrTel(noa.getValue());
if (!displayChatAddressOnly) { if (!mDisplayChatAddressOnly) {
v.findViewById(R.id.contact_call).setOnClickListener(dialListener); v.findViewById(R.id.contact_call).setOnClickListener(mDialListener);
if (contactAddress != null) { if (contactAddress != null) {
v.findViewById(R.id.contact_call).setTag(contactAddress); v.findViewById(R.id.contact_call).setTag(contactAddress);
} else { } else {
@ -287,8 +288,8 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
v.findViewById(R.id.contact_call).setVisibility(View.GONE); v.findViewById(R.id.contact_call).setVisibility(View.GONE);
} }
v.findViewById(R.id.contact_chat).setOnClickListener(chatListener); v.findViewById(R.id.contact_chat).setOnClickListener(mChatListener);
v.findViewById(R.id.contact_chat_secured).setOnClickListener(chatListener); v.findViewById(R.id.contact_chat_secured).setOnClickListener(mChatListener);
if (contactAddress != null) { if (contactAddress != null) {
v.findViewById(R.id.contact_chat).setTag(contactAddress); v.findViewById(R.id.contact_chat).setTag(contactAddress);
v.findViewById(R.id.contact_chat_secured).setTag(contactAddress); v.findViewById(R.id.contact_chat_secured).setTag(contactAddress);
@ -298,7 +299,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
} }
if (v.findViewById(R.id.friendLinphone).getVisibility() if (v.findViewById(R.id.friendLinphone).getVisibility()
== View.VISIBLE /* TODO Does contact have LIME capability ?*/ == View.VISIBLE /* TODO Does mContact have LIME capability ?*/
&& lpc.getConferenceFactoryUri() != null) { && lpc.getConferenceFactoryUri() != null) {
v.findViewById(R.id.contact_chat_secured).setVisibility(View.VISIBLE); v.findViewById(R.id.contact_chat_secured).setVisibility(View.VISIBLE);
} else { } else {
@ -323,8 +324,8 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL); LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
} }
contact.refresh(); mContact.refresh();
displayContact(inflater, view); displayContact(mInflater, mView);
} }
@Override @Override
@ -332,7 +333,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
int id = v.getId(); int id = v.getId();
if (id == R.id.editContact) { if (id == R.id.editContact) {
ContactsManager.getInstance().editContact(getActivity(), contact, null); ContactsManager.getInstance().editContact(getActivity(), mContact, null);
} else if (id == R.id.deleteContact) { } else if (id == R.id.deleteContact) {
final Dialog dialog = final Dialog dialog =
LinphoneActivity.instance().displayDialog(getString(R.string.delete_text)); LinphoneActivity.instance().displayDialog(getString(R.string.delete_text));
@ -343,7 +344,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
contact.delete(); mContact.delete();
LinphoneActivity.instance().displayContacts(false); LinphoneActivity.instance().displayContacts(false);
dialog.dismiss(); dialog.dismiss();
} }

View file

@ -64,65 +64,66 @@ import org.linphone.utils.LinphoneUtils;
public class ContactEditorFragment extends Fragment { public class ContactEditorFragment extends Fragment {
private static final int ADD_PHOTO = 1337; private static final int ADD_PHOTO = 1337;
private static final int PHOTO_SIZE = 128; private static final int PHOTO_SIZE = 128;
private View view;
private ImageView cancel, deleteContact, ok; private View mView;
private ImageView addNumber, addSipAddress, contactPicture; private ImageView mCancel, mDeleteContact, mOk;
private LinearLayout phoneNumbersSection, sipAddressesSection; private ImageView mAddNumber, mAddSipAddress, mContactPicture;
private EditText firstName, lastName, organization; private LinearLayout mPhoneNumbersSection, mSipAddressesSection;
private LayoutInflater inflater; private EditText mFirstName, mLastName, mOrganization;
private boolean isNewContact; private LayoutInflater mInflater;
private LinphoneContact contact; private boolean mIsNewContact;
private List<LinphoneNumberOrAddress> numbersAndAddresses; private LinphoneContact mContact;
private int firstSipAddressIndex = -1; private List<LinphoneNumberOrAddress> mNumbersAndAddresses;
private LinearLayout sipAddresses, numbers; private int mFirstSipAddressIndex = -1;
private String newSipOrNumberToAdd, newDisplayName; private LinearLayout mSipAddresses, mNumbers;
private Uri pickedPhotoForContactUri; private String mNewSipOrNumberToAdd, mNewDisplayName;
private byte[] photoToAdd; private Uri mPickedPhotoForContactUri;
private byte[] mPhotoToAdd;
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
this.inflater = inflater; mInflater = inflater;
contact = null; mContact = null;
isNewContact = true; mIsNewContact = true;
if (getArguments() != null) { if (getArguments() != null) {
Serializable obj = getArguments().getSerializable("Contact"); Serializable obj = getArguments().getSerializable("Contact");
if (obj != null) { if (obj != null) {
contact = (LinphoneContact) obj; mContact = (LinphoneContact) obj;
isNewContact = false; mIsNewContact = false;
if (getArguments().getString("NewSipAdress") != null) { if (getArguments().getString("NewSipAdress") != null) {
newSipOrNumberToAdd = getArguments().getString("NewSipAdress"); mNewSipOrNumberToAdd = getArguments().getString("NewSipAdress");
} }
if (getArguments().getString("NewDisplayName") != null) { if (getArguments().getString("NewDisplayName") != null) {
newDisplayName = getArguments().getString("NewDisplayName"); mNewDisplayName = getArguments().getString("NewDisplayName");
} }
} else if (getArguments().getString("NewSipAdress") != null) { } else if (getArguments().getString("NewSipAdress") != null) {
newSipOrNumberToAdd = getArguments().getString("NewSipAdress"); mNewSipOrNumberToAdd = getArguments().getString("NewSipAdress");
if (getArguments().getString("NewDisplayName") != null) { if (getArguments().getString("NewDisplayName") != null) {
newDisplayName = getArguments().getString("NewDisplayName"); mNewDisplayName = getArguments().getString("NewDisplayName");
} }
} }
} }
view = inflater.inflate(R.layout.contact_edit, container, false); mView = inflater.inflate(R.layout.contact_edit, container, false);
phoneNumbersSection = view.findViewById(R.id.phone_numbers); mPhoneNumbersSection = mView.findViewById(R.id.phone_numbers);
if (getResources().getBoolean(R.bool.hide_phone_numbers_in_editor) if (getResources().getBoolean(R.bool.hide_phone_numbers_in_editor)
|| !ContactsManager.getInstance().hasContactsAccess()) { || !ContactsManager.getInstance().hasContactsAccess()) {
// Currently linphone friends don't support phone numbers, so hide them // Currently linphone friends don't support phone mNumbers, so hide them
phoneNumbersSection.setVisibility(View.GONE); mPhoneNumbersSection.setVisibility(View.GONE);
} }
sipAddressesSection = view.findViewById(R.id.sip_addresses); mSipAddressesSection = mView.findViewById(R.id.sip_addresses);
if (getResources().getBoolean(R.bool.hide_sip_addresses_in_editor)) { if (getResources().getBoolean(R.bool.hide_sip_addresses_in_editor)) {
sipAddressesSection.setVisibility(View.GONE); mSipAddressesSection.setVisibility(View.GONE);
} }
deleteContact = view.findViewById(R.id.delete_contact); mDeleteContact = mView.findViewById(R.id.delete_contact);
cancel = view.findViewById(R.id.cancel); mCancel = mView.findViewById(R.id.cancel);
cancel.setOnClickListener( mCancel.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -130,14 +131,14 @@ public class ContactEditorFragment extends Fragment {
} }
}); });
ok = view.findViewById(R.id.ok); mOk = mView.findViewById(R.id.ok);
ok.setOnClickListener( mOk.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (isNewContact) { if (mIsNewContact) {
boolean areAllFielsEmpty = true; boolean areAllFielsEmpty = true;
for (LinphoneNumberOrAddress nounoa : numbersAndAddresses) { for (LinphoneNumberOrAddress nounoa : mNumbersAndAddresses) {
if (nounoa.getValue() != null && !nounoa.getValue().equals("")) { if (nounoa.getValue() != null && !nounoa.getValue().equals("")) {
areAllFielsEmpty = false; areAllFielsEmpty = false;
break; break;
@ -147,32 +148,32 @@ public class ContactEditorFragment extends Fragment {
getFragmentManager().popBackStackImmediate(); getFragmentManager().popBackStackImmediate();
return; return;
} }
contact = LinphoneContact.createContact(); mContact = LinphoneContact.createContact();
} }
contact.setFirstNameAndLastName( mContact.setFirstNameAndLastName(
firstName.getText().toString(), mFirstName.getText().toString(),
lastName.getText().toString(), mLastName.getText().toString(),
true); true);
if (photoToAdd != null) { if (mPhotoToAdd != null) {
contact.setPhoto(photoToAdd); mContact.setPhoto(mPhotoToAdd);
} }
for (LinphoneNumberOrAddress noa : numbersAndAddresses) { for (LinphoneNumberOrAddress noa : mNumbersAndAddresses) {
if (noa.isSIPAddress() && noa.getValue() != null) { if (noa.isSIPAddress() && noa.getValue() != null) {
noa.setValue( noa.setValue(
LinphoneUtils.getFullAddressFromUsername(noa.getValue())); LinphoneUtils.getFullAddressFromUsername(noa.getValue()));
} }
contact.addOrUpdateNumberOrAddress(noa); mContact.addOrUpdateNumberOrAddress(noa);
} }
contact.setOrganization(organization.getText().toString(), true); mContact.setOrganization(mOrganization.getText().toString(), true);
contact.save(); mContact.save();
getFragmentManager().popBackStackImmediate(); getFragmentManager().popBackStackImmediate();
} }
}); });
lastName = view.findViewById(R.id.contactLastName); mLastName = mView.findViewById(R.id.contactLastName);
// Hack to display keyboard when touching focused edittext on Nexus One // Hack to display keyboard when touching focused edittext on Nexus One
if (Version.sdkStrictlyBelow(Version.API11_HONEYCOMB_30)) { if (Version.sdkStrictlyBelow(Version.API11_HONEYCOMB_30)) {
lastName.setOnClickListener( mLastName.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -184,14 +185,14 @@ public class ContactEditorFragment extends Fragment {
} }
}); });
} }
lastName.addTextChangedListener( mLastName.addTextChangedListener(
new TextWatcher() { new TextWatcher() {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
if (lastName.getText().length() > 0 || firstName.getText().length() > 0) { if (mLastName.getText().length() > 0 || mFirstName.getText().length() > 0) {
ok.setEnabled(true); mOk.setEnabled(true);
} else { } else {
ok.setEnabled(false); mOk.setEnabled(false);
} }
} }
@ -203,15 +204,15 @@ public class ContactEditorFragment extends Fragment {
public void afterTextChanged(Editable s) {} public void afterTextChanged(Editable s) {}
}); });
firstName = view.findViewById(R.id.contactFirstName); mFirstName = mView.findViewById(R.id.contactFirstName);
firstName.addTextChangedListener( mFirstName.addTextChangedListener(
new TextWatcher() { new TextWatcher() {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
if (firstName.getText().length() > 0 || lastName.getText().length() > 0) { if (mFirstName.getText().length() > 0 || mLastName.getText().length() > 0) {
ok.setEnabled(true); mOk.setEnabled(true);
} else { } else {
ok.setEnabled(false); mOk.setEnabled(false);
} }
} }
@ -223,29 +224,29 @@ public class ContactEditorFragment extends Fragment {
public void afterTextChanged(Editable s) {} public void afterTextChanged(Editable s) {}
}); });
organization = view.findViewById(R.id.contactOrganization); mOrganization = mView.findViewById(R.id.contactOrganization);
boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization); boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization);
if (!isOrgVisible) { if (!isOrgVisible) {
organization.setVisibility(View.GONE); mOrganization.setVisibility(View.GONE);
view.findViewById(R.id.contactOrganizationTitle).setVisibility(View.GONE); mView.findViewById(R.id.contactOrganizationTitle).setVisibility(View.GONE);
} else { } else {
if (!isNewContact) { if (!mIsNewContact) {
organization.setText(contact.getOrganization()); mOrganization.setText(mContact.getOrganization());
} }
} }
if (!isNewContact) { if (!mIsNewContact) {
String fn = contact.getFirstName(); String fn = mContact.getFirstName();
String ln = contact.getLastName(); String ln = mContact.getLastName();
if (fn != null || ln != null) { if (fn != null || ln != null) {
firstName.setText(fn); mFirstName.setText(fn);
lastName.setText(ln); mLastName.setText(ln);
} else { } else {
lastName.setText(contact.getFullName()); mLastName.setText(mContact.getFullName());
firstName.setText(""); mFirstName.setText("");
} }
deleteContact.setOnClickListener( mDeleteContact.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -259,7 +260,7 @@ public class ContactEditorFragment extends Fragment {
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
contact.delete(); mContact.delete();
LinphoneActivity.instance().displayContacts(false); LinphoneActivity.instance().displayContacts(false);
dialog.dismiss(); dialog.dismiss();
} }
@ -276,21 +277,21 @@ public class ContactEditorFragment extends Fragment {
} }
}); });
} else { } else {
deleteContact.setVisibility(View.INVISIBLE); mDeleteContact.setVisibility(View.INVISIBLE);
} }
contactPicture = view.findViewById(R.id.contact_picture); mContactPicture = mView.findViewById(R.id.contact_picture);
if (contact != null) { if (mContact != null) {
ImageUtils.setImagePictureFromUri( ImageUtils.setImagePictureFromUri(
getActivity(), getActivity(),
contactPicture, mContactPicture,
contact.getPhotoUri(), mContact.getPhotoUri(),
contact.getThumbnailUri()); mContact.getThumbnailUri());
} else { } else {
contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap()); mContactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
} }
contactPicture.setOnClickListener( mContactPicture.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -299,37 +300,37 @@ public class ContactEditorFragment extends Fragment {
} }
}); });
numbersAndAddresses = new ArrayList<>(); mNumbersAndAddresses = new ArrayList<>();
sipAddresses = initSipAddressFields(contact); mSipAddresses = initSipAddressFields(mContact);
numbers = initNumbersFields(contact); mNumbers = initNumbersFields(mContact);
addSipAddress = view.findViewById(R.id.add_address_field); mAddSipAddress = mView.findViewById(R.id.add_address_field);
if (getResources().getBoolean(R.bool.allow_only_one_sip_address)) { if (getResources().getBoolean(R.bool.allow_only_one_sip_address)) {
addSipAddress.setVisibility(View.GONE); mAddSipAddress.setVisibility(View.GONE);
} }
addSipAddress.setOnClickListener( mAddSipAddress.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
addEmptyRowToAllowNewNumberOrAddress(sipAddresses, true); addEmptyRowToAllowNewNumberOrAddress(mSipAddresses, true);
} }
}); });
addNumber = view.findViewById(R.id.add_number_field); mAddNumber = mView.findViewById(R.id.add_number_field);
if (getResources().getBoolean(R.bool.allow_only_one_phone_number)) { if (getResources().getBoolean(R.bool.allow_only_one_phone_number)) {
addNumber.setVisibility(View.GONE); mAddNumber.setVisibility(View.GONE);
} }
addNumber.setOnClickListener( mAddNumber.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
addEmptyRowToAllowNewNumberOrAddress(numbers, false); addEmptyRowToAllowNewNumberOrAddress(mNumbers, false);
} }
}); });
lastName.requestFocus(); mLastName.requestFocus();
return view; return mView;
} }
@Override @Override
@ -360,21 +361,21 @@ public class ContactEditorFragment extends Fragment {
} }
private void pickImage() { private void pickImage() {
pickedPhotoForContactUri = null; mPickedPhotoForContactUri = null;
final List<Intent> cameraIntents = new ArrayList<>(); final List<Intent> cameraIntents = new ArrayList<>();
final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = File file =
new File( new File(
FileUtils.getStorageDirectory(LinphoneActivity.instance()), FileUtils.getStorageDirectory(LinphoneActivity.instance()),
getString(R.string.temp_photo_name)); getString(R.string.temp_photo_name));
pickedPhotoForContactUri = Uri.fromFile(file); mPickedPhotoForContactUri = Uri.fromFile(file);
captureIntent.putExtra("outputX", PHOTO_SIZE); captureIntent.putExtra("outputX", PHOTO_SIZE);
captureIntent.putExtra("outputY", PHOTO_SIZE); captureIntent.putExtra("outputY", PHOTO_SIZE);
captureIntent.putExtra("aspectX", 0); captureIntent.putExtra("aspectX", 0);
captureIntent.putExtra("aspectY", 0); captureIntent.putExtra("aspectY", 0);
captureIntent.putExtra("scale", true); captureIntent.putExtra("scale", true);
captureIntent.putExtra("return-data", false); captureIntent.putExtra("return-data", false);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, pickedPhotoForContactUri); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mPickedPhotoForContactUri);
cameraIntents.add(captureIntent); cameraIntents.add(captureIntent);
final Intent galleryIntent = new Intent(); final Intent galleryIntent = new Intent();
@ -408,8 +409,8 @@ public class ContactEditorFragment extends Fragment {
} catch (IOException e) { } catch (IOException e) {
Log.e(e); Log.e(e);
} }
} else if (pickedPhotoForContactUri != null) { } else if (mPickedPhotoForContactUri != null) {
String filePath = pickedPhotoForContactUri.getPath(); String filePath = mPickedPhotoForContactUri.getPath();
editContactPicture(filePath, null); editContactPicture(filePath, null);
} else { } else {
File file = File file =
@ -417,8 +418,8 @@ public class ContactEditorFragment extends Fragment {
FileUtils.getStorageDirectory(LinphoneActivity.instance()), FileUtils.getStorageDirectory(LinphoneActivity.instance()),
getString(R.string.temp_photo_name)); getString(R.string.temp_photo_name));
if (file.exists()) { if (file.exists()) {
pickedPhotoForContactUri = Uri.fromFile(file); mPickedPhotoForContactUri = Uri.fromFile(file);
String filePath = pickedPhotoForContactUri.getPath(); String filePath = mPickedPhotoForContactUri.getPath();
editContactPicture(filePath, null); editContactPicture(filePath, null);
} }
} }
@ -443,8 +444,8 @@ public class ContactEditorFragment extends Fragment {
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
scaledPhoto.compress(Bitmap.CompressFormat.PNG, 0, stream); scaledPhoto.compress(Bitmap.CompressFormat.PNG, 0, stream);
contactPicture.setImageBitmap(scaledPhoto); mContactPicture.setImageBitmap(scaledPhoto);
photoToAdd = stream.toByteArray(); mPhotoToAdd = stream.toByteArray();
} }
private int getThumbnailSize() { private int getThumbnailSize() {
@ -468,7 +469,7 @@ public class ContactEditorFragment extends Fragment {
} }
private LinearLayout initNumbersFields(final LinphoneContact contact) { private LinearLayout initNumbersFields(final LinphoneContact contact) {
LinearLayout controls = view.findViewById(R.id.controls_numbers); LinearLayout controls = mView.findViewById(R.id.controls_numbers);
controls.removeAllViews(); controls.removeAllViews();
if (contact != null) { if (contact != null) {
@ -480,19 +481,19 @@ public class ContactEditorFragment extends Fragment {
} }
} }
if (newSipOrNumberToAdd != null) { if (mNewSipOrNumberToAdd != null) {
boolean isSip = boolean isSip =
LinphoneUtils.isStrictSipAddress(newSipOrNumberToAdd) LinphoneUtils.isStrictSipAddress(mNewSipOrNumberToAdd)
|| !LinphoneUtils.isNumberAddress(newSipOrNumberToAdd); || !LinphoneUtils.isNumberAddress(mNewSipOrNumberToAdd);
if (!isSip) { if (!isSip) {
View view = displayNumberOrAddress(controls, newSipOrNumberToAdd, false); View view = displayNumberOrAddress(controls, mNewSipOrNumberToAdd, false);
if (view != null) controls.addView(view); if (view != null) controls.addView(view);
} }
} }
if (newDisplayName != null) { if (mNewDisplayName != null) {
EditText lastNameEditText = view.findViewById(R.id.contactLastName); EditText lastNameEditText = mView.findViewById(R.id.contactLastName);
if (view != null) lastNameEditText.setText(newDisplayName); if (mView != null) lastNameEditText.setText(mNewDisplayName);
} }
if (controls.getChildCount() == 0) { if (controls.getChildCount() == 0) {
@ -503,7 +504,7 @@ public class ContactEditorFragment extends Fragment {
} }
private LinearLayout initSipAddressFields(final LinphoneContact contact) { private LinearLayout initSipAddressFields(final LinphoneContact contact) {
LinearLayout controls = view.findViewById(R.id.controls_sip_address); LinearLayout controls = mView.findViewById(R.id.controls_sip_address);
controls.removeAllViews(); controls.removeAllViews();
if (contact != null) { if (contact != null) {
@ -515,12 +516,12 @@ public class ContactEditorFragment extends Fragment {
} }
} }
if (newSipOrNumberToAdd != null) { if (mNewSipOrNumberToAdd != null) {
boolean isSip = boolean isSip =
LinphoneUtils.isStrictSipAddress(newSipOrNumberToAdd) LinphoneUtils.isStrictSipAddress(mNewSipOrNumberToAdd)
|| !LinphoneUtils.isNumberAddress(newSipOrNumberToAdd); || !LinphoneUtils.isNumberAddress(mNewSipOrNumberToAdd);
if (isSip) { if (isSip) {
View view = displayNumberOrAddress(controls, newSipOrNumberToAdd, true); View view = displayNumberOrAddress(controls, mNewSipOrNumberToAdd, true);
if (view != null) controls.addView(view); if (view != null) controls.addView(view);
} }
} }
@ -545,8 +546,8 @@ public class ContactEditorFragment extends Fragment {
boolean forceAddNumber) { boolean forceAddNumber) {
String displayNumberOrAddress = numberOrAddress; String displayNumberOrAddress = numberOrAddress;
if (isSIP) { if (isSIP) {
if (firstSipAddressIndex == -1) { if (mFirstSipAddressIndex == -1) {
firstSipAddressIndex = controls.getChildCount(); mFirstSipAddressIndex = controls.getChildCount();
} }
displayNumberOrAddress = displayNumberOrAddress =
LinphoneUtils.getDisplayableUsernameFromAddress(numberOrAddress); LinphoneUtils.getDisplayableUsernameFromAddress(numberOrAddress);
@ -563,16 +564,16 @@ public class ContactEditorFragment extends Fragment {
if (forceAddNumber) { if (forceAddNumber) {
tempNounoa = new LinphoneNumberOrAddress(null, isSIP); tempNounoa = new LinphoneNumberOrAddress(null, isSIP);
} else { } else {
if (isNewContact || newSipOrNumberToAdd != null) { if (mIsNewContact || mNewSipOrNumberToAdd != null) {
tempNounoa = new LinphoneNumberOrAddress(numberOrAddress, isSIP); tempNounoa = new LinphoneNumberOrAddress(numberOrAddress, isSIP);
} else { } else {
tempNounoa = new LinphoneNumberOrAddress(null, isSIP, numberOrAddress); tempNounoa = new LinphoneNumberOrAddress(null, isSIP, numberOrAddress);
} }
} }
final LinphoneNumberOrAddress nounoa = tempNounoa; final LinphoneNumberOrAddress nounoa = tempNounoa;
numbersAndAddresses.add(nounoa); mNumbersAndAddresses.add(nounoa);
final View view = inflater.inflate(R.layout.contact_edit_row, null); final View view = mInflater.inflate(R.layout.contact_edit_row, null);
final EditText noa = view.findViewById(R.id.numoraddr); final EditText noa = view.findViewById(R.id.numoraddr);
if (!isSIP) { if (!isSIP) {
@ -606,10 +607,10 @@ public class ContactEditorFragment extends Fragment {
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (contact != null) { if (mContact != null) {
contact.removeNumberOrAddress(nounoa); mContact.removeNumberOrAddress(nounoa);
} }
numbersAndAddresses.remove(nounoa); mNumbersAndAddresses.remove(nounoa);
view.setVisibility(View.GONE); view.setVisibility(View.GONE);
} }
}); });
@ -619,11 +620,11 @@ public class ContactEditorFragment extends Fragment {
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private void addEmptyRowToAllowNewNumberOrAddress( private void addEmptyRowToAllowNewNumberOrAddress(
final LinearLayout controls, final boolean isSip) { final LinearLayout controls, final boolean isSip) {
final View view = inflater.inflate(R.layout.contact_edit_row, null); final View view = mInflater.inflate(R.layout.contact_edit_row, null);
final LinphoneNumberOrAddress nounoa = new LinphoneNumberOrAddress(null, isSip); final LinphoneNumberOrAddress nounoa = new LinphoneNumberOrAddress(null, isSip);
final EditText noa = view.findViewById(R.id.numoraddr); final EditText noa = view.findViewById(R.id.numoraddr);
numbersAndAddresses.add(nounoa); mNumbersAndAddresses.add(nounoa);
noa.setHint(isSip ? getString(R.string.sip_address) : getString(R.string.phone_number)); noa.setHint(isSip ? getString(R.string.sip_address) : getString(R.string.phone_number));
if (!isSip) { if (!isSip) {
noa.setInputType(InputType.TYPE_CLASS_PHONE); noa.setInputType(InputType.TYPE_CLASS_PHONE);
@ -653,7 +654,7 @@ public class ContactEditorFragment extends Fragment {
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
numbersAndAddresses.remove(nounoa); mNumbersAndAddresses.remove(nounoa);
view.setVisibility(View.GONE); view.setVisibility(View.GONE);
} }
}); });

View file

@ -47,17 +47,17 @@ public class ContactsListFragment extends Fragment
ContactsUpdatedListener, ContactsUpdatedListener,
ContactsListAdapter.ViewHolder.ClickListener, ContactsListAdapter.ViewHolder.ClickListener,
SelectableHelper.DeleteListener { SelectableHelper.DeleteListener {
private RecyclerView contactsList; private RecyclerView mContactsList;
private TextView noSipContact, noContact; private TextView mNoSipContact, mNoContact;
private ImageView allContacts, linphoneContacts, newContact; private ImageView mAllContacts, mLinphoneContacts, mNewContact;
private boolean onlyDisplayLinphoneContacts; private boolean mOnlyDisplayLinphoneContacts;
private View allContactsSelected, linphoneContactsSelected; private View mAllContactsSelected, mLinphoneContactsSelected;
private int lastKnownPosition; private int mLastKnownPosition;
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false; private boolean mEditOnClick = false, mEditConsumed = false, mOnlyDisplayChatAddress = false;
private String sipAddressToAdd, displayName = null; private String mSipAddressToAdd, mDisplayName = null;
private SearchView mSearchView; private SearchView mSearchView;
private ProgressBar contactsFetchInProgress; private ProgressBar mContactsFetchInProgress;
private LinearLayoutManager layoutManager; private LinearLayoutManager mLayoutManager;
private Context mContext; private Context mContext;
private SelectableHelper mSelectionHelper; private SelectableHelper mSelectionHelper;
private ContactsListAdapter mContactAdapter; private ContactsListAdapter mContactAdapter;
@ -71,83 +71,83 @@ public class ContactsListFragment extends Fragment
mSelectionHelper.setDialogMessage(R.string.delete_contacts_text); mSelectionHelper.setDialogMessage(R.string.delete_contacts_text);
if (getArguments() != null) { if (getArguments() != null) {
editOnClick = getArguments().getBoolean("EditOnClick"); mEditOnClick = getArguments().getBoolean("EditOnClick");
sipAddressToAdd = getArguments().getString("SipAddress"); mSipAddressToAdd = getArguments().getString("SipAddress");
if (getArguments().getString("DisplayName") != null) if (getArguments().getString("DisplayName") != null)
displayName = getArguments().getString("DisplayName"); mDisplayName = getArguments().getString("DisplayName");
onlyDisplayChatAddress = getArguments().getBoolean("ChatAddressOnly"); mOnlyDisplayChatAddress = getArguments().getBoolean("ChatAddressOnly");
} }
noSipContact = view.findViewById(R.id.noSipContact); mNoSipContact = view.findViewById(R.id.noSipContact);
noContact = view.findViewById(R.id.noContact); mNoContact = view.findViewById(R.id.noContact);
contactsList = view.findViewById(R.id.contactsList); mContactsList = view.findViewById(R.id.contactsList);
allContacts = view.findViewById(R.id.all_contacts); mAllContacts = view.findViewById(R.id.all_contacts);
linphoneContacts = view.findViewById(R.id.linphone_contacts); mLinphoneContacts = view.findViewById(R.id.linphone_contacts);
allContactsSelected = view.findViewById(R.id.all_contacts_select); mAllContactsSelected = view.findViewById(R.id.all_contacts_select);
linphoneContactsSelected = view.findViewById(R.id.linphone_contacts_select); mLinphoneContactsSelected = view.findViewById(R.id.linphone_contacts_select);
contactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress); mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
newContact = view.findViewById(R.id.newContact); mNewContact = view.findViewById(R.id.newContact);
allContacts.setOnClickListener( mAllContacts.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
onlyDisplayLinphoneContacts = false; mOnlyDisplayLinphoneContacts = false;
allContactsSelected.setVisibility(View.VISIBLE); mAllContactsSelected.setVisibility(View.VISIBLE);
allContacts.setEnabled(false); mAllContacts.setEnabled(false);
linphoneContacts.setEnabled(true); mLinphoneContacts.setEnabled(true);
linphoneContactsSelected.setVisibility(View.INVISIBLE); mLinphoneContactsSelected.setVisibility(View.INVISIBLE);
changeContactsAdapter(); changeContactsAdapter();
} }
}); });
linphoneContacts.setOnClickListener( mLinphoneContacts.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
allContactsSelected.setVisibility(View.INVISIBLE); mAllContactsSelected.setVisibility(View.INVISIBLE);
linphoneContactsSelected.setVisibility(View.VISIBLE); mLinphoneContactsSelected.setVisibility(View.VISIBLE);
linphoneContacts.setEnabled(false); mLinphoneContacts.setEnabled(false);
allContacts.setEnabled(true); mAllContacts.setEnabled(true);
onlyDisplayLinphoneContacts = true; mOnlyDisplayLinphoneContacts = true;
changeContactsAdapter(); changeContactsAdapter();
} }
}); });
newContact.setOnClickListener( mNewContact.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
editConsumed = true; mEditConsumed = true;
ContactsManager.getInstance() ContactsManager.getInstance()
.createContact(getActivity(), displayName, sipAddressToAdd); .createContact(getActivity(), mDisplayName, mSipAddressToAdd);
} }
}); });
if (getResources().getBoolean(R.bool.hide_non_linphone_contacts)) { if (getResources().getBoolean(R.bool.hide_non_linphone_contacts)) {
allContacts.setEnabled(false); mAllContacts.setEnabled(false);
linphoneContacts.setEnabled(false); mLinphoneContacts.setEnabled(false);
onlyDisplayLinphoneContacts = true; mOnlyDisplayLinphoneContacts = true;
allContacts.setOnClickListener(null); mAllContacts.setOnClickListener(null);
linphoneContacts.setOnClickListener(null); mLinphoneContacts.setOnClickListener(null);
linphoneContacts.setVisibility(View.INVISIBLE); mLinphoneContacts.setVisibility(View.INVISIBLE);
linphoneContactsSelected.setVisibility(View.INVISIBLE); mLinphoneContactsSelected.setVisibility(View.INVISIBLE);
} else { } else {
allContacts.setEnabled(onlyDisplayLinphoneContacts); mAllContacts.setEnabled(mOnlyDisplayLinphoneContacts);
linphoneContacts.setEnabled(!allContacts.isEnabled()); mLinphoneContacts.setEnabled(!mAllContacts.isEnabled());
} }
newContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0); mNewContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0);
if (!ContactsManager.getInstance().contactsFetchedOnce()) { if (!ContactsManager.getInstance().contactsFetchedOnce()) {
contactsFetchInProgress.setVisibility(View.VISIBLE); mContactsFetchInProgress.setVisibility(View.VISIBLE);
} else { } else {
if (!onlyDisplayLinphoneContacts if (!mOnlyDisplayLinphoneContacts
&& ContactsManager.getInstance().getContacts().size() == 0) { && ContactsManager.getInstance().getContacts().size() == 0) {
noContact.setVisibility(View.VISIBLE); mNoContact.setVisibility(View.VISIBLE);
} else if (onlyDisplayLinphoneContacts } else if (mOnlyDisplayLinphoneContacts
&& ContactsManager.getInstance().getSIPContacts().size() == 0) { && ContactsManager.getInstance().getSIPContacts().size() == 0) {
noSipContact.setVisibility(View.VISIBLE); mNoSipContact.setVisibility(View.VISIBLE);
} }
} }
@ -166,24 +166,24 @@ public class ContactsListFragment extends Fragment
} }
}); });
layoutManager = new LinearLayoutManager(mContext); mLayoutManager = new LinearLayoutManager(mContext);
contactsList.setLayoutManager(layoutManager); mContactsList.setLayoutManager(mLayoutManager);
DividerItemDecoration dividerItemDecoration = DividerItemDecoration dividerItemDecoration =
new DividerItemDecoration( new DividerItemDecoration(
contactsList.getContext(), layoutManager.getOrientation()); mContactsList.getContext(), mLayoutManager.getOrientation());
dividerItemDecoration.setDrawable( dividerItemDecoration.setDrawable(
getActivity().getResources().getDrawable(R.drawable.divider)); getActivity().getResources().getDrawable(R.drawable.divider));
contactsList.addItemDecoration(dividerItemDecoration); mContactsList.addItemDecoration(dividerItemDecoration);
return view; return view;
} }
public void displayFirstContact() { public void displayFirstContact() {
if (contactsList != null if (mContactsList != null
&& contactsList.getAdapter() != null && mContactsList.getAdapter() != null
&& contactsList.getAdapter().getItemCount() > 0) { && mContactsList.getAdapter().getItemCount() > 0) {
ContactsListAdapter mAdapt = (ContactsListAdapter) contactsList.getAdapter(); ContactsListAdapter mAdapt = (ContactsListAdapter) mContactsList.getAdapter();
LinphoneActivity.instance().displayContact((LinphoneContact) mAdapt.getItem(0), false); LinphoneActivity.instance().displayContact((LinphoneContact) mAdapt.getItem(0), false);
} else { } else {
LinphoneActivity.instance().displayEmptyFragment(); LinphoneActivity.instance().displayEmptyFragment();
@ -201,7 +201,7 @@ public class ContactsListFragment extends Fragment
List<LinphoneContact> listContact; List<LinphoneContact> listContact;
if (onlyDisplayLinphoneContacts) { if (mOnlyDisplayLinphoneContacts) {
listContact = ContactsManager.getInstance().getSIPContacts(search); listContact = ContactsManager.getInstance().getSIPContacts(search);
} else { } else {
listContact = ContactsManager.getInstance().getContacts(search); listContact = ContactsManager.getInstance().getContacts(search);
@ -212,30 +212,30 @@ public class ContactsListFragment extends Fragment
mContactAdapter = new ContactsListAdapter(mContext, listContact, this, mSelectionHelper); mContactAdapter = new ContactsListAdapter(mContext, listContact, this, mSelectionHelper);
// contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); // mContactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
mSelectionHelper.setAdapter(mContactAdapter); mSelectionHelper.setAdapter(mContactAdapter);
if (isEditionEnabled) { if (isEditionEnabled) {
mSelectionHelper.enterEditionMode(); mSelectionHelper.enterEditionMode();
} }
contactsList.setAdapter(mContactAdapter); mContactsList.setAdapter(mContactAdapter);
} }
private void changeContactsAdapter() { private void changeContactsAdapter() {
changeContactsToggle(); changeContactsToggle();
List<LinphoneContact> listContact; List<LinphoneContact> listContact;
noSipContact.setVisibility(View.GONE); mNoSipContact.setVisibility(View.GONE);
noContact.setVisibility(View.GONE); mNoContact.setVisibility(View.GONE);
contactsList.setVisibility(View.VISIBLE); mContactsList.setVisibility(View.VISIBLE);
boolean isEditionEnabled = false; boolean isEditionEnabled = false;
if (mSearchView.getQuery().toString() == "") { if (mSearchView.getQuery().toString() == "") {
if (onlyDisplayLinphoneContacts) { if (mOnlyDisplayLinphoneContacts) {
listContact = ContactsManager.getInstance().getSIPContacts(); listContact = ContactsManager.getInstance().getSIPContacts();
} else { } else {
listContact = ContactsManager.getInstance().getContacts(); listContact = ContactsManager.getInstance().getContacts();
} }
} else { } else {
if (onlyDisplayLinphoneContacts) { if (mOnlyDisplayLinphoneContacts) {
listContact = listContact =
ContactsManager.getInstance() ContactsManager.getInstance()
.getSIPContacts(mSearchView.getQuery().toString()); .getSIPContacts(mSearchView.getQuery().toString());
@ -257,41 +257,41 @@ public class ContactsListFragment extends Fragment
if (isEditionEnabled) { if (isEditionEnabled) {
mSelectionHelper.enterEditionMode(); mSelectionHelper.enterEditionMode();
} }
contactsList.setAdapter(mContactAdapter); mContactsList.setAdapter(mContactAdapter);
mContactAdapter.notifyDataSetChanged(); mContactAdapter.notifyDataSetChanged();
if (!onlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) { if (!mOnlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) {
noContact.setVisibility(View.VISIBLE); mNoContact.setVisibility(View.VISIBLE);
} else if (onlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) { } else if (mOnlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) {
noSipContact.setVisibility(View.VISIBLE); mNoSipContact.setVisibility(View.VISIBLE);
} }
} }
private void changeContactsToggle() { private void changeContactsToggle() {
if (onlyDisplayLinphoneContacts if (mOnlyDisplayLinphoneContacts
&& !getResources().getBoolean(R.bool.hide_non_linphone_contacts)) { && !getResources().getBoolean(R.bool.hide_non_linphone_contacts)) {
allContacts.setEnabled(true); mAllContacts.setEnabled(true);
allContactsSelected.setVisibility(View.INVISIBLE); mAllContactsSelected.setVisibility(View.INVISIBLE);
linphoneContacts.setEnabled(false); mLinphoneContacts.setEnabled(false);
linphoneContactsSelected.setVisibility(View.VISIBLE); mLinphoneContactsSelected.setVisibility(View.VISIBLE);
} else { } else {
allContacts.setEnabled(false); mAllContacts.setEnabled(false);
allContactsSelected.setVisibility(View.VISIBLE); mAllContactsSelected.setVisibility(View.VISIBLE);
linphoneContacts.setEnabled(true); mLinphoneContacts.setEnabled(true);
linphoneContactsSelected.setVisibility(View.INVISIBLE); mLinphoneContactsSelected.setVisibility(View.INVISIBLE);
} }
} }
@Override @Override
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
LinphoneContact contact = (LinphoneContact) adapter.getItemAtPosition(position); LinphoneContact contact = (LinphoneContact) adapter.getItemAtPosition(position);
if (editOnClick) { if (mEditOnClick) {
editConsumed = true; mEditConsumed = true;
ContactsManager.getInstance().editContact(getActivity(), contact, sipAddressToAdd); ContactsManager.getInstance().editContact(getActivity(), contact, mSipAddressToAdd);
} else { } else {
lastKnownPosition = layoutManager.findFirstVisibleItemPosition(); mLastKnownPosition = mLayoutManager.findFirstVisibleItemPosition();
LinphoneActivity.instance().displayContact(contact, onlyDisplayChatAddress); LinphoneActivity.instance().displayContact(contact, mOnlyDisplayChatAddress);
} }
} }
@ -302,12 +302,12 @@ public class ContactsListFragment extends Fragment
if (mContactAdapter.isEditionEnabled()) { if (mContactAdapter.isEditionEnabled()) {
mContactAdapter.toggleSelection(position); mContactAdapter.toggleSelection(position);
} else if (editOnClick) { } else if (mEditOnClick) {
editConsumed = true; mEditConsumed = true;
ContactsManager.getInstance().editContact(getActivity(), contact, sipAddressToAdd); ContactsManager.getInstance().editContact(getActivity(), contact, mSipAddressToAdd);
} else { } else {
lastKnownPosition = layoutManager.findFirstVisibleItemPosition(); mLastKnownPosition = mLayoutManager.findFirstVisibleItemPosition();
LinphoneActivity.instance().displayContact(contact, onlyDisplayChatAddress); LinphoneActivity.instance().displayContact(contact, mOnlyDisplayChatAddress);
} }
} }
@ -325,14 +325,14 @@ public class ContactsListFragment extends Fragment
super.onResume(); super.onResume();
ContactsManager.addContactsListener(this); ContactsManager.addContactsListener(this);
if (editConsumed) { if (mEditConsumed) {
editOnClick = false; mEditOnClick = false;
sipAddressToAdd = null; mSipAddressToAdd = null;
} }
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS_LIST); LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS_LIST);
onlyDisplayLinphoneContacts = mOnlyDisplayLinphoneContacts =
ContactsManager.getInstance().isLinphoneContactsPrefered() ContactsManager.getInstance().isLinphoneContactsPrefered()
|| getResources().getBoolean(R.bool.hide_non_linphone_contacts); || getResources().getBoolean(R.bool.hide_non_linphone_contacts);
} }
@ -353,17 +353,17 @@ public class ContactsListFragment extends Fragment
!= FragmentsAvailable.CONTACTS_LIST) return; != FragmentsAvailable.CONTACTS_LIST) return;
if (mContactAdapter != null) { if (mContactAdapter != null) {
mContactAdapter.updateDataSet( mContactAdapter.updateDataSet(
onlyDisplayLinphoneContacts mOnlyDisplayLinphoneContacts
? ContactsManager.getInstance().getSIPContacts() ? ContactsManager.getInstance().getSIPContacts()
: ContactsManager.getInstance().getContacts()); : ContactsManager.getInstance().getContacts());
mContactAdapter.notifyDataSetChanged(); mContactAdapter.notifyDataSetChanged();
if (mContactAdapter.getItemCount() > 0) { if (mContactAdapter.getItemCount() > 0) {
noContact.setVisibility(View.GONE); mNoContact.setVisibility(View.GONE);
noSipContact.setVisibility(View.GONE); mNoSipContact.setVisibility(View.GONE);
} }
} }
contactsFetchInProgress.setVisibility(View.GONE); mContactsFetchInProgress.setVisibility(View.GONE);
} }
public void invalidate() { public void invalidate() {
@ -372,7 +372,7 @@ public class ContactsListFragment extends Fragment
} else { } else {
changeContactsAdapter(); changeContactsAdapter();
} }
contactsList.scrollToPosition(lastKnownPosition); mContactsList.scrollToPosition(mLastKnownPosition);
} }
@Override @Override

View file

@ -73,39 +73,40 @@ public class ContactsManager extends ContentObserver implements FriendListListen
"data4", // Normalized phone number "data4", // Normalized phone number
}; };
private static ContactsManager instance; private static ContactsManager sInstance;
private static ArrayList<ContactsUpdatedListener> contactsUpdatedListeners; private static ArrayList<ContactsUpdatedListener> sContactsUpdatedListeners;
private List<LinphoneContact> mContacts, mSipContacts; private List<LinphoneContact> mContacts, mSipContacts;
private MagicSearch magicSearch; private MagicSearch mMagicSearch;
private Bitmap defaultAvatar; private Bitmap mDefaultAvatar;
private boolean mContactsFetchedOnce = false; private boolean mContactsFetchedOnce = false;
private Context mContext; private Context mContext;
private AsyncContactsLoader mLoadContactTask; private AsyncContactsLoader mLoadContactTask;
private ContactsManager() { private ContactsManager() {
super(LinphoneService.instance().mHandler); super(LinphoneService.instance().handler);
defaultAvatar = mDefaultAvatar =
BitmapFactory.decodeResource( BitmapFactory.decodeResource(
LinphoneService.instance().getResources(), R.drawable.avatar); LinphoneService.instance().getResources(), R.drawable.avatar);
contactsUpdatedListeners = new ArrayList<>(); sContactsUpdatedListeners = new ArrayList<>();
mContacts = new ArrayList<>(); mContacts = new ArrayList<>();
mSipContacts = new ArrayList<>(); mSipContacts = new ArrayList<>();
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) { if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
magicSearch = LinphoneManager.getLcIfManagerNotDestroyedOrNull().createMagicSearch(); mMagicSearch = LinphoneManager.getLcIfManagerNotDestroyedOrNull().createMagicSearch();
} }
} }
public static void addContactsListener(ContactsUpdatedListener listener) { public static void addContactsListener(ContactsUpdatedListener listener) {
contactsUpdatedListeners.add(listener); sContactsUpdatedListeners.add(listener);
} }
public static void removeContactsListener(ContactsUpdatedListener listener) { public static void removeContactsListener(ContactsUpdatedListener listener) {
contactsUpdatedListeners.remove(listener); sContactsUpdatedListeners.remove(listener);
} }
public static final ContactsManager getInstance() { public static final ContactsManager getInstance() {
if (instance == null) instance = new ContactsManager(); if (sInstance == null) sInstance = new ContactsManager();
return instance; return sInstance;
} }
public static String getAddressOrNumberForAndroidContact( public static String getAddressOrNumberForAndroidContact(
@ -145,12 +146,12 @@ public class ContactsManager extends ContentObserver implements FriendListListen
list.setListener(null); list.setListener(null);
} }
} }
defaultAvatar.recycle(); mDefaultAvatar.recycle();
instance = null; sInstance = null;
} }
public MagicSearch getMagicSearch() { public MagicSearch getMagicSearch() {
return magicSearch; return mMagicSearch;
} }
public boolean contactsFetchedOnce() { public boolean contactsFetchedOnce() {
@ -158,7 +159,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
} }
public Bitmap getDefaultAvatarBitmap() { public Bitmap getDefaultAvatarBitmap() {
return defaultAvatar; return mDefaultAvatar;
} }
@Override @Override
@ -382,7 +383,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
for (Friend lf : friends) { for (Friend lf : friends) {
boolean newContact = ContactsManager.getInstance().refreshSipContact(lf); boolean newContact = ContactsManager.getInstance().refreshSipContact(lf);
if (newContact) { if (newContact) {
for (ContactsUpdatedListener listener : contactsUpdatedListeners) { for (ContactsUpdatedListener listener : sContactsUpdatedListeners) {
listener.onContactsUpdated(); listener.onContactsUpdated();
} }
} }
@ -626,7 +627,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
@Override @Override
protected void onPostExecute(AsyncContactsData data) { protected void onPostExecute(AsyncContactsData data) {
for (ContactsUpdatedListener listener : contactsUpdatedListeners) { for (ContactsUpdatedListener listener : sContactsUpdatedListeners) {
listener.onContactsUpdated(); listener.onContactsUpdated();
} }
for (LinphoneContact contact : data.contacts) { for (LinphoneContact contact : data.contacts) {

View file

@ -47,30 +47,30 @@ import org.linphone.mediastream.Log;
public class LinphoneContact implements Serializable, Comparable<LinphoneContact> { public class LinphoneContact implements Serializable, Comparable<LinphoneContact> {
private static final long serialVersionUID = 9015568163905205244L; private static final long serialVersionUID = 9015568163905205244L;
private transient Friend friend; private transient Friend mFriend;
private String fullName, private String mFullName,
firstName, mFirstName,
lastName, mLastName,
androidId, mAndroidId,
androidRawId, mAndroidRawId,
androidTagId, mAndroidTagId,
organization, mOrganization,
androidLookupKey; mAndroidLookupKey;
private transient Uri photoUri, thumbnailUri; private transient Uri mPhotoUri, mThumbnailUri;
private List<LinphoneNumberOrAddress> addresses; private List<LinphoneNumberOrAddress> mAddresses;
private transient ArrayList<ContentProviderOperation> changesToCommit; private transient ArrayList<ContentProviderOperation> mChangesToCommit;
private transient ArrayList<ContentProviderOperation> changesToCommit2; private transient ArrayList<ContentProviderOperation> mChangesToCommit2;
private boolean hasSipAddress; private boolean mHasSipAddress;
public LinphoneContact() { public LinphoneContact() {
addresses = new ArrayList<>(); mAddresses = new ArrayList<>();
androidId = null; mAndroidId = null;
androidLookupKey = null; mAndroidLookupKey = null;
thumbnailUri = null; mThumbnailUri = null;
photoUri = null; mPhotoUri = null;
changesToCommit = new ArrayList<>(); mChangesToCommit = new ArrayList<>();
changesToCommit2 = new ArrayList<>(); mChangesToCommit2 = new ArrayList<>();
hasSipAddress = false; mHasSipAddress = false;
} }
public static LinphoneContact createContact() { public static LinphoneContact createContact() {
@ -83,7 +83,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
private static LinphoneContact createAndroidContact() { private static LinphoneContact createAndroidContact() {
LinphoneContact contact = new LinphoneContact(); LinphoneContact contact = new LinphoneContact();
contact.changesToCommit.add( contact.mChangesToCommit.add(
ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null) .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null) .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
@ -102,7 +102,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
// Disable subscribes for now // Disable subscribes for now
friend.enableSubscribes(false); friend.enableSubscribes(false);
friend.setIncSubscribePolicy(SubscribePolicy.SPDeny); friend.setIncSubscribePolicy(SubscribePolicy.SPDeny);
contact.friend = friend; contact.mFriend = friend;
friend.setUserData(contact); friend.setUserData(contact);
return contact; return contact;
} }
@ -149,26 +149,26 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
private void addChangesToCommit( private void addChangesToCommit(
ContentProviderOperation operation, boolean doItAfterAccountCreation) { ContentProviderOperation operation, boolean doItAfterAccountCreation) {
if (doItAfterAccountCreation) { if (doItAfterAccountCreation) {
changesToCommit2.add(operation); mChangesToCommit2.add(operation);
} else { } else {
changesToCommit.add(operation); mChangesToCommit.add(operation);
} }
} }
public String getFullName() { public String getFullName() {
return fullName; return mFullName;
} }
public void setFullName(String name) { public void setFullName(String name) {
fullName = name; mFullName = name;
} }
public void setFirstNameAndLastName(String fn, String ln, boolean commitChanges) { public void setFirstNameAndLastName(String fn, String ln, boolean commitChanges) {
if (fn != null && fn.length() == 0 && ln != null && ln.length() == 0) return; if (fn != null && fn.length() == 0 && ln != null && ln.length() == 0) return;
if (fn != null && fn.equals(firstName) && ln != null && ln.equals(lastName)) return; if (fn != null && fn.equals(mFirstName) && ln != null && ln.equals(mLastName)) return;
if (isAndroidContact() && commitChanges) { if (isAndroidContact() && commitChanges) {
if (firstName != null || lastName != null) { if (mFirstName != null || mLastName != null) {
String select = String select =
ContactsContract.Data.CONTACT_ID ContactsContract.Data.CONTACT_ID
+ "=? AND " + "=? AND "
@ -212,39 +212,39 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
} }
firstName = fn; mFirstName = fn;
lastName = ln; mLastName = ln;
if (fullName == null) { if (mFullName == null) {
if (firstName != null if (mFirstName != null
&& lastName != null && mLastName != null
&& firstName.length() > 0 && mFirstName.length() > 0
&& lastName.length() > 0) { && mLastName.length() > 0) {
fullName = firstName + " " + lastName; mFullName = mFirstName + " " + mLastName;
} else if (firstName != null && firstName.length() > 0) { } else if (mFirstName != null && mFirstName.length() > 0) {
fullName = firstName; mFullName = mFirstName;
} else if (lastName != null && lastName.length() > 0) { } else if (mLastName != null && mLastName.length() > 0) {
fullName = lastName; mFullName = mLastName;
} }
} }
} }
public String getFirstName() { public String getFirstName() {
return firstName; return mFirstName;
} }
public String getLastName() { public String getLastName() {
return lastName; return mLastName;
} }
public String getOrganization() { public String getOrganization() {
return organization; return mOrganization;
} }
public void setOrganization(String org, boolean commitChanges) { public void setOrganization(String org, boolean commitChanges) {
if (org != null && org.equals(organization)) return; if (org != null && org.equals(mOrganization)) return;
if (isAndroidContact() && commitChanges) { if (isAndroidContact() && commitChanges) {
if (androidRawId != null) { if (mAndroidRawId != null) {
String select = String select =
ContactsContract.Data.CONTACT_ID ContactsContract.Data.CONTACT_ID
+ "=? AND " + "=? AND "
@ -254,7 +254,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
+ "'"; + "'";
String[] args = new String[] {getAndroidId()}; String[] args = new String[] {getAndroidId()};
if (organization != null) { if (mOrganization != null) {
addChangesToCommit( addChangesToCommit(
ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI) ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(select, args) .withSelection(select, args)
@ -270,7 +270,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} else { } else {
addChangesToCommit( addChangesToCommit(
ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValue(ContactsContract.Data.RAW_CONTACT_ID, androidRawId) .withValue(ContactsContract.Data.RAW_CONTACT_ID, mAndroidRawId)
.withValue( .withValue(
ContactsContract.Data.MIMETYPE, ContactsContract.Data.MIMETYPE,
ContactsContract.CommonDataKinds.Organization ContactsContract.CommonDataKinds.Organization
@ -296,38 +296,38 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
} }
organization = org; mOrganization = org;
} }
public boolean hasPhoto() { public boolean hasPhoto() {
return photoUri != null; return mPhotoUri != null;
} }
public Uri getPhotoUri() { public Uri getPhotoUri() {
return photoUri; return mPhotoUri;
} }
public void setPhotoUri(Uri uri) { public void setPhotoUri(Uri uri) {
if (uri.equals(photoUri)) return; if (uri.equals(mPhotoUri)) return;
photoUri = uri; mPhotoUri = uri;
} }
public Uri getThumbnailUri() { public Uri getThumbnailUri() {
return thumbnailUri; return mThumbnailUri;
} }
public void setThumbnailUri(Uri uri) { public void setThumbnailUri(Uri uri) {
if (uri.equals(thumbnailUri)) return; if (uri.equals(mThumbnailUri)) return;
thumbnailUri = uri; mThumbnailUri = uri;
} }
public void setPhoto(byte[] photo) { public void setPhoto(byte[] photo) {
if (photo != null) { if (photo != null) {
if (isAndroidContact()) { if (isAndroidContact()) {
if (androidRawId != null) { if (mAndroidRawId != null) {
addChangesToCommit( addChangesToCommit(
ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValue(ContactsContract.Data.RAW_CONTACT_ID, androidRawId) .withValue(ContactsContract.Data.RAW_CONTACT_ID, mAndroidRawId)
.withValue( .withValue(
ContactsContract.Data.MIMETYPE, ContactsContract.Data.MIMETYPE,
ContactsContract.CommonDataKinds.Photo ContactsContract.CommonDataKinds.Photo
@ -356,12 +356,12 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
public void addNumberOrAddress(LinphoneNumberOrAddress noa) { public void addNumberOrAddress(LinphoneNumberOrAddress noa) {
if (noa == null) return; if (noa == null) return;
if (noa.isSIPAddress()) { if (noa.isSIPAddress()) {
hasSipAddress = true; mHasSipAddress = true;
addresses.add(noa); mAddresses.add(noa);
} else { } else {
boolean found = false; boolean found = false;
// Check for duplicated phone numbers but with different formats // Check for duplicated phone numbers but with different formats
for (LinphoneNumberOrAddress number : addresses) { for (LinphoneNumberOrAddress number : mAddresses) {
if (!number.isSIPAddress() if (!number.isSIPAddress()
&& noa.getNormalizedPhone().equals(number.getNormalizedPhone())) { && noa.getNormalizedPhone().equals(number.getNormalizedPhone())) {
found = true; found = true;
@ -369,13 +369,13 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
} }
if (!found) { if (!found) {
addresses.add(noa); mAddresses.add(noa);
} }
} }
} }
public List<LinphoneNumberOrAddress> getNumbersOrAddresses() { public List<LinphoneNumberOrAddress> getNumbersOrAddresses() {
return addresses; return mAddresses;
} }
public boolean hasAddress(String address) { public boolean hasAddress(String address) {
@ -394,19 +394,19 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
public boolean hasAddress() { public boolean hasAddress() {
return hasSipAddress; return mHasSipAddress;
} }
public void removeNumberOrAddress(LinphoneNumberOrAddress noa) { public void removeNumberOrAddress(LinphoneNumberOrAddress noa) {
if (noa != null && noa.getOldValue() != null) { if (noa != null && noa.getOldValue() != null) {
if (isAndroidContact()) { if (isAndroidContact()) {
if (androidTagId != null && noa.isSIPAddress()) { if (mAndroidTagId != null && noa.isSIPAddress()) {
String select = String select =
ContactsContract.Data.RAW_CONTACT_ID ContactsContract.Data.RAW_CONTACT_ID
+ "=? AND " + "=? AND "
+ ContactsContract.Data.DATA1 + ContactsContract.Data.DATA1
+ "=?"; + "=?";
String[] args = new String[] {androidTagId, noa.getOldValue()}; String[] args = new String[] {mAndroidTagId, noa.getOldValue()};
addChangesToCommit( addChangesToCommit(
ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI) ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
@ -454,7 +454,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
} }
LinphoneNumberOrAddress toRemove = null; LinphoneNumberOrAddress toRemove = null;
for (LinphoneNumberOrAddress address : addresses) { for (LinphoneNumberOrAddress address : mAddresses) {
if (noa.getOldValue().equals(address.getValue()) if (noa.getOldValue().equals(address.getValue())
&& noa.isSIPAddress() == address.isSIPAddress()) { && noa.isSIPAddress() == address.isSIPAddress()) {
toRemove = address; toRemove = address;
@ -462,7 +462,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
} }
if (toRemove != null) { if (toRemove != null) {
addresses.remove(toRemove); mAddresses.remove(toRemove);
} }
} }
} }
@ -477,13 +477,13 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
.getContext() .getContext()
.getResources() .getResources()
.getBoolean(R.bool.use_linphone_tag)) { .getBoolean(R.bool.use_linphone_tag)) {
if (androidTagId != null) { if (mAndroidTagId != null) {
addChangesToCommit( addChangesToCommit(
ContentProviderOperation.newInsert( ContentProviderOperation.newInsert(
ContactsContract.Data.CONTENT_URI) ContactsContract.Data.CONTENT_URI)
.withValue( .withValue(
ContactsContract.Data.RAW_CONTACT_ID, ContactsContract.Data.RAW_CONTACT_ID,
androidTagId) mAndroidTagId)
.withValue( .withValue(
ContactsContract.Data.MIMETYPE, ContactsContract.Data.MIMETYPE,
ContactsManager.getInstance() ContactsManager.getInstance()
@ -545,13 +545,13 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
ContactsManager.getInstance() ContactsManager.getInstance()
.getString(R.string.addressbook_label)); .getString(R.string.addressbook_label));
} }
if (androidRawId != null) { if (mAndroidRawId != null) {
addChangesToCommit( addChangesToCommit(
ContentProviderOperation.newInsert( ContentProviderOperation.newInsert(
ContactsContract.Data.CONTENT_URI) ContactsContract.Data.CONTENT_URI)
.withValue( .withValue(
ContactsContract.Data.RAW_CONTACT_ID, ContactsContract.Data.RAW_CONTACT_ID,
androidRawId) mAndroidRawId)
.withValues(values) .withValues(values)
.build(), .build(),
false); false);
@ -572,7 +572,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
.getContext() .getContext()
.getResources() .getResources()
.getBoolean(R.bool.use_linphone_tag)) { .getBoolean(R.bool.use_linphone_tag)) {
if (androidTagId != null) { if (mAndroidTagId != null) {
addChangesToCommit( addChangesToCommit(
ContentProviderOperation.newUpdate( ContentProviderOperation.newUpdate(
ContactsContract.Data.CONTENT_URI) ContactsContract.Data.CONTENT_URI)
@ -581,7 +581,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
+ "=? AND " + "=? AND "
+ ContactsContract.Data.DATA1 + ContactsContract.Data.DATA1
+ "=? ", + "=? ",
new String[] {androidTagId, noa.getOldValue()}) new String[] {mAndroidTagId, noa.getOldValue()})
.withValue(ContactsContract.Data.DATA1, noa.getValue()) .withValue(ContactsContract.Data.DATA1, noa.getValue())
.withValue( .withValue(
ContactsContract.Data.DATA2, ContactsContract.Data.DATA2,
@ -671,7 +671,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
noa.setOldValue("sip:" + noa.getOldValue()); noa.setOldValue("sip:" + noa.getOldValue());
} }
} }
for (LinphoneNumberOrAddress address : addresses) { for (LinphoneNumberOrAddress address : mAddresses) {
if (noa.getOldValue().equals(address.getValue()) if (noa.getOldValue().equals(address.getValue())
&& noa.isSIPAddress() == address.isSIPAddress()) { && noa.isSIPAddress() == address.isSIPAddress()) {
address.setValue(noa.getValue()); address.setValue(noa.getValue());
@ -679,32 +679,32 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
} }
} else { } else {
addresses.add(noa); mAddresses.add(noa);
} }
} }
} }
} }
public String getAndroidId() { public String getAndroidId() {
return androidId; return mAndroidId;
} }
public void setAndroidId(String id) { public void setAndroidId(String id) {
androidId = id; mAndroidId = id;
setThumbnailUri(getContactThumbnailPictureUri()); setThumbnailUri(getContactThumbnailPictureUri());
setPhotoUri(getContactPictureUri()); setPhotoUri(getContactPictureUri());
} }
public String getAndroidLookupKey() { public String getAndroidLookupKey() {
return androidLookupKey; return mAndroidLookupKey;
} }
public void setAndroidLookupKey(String lookupKey) { public void setAndroidLookupKey(String lookupKey) {
androidLookupKey = lookupKey; mAndroidLookupKey = lookupKey;
} }
public Friend getFriend() { public Friend getFriend() {
return friend; return mFriend;
} }
private void createOrUpdateFriend() { private void createOrUpdateFriend() {
@ -713,48 +713,48 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
if (lc == null) return; if (lc == null) return;
if (!isFriend()) { if (!isFriend()) {
friend = lc.createFriend(); mFriend = lc.createFriend();
friend.enableSubscribes(false); mFriend.enableSubscribes(false);
friend.setIncSubscribePolicy(SubscribePolicy.SPDeny); mFriend.setIncSubscribePolicy(SubscribePolicy.SPDeny);
if (isAndroidContact()) { if (isAndroidContact()) {
friend.setRefKey(getAndroidId()); mFriend.setRefKey(getAndroidId());
} }
friend.setUserData(this); mFriend.setUserData(this);
created = true; created = true;
} }
if (isFriend()) { if (isFriend()) {
friend.edit(); mFriend.edit();
friend.setName(fullName); mFriend.setName(mFullName);
if (friend.getVcard() != null) { if (mFriend.getVcard() != null) {
friend.getVcard().setFamilyName(lastName); mFriend.getVcard().setFamilyName(mLastName);
friend.getVcard().setGivenName(firstName); mFriend.getVcard().setGivenName(mFirstName);
} }
if (organization != null) { if (mOrganization != null) {
friend.getVcard().setOrganization(organization); mFriend.getVcard().setOrganization(mOrganization);
} }
if (!created) { if (!created) {
for (Address address : friend.getAddresses()) { for (Address address : mFriend.getAddresses()) {
friend.removeAddress(address); mFriend.removeAddress(address);
} }
for (String phone : friend.getPhoneNumbers()) { for (String phone : mFriend.getPhoneNumbers()) {
friend.removePhoneNumber(phone); mFriend.removePhoneNumber(phone);
} }
} }
for (LinphoneNumberOrAddress noa : addresses) { for (LinphoneNumberOrAddress noa : mAddresses) {
if (noa.isSIPAddress()) { if (noa.isSIPAddress()) {
Address addr = lc.interpretUrl(noa.getValue()); Address addr = lc.interpretUrl(noa.getValue());
if (addr != null) { if (addr != null) {
friend.addAddress(addr); mFriend.addAddress(addr);
} }
} else { } else {
friend.addPhoneNumber(noa.getValue()); mFriend.addPhoneNumber(noa.getValue());
} }
} }
friend.done(); mFriend.done();
} }
if (created) { if (created) {
lc.addFriend(friend); lc.addFriend(mFriend);
} }
if (!ContactsManager.getInstance().hasContactsAccess()) { if (!ContactsManager.getInstance().hasContactsAccess()) {
@ -769,17 +769,17 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
public void save() { public void save() {
if (isAndroidContact() if (isAndroidContact()
&& ContactsManager.getInstance().hasContactsAccess() && ContactsManager.getInstance().hasContactsAccess()
&& changesToCommit.size() > 0) { && mChangesToCommit.size() > 0) {
try { try {
LinphoneService.instance() LinphoneService.instance()
.getContentResolver() .getContentResolver()
.applyBatch(ContactsContract.AUTHORITY, changesToCommit); .applyBatch(ContactsContract.AUTHORITY, mChangesToCommit);
createLinphoneTagIfNeeded(); createLinphoneTagIfNeeded();
} catch (Exception e) { } catch (Exception e) {
Log.e(e); Log.e(e);
} finally { } finally {
changesToCommit = new ArrayList<>(); mChangesToCommit = new ArrayList<>();
changesToCommit2 = new ArrayList<>(); mChangesToCommit2 = new ArrayList<>();
} }
} }
@ -797,51 +797,51 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
public void deleteFriend() { public void deleteFriend() {
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (friend != null && lc != null) { if (mFriend != null && lc != null) {
for (FriendList list : lc.getFriendsLists()) { for (FriendList list : lc.getFriendsLists()) {
list.removeFriend(friend); list.removeFriend(mFriend);
} }
} }
} }
public void clearAddresses() { public void clearAddresses() {
addresses.clear(); mAddresses.clear();
} }
public void refresh() { public void refresh() {
addresses = new ArrayList<>(); mAddresses = new ArrayList<>();
if (isAndroidContact()) { if (isAndroidContact()) {
getContactNames(); getContactNames();
getNativeContactOrganization(); getNativeContactOrganization();
getAndroidIds(); getAndroidIds();
hasSipAddress = false; mHasSipAddress = false;
for (LinphoneNumberOrAddress noa : getAddressesAndNumbersForAndroidContact()) { for (LinphoneNumberOrAddress noa : getAddressesAndNumbersForAndroidContact()) {
addNumberOrAddress(noa); addNumberOrAddress(noa);
} }
} else if (isFriend()) { } else if (isFriend()) {
fullName = friend.getName(); mFullName = mFriend.getName();
lastName = friend.getVcard().getFamilyName(); mLastName = mFriend.getVcard().getFamilyName();
firstName = friend.getVcard().getGivenName(); mFirstName = mFriend.getVcard().getGivenName();
thumbnailUri = null; mThumbnailUri = null;
photoUri = null; mPhotoUri = null;
hasSipAddress = friend.getAddress() != null; mHasSipAddress = mFriend.getAddress() != null;
organization = friend.getVcard().getOrganization(); mOrganization = mFriend.getVcard().getOrganization();
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null && lc.vcardSupported()) { if (lc != null && lc.vcardSupported()) {
for (Address addr : friend.getAddresses()) { for (Address addr : mFriend.getAddresses()) {
if (addr != null) { if (addr != null) {
addNumberOrAddress( addNumberOrAddress(
new LinphoneNumberOrAddress(addr.asStringUriOnly(), true)); new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
} }
} }
for (String tel : friend.getPhoneNumbers()) { for (String tel : mFriend.getPhoneNumbers()) {
if (tel != null) { if (tel != null) {
addNumberOrAddress(new LinphoneNumberOrAddress(tel, false)); addNumberOrAddress(new LinphoneNumberOrAddress(tel, false));
} }
} }
} else { } else {
Address addr = friend.getAddress(); Address addr = mFriend.getAddress();
addNumberOrAddress(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true)); addNumberOrAddress(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
} }
} }
@ -854,22 +854,22 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
public boolean isAndroidContact() { public boolean isAndroidContact() {
return androidId != null; return mAndroidId != null;
} }
public boolean isFriend() { public boolean isFriend() {
return friend != null; return mFriend != null;
} }
public void setFriend(Friend f) { public void setFriend(Friend f) {
friend = f; mFriend = f;
friend.setUserData(this); mFriend.setUserData(this);
} }
public boolean isInFriendList() { public boolean isInFriendList() {
if (friend == null) return false; if (mFriend == null) return false;
for (LinphoneNumberOrAddress noa : addresses) { for (LinphoneNumberOrAddress noa : mAddresses) {
PresenceModel pm = friend.getPresenceModelForUriOrTel(noa.getValue()); PresenceModel pm = mFriend.getPresenceModelForUriOrTel(noa.getValue());
if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) { if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
return true; return true;
} }
@ -878,19 +878,19 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
} }
public String getPresenceModelForUriOrTel(String uri) { public String getPresenceModelForUriOrTel(String uri) {
if (friend != null && friend.getPresenceModelForUriOrTel(uri) != null) { if (mFriend != null && mFriend.getPresenceModelForUriOrTel(uri) != null) {
return friend.getPresenceModelForUriOrTel(uri).getContact(); return mFriend.getPresenceModelForUriOrTel(uri).getContact();
} }
return null; return null;
} }
public void getAndroidIds() { public void getAndroidIds() {
androidRawId = findRawContactID(); mAndroidRawId = findRawContactID();
if (LinphoneManager.getInstance() if (LinphoneManager.getInstance()
.getContext() .getContext()
.getResources() .getResources()
.getBoolean(R.bool.use_linphone_tag)) { .getBoolean(R.bool.use_linphone_tag)) {
androidTagId = findLinphoneRawContactId(); mAndroidTagId = findLinphoneRawContactId();
} }
} }
@ -928,12 +928,12 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
Cursor c = resolver.query(ContactsContract.Data.CONTENT_URI, proj, select, args, null); Cursor c = resolver.query(ContactsContract.Data.CONTENT_URI, proj, select, args, null);
if (c != null) { if (c != null) {
if (c.moveToFirst()) { if (c.moveToFirst()) {
firstName = mFirstName =
c.getString( c.getString(
c.getColumnIndex( c.getColumnIndex(
ContactsContract.CommonDataKinds.StructuredName ContactsContract.CommonDataKinds.StructuredName
.GIVEN_NAME)); .GIVEN_NAME));
lastName = mLastName =
c.getString( c.getString(
c.getColumnIndex( c.getColumnIndex(
ContactsContract.CommonDataKinds.StructuredName ContactsContract.CommonDataKinds.StructuredName
@ -958,7 +958,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
Cursor c = resolver.query(ContactsContract.Data.CONTENT_URI, proj, select, args, null); Cursor c = resolver.query(ContactsContract.Data.CONTENT_URI, proj, select, args, null);
if (c != null) { if (c != null) {
if (c.moveToFirst()) { if (c.moveToFirst()) {
organization = mOrganization =
c.getString( c.getString(
c.getColumnIndex( c.getColumnIndex(
ContactsContract.CommonDataKinds.Organization.COMPANY)); ContactsContract.CommonDataKinds.Organization.COMPANY));
@ -1077,7 +1077,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
.getContext() .getContext()
.getResources() .getResources()
.getBoolean(R.bool.use_linphone_tag)) { .getBoolean(R.bool.use_linphone_tag)) {
if (androidTagId == null && findLinphoneRawContactId() == null) { if (mAndroidTagId == null && findLinphoneRawContactId() == null) {
createLinphoneContactTag(); createLinphoneContactTag();
} }
} }
@ -1118,13 +1118,13 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
ContactsContract.AggregationExceptions.TYPE_KEEP_TOGETHER) ContactsContract.AggregationExceptions.TYPE_KEEP_TOGETHER)
.withValue( .withValue(
ContactsContract.AggregationExceptions.RAW_CONTACT_ID1, ContactsContract.AggregationExceptions.RAW_CONTACT_ID1,
androidRawId) mAndroidRawId)
.withValueBackReference( .withValueBackReference(
ContactsContract.AggregationExceptions.RAW_CONTACT_ID2, 0) ContactsContract.AggregationExceptions.RAW_CONTACT_ID2, 0)
.build()); .build());
if (changesToCommit2.size() > 0) { if (mChangesToCommit2.size() > 0) {
for (ContentProviderOperation cpo : changesToCommit2) { for (ContentProviderOperation cpo : mChangesToCommit2) {
batch.add(cpo); batch.add(cpo);
} }
} }
@ -1133,7 +1133,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
LinphoneService.instance() LinphoneService.instance()
.getContentResolver() .getContentResolver()
.applyBatch(ContactsContract.AUTHORITY, batch); .applyBatch(ContactsContract.AUTHORITY, batch);
androidTagId = findLinphoneRawContactId(); mAndroidTagId = findLinphoneRawContactId();
} catch (Exception e) { } catch (Exception e) {
Log.e(e); Log.e(e);
} }

View file

@ -24,34 +24,34 @@ import java.io.Serializable;
public class LinphoneNumberOrAddress implements Serializable, Comparable<LinphoneNumberOrAddress> { public class LinphoneNumberOrAddress implements Serializable, Comparable<LinphoneNumberOrAddress> {
private static final long serialVersionUID = -2301689469730072896L; private static final long serialVersionUID = -2301689469730072896L;
private boolean isSIPAddress; private boolean mIsSIPAddress;
private String value, oldValueForUpdatePurpose; private String mValue, mOldValueForUpdatePurpose;
private String normalizedPhone; private String mNormalizedPhone;
public LinphoneNumberOrAddress(String v, boolean isSIP) { public LinphoneNumberOrAddress(String v, boolean isSIP) {
value = v; mValue = v;
isSIPAddress = isSIP; mIsSIPAddress = isSIP;
oldValueForUpdatePurpose = null; mOldValueForUpdatePurpose = null;
normalizedPhone = null; mNormalizedPhone = null;
} }
public LinphoneNumberOrAddress(String v, String normalizedV) { public LinphoneNumberOrAddress(String v, String normalizedV) {
value = v; mValue = v;
normalizedPhone = normalizedV != null ? normalizedV : v; mNormalizedPhone = normalizedV != null ? normalizedV : v;
isSIPAddress = false; mIsSIPAddress = false;
oldValueForUpdatePurpose = null; mOldValueForUpdatePurpose = null;
} }
public LinphoneNumberOrAddress(String v, boolean isSip, String old) { public LinphoneNumberOrAddress(String v, boolean isSip, String old) {
this(v, isSip); this(v, isSip);
oldValueForUpdatePurpose = old; mOldValueForUpdatePurpose = old;
} }
@Override @Override
public int compareTo(LinphoneNumberOrAddress noa) { public int compareTo(LinphoneNumberOrAddress noa) {
if (value != null) { if (mValue != null) {
if (noa.isSIPAddress() && isSIPAddress()) { if (noa.isSIPAddress() && isSIPAddress()) {
return value.compareTo(noa.getValue()); return mValue.compareTo(noa.getValue());
} else if (!noa.isSIPAddress() && !isSIPAddress()) { } else if (!noa.isSIPAddress() && !isSIPAddress()) {
return getNormalizedPhone().compareTo(noa.getNormalizedPhone()); return getNormalizedPhone().compareTo(noa.getNormalizedPhone());
} }
@ -67,26 +67,26 @@ public class LinphoneNumberOrAddress implements Serializable, Comparable<Linphon
} }
public boolean isSIPAddress() { public boolean isSIPAddress() {
return isSIPAddress; return mIsSIPAddress;
} }
public String getOldValue() { public String getOldValue() {
return oldValueForUpdatePurpose; return mOldValueForUpdatePurpose;
} }
public void setOldValue(String v) { public void setOldValue(String v) {
oldValueForUpdatePurpose = v; mOldValueForUpdatePurpose = v;
} }
public String getValue() { public String getValue() {
return value; return mValue;
} }
public void setValue(String v) { public void setValue(String v) {
value = v; mValue = v;
} }
public String getNormalizedPhone() { public String getNormalizedPhone() {
return normalizedPhone != null ? normalizedPhone : value; return mNormalizedPhone != null ? mNormalizedPhone : mValue;
} }
} }

View file

@ -46,9 +46,9 @@ public class SearchContactsListAdapter
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String TAG = SearchContactsListAdapter.class.getSimpleName(); private static final String TAG = SearchContactsListAdapter.class.getSimpleName();
private List<ContactAddress> contacts; private List<ContactAddress> mContacts;
private List<ContactAddress> contactsSelected; private List<ContactAddress> mContactsSelected;
private ProgressBar progressBar; private ProgressBar mProgressBar;
private boolean mOnlySipContact = false; private boolean mOnlySipContact = false;
private ViewHolder.ClickListener mListener; private ViewHolder.ClickListener mListener;
private boolean mHideSelectionMark; private boolean mHideSelectionMark;
@ -61,14 +61,14 @@ public class SearchContactsListAdapter
boolean hideSelectionMark) { boolean hideSelectionMark) {
mHideSelectionMark = hideSelectionMark; mHideSelectionMark = hideSelectionMark;
mListener = clickListener; mListener = clickListener;
progressBar = pB; mProgressBar = pB;
setContactsSelectedList(null); setContactsSelectedList(null);
setContactsList(contactsList); setContactsList(contactsList);
mPreviousSearch = null; mPreviousSearch = null;
} }
public List<ContactAddress> getContacts() { public List<ContactAddress> getContacts() {
return contacts; return mContacts;
} }
public void setOnlySipContact(boolean enable) { public void setOnlySipContact(boolean enable) {
@ -156,7 +156,7 @@ public class SearchContactsListAdapter
} }
private boolean contactIsSelected(ContactAddress ca) { private boolean contactIsSelected(ContactAddress ca) {
for (ContactAddress c : contactsSelected) { for (ContactAddress c : mContactsSelected) {
Address addr = c.getAddress(); Address addr = c.getAddress();
if (addr.getUsername() != null && ca.getAddress() != null) { if (addr.getUsername() != null && ca.getAddress() != null) {
if (addr.asStringUriOnly().compareTo(ca.getAddress().asStringUriOnly()) == 0) if (addr.asStringUriOnly().compareTo(ca.getAddress().asStringUriOnly()) == 0)
@ -171,14 +171,14 @@ public class SearchContactsListAdapter
} }
public List<ContactAddress> getContactsSelectedList() { public List<ContactAddress> getContactsSelectedList() {
return contactsSelected; return mContactsSelected;
} }
public void setContactsSelectedList(List<ContactAddress> contactsList) { public void setContactsSelectedList(List<ContactAddress> contactsList) {
if (contactsList == null) { if (contactsList == null) {
contactsSelected = new ArrayList<>(); mContactsSelected = new ArrayList<>();
} else { } else {
contactsSelected = contactsList; mContactsSelected = contactsList;
} }
} }
@ -221,7 +221,7 @@ public class SearchContactsListAdapter
} }
} }
for (ContactAddress caS : contactsSelected) { for (ContactAddress caS : mContactsSelected) {
for (ContactAddress ca : list) { for (ContactAddress ca : list) {
if (ca.equals(caS)) ca.setSelect(true); if (ca.equals(caS)) ca.setSelect(true);
} }
@ -231,24 +231,24 @@ public class SearchContactsListAdapter
public void setContactsList(List<ContactAddress> contactsList) { public void setContactsList(List<ContactAddress> contactsList) {
if (contactsList == null) { if (contactsList == null) {
contacts = getContactsList(); mContacts = getContactsList();
if (progressBar != null) progressBar.setVisibility(View.GONE); if (mProgressBar != null) mProgressBar.setVisibility(View.GONE);
} else { } else {
contacts = contactsList; mContacts = contactsList;
} }
} }
public int getCount() { public int getCount() {
return contacts.size(); return mContacts.size();
} }
public ContactAddress getItem(int position) { public ContactAddress getItem(int position) {
return contacts.get(position); return mContacts.get(position);
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return contacts.size(); return mContacts.size();
} }
public void searchContacts(String search, RecyclerView resultContactsSearch) { public void searchContacts(String search, RecyclerView resultContactsSearch) {
@ -333,7 +333,7 @@ public class SearchContactsListAdapter
} }
} }
contacts = result; mContacts = result;
resultContactsSearch.setAdapter(this); resultContactsSearch.setAdapter(this);
notifyDataSetChanged(); notifyDataSetChanged();
} }

View file

@ -44,11 +44,11 @@ import org.linphone.mediastream.Log;
import org.linphone.settings.LinphonePreferences; import org.linphone.settings.LinphonePreferences;
public class AboutFragment extends Fragment implements OnClickListener { public class AboutFragment extends Fragment implements OnClickListener {
View sendLogButton = null; private View mSendLogButton = null;
View resetLogButton = null; private View mResetLogButton = null;
CoreListenerStub mListener; private CoreListenerStub mListener;
private ProgressDialog progress; private ProgressDialog mProgress;
private boolean uploadInProgress; private boolean mUploadInProgress;
@Override @Override
public View onCreateView( public View onCreateView(
@ -70,14 +70,14 @@ public class AboutFragment extends Fragment implements OnClickListener {
getString(R.string.about_version), getString(R.string.about_version),
BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")")); BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")"));
sendLogButton = view.findViewById(R.id.send_log); mSendLogButton = view.findViewById(R.id.send_log);
sendLogButton.setOnClickListener(this); mSendLogButton.setOnClickListener(this);
sendLogButton.setVisibility( mSendLogButton.setVisibility(
LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE); LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
resetLogButton = view.findViewById(R.id.reset_log); mResetLogButton = view.findViewById(R.id.reset_log);
resetLogButton.setOnClickListener(this); mResetLogButton.setOnClickListener(this);
resetLogButton.setVisibility( mResetLogButton.setVisibility(
LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE); LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
mListener = mListener =
@ -93,8 +93,8 @@ public class AboutFragment extends Fragment implements OnClickListener {
displayUploadLogsInProgress(); displayUploadLogsInProgress();
} else if (state == LogCollectionUploadState.Delivered } else if (state == LogCollectionUploadState.Delivered
|| state == LogCollectionUploadState.NotDelivered) { || state == LogCollectionUploadState.NotDelivered) {
uploadInProgress = false; mUploadInProgress = false;
if (progress != null) progress.dismiss(); if (mProgress != null) mProgress.dismiss();
if (state == LogCollectionUploadState.Delivered) { if (state == LogCollectionUploadState.Delivered) {
sendLogs(LinphoneService.instance().getApplicationContext(), info); sendLogs(LinphoneService.instance().getApplicationContext(), info);
} }
@ -106,21 +106,22 @@ public class AboutFragment extends Fragment implements OnClickListener {
} }
private void displayUploadLogsInProgress() { private void displayUploadLogsInProgress() {
if (uploadInProgress) { if (mUploadInProgress) {
return; return;
} }
uploadInProgress = true; mUploadInProgress = true;
progress = ProgressDialog.show(LinphoneActivity.instance(), null, null); mProgress = ProgressDialog.show(LinphoneActivity.instance(), null, null);
Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorE)); Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorE));
d.setAlpha(200); d.setAlpha(200);
progress.getWindow() mProgress
.getWindow()
.setLayout( .setLayout(
WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT); WindowManager.LayoutParams.MATCH_PARENT);
progress.getWindow().setBackgroundDrawable(d); mProgress.getWindow().setBackgroundDrawable(d);
progress.setContentView(R.layout.progress_dialog); mProgress.setContentView(R.layout.progress_dialog);
progress.show(); mProgress.show();
} }
private void sendLogs(Context context, String info) { private void sendLogs(Context context, String info) {
@ -169,11 +170,11 @@ public class AboutFragment extends Fragment implements OnClickListener {
public void onClick(View v) { public void onClick(View v) {
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (v == sendLogButton) { if (v == mSendLogButton) {
if (lc != null) { if (lc != null) {
lc.uploadLogCollection(); lc.uploadLogCollection();
} }
} else if (v == resetLogButton) { } else if (v == mResetLogButton) {
if (lc != null) { if (lc != null) {
lc.resetLogCollection(); lc.resetLogCollection();
} }

View file

@ -43,18 +43,18 @@ import org.linphone.views.CallButton;
import org.linphone.views.EraseButton; import org.linphone.views.EraseButton;
public class DialerFragment extends Fragment { public class DialerFragment extends Fragment {
private static DialerFragment instance; private static DialerFragment sInstance;
private static boolean isCallTransferOngoing = false; private static boolean sIsCallTransferOngoing = false;
private AddressAware numpad; private AddressAware mNumpad;
private AddressText mAddress; private AddressText mAddress;
private CallButton mCall; private CallButton mCall;
private ImageView mAddContact; private ImageView mAddContact;
private OnClickListener addContactListener, cancelListener, transferListener; private OnClickListener mAddContactListener, mCancelListener, mTransferListener;
/** @return null if not ready yet */ /** @return null if not ready yet */
public static DialerFragment instance() { public static DialerFragment instance() {
return instance; return sInstance;
} }
@Override @Override
@ -73,7 +73,7 @@ public class DialerFragment extends Fragment {
if (LinphoneActivity.isInstanciated() if (LinphoneActivity.isInstanciated()
&& LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null && LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null
&& LinphoneManager.getLcIfManagerNotDestroyedOrNull().getCallsNb() > 0) { && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getCallsNb() > 0) {
if (isCallTransferOngoing) { if (sIsCallTransferOngoing) {
mCall.setImageResource(R.drawable.call_transfer); mCall.setImageResource(R.drawable.call_transfer);
} else { } else {
mCall.setImageResource(R.drawable.call_add); mCall.setImageResource(R.drawable.call_add);
@ -89,9 +89,9 @@ public class DialerFragment extends Fragment {
} }
} }
numpad = view.findViewById(R.id.numpad); mNumpad = view.findViewById(R.id.numpad);
if (numpad != null) { if (mNumpad != null) {
numpad.setAddressWidget(mAddress); mNumpad.setAddressWidget(mAddress);
} }
mAddContact = view.findViewById(R.id.add_contact); mAddContact = view.findViewById(R.id.add_contact);
@ -100,7 +100,7 @@ public class DialerFragment extends Fragment {
&& LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null && LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null
&& LinphoneManager.getLc().getCallsNb() > 0)); && LinphoneManager.getLc().getCallsNb() > 0));
addContactListener = mAddContactListener =
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -108,7 +108,7 @@ public class DialerFragment extends Fragment {
.displayContactsForEdition(mAddress.getText().toString()); .displayContactsForEdition(mAddress.getText().toString());
} }
}; };
cancelListener = mCancelListener =
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -116,7 +116,7 @@ public class DialerFragment extends Fragment {
.resetClassicMenuLayoutAndGoBackToCallIfStillRunning(); .resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
} }
}; };
transferListener = mTransferListener =
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -125,7 +125,7 @@ public class DialerFragment extends Fragment {
return; return;
} }
lc.transferCall(lc.getCurrentCall(), mAddress.getText().toString()); lc.transferCall(lc.getCurrentCall(), mAddress.getText().toString());
isCallTransferOngoing = false; sIsCallTransferOngoing = false;
LinphoneActivity.instance() LinphoneActivity.instance()
.resetClassicMenuLayoutAndGoBackToCallIfStillRunning(); .resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
} }
@ -142,21 +142,21 @@ public class DialerFragment extends Fragment {
} }
} }
instance = this; sInstance = this;
return view; return view;
} }
@Override @Override
public void onPause() { public void onPause() {
instance = null; sInstance = null;
super.onPause(); super.onPause();
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
instance = this; sInstance = this;
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER); LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER);
@ -168,21 +168,21 @@ public class DialerFragment extends Fragment {
getResources().getConfiguration().orientation getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE; == Configuration.ORIENTATION_LANDSCAPE;
if (isOrientationLandscape && !getResources().getBoolean(R.bool.isTablet)) { if (isOrientationLandscape && !getResources().getBoolean(R.bool.isTablet)) {
((LinearLayout) numpad).setVisibility(View.GONE); ((LinearLayout) mNumpad).setVisibility(View.GONE);
} else { } else {
((LinearLayout) numpad).setVisibility(View.VISIBLE); ((LinearLayout) mNumpad).setVisibility(View.VISIBLE);
} }
resetLayout(); resetLayout();
String addressWaitingToBeCalled = LinphoneActivity.instance().mAddressWaitingToBeCalled; String addressWaitingToBeCalled = LinphoneActivity.instance().addressWaitingToBeCalled;
if (addressWaitingToBeCalled != null) { if (addressWaitingToBeCalled != null) {
mAddress.setText(addressWaitingToBeCalled); mAddress.setText(addressWaitingToBeCalled);
if (getResources() if (getResources()
.getBoolean(R.bool.automatically_start_intercepted_outgoing_gsm_call)) { .getBoolean(R.bool.automatically_start_intercepted_outgoing_gsm_call)) {
newOutgoingCall(addressWaitingToBeCalled); newOutgoingCall(addressWaitingToBeCalled);
} }
LinphoneActivity.instance().mAddressWaitingToBeCalled = null; LinphoneActivity.instance().addressWaitingToBeCalled = null;
} }
} }
@ -190,23 +190,23 @@ public class DialerFragment extends Fragment {
if (!LinphoneActivity.isInstanciated()) { if (!LinphoneActivity.isInstanciated()) {
return; return;
} }
isCallTransferOngoing = LinphoneActivity.instance().isCallTransfer(); sIsCallTransferOngoing = LinphoneActivity.instance().isCallTransfer();
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc == null) { if (lc == null) {
return; return;
} }
if (lc.getCallsNb() > 0) { if (lc.getCallsNb() > 0) {
if (isCallTransferOngoing) { if (sIsCallTransferOngoing) {
mCall.setImageResource(R.drawable.call_transfer); mCall.setImageResource(R.drawable.call_transfer);
mCall.setExternalClickListener(transferListener); mCall.setExternalClickListener(mTransferListener);
} else { } else {
mCall.setImageResource(R.drawable.call_add); mCall.setImageResource(R.drawable.call_add);
mCall.resetClickListener(); mCall.resetClickListener();
} }
mAddContact.setEnabled(true); mAddContact.setEnabled(true);
mAddContact.setImageResource(R.drawable.call_back); mAddContact.setImageResource(R.drawable.call_back);
mAddContact.setOnClickListener(cancelListener); mAddContact.setOnClickListener(mCancelListener);
} else { } else {
if (LinphoneManager.getLc().getVideoActivationPolicy().getAutomaticallyInitiate()) { if (LinphoneManager.getLc().getVideoActivationPolicy().getAutomaticallyInitiate()) {
mCall.setImageResource(R.drawable.call_video_start); mCall.setImageResource(R.drawable.call_video_start);
@ -215,7 +215,7 @@ public class DialerFragment extends Fragment {
} }
mAddContact.setEnabled(false); mAddContact.setEnabled(false);
mAddContact.setImageResource(R.drawable.contact_add); mAddContact.setImageResource(R.drawable.contact_add);
mAddContact.setOnClickListener(addContactListener); mAddContact.setOnClickListener(mAddContactListener);
enableDisableAddContact(); enableDisableAddContact();
} }
} }

View file

@ -54,13 +54,13 @@ import org.linphone.mediastream.Log;
import org.linphone.settings.LinphonePreferences; import org.linphone.settings.LinphonePreferences;
public class StatusFragment extends Fragment { public class StatusFragment extends Fragment {
private Handler refreshHandler = new Handler(); private Handler mRefreshHandler = new Handler();
private TextView statusText, voicemailCount; private TextView mStatusText, mVoicemailCount;
private ImageView statusLed, callQuality, encryption, menu, voicemail; private ImageView mStatusLed, mCallQuality, mEncryption, mMenu, mVoicemail;
private Runnable mCallQualityUpdater; private Runnable mCallQualityUpdater;
private boolean isInCall, isAttached = false; private boolean mIsInCall, mIsAttached = false;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private Dialog ZRTPdialog = null; private Dialog mZrtpDialog = null;
private int mDisplayedQuality = -1; private int mDisplayedQuality = -1;
@Override @Override
@ -68,13 +68,13 @@ public class StatusFragment extends Fragment {
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.status, container, false); View view = inflater.inflate(R.layout.status, container, false);
statusText = view.findViewById(R.id.status_text); mStatusText = view.findViewById(R.id.status_text);
statusLed = view.findViewById(R.id.status_led); mStatusLed = view.findViewById(R.id.status_led);
callQuality = view.findViewById(R.id.call_quality); mCallQuality = view.findViewById(R.id.call_quality);
encryption = view.findViewById(R.id.encryption); mEncryption = view.findViewById(R.id.encryption);
menu = view.findViewById(R.id.side_menu_button); mMenu = view.findViewById(R.id.side_menu_button);
voicemail = view.findViewById(R.id.voicemail); mVoicemail = view.findViewById(R.id.voicemail);
voicemailCount = view.findViewById(R.id.voicemail_count); mVoicemailCount = view.findViewById(R.id.voicemail_count);
// We create it once to not delay the first display // We create it once to not delay the first display
populateSliderContent(); populateSliderContent();
@ -87,28 +87,28 @@ public class StatusFragment extends Fragment {
final ProxyConfig proxy, final ProxyConfig proxy,
final RegistrationState state, final RegistrationState state,
String smessage) { String smessage) {
if (!isAttached || !LinphoneService.isReady()) { if (!mIsAttached || !LinphoneService.isReady()) {
return; return;
} }
if (lc.getProxyConfigList() == null) { if (lc.getProxyConfigList() == null) {
statusLed.setImageResource(R.drawable.led_disconnected); mStatusLed.setImageResource(R.drawable.led_disconnected);
statusText.setText(getString(R.string.no_account)); mStatusText.setText(getString(R.string.no_account));
} else { } else {
statusLed.setVisibility(View.VISIBLE); mStatusLed.setVisibility(View.VISIBLE);
} }
if (lc.getDefaultProxyConfig() != null if (lc.getDefaultProxyConfig() != null
&& lc.getDefaultProxyConfig().equals(proxy)) { && lc.getDefaultProxyConfig().equals(proxy)) {
statusLed.setImageResource(getStatusIconResource(state, true)); mStatusLed.setImageResource(getStatusIconResource(state, true));
statusText.setText(getStatusIconText(state)); mStatusText.setText(getStatusIconText(state));
} else if (lc.getDefaultProxyConfig() == null) { } else if (lc.getDefaultProxyConfig() == null) {
statusLed.setImageResource(getStatusIconResource(state, true)); mStatusLed.setImageResource(getStatusIconResource(state, true));
statusText.setText(getStatusIconText(state)); mStatusText.setText(getStatusIconText(state));
} }
try { try {
statusText.setOnClickListener( mStatusText.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -135,28 +135,28 @@ public class StatusFragment extends Fragment {
unreadCount = Integer.parseInt(intToParse[0]); unreadCount = Integer.parseInt(intToParse[0]);
if (unreadCount > 0) { if (unreadCount > 0) {
voicemailCount.setText(unreadCount); mVoicemailCount.setText(unreadCount);
voicemail.setVisibility(View.VISIBLE); mVoicemail.setVisibility(View.VISIBLE);
voicemailCount.setVisibility(View.VISIBLE); mVoicemailCount.setVisibility(View.VISIBLE);
} else { } else {
voicemail.setVisibility(View.GONE); mVoicemail.setVisibility(View.GONE);
voicemailCount.setVisibility(View.GONE); mVoicemailCount.setVisibility(View.GONE);
} }
} }
}; };
isAttached = true; mIsAttached = true;
Activity activity = getActivity(); Activity activity = getActivity();
if (activity instanceof LinphoneActivity) { if (activity instanceof LinphoneActivity) {
((LinphoneActivity) activity).updateStatusFragment(this); ((LinphoneActivity) activity).updateStatusFragment(this);
isInCall = false; mIsInCall = false;
} else if (activity instanceof CallActivity) { } else if (activity instanceof CallActivity) {
((CallActivity) activity).updateStatusFragment(this); ((CallActivity) activity).updateStatusFragment(this);
isInCall = true; mIsInCall = true;
} else if (activity instanceof AssistantActivity) { } else if (activity instanceof AssistantActivity) {
((AssistantActivity) activity).updateStatusFragment(this); ((AssistantActivity) activity).updateStatusFragment(this);
isInCall = false; mIsInCall = false;
} }
return view; return view;
@ -177,38 +177,38 @@ public class StatusFragment extends Fragment {
@Override @Override
public void onDetach() { public void onDetach() {
super.onDetach(); super.onDetach();
isAttached = false; mIsAttached = false;
} }
// NORMAL STATUS BAR // NORMAL STATUS BAR
private void populateSliderContent() { private void populateSliderContent() {
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) { if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) {
voicemailCount.setVisibility(View.GONE); mVoicemailCount.setVisibility(View.GONE);
if (isInCall && isAttached) { if (mIsInCall && mIsAttached) {
// Call call = LinphoneManager.getLc().getCurrentCall(); // Call call = LinphoneManager.getLc().getCurrentCall();
// initCallStatsRefresher(call, callStats); // initCallStatsRefresher(call, callStats);
} else if (!isInCall) { } else if (!mIsInCall) {
voicemailCount.setVisibility(View.VISIBLE); mVoicemailCount.setVisibility(View.VISIBLE);
} }
if (LinphoneManager.getLc().getProxyConfigList().length == 0) { if (LinphoneManager.getLc().getProxyConfigList().length == 0) {
statusLed.setImageResource(R.drawable.led_disconnected); mStatusLed.setImageResource(R.drawable.led_disconnected);
statusText.setText(getString(R.string.no_account)); mStatusText.setText(getString(R.string.no_account));
} }
} }
} }
public void resetAccountStatus() { public void resetAccountStatus() {
if (LinphoneManager.getLc().getProxyConfigList().length == 0) { if (LinphoneManager.getLc().getProxyConfigList().length == 0) {
statusLed.setImageResource(R.drawable.led_disconnected); mStatusLed.setImageResource(R.drawable.led_disconnected);
statusText.setText(getString(R.string.no_account)); mStatusText.setText(getString(R.string.no_account));
} }
} }
public void enableSideMenu(boolean enabled) { public void enableSideMenu(boolean enabled) {
menu.setEnabled(enabled); mMenu.setEnabled(enabled);
} }
private int getStatusIconResource(RegistrationState state, boolean isDefaultAccount) { private int getStatusIconResource(RegistrationState state, boolean isDefaultAccount) {
@ -239,8 +239,9 @@ public class StatusFragment extends Fragment {
private String getStatusIconText(RegistrationState state) { private String getStatusIconText(RegistrationState state) {
Context context = getActivity(); Context context = getActivity();
if (!isAttached && LinphoneActivity.isInstanciated()) context = LinphoneActivity.instance(); if (!mIsAttached && LinphoneActivity.isInstanciated())
else if (!isAttached && LinphoneService.isReady()) context = LinphoneService.instance(); context = LinphoneActivity.instance();
else if (!mIsAttached && LinphoneService.isReady()) context = LinphoneService.instance();
try { try {
if (state == RegistrationState.Ok if (state == RegistrationState.Ok
@ -265,8 +266,8 @@ public class StatusFragment extends Fragment {
// INCALL STATUS BAR // INCALL STATUS BAR
private void startCallQuality() { private void startCallQuality() {
callQuality.setVisibility(View.VISIBLE); mCallQuality.setVisibility(View.VISIBLE);
refreshHandler.postDelayed( mRefreshHandler.postDelayed(
mCallQualityUpdater = mCallQualityUpdater =
new Runnable() { new Runnable() {
Call mCurrentCall = LinphoneManager.getLc().getCurrentCall(); Call mCurrentCall = LinphoneManager.getLc().getCurrentCall();
@ -279,8 +280,8 @@ public class StatusFragment extends Fragment {
float newQuality = mCurrentCall.getCurrentQuality(); float newQuality = mCurrentCall.getCurrentQuality();
updateQualityOfSignalIcon(newQuality); updateQualityOfSignalIcon(newQuality);
if (isInCall) { if (mIsInCall) {
refreshHandler.postDelayed(this, 1000); mRefreshHandler.postDelayed(this, 1000);
} else mCallQualityUpdater = null; } else mCallQualityUpdater = null;
} }
}, },
@ -293,19 +294,19 @@ public class StatusFragment extends Fragment {
if (iQuality == mDisplayedQuality) return; if (iQuality == mDisplayedQuality) return;
if (quality >= 4) // Good Quality if (quality >= 4) // Good Quality
{ {
callQuality.setImageResource(R.drawable.call_quality_indicator_4); mCallQuality.setImageResource(R.drawable.call_quality_indicator_4);
} else if (quality >= 3) // Average quality } else if (quality >= 3) // Average quality
{ {
callQuality.setImageResource(R.drawable.call_quality_indicator_3); mCallQuality.setImageResource(R.drawable.call_quality_indicator_3);
} else if (quality >= 2) // Low quality } else if (quality >= 2) // Low quality
{ {
callQuality.setImageResource(R.drawable.call_quality_indicator_2); mCallQuality.setImageResource(R.drawable.call_quality_indicator_2);
} else if (quality >= 1) // Very low quality } else if (quality >= 1) // Very low quality
{ {
callQuality.setImageResource(R.drawable.call_quality_indicator_1); mCallQuality.setImageResource(R.drawable.call_quality_indicator_1);
} else // Worst quality } else // Worst quality
{ {
callQuality.setImageResource(R.drawable.call_quality_indicator_0); mCallQuality.setImageResource(R.drawable.call_quality_indicator_0);
} }
mDisplayedQuality = iQuality; mDisplayedQuality = iQuality;
} }
@ -323,27 +324,27 @@ public class StatusFragment extends Fragment {
} }
Call call = lc.getCurrentCall(); Call call = lc.getCurrentCall();
if (isInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) { if (mIsInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) {
if (call != null) { if (call != null) {
startCallQuality(); startCallQuality();
refreshStatusItems(call, call.getCurrentParams().videoEnabled()); refreshStatusItems(call, call.getCurrentParams().videoEnabled());
} }
menu.setVisibility(View.INVISIBLE); mMenu.setVisibility(View.INVISIBLE);
callQuality.setVisibility(View.VISIBLE); mCallQuality.setVisibility(View.VISIBLE);
// We are obviously connected // We are obviously connected
if (lc.getDefaultProxyConfig() == null) { if (lc.getDefaultProxyConfig() == null) {
statusLed.setImageResource(R.drawable.led_disconnected); mStatusLed.setImageResource(R.drawable.led_disconnected);
statusText.setText(getString(R.string.no_account)); mStatusText.setText(getString(R.string.no_account));
} else { } else {
statusLed.setImageResource( mStatusLed.setImageResource(
getStatusIconResource(lc.getDefaultProxyConfig().getState(), true)); getStatusIconResource(lc.getDefaultProxyConfig().getState(), true));
statusText.setText(getStatusIconText(lc.getDefaultProxyConfig().getState())); mStatusText.setText(getStatusIconText(lc.getDefaultProxyConfig().getState()));
} }
} }
} else { } else {
statusText.setVisibility(View.VISIBLE); mStatusText.setVisibility(View.VISIBLE);
encryption.setVisibility(View.GONE); mEncryption.setVisibility(View.GONE);
} }
} }
@ -357,14 +358,14 @@ public class StatusFragment extends Fragment {
} }
if (mCallQualityUpdater != null) { if (mCallQualityUpdater != null) {
refreshHandler.removeCallbacks(mCallQualityUpdater); mRefreshHandler.removeCallbacks(mCallQualityUpdater);
mCallQualityUpdater = null; mCallQualityUpdater = null;
} }
} }
public void refreshStatusItems(final Call call, boolean isVideoEnabled) { public void refreshStatusItems(final Call call, boolean isVideoEnabled) {
if (call != null) { if (call != null) {
voicemailCount.setVisibility(View.GONE); mVoicemailCount.setVisibility(View.GONE);
MediaEncryption mediaEncryption = call.getCurrentParams().getMediaEncryption(); MediaEncryption mediaEncryption = call.getCurrentParams().getMediaEncryption();
if (isVideoEnabled) { if (isVideoEnabled) {
@ -373,25 +374,25 @@ public class StatusFragment extends Fragment {
// background.setVisibility(View.VISIBLE); // background.setVisibility(View.VISIBLE);
} }
encryption.setVisibility(View.VISIBLE); mEncryption.setVisibility(View.VISIBLE);
if (mediaEncryption == MediaEncryption.SRTP if (mediaEncryption == MediaEncryption.SRTP
|| (mediaEncryption == MediaEncryption.ZRTP || (mediaEncryption == MediaEncryption.ZRTP
&& call.getAuthenticationTokenVerified()) && call.getAuthenticationTokenVerified())
|| mediaEncryption == MediaEncryption.DTLS) { || mediaEncryption == MediaEncryption.DTLS) {
encryption.setImageResource(R.drawable.security_ok); mEncryption.setImageResource(R.drawable.security_ok);
} else if (mediaEncryption == MediaEncryption.ZRTP } else if (mediaEncryption == MediaEncryption.ZRTP
&& !call.getAuthenticationTokenVerified()) { && !call.getAuthenticationTokenVerified()) {
encryption.setImageResource(R.drawable.security_pending); mEncryption.setImageResource(R.drawable.security_pending);
} else { } else {
encryption.setImageResource(R.drawable.security_ko); mEncryption.setImageResource(R.drawable.security_ko);
// Do not show the unsecure icon if user doesn't want to do call encryption // Do not show the unsecure icon if user doesn't want to do call mEncryption
if (LinphonePreferences.instance().getMediaEncryption() == MediaEncryption.None) { if (LinphonePreferences.instance().getMediaEncryption() == MediaEncryption.None) {
encryption.setVisibility(View.GONE); mEncryption.setVisibility(View.GONE);
} }
} }
if (mediaEncryption == MediaEncryption.ZRTP) { if (mediaEncryption == MediaEncryption.ZRTP) {
encryption.setOnClickListener( mEncryption.setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -399,7 +400,7 @@ public class StatusFragment extends Fragment {
} }
}); });
} else { } else {
encryption.setOnClickListener(null); mEncryption.setOnClickListener(null);
} }
} }
} }
@ -410,7 +411,7 @@ public class StatusFragment extends Fragment {
return; return;
} }
if (ZRTPdialog == null || !ZRTPdialog.isShowing()) { if (mZrtpDialog == null || !mZrtpDialog.isShowing()) {
String token = call.getAuthenticationToken(); String token = call.getAuthenticationToken();
if (token == null) { if (token == null) {
@ -422,19 +423,20 @@ public class StatusFragment extends Fragment {
return; return;
} }
ZRTPdialog = new Dialog(getActivity()); mZrtpDialog = new Dialog(getActivity());
ZRTPdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); mZrtpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
ZRTPdialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); mZrtpDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
ZRTPdialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); mZrtpDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
ZRTPdialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mZrtpDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorC)); Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorC));
d.setAlpha(200); d.setAlpha(200);
ZRTPdialog.setContentView(R.layout.dialog); mZrtpDialog.setContentView(R.layout.dialog);
ZRTPdialog.getWindow() mZrtpDialog
.getWindow()
.setLayout( .setLayout(
WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT); WindowManager.LayoutParams.MATCH_PARENT);
ZRTPdialog.getWindow().setBackgroundDrawable(d); mZrtpDialog.getWindow().setBackgroundDrawable(d);
String zrtpToRead, zrtpToListen; String zrtpToRead, zrtpToListen;
if (call.getDir().equals(Call.Dir.Incoming)) { if (call.getDir().equals(Call.Dir.Incoming)) {
@ -445,27 +447,27 @@ public class StatusFragment extends Fragment {
zrtpToRead = token.substring(2); zrtpToRead = token.substring(2);
} }
TextView localSas = ZRTPdialog.findViewById(R.id.zrtp_sas_local); TextView localSas = mZrtpDialog.findViewById(R.id.zrtp_sas_local);
localSas.setText(zrtpToRead.toUpperCase()); localSas.setText(zrtpToRead.toUpperCase());
TextView remoteSas = ZRTPdialog.findViewById(R.id.zrtp_sas_remote); TextView remoteSas = mZrtpDialog.findViewById(R.id.zrtp_sas_remote);
remoteSas.setText(zrtpToListen.toUpperCase()); remoteSas.setText(zrtpToListen.toUpperCase());
TextView message = ZRTPdialog.findViewById(R.id.dialog_message); TextView message = mZrtpDialog.findViewById(R.id.dialog_message);
message.setVisibility(View.GONE); message.setVisibility(View.GONE);
ZRTPdialog.findViewById(R.id.dialog_zrtp_layout).setVisibility(View.VISIBLE); mZrtpDialog.findViewById(R.id.dialog_zrtp_layout).setVisibility(View.VISIBLE);
TextView title = ZRTPdialog.findViewById(R.id.dialog_title); TextView title = mZrtpDialog.findViewById(R.id.dialog_title);
title.setText(getString(R.string.zrtp_dialog_title)); title.setText(getString(R.string.zrtp_dialog_title));
title.setVisibility(View.VISIBLE); title.setVisibility(View.VISIBLE);
Button delete = ZRTPdialog.findViewById(R.id.dialog_delete_button); Button delete = mZrtpDialog.findViewById(R.id.dialog_delete_button);
delete.setText(R.string.deny); delete.setText(R.string.deny);
Button cancel = ZRTPdialog.findViewById(R.id.dialog_cancel_button); Button cancel = mZrtpDialog.findViewById(R.id.dialog_cancel_button);
cancel.setVisibility(View.GONE); cancel.setVisibility(View.GONE);
Button accept = ZRTPdialog.findViewById(R.id.dialog_ok_button); Button accept = mZrtpDialog.findViewById(R.id.dialog_ok_button);
accept.setVisibility(View.VISIBLE); accept.setVisibility(View.VISIBLE);
accept.setText(R.string.accept); accept.setText(R.string.accept);
ImageView icon = ZRTPdialog.findViewById(R.id.dialog_icon); ImageView icon = mZrtpDialog.findViewById(R.id.dialog_icon);
icon.setVisibility(View.VISIBLE); icon.setVisibility(View.VISIBLE);
icon.setImageResource(R.drawable.security_2_indicator); icon.setImageResource(R.drawable.security_2_indicator);
@ -475,11 +477,11 @@ public class StatusFragment extends Fragment {
public void onClick(View view) { public void onClick(View view) {
if (call != null) { if (call != null) {
call.setAuthenticationTokenVerified(false); call.setAuthenticationTokenVerified(false);
if (encryption != null) { if (mEncryption != null) {
encryption.setImageResource(R.drawable.security_ko); mEncryption.setImageResource(R.drawable.security_ko);
} }
} }
ZRTPdialog.dismiss(); mZrtpDialog.dismiss();
} }
}); });
@ -488,13 +490,13 @@ public class StatusFragment extends Fragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
call.setAuthenticationTokenVerified(true); call.setAuthenticationTokenVerified(true);
if (encryption != null) { if (mEncryption != null) {
encryption.setImageResource(R.drawable.security_ok); mEncryption.setImageResource(R.drawable.security_ok);
} }
ZRTPdialog.dismiss(); mZrtpDialog.dismiss();
} }
}); });
ZRTPdialog.show(); mZrtpDialog.show();
} }
} }
} }

View file

@ -43,7 +43,7 @@ import org.linphone.views.ContactAvatar;
public class HistoryAdapter extends SelectableAdapter<HistoryViewHolder> { public class HistoryAdapter extends SelectableAdapter<HistoryViewHolder> {
private List<CallLog> mLogs; private List<CallLog> mLogs;
private Context mContext; private Context mContext;
private HistoryViewHolder.ClickListener clickListener; private HistoryViewHolder.ClickListener mClickListener;
public HistoryAdapter( public HistoryAdapter(
Context aContext, Context aContext,
@ -51,9 +51,9 @@ public class HistoryAdapter extends SelectableAdapter<HistoryViewHolder> {
HistoryViewHolder.ClickListener listener, HistoryViewHolder.ClickListener listener,
SelectableHelper helper) { SelectableHelper helper) {
super(helper); super(helper);
this.mLogs = logs; mLogs = logs;
this.mContext = aContext; mContext = aContext;
this.clickListener = listener; mClickListener = listener;
} }
public int getCount() { public int getCount() {
@ -70,7 +70,7 @@ public class HistoryAdapter extends SelectableAdapter<HistoryViewHolder> {
View v = View v =
LayoutInflater.from(parent.getContext()) LayoutInflater.from(parent.getContext())
.inflate(R.layout.history_cell, parent, false); .inflate(R.layout.history_cell, parent, false);
return new HistoryViewHolder(v, clickListener); return new HistoryViewHolder(v, mClickListener);
} }
@Override @Override

View file

@ -47,61 +47,61 @@ import org.linphone.utils.ImageUtils;
import org.linphone.utils.LinphoneUtils; import org.linphone.utils.LinphoneUtils;
public class HistoryDetailFragment extends Fragment implements OnClickListener { public class HistoryDetailFragment extends Fragment implements OnClickListener {
private ImageView dialBack, chat, addToContacts, goToContact, back; private ImageView mDialBack, mChat, mAddToContacts, mGoToContact, mBack;
private View view; private View mView;
private ImageView contactPicture, callDirection; private ImageView mContactPicture, mCallDirection;
private TextView contactName, contactAddress, time, date; private TextView mContactName, mContactAddress, mTime, mDate;
private String sipUri, displayName, pictureUri; private String mSipUri, mDisplayName, mPictureUri;
private RelativeLayout mWaitLayout; private RelativeLayout mWaitLayout;
private LinphoneContact contact; private LinphoneContact mContact;
private ChatRoom mChatRoom; private ChatRoom mChatRoom;
private ChatRoomListenerStub mChatRoomCreationListener; private ChatRoomListenerStub mChatRoomCreationListener;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
sipUri = getArguments().getString("SipUri"); mSipUri = getArguments().getString("SipUri");
displayName = getArguments().getString("DisplayName"); mDisplayName = getArguments().getString("DisplayName");
pictureUri = getArguments().getString("PictureUri"); mPictureUri = getArguments().getString("PictureUri");
String status = getArguments().getString("Call.Status"); String status = getArguments().getString("Call.Status");
String callTime = getArguments().getString("CallTime"); String callTime = getArguments().getString("CallTime");
String callDate = getArguments().getString("CallDate"); String callDate = getArguments().getString("CallDate");
view = inflater.inflate(R.layout.history_detail, container, false); mView = inflater.inflate(R.layout.history_detail, container, false);
mWaitLayout = view.findViewById(R.id.waitScreen); mWaitLayout = mView.findViewById(R.id.waitScreen);
mWaitLayout.setVisibility(View.GONE); mWaitLayout.setVisibility(View.GONE);
dialBack = view.findViewById(R.id.call); mDialBack = mView.findViewById(R.id.call);
dialBack.setOnClickListener(this); mDialBack.setOnClickListener(this);
back = view.findViewById(R.id.back); mBack = mView.findViewById(R.id.back);
if (getResources().getBoolean(R.bool.isTablet)) { if (getResources().getBoolean(R.bool.isTablet)) {
back.setVisibility(View.INVISIBLE); mBack.setVisibility(View.INVISIBLE);
} else { } else {
back.setOnClickListener(this); mBack.setOnClickListener(this);
} }
chat = view.findViewById(R.id.chat); mChat = mView.findViewById(R.id.chat);
chat.setOnClickListener(this); mChat.setOnClickListener(this);
if (getResources().getBoolean(R.bool.disable_chat)) if (getResources().getBoolean(R.bool.disable_chat))
view.findViewById(R.id.chat).setVisibility(View.GONE); mView.findViewById(R.id.chat).setVisibility(View.GONE);
addToContacts = view.findViewById(R.id.add_contact); mAddToContacts = mView.findViewById(R.id.add_contact);
addToContacts.setOnClickListener(this); mAddToContacts.setOnClickListener(this);
goToContact = view.findViewById(R.id.goto_contact); mGoToContact = mView.findViewById(R.id.goto_contact);
goToContact.setOnClickListener(this); mGoToContact.setOnClickListener(this);
contactPicture = view.findViewById(R.id.contact_picture); mContactPicture = mView.findViewById(R.id.contact_picture);
contactName = view.findViewById(R.id.contact_name); mContactName = mView.findViewById(R.id.contact_name);
contactAddress = view.findViewById(R.id.contact_address); mContactAddress = mView.findViewById(R.id.contact_address);
callDirection = view.findViewById(R.id.direction); mCallDirection = mView.findViewById(R.id.direction);
time = view.findViewById(R.id.time); mTime = mView.findViewById(R.id.time);
date = view.findViewById(R.id.date); mDate = mView.findViewById(R.id.date);
displayHistory(status, callTime, callDate); displayHistory(status, callTime, callDate);
@ -117,14 +117,14 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
mWaitLayout.setVisibility(View.GONE); mWaitLayout.setVisibility(View.GONE);
LinphoneActivity.instance().displayChatRoomError(); LinphoneActivity.instance().displayChatRoomError();
Log.e( Log.e(
"Group chat room for address " "Group mChat room for address "
+ cr.getPeerAddress() + cr.getPeerAddress()
+ " has failed !"); + " has failed !");
} }
} }
}; };
return view; return mView;
} }
@Override @Override
@ -137,49 +137,49 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
private void displayHistory(String status, String callTime, String callDate) { private void displayHistory(String status, String callTime, String callDate) {
if (status.equals(getResources().getString(R.string.missed))) { if (status.equals(getResources().getString(R.string.missed))) {
callDirection.setImageResource(R.drawable.call_missed); mCallDirection.setImageResource(R.drawable.call_missed);
} else if (status.equals(getResources().getString(R.string.incoming))) { } else if (status.equals(getResources().getString(R.string.incoming))) {
callDirection.setImageResource(R.drawable.call_incoming); mCallDirection.setImageResource(R.drawable.call_incoming);
} else if (status.equals(getResources().getString(R.string.outgoing))) { } else if (status.equals(getResources().getString(R.string.outgoing))) {
callDirection.setImageResource(R.drawable.call_outgoing); mCallDirection.setImageResource(R.drawable.call_outgoing);
} }
time.setText(callTime == null ? "" : callTime); mTime.setText(callTime == null ? "" : callTime);
Long longDate = Long.parseLong(callDate); Long longDate = Long.parseLong(callDate);
date.setText( mDate.setText(
LinphoneUtils.timestampToHumanDate( LinphoneUtils.timestampToHumanDate(
getActivity(), longDate, getString(R.string.history_detail_date_format))); getActivity(), longDate, getString(R.string.history_detail_date_format)));
Address lAddress = Factory.instance().createAddress(sipUri); Address lAddress = Factory.instance().createAddress(mSipUri);
if (lAddress != null) { if (lAddress != null) {
contactAddress.setText(lAddress.asStringUriOnly()); mContactAddress.setText(lAddress.asStringUriOnly());
contact = ContactsManager.getInstance().findContactFromAddress(lAddress); mContact = ContactsManager.getInstance().findContactFromAddress(lAddress);
if (contact != null) { if (mContact != null) {
contactName.setText(contact.getFullName()); mContactName.setText(mContact.getFullName());
ImageUtils.setImagePictureFromUri( ImageUtils.setImagePictureFromUri(
view.getContext(), mView.getContext(),
contactPicture, mContactPicture,
contact.getPhotoUri(), mContact.getPhotoUri(),
contact.getThumbnailUri()); mContact.getThumbnailUri());
addToContacts.setVisibility(View.GONE); mAddToContacts.setVisibility(View.GONE);
goToContact.setVisibility(View.VISIBLE); mGoToContact.setVisibility(View.VISIBLE);
} else { } else {
contactName.setText( mContactName.setText(
displayName == null mDisplayName == null
? LinphoneUtils.getAddressDisplayName(sipUri) ? LinphoneUtils.getAddressDisplayName(mSipUri)
: displayName); : mDisplayName);
contactPicture.setImageBitmap( mContactPicture.setImageBitmap(
ContactsManager.getInstance().getDefaultAvatarBitmap()); ContactsManager.getInstance().getDefaultAvatarBitmap());
addToContacts.setVisibility(View.VISIBLE); mAddToContacts.setVisibility(View.VISIBLE);
goToContact.setVisibility(View.GONE); mGoToContact.setVisibility(View.GONE);
} }
} else { } else {
contactAddress.setText(sipUri); mContactAddress.setText(mSipUri);
contactName.setText( mContactName.setText(
displayName == null mDisplayName == null
? LinphoneUtils.getAddressDisplayName(sipUri) ? LinphoneUtils.getAddressDisplayName(mSipUri)
: displayName); : mDisplayName);
} }
} }
@ -194,9 +194,9 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
displayName = LinphoneUtils.getUsernameFromAddress(sipUri); displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
} }
this.sipUri = sipUri; this.mSipUri = sipUri;
this.displayName = displayName; this.mDisplayName = displayName;
this.pictureUri = pictureUri; this.mPictureUri = pictureUri;
displayHistory(status, callTime, callDate); displayHistory(status, callTime, callDate);
} }
@ -219,10 +219,12 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
if (id == R.id.call) { if (id == R.id.call) {
LinphoneActivity.instance() LinphoneActivity.instance()
.setAddresGoToDialerAndCall( .setAddresGoToDialerAndCall(
sipUri, displayName, pictureUri == null ? null : Uri.parse(pictureUri)); mSipUri,
mDisplayName,
mPictureUri == null ? null : Uri.parse(mPictureUri));
} else if (id == R.id.chat) { } else if (id == R.id.chat) {
Core lc = LinphoneManager.getLc(); Core lc = LinphoneManager.getLc();
Address participant = Factory.instance().createAddress(sipUri); Address participant = Factory.instance().createAddress(mSipUri);
ChatRoom room = ChatRoom room =
lc.findOneToOneChatRoom( lc.findOneToOneChatRoom(
lc.getDefaultProxyConfig().getContact(), participant, false); lc.getDefaultProxyConfig().getContact(), participant, false);
@ -246,7 +248,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
} }
} }
} else if (id == R.id.add_contact) { } else if (id == R.id.add_contact) {
Address addr = Factory.instance().createAddress(sipUri); Address addr = Factory.instance().createAddress(mSipUri);
if (addr != null) { if (addr != null) {
String address = String address =
"sip:" + addr.getUsername() + "@" + addr.getDomain(); // Clean gruu param "sip:" + addr.getUsername() + "@" + addr.getDomain(); // Clean gruu param
@ -258,7 +260,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
} }
} }
} else if (id == R.id.goto_contact) { } else if (id == R.id.goto_contact) {
LinphoneActivity.instance().displayContact(contact, false); LinphoneActivity.instance().displayContact(mContact, false);
} }
} }
} }

View file

@ -1,7 +1,7 @@
package org.linphone.history; package org.linphone.history;
/* /*
HistoryListFragment.java HistoryFragment.java
Copyright (C) 2017 Belledonne Communications, Grenoble, France Copyright (C) 2017 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -47,16 +47,16 @@ import org.linphone.core.CallLog;
import org.linphone.fragments.FragmentsAvailable; import org.linphone.fragments.FragmentsAvailable;
import org.linphone.utils.SelectableHelper; import org.linphone.utils.SelectableHelper;
public class HistoryListFragment extends Fragment public class HistoryFragment extends Fragment
implements OnClickListener, implements OnClickListener,
OnItemClickListener, OnItemClickListener,
HistoryViewHolder.ClickListener, HistoryViewHolder.ClickListener,
ContactsUpdatedListener, ContactsUpdatedListener,
SelectableHelper.DeleteListener { SelectableHelper.DeleteListener {
private RecyclerView historyList; private RecyclerView mHistoryList;
private TextView noCallHistory, noMissedCallHistory; private TextView mNoCallHistory, mNoMissedCallHistory;
private ImageView missedCalls, allCalls; private ImageView mMissedCalls, mAllCalls;
private View allCallsSelected, missedCallsSelected; private View mAllCallsSelected, mMissedCallsSelected;
private boolean mOnlyDisplayMissedCalls; private boolean mOnlyDisplayMissedCalls;
private List<CallLog> mLogs; private List<CallLog> mLogs;
private HistoryAdapter mHistoryAdapter; private HistoryAdapter mHistoryAdapter;
@ -71,31 +71,31 @@ public class HistoryListFragment extends Fragment
mContext = getActivity().getApplicationContext(); mContext = getActivity().getApplicationContext();
mSelectionHelper = new SelectableHelper(view, this); mSelectionHelper = new SelectableHelper(view, this);
noCallHistory = view.findViewById(R.id.no_call_history); mNoCallHistory = view.findViewById(R.id.no_call_history);
noMissedCallHistory = view.findViewById(R.id.no_missed_call_history); mNoMissedCallHistory = view.findViewById(R.id.no_missed_call_history);
historyList = view.findViewById(R.id.history_list); mHistoryList = view.findViewById(R.id.history_list);
mLayoutManager = new LinearLayoutManager(mContext); mLayoutManager = new LinearLayoutManager(mContext);
historyList.setLayoutManager(mLayoutManager); mHistoryList.setLayoutManager(mLayoutManager);
// Divider between items // Divider between items
DividerItemDecoration dividerItemDecoration = DividerItemDecoration dividerItemDecoration =
new DividerItemDecoration( new DividerItemDecoration(
historyList.getContext(), mLayoutManager.getOrientation()); mHistoryList.getContext(), mLayoutManager.getOrientation());
dividerItemDecoration.setDrawable(mContext.getResources().getDrawable(R.drawable.divider)); dividerItemDecoration.setDrawable(mContext.getResources().getDrawable(R.drawable.divider));
historyList.addItemDecoration(dividerItemDecoration); mHistoryList.addItemDecoration(dividerItemDecoration);
allCalls = view.findViewById(R.id.all_calls); mAllCalls = view.findViewById(R.id.all_calls);
allCalls.setOnClickListener(this); mAllCalls.setOnClickListener(this);
allCallsSelected = view.findViewById(R.id.all_calls_select); mAllCallsSelected = view.findViewById(R.id.all_calls_select);
missedCalls = view.findViewById(R.id.missed_calls); mMissedCalls = view.findViewById(R.id.missed_calls);
missedCalls.setOnClickListener(this); mMissedCalls.setOnClickListener(this);
missedCallsSelected = view.findViewById(R.id.missed_calls_select); mMissedCallsSelected = view.findViewById(R.id.missed_calls_select);
allCalls.setEnabled(false); mAllCalls.setEnabled(false);
mOnlyDisplayMissedCalls = false; mOnlyDisplayMissedCalls = false;
return view; return view;
@ -134,20 +134,20 @@ public class HistoryListFragment extends Fragment
private void hideHistoryListAndDisplayMessageIfEmpty() { private void hideHistoryListAndDisplayMessageIfEmpty() {
removeNotMissedCallsFromLogs(); removeNotMissedCallsFromLogs();
noCallHistory.setVisibility(View.GONE); mNoCallHistory.setVisibility(View.GONE);
noMissedCallHistory.setVisibility(View.GONE); mNoMissedCallHistory.setVisibility(View.GONE);
if (mLogs.isEmpty()) { if (mLogs.isEmpty()) {
if (mOnlyDisplayMissedCalls) { if (mOnlyDisplayMissedCalls) {
noMissedCallHistory.setVisibility(View.VISIBLE); mNoMissedCallHistory.setVisibility(View.VISIBLE);
} else { } else {
noCallHistory.setVisibility(View.VISIBLE); mNoCallHistory.setVisibility(View.VISIBLE);
} }
historyList.setVisibility(View.GONE); mHistoryList.setVisibility(View.GONE);
} else { } else {
noCallHistory.setVisibility(View.GONE); mNoCallHistory.setVisibility(View.GONE);
noMissedCallHistory.setVisibility(View.GONE); mNoMissedCallHistory.setVisibility(View.GONE);
historyList.setVisibility(View.VISIBLE); mHistoryList.setVisibility(View.VISIBLE);
} }
} }
@ -166,7 +166,7 @@ public class HistoryListFragment extends Fragment
mHistoryAdapter = mHistoryAdapter =
new HistoryAdapter( new HistoryAdapter(
getActivity().getApplicationContext(), mLogs, this, mSelectionHelper); getActivity().getApplicationContext(), mLogs, this, mSelectionHelper);
historyList.setAdapter(mHistoryAdapter); mHistoryList.setAdapter(mHistoryAdapter);
mSelectionHelper.setAdapter(mHistoryAdapter); mSelectionHelper.setAdapter(mHistoryAdapter);
mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog); mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
} }
@ -182,7 +182,7 @@ public class HistoryListFragment extends Fragment
if (!LinphoneActivity.isInstanciated() if (!LinphoneActivity.isInstanciated()
|| LinphoneActivity.instance().getCurrentFragment() || LinphoneActivity.instance().getCurrentFragment()
!= FragmentsAvailable.HISTORY_LIST) return; != FragmentsAvailable.HISTORY_LIST) return;
HistoryAdapter adapter = (HistoryAdapter) historyList.getAdapter(); HistoryAdapter adapter = (HistoryAdapter) mHistoryList.getAdapter();
if (adapter != null) { if (adapter != null) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
@ -193,23 +193,23 @@ public class HistoryListFragment extends Fragment
int id = v.getId(); int id = v.getId();
if (id == R.id.all_calls) { if (id == R.id.all_calls) {
allCalls.setEnabled(false); mAllCalls.setEnabled(false);
allCallsSelected.setVisibility(View.VISIBLE); mAllCallsSelected.setVisibility(View.VISIBLE);
missedCallsSelected.setVisibility(View.INVISIBLE); mMissedCallsSelected.setVisibility(View.INVISIBLE);
missedCalls.setEnabled(true); mMissedCalls.setEnabled(true);
mOnlyDisplayMissedCalls = false; mOnlyDisplayMissedCalls = false;
refresh(); refresh();
} }
if (id == R.id.missed_calls) { if (id == R.id.missed_calls) {
allCalls.setEnabled(true); mAllCalls.setEnabled(true);
allCallsSelected.setVisibility(View.INVISIBLE); mAllCallsSelected.setVisibility(View.INVISIBLE);
missedCallsSelected.setVisibility(View.VISIBLE); mMissedCallsSelected.setVisibility(View.VISIBLE);
missedCalls.setEnabled(false); mMissedCalls.setEnabled(false);
mOnlyDisplayMissedCalls = true; mOnlyDisplayMissedCalls = true;
} }
hideHistoryListAndDisplayMessageIfEmpty(); hideHistoryListAndDisplayMessageIfEmpty();
mHistoryAdapter = new HistoryAdapter(mContext, mLogs, this, mSelectionHelper); mHistoryAdapter = new HistoryAdapter(mContext, mLogs, this, mSelectionHelper);
historyList.setAdapter(mHistoryAdapter); mHistoryList.setAdapter(mHistoryAdapter);
mSelectionHelper.setAdapter(mHistoryAdapter); mSelectionHelper.setAdapter(mHistoryAdapter);
mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog); mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
} }

View file

@ -38,6 +38,7 @@ public class HistoryViewHolder extends RecyclerView.ViewHolder
public RelativeLayout CallContact; public RelativeLayout CallContact;
public LinearLayout separator; public LinearLayout separator;
public TextView separatorText; public TextView separatorText;
private ClickListener mListener; private ClickListener mListener;
public HistoryViewHolder(View view, ClickListener listener) { public HistoryViewHolder(View view, ClickListener listener) {

View file

@ -23,12 +23,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Notifiable { public class Notifiable {
int mNotificationId; private int mNotificationId;
List<NotifiableMessage> mMessages; private List<NotifiableMessage> mMessages;
boolean mIsGroup; private boolean mIsGroup;
String mGroupTitle; private String mGroupTitle;
String mLocalIdentity; private String mLocalIdentity;
String mMyself; private String mMyself;
public Notifiable(int id) { public Notifiable(int id) {
mNotificationId = id; mNotificationId = id;

View file

@ -23,12 +23,12 @@ import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
public class NotifiableMessage { public class NotifiableMessage {
String mMessage; private String mMessage;
String mSender; private String mSender;
long mTime; private long mTime;
Bitmap mSenderBitmap; private Bitmap mSenderBitmap;
Uri mFilePath; private Uri mFilePath;
String mFileMime; private String mFileMime;
public NotifiableMessage( public NotifiableMessage(
String message, String sender, long time, Uri filePath, String fileMime) { String message, String sender, long time, Uri filePath, String fileMime) {

View file

@ -39,36 +39,37 @@ import org.linphone.xmlrpc.XmlRpcListenerBase;
public class InAppPurchaseActivity extends Activity public class InAppPurchaseActivity extends Activity
implements InAppPurchaseListener, OnClickListener { implements InAppPurchaseListener, OnClickListener {
private static InAppPurchaseActivity instance; private static InAppPurchaseActivity sInstance;
private InAppPurchaseHelper inAppPurchaseHelper;
private ImageView cancel, back;
private ProgressBar inProgress;
private List<Purchasable> purchasedItems; private InAppPurchaseHelper mInAppPurchaseHelper;
private Fragment fragment; private ImageView mCancel, mBack;
private ProgressBar mInProgress;
private List<Purchasable> mPurchasedItems;
private Fragment mFragment;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
public static InAppPurchaseActivity instance() { public static InAppPurchaseActivity instance() {
return instance; return sInstance;
} }
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
inAppPurchaseHelper = new InAppPurchaseHelper(this, this); mInAppPurchaseHelper = new InAppPurchaseHelper(this, this);
setContentView(R.layout.in_app); setContentView(R.layout.in_app);
inProgress = findViewById(R.id.purchaseItemsFetchInProgress); mInProgress = findViewById(R.id.purchaseItemsFetchInProgress);
inProgress.setVisibility(View.VISIBLE); mInProgress.setVisibility(View.VISIBLE);
back = findViewById(R.id.back); mBack = findViewById(R.id.back);
back.setOnClickListener(this); mBack.setOnClickListener(this);
back.setVisibility(View.INVISIBLE); mBack.setVisibility(View.INVISIBLE);
cancel = findViewById(R.id.cancel); mCancel = findViewById(R.id.cancel);
cancel.setOnClickListener(this); mCancel.setOnClickListener(this);
instance = this; sInstance = this;
} }
private void changeFragment(Fragment newFragment) { private void changeFragment(Fragment newFragment) {
@ -78,44 +79,44 @@ public class InAppPurchaseActivity extends Activity
} }
public void displayInappList() { public void displayInappList() {
fragment = new InAppPurchaseListFragment(); mFragment = new InAppPurchaseListFragment();
changeFragment(fragment); changeFragment(mFragment);
} }
public void displayPurchase(Purchasable item) { public void displayPurchase(Purchasable item) {
Bundle extra = new Bundle(); Bundle extra = new Bundle();
extra.putString("item_id", item.getId()); extra.putString("item_id", item.getId());
fragment = new InAppPurchaseFragment(); mFragment = new InAppPurchaseFragment();
fragment.setArguments(extra); mFragment.setArguments(extra);
changeFragment(fragment); changeFragment(mFragment);
} }
public void buyInapp(String username, Purchasable item) { public void buyInapp(String username, Purchasable item) {
LinphonePreferences.instance().setInAppPurchasedItem(item); LinphonePreferences.instance().setInAppPurchasedItem(item);
inAppPurchaseHelper.purchaseItemAsync(item.getId(), username); mInAppPurchaseHelper.purchaseItemAsync(item.getId(), username);
} }
public String getGmailAccount() { public String getGmailAccount() {
return inAppPurchaseHelper.getGmailAccount(); return mInAppPurchaseHelper.getGmailAccount();
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
instance = null; sInstance = null;
inAppPurchaseHelper.destroy(); mInAppPurchaseHelper.destroy();
super.onDestroy(); super.onDestroy();
} }
public List<Purchasable> getPurchasedItems() { public List<Purchasable> getPurchasedItems() {
if (purchasedItems == null || purchasedItems.size() == 0) { if (mPurchasedItems == null || mPurchasedItems.size() == 0) {
Log.w("nul"); Log.w("nul");
} }
return purchasedItems; return mPurchasedItems;
} }
public Purchasable getPurchasedItem(String id) { public Purchasable getPurchasedItem(String id) {
for (Purchasable item : purchasedItems) { for (Purchasable item : mPurchasedItems) {
if (item.getId().equals(id)) { if (item.getId().equals(id)) {
return item; return item;
} }
@ -125,32 +126,32 @@ public class InAppPurchaseActivity extends Activity
@Override @Override
public void onServiceAvailableForQueries() { public void onServiceAvailableForQueries() {
// email.setText(inAppPurchaseHelper.getGmailAccount()); // email.setText(mInAppPurchaseHelper.getGmailAccount());
// email.setEnabled(false); // email.setEnabled(false);
// inAppPurchaseHelper.getPurchasedItemsAsync(); // mInAppPurchaseHelper.getPurchasedItemsAsync();
inAppPurchaseHelper.getAvailableItemsForPurchaseAsync(); mInAppPurchaseHelper.getAvailableItemsForPurchaseAsync();
} }
@Override @Override
public void onAvailableItemsForPurchaseQueryFinished(ArrayList<Purchasable> items) { public void onAvailableItemsForPurchaseQueryFinished(ArrayList<Purchasable> items) {
// purchasableItemsLayout.removeAllViews(); // purchasableItemsLayout.removeAllViews();
inProgress.setVisibility(View.GONE); mInProgress.setVisibility(View.GONE);
purchasedItems = new ArrayList<>(); mPurchasedItems = new ArrayList<>();
for (Purchasable item : items) { for (Purchasable item : items) {
purchasedItems.add(item); mPurchasedItems.add(item);
} }
displayInappList(); displayInappList();
} }
@Override @Override
public void onPurchasedItemsQueryFinished(ArrayList<Purchasable> items) { public void onPurchasedItemsQueryFinished(ArrayList<Purchasable> items) {
purchasedItems = items; mPurchasedItems = items;
if (items == null || items.size() == 0) { if (items == null || items.size() == 0) {
inAppPurchaseHelper.getAvailableItemsForPurchaseAsync(); mInAppPurchaseHelper.getAvailableItemsForPurchaseAsync();
} else { } else {
for (Purchasable purchasedItem : purchasedItems) { for (Purchasable purchasedItem : mPurchasedItems) {
Log.d( Log.d(
"[In-app purchase] Found already bought item, expires " "[In-app purchase] Found already bought item, expires "
+ purchasedItem.getExpireDate()); + purchasedItem.getExpireDate());
@ -194,7 +195,7 @@ public class InAppPurchaseActivity extends Activity
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
inAppPurchaseHelper.parseAndVerifyPurchaseItemResultAsync(requestCode, resultCode, data); mInAppPurchaseHelper.parseAndVerifyPurchaseItemResultAsync(requestCode, resultCode, data);
} }
@Override @Override
@ -207,7 +208,7 @@ public class InAppPurchaseActivity extends Activity
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
inProgress.setVisibility(View.GONE); mInProgress.setVisibility(View.GONE);
Toast.makeText(InAppPurchaseActivity.this, error, Toast.LENGTH_LONG).show(); Toast.makeText(InAppPurchaseActivity.this, error, Toast.LENGTH_LONG).show();
} }
}); });

View file

@ -36,13 +36,13 @@ import org.linphone.core.ProxyConfig;
import org.linphone.settings.LinphonePreferences; import org.linphone.settings.LinphonePreferences;
public class InAppPurchaseFragment extends Fragment implements View.OnClickListener { public class InAppPurchaseFragment extends Fragment implements View.OnClickListener {
private LinearLayout usernameLayout; private LinearLayout mUsernameLayout;
private EditText username, email; private EditText mUsername, mEmail;
private TextView errorMessage; private TextView mErrorMessage;
private boolean usernameOk = false, emailOk = false; private boolean mUsernameOk = false, mEmailOk = false;
private String defaultUsername, defaultEmail; private String mDefaultUsername, mDefaultEmail;
private Button buyItemButton; private Button mBuyItemButton;
@Override @Override
public View onCreateView( public View onCreateView(
@ -54,41 +54,41 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
String id = getArguments().getString("item_id"); String id = getArguments().getString("item_id");
Purchasable item = InAppPurchaseActivity.instance().getPurchasedItem(id); Purchasable item = InAppPurchaseActivity.instance().getPurchasedItem(id);
buyItemButton = view.findViewById(R.id.inapp_button); mBuyItemButton = view.findViewById(R.id.inapp_button);
displayBuySubscriptionButton(item); displayBuySubscriptionButton(item);
defaultEmail = InAppPurchaseActivity.instance().getGmailAccount(); mDefaultEmail = InAppPurchaseActivity.instance().getGmailAccount();
defaultUsername = mDefaultUsername =
LinphonePreferences.instance() LinphonePreferences.instance()
.getAccountUsername( .getAccountUsername(
LinphonePreferences.instance().getDefaultAccountIndex()); LinphonePreferences.instance().getDefaultAccountIndex());
usernameLayout = view.findViewById(R.id.username_layout); mUsernameLayout = view.findViewById(R.id.username_layout);
username = view.findViewById(R.id.username); mUsername = view.findViewById(R.id.username);
if (!getResources().getBoolean(R.bool.hide_username_in_inapp)) { if (!getResources().getBoolean(R.bool.hide_username_in_inapp)) {
usernameLayout.setVisibility(View.VISIBLE); mUsernameLayout.setVisibility(View.VISIBLE);
username.setText( mUsername.setText(
LinphonePreferences.instance() LinphonePreferences.instance()
.getAccountUsername( .getAccountUsername(
LinphonePreferences.instance().getDefaultAccountIndex())); LinphonePreferences.instance().getDefaultAccountIndex()));
addUsernameHandler(username, errorMessage); addUsernameHandler(mUsername, mErrorMessage);
} else { } else {
if (defaultUsername != null) { if (mDefaultUsername != null) {
usernameLayout.setVisibility(View.GONE); mUsernameLayout.setVisibility(View.GONE);
usernameOk = true; mUsernameOk = true;
} }
} }
email = view.findViewById(R.id.email); mEmail = view.findViewById(R.id.email);
if (defaultEmail != null) { if (mDefaultEmail != null) {
email.setText(defaultEmail); mEmail.setText(mDefaultEmail);
emailOk = true; mEmailOk = true;
} }
buyItemButton.setEnabled(emailOk && usernameOk); mBuyItemButton.setEnabled(mEmailOk && mUsernameOk);
errorMessage = view.findViewById(R.id.username_error); mErrorMessage = view.findViewById(R.id.username_error);
return view; return view;
} }
@ -102,15 +102,15 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
CharSequence s, int start, int count, int after) {} CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int count, int after) { public void onTextChanged(CharSequence s, int start, int count, int after) {
usernameOk = false; mUsernameOk = false;
String username = s.toString(); String username = s.toString();
if (isUsernameCorrect(username)) { if (isUsernameCorrect(username)) {
usernameOk = true; mUsernameOk = true;
errorMessage.setText(""); errorMessage.setText("");
} else { } else {
errorMessage.setText(R.string.wizard_username_incorrect); errorMessage.setText(R.string.wizard_username_incorrect);
} }
if (buyItemButton != null) buyItemButton.setEnabled(usernameOk); if (mBuyItemButton != null) mBuyItemButton.setEnabled(mUsernameOk);
} }
}); });
} }
@ -121,10 +121,10 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
} }
private void displayBuySubscriptionButton(Purchasable item) { private void displayBuySubscriptionButton(Purchasable item) {
buyItemButton.setText("Buy account (" + item.getPrice() + ")"); mBuyItemButton.setText("Buy account (" + item.getPrice() + ")");
buyItemButton.setTag(item); mBuyItemButton.setTag(item);
buyItemButton.setOnClickListener(this); mBuyItemButton.setOnClickListener(this);
buyItemButton.setEnabled(usernameOk && emailOk); mBuyItemButton.setEnabled(mUsernameOk && mEmailOk);
} }
@Override @Override
@ -134,7 +134,7 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
} }
private String getUsername() { private String getUsername() {
String username = this.username.getText().toString(); String username = this.mUsername.getText().toString();
ProxyConfig lpc = LinphoneManager.getLc().createProxyConfig(); ProxyConfig lpc = LinphoneManager.getLc().createProxyConfig();
username = lpc.normalizePhoneNumber(username); username = lpc.normalizePhoneNumber(username);
return username.toLowerCase(Locale.getDefault()); return username.toLowerCase(Locale.getDefault());

View file

@ -32,7 +32,7 @@ import java.util.List;
import org.linphone.R; import org.linphone.R;
public class InAppPurchaseListFragment extends Fragment implements AdapterView.OnItemClickListener { public class InAppPurchaseListFragment extends Fragment implements AdapterView.OnItemClickListener {
private ListView inappList; private ListView mInappList;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private List<Purchasable> mPurchasableItems; private List<Purchasable> mPurchasableItems;
@ -43,11 +43,11 @@ public class InAppPurchaseListFragment extends Fragment implements AdapterView.O
View view = inflater.inflate(R.layout.in_app_list, container, false); View view = inflater.inflate(R.layout.in_app_list, container, false);
mPurchasableItems = InAppPurchaseActivity.instance().getPurchasedItems(); mPurchasableItems = InAppPurchaseActivity.instance().getPurchasedItems();
inappList = view.findViewById(R.id.inapp_list); mInappList = view.findViewById(R.id.inapp_list);
if (mPurchasableItems != null) { if (mPurchasableItems != null) {
inappList.setAdapter(new InAppListAdapter()); mInappList.setAdapter(new InAppListAdapter());
inappList.setOnItemClickListener(this); mInappList.setOnItemClickListener(this);
} }
return view; return view;
} }

View file

@ -25,81 +25,81 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
public class Purchasable { public class Purchasable {
private String id, title, description, price; private String mId, mTitle, mDescription, mPrice;
private long expire; private long mExpire;
private String purchasePayload, purchasePayloadSignature; private String mPurchasePayload, mPurchasePayloadSignature;
private String userData; private String mUserData;
public Purchasable(String id) { public Purchasable(String id) {
this.id = id; this.mId = id;
} }
public String getId() { public String getId() {
return id; return mId;
} }
public String getTitle() { public String getTitle() {
return title; return mTitle;
} }
public Purchasable setTitle(String title) { public Purchasable setTitle(String title) {
this.title = title; this.mTitle = title;
return this; return this;
} }
public String getDescription() { public String getDescription() {
return description; return mDescription;
} }
public Purchasable setDescription(String description) { public Purchasable setDescription(String description) {
this.description = description; this.mDescription = description;
return this; return this;
} }
public String getPrice() { public String getPrice() {
return price; return mPrice;
} }
public Purchasable setPrice(String price) { public Purchasable setPrice(String price) {
this.price = price; this.mPrice = price;
return this; return this;
} }
public long getExpire() { public long getExpire() {
return expire; return mExpire;
} }
public Purchasable setExpire(long expire) { public Purchasable setExpire(long expire) {
this.expire = expire; this.mExpire = expire;
return this; return this;
} }
public String getExpireDate() { public String getExpireDate() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault()); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault());
Date date = new Date(expire); Date date = new Date(mExpire);
return dateFormat.format(date); return dateFormat.format(date);
} }
public Purchasable setPayloadAndSignature(String payload, String signature) { public Purchasable setPayloadAndSignature(String payload, String signature) {
this.purchasePayload = payload; this.mPurchasePayload = payload;
this.purchasePayloadSignature = signature; this.mPurchasePayloadSignature = signature;
return this; return this;
} }
public String getPayload() { public String getPayload() {
return this.purchasePayload; return this.mPurchasePayload;
} }
public String getPayloadSignature() { public String getPayloadSignature() {
return this.purchasePayloadSignature; return this.mPurchasePayloadSignature;
} }
public String getUserData() { public String getUserData() {
return this.userData; return this.mUserData;
} }
public Purchasable setUserData(String data) { public Purchasable setUserData(String data) {
this.userData = data; this.mUserData = data;
return this; return this;
} }
} }

View file

@ -34,7 +34,7 @@ import org.linphone.LinphoneService;
import org.linphone.call.CallActivity; import org.linphone.call.CallActivity;
public class BluetoothManager extends BroadcastReceiver { public class BluetoothManager extends BroadcastReceiver {
private static BluetoothManager instance; private static BluetoothManager sInstance;
private Context mContext; private Context mContext;
private AudioManager mAudioManager; private AudioManager mAudioManager;
@ -42,24 +42,24 @@ public class BluetoothManager extends BroadcastReceiver {
private BluetoothHeadset mBluetoothHeadset; private BluetoothHeadset mBluetoothHeadset;
private BluetoothDevice mBluetoothDevice; private BluetoothDevice mBluetoothDevice;
private BluetoothProfile.ServiceListener mProfileListener; private BluetoothProfile.ServiceListener mProfileListener;
private boolean isBluetoothConnected; private boolean mIsBluetoothConnected;
private boolean isScoConnected; private boolean mIsScoConnected;
public BluetoothManager() { public BluetoothManager() {
isBluetoothConnected = false; mIsBluetoothConnected = false;
if (!ensureInit()) { if (!ensureInit()) {
android.util.Log.w( android.util.Log.w(
"BluetoothManager", "BluetoothManager",
"[Bluetooth] Manager tried to init but LinphoneService not ready yet..."); "[Bluetooth] Manager tried to init but LinphoneService not ready yet...");
} }
instance = this; sInstance = this;
} }
public static BluetoothManager getInstance() { public static BluetoothManager getInstance() {
if (instance == null) { if (sInstance == null) {
instance = new BluetoothManager(); sInstance = new BluetoothManager();
} }
return instance; return sInstance;
} }
public void initBluetooth() { public void initBluetooth() {
@ -85,7 +85,7 @@ public class BluetoothManager extends BroadcastReceiver {
} }
private void startBluetooth() { private void startBluetooth() {
if (isBluetoothConnected) { if (mIsBluetoothConnected) {
android.util.Log.e("BluetoothManager", "[Bluetooth] Already started, skipping..."); android.util.Log.e("BluetoothManager", "[Bluetooth] Already started, skipping...");
return; return;
} }
@ -107,14 +107,14 @@ public class BluetoothManager extends BroadcastReceiver {
android.util.Log.d( android.util.Log.d(
"BluetoothManager", "[Bluetooth] Headset connected"); "BluetoothManager", "[Bluetooth] Headset connected");
mBluetoothHeadset = (BluetoothHeadset) proxy; mBluetoothHeadset = (BluetoothHeadset) proxy;
isBluetoothConnected = true; mIsBluetoothConnected = true;
} }
} }
public void onServiceDisconnected(int profile) { public void onServiceDisconnected(int profile) {
if (profile == BluetoothProfile.HEADSET) { if (profile == BluetoothProfile.HEADSET) {
mBluetoothHeadset = null; mBluetoothHeadset = null;
isBluetoothConnected = false; mIsBluetoothConnected = false;
android.util.Log.d( android.util.Log.d(
"BluetoothManager", "[Bluetooth] Headset disconnected"); "BluetoothManager", "[Bluetooth] Headset disconnected");
LinphoneManager.getInstance().routeAudioToReceiver(); LinphoneManager.getInstance().routeAudioToReceiver();
@ -211,7 +211,7 @@ public class BluetoothManager extends BroadcastReceiver {
public boolean isUsingBluetoothAudioRoute() { public boolean isUsingBluetoothAudioRoute() {
return mBluetoothHeadset != null return mBluetoothHeadset != null
&& mBluetoothHeadset.isAudioConnected(mBluetoothDevice) && mBluetoothHeadset.isAudioConnected(mBluetoothDevice)
&& isScoConnected; && mIsScoConnected;
} }
public boolean isBluetoothHeadsetAvailable() { public boolean isBluetoothHeadsetAvailable() {
@ -251,7 +251,7 @@ public class BluetoothManager extends BroadcastReceiver {
// Hack to ensure bluetooth sco is really stopped // Hack to ensure bluetooth sco is really stopped
int retries = 0; int retries = 0;
while (isScoConnected && retries < 10) { while (mIsScoConnected && retries < 10) {
retries++; retries++;
try { try {
@ -268,7 +268,7 @@ public class BluetoothManager extends BroadcastReceiver {
public void stopBluetooth() { public void stopBluetooth() {
android.util.Log.w("BluetoothManager", "[Bluetooth] Stopping..."); android.util.Log.w("BluetoothManager", "[Bluetooth] Stopping...");
isBluetoothConnected = false; mIsBluetoothConnected = false;
disableBluetoothSCO(); disableBluetoothSCO();
@ -310,15 +310,15 @@ public class BluetoothManager extends BroadcastReceiver {
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) { if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: connected"); android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: connected");
// LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH); // LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
isScoConnected = true; mIsScoConnected = true;
} else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) { } else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: disconnected"); android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: disconnected");
// LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER); // LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER);
isScoConnected = false; mIsScoConnected = false;
} else if (state == AudioManager.SCO_AUDIO_STATE_CONNECTING) { } else if (state == AudioManager.SCO_AUDIO_STATE_CONNECTING) {
android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: connecting"); android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: connecting");
// LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH); // LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
isScoConnected = true; mIsScoConnected = true;
} else { } else {
android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: " + state); android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: " + state);
} }

View file

@ -29,13 +29,11 @@ import org.linphone.settings.LinphonePreferences;
public class OutgoingCallReceiver extends BroadcastReceiver { public class OutgoingCallReceiver extends BroadcastReceiver {
private static final String TAG = "CallHandler"; private static final String TAG = "CallHandler";
private final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched"; private static final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
private LinphonePreferences mPrefs;
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
mPrefs = LinphonePreferences.instance(); LinphonePreferences mPrefs = LinphonePreferences.instance();
Log.e(TAG, "===>>>> Linphone OutgoingCallReceiver "); Log.e(TAG, "===>>>> Linphone OutgoingCallReceiver ");
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) { if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
Log.e(TAG, "===>>>> Linphone OutgoingCallReceiver : ACTION_NEW_OUTGOING_CALL"); Log.e(TAG, "===>>>> Linphone OutgoingCallReceiver : ACTION_NEW_OUTGOING_CALL");

View file

@ -36,6 +36,7 @@ import org.linphone.mediastream.Log;
public class Recording implements PlayerListener, Comparable<Recording> { public class Recording implements PlayerListener, Comparable<Recording> {
public static final Pattern RECORD_PATTERN = public static final Pattern RECORD_PATTERN =
Pattern.compile(".*/(.*)_(\\d{2}-\\d{2}-\\d{4}-\\d{2}-\\d{2}-\\d{2})\\..*"); Pattern.compile(".*/(.*)_(\\d{2}-\\d{2}-\\d{4}-\\d{2}-\\d{2}-\\d{2})\\..*");
private String mRecordPath, mName; private String mRecordPath, mName;
private Date mRecordDate; private Date mRecordDate;
private Player mPlayer; private Player mPlayer;

View file

@ -36,9 +36,9 @@ import org.linphone.utils.SelectableAdapter;
import org.linphone.utils.SelectableHelper; import org.linphone.utils.SelectableHelper;
public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> { public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
private List<Recording> recordings; private List<Recording> mRecordings;
private Context context; private Context mContext;
private RecordingViewHolder.ClickListener clickListener; private RecordingViewHolder.ClickListener mClickListener;
public RecordingsAdapter( public RecordingsAdapter(
Context context, Context context,
@ -47,14 +47,14 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
SelectableHelper helper) { SelectableHelper helper) {
super(helper); super(helper);
this.recordings = recordings; mRecordings = recordings;
this.context = context; mContext = context;
this.clickListener = listener; mClickListener = listener;
} }
@Override @Override
public Object getItem(int position) { public Object getItem(int position) {
return recordings.get(position); return mRecordings.get(position);
} }
@NonNull @NonNull
@ -63,13 +63,13 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
View v = View v =
LayoutInflater.from(viewGroup.getContext()) LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.recording_cell, viewGroup, false); .inflate(R.layout.recording_cell, viewGroup, false);
return new RecordingViewHolder(v, clickListener); return new RecordingViewHolder(v, mClickListener);
} }
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
@Override @Override
public void onBindViewHolder(@NonNull final RecordingViewHolder viewHolder, int i) { public void onBindViewHolder(@NonNull final RecordingViewHolder viewHolder, int i) {
final Recording record = recordings.get(i); final Recording record = mRecordings.get(i);
viewHolder.name.setSelected(true); // For automated horizontal scrolling of long texts viewHolder.name.setSelected(true); // For automated horizontal scrolling of long texts
@ -80,7 +80,7 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
viewHolder.select.setChecked(isSelected(i)); viewHolder.select.setChecked(isSelected(i));
if (i > 0) { if (i > 0) {
Recording previousRecord = recordings.get(i - 1); Recording previousRecord = mRecordings.get(i - 1);
Date previousRecordDate = previousRecord.getRecordDate(); Date previousRecordDate = previousRecord.getRecordDate();
Calendar previousRecordTime = Calendar.getInstance(); Calendar previousRecordTime = Calendar.getInstance();
previousRecordTime.setTime(previousRecordDate); previousRecordTime.setTime(previousRecordDate);
@ -198,20 +198,20 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
@Override @Override
public int getItemCount() { public int getItemCount() {
return recordings.size(); return mRecordings.size();
} }
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
private String DateToHumanDate(Calendar cal) { private String DateToHumanDate(Calendar cal) {
SimpleDateFormat dateFormat; SimpleDateFormat dateFormat;
if (isToday(cal)) { if (isToday(cal)) {
return context.getString(R.string.today); return mContext.getString(R.string.today);
} else if (isYesterday(cal)) { } else if (isYesterday(cal)) {
return context.getString(R.string.yesterday); return mContext.getString(R.string.yesterday);
} else { } else {
dateFormat = dateFormat =
new SimpleDateFormat( new SimpleDateFormat(
context.getResources().getString(R.string.history_date_format)); mContext.getResources().getString(R.string.history_date_format));
} }
return dateFormat.format(cal.getTime()); return dateFormat.format(cal.getTime());

View file

@ -18,7 +18,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
@ -48,8 +47,8 @@ import org.linphone.utils.LinphoneUtils;
public class AccountPreferencesFragment extends PreferencesListFragment public class AccountPreferencesFragment extends PreferencesListFragment
implements AccountCreatorListener { implements AccountCreatorListener {
private int n; private int mN;
OnPreferenceClickListener linkAccountListener = private OnPreferenceClickListener linkAccountListener =
new OnPreferenceClickListener() { new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
@ -57,14 +56,14 @@ public class AccountPreferencesFragment extends PreferencesListFragment
assistant.setClass(LinphoneActivity.instance(), AssistantActivity.class); assistant.setClass(LinphoneActivity.instance(), AssistantActivity.class);
assistant.putExtra("LinkPhoneNumber", true); assistant.putExtra("LinkPhoneNumber", true);
assistant.putExtra("FromPref", true); assistant.putExtra("FromPref", true);
assistant.putExtra("AccountNumber", n); assistant.putExtra("AccountNumber", mN);
startActivity(assistant); startActivity(assistant);
return true; return true;
} }
}; };
private boolean isNewAccount = false; private boolean mIsNewAccount = false;
private LinphonePreferences mPrefs; private LinphonePreferences mPrefs;
OnPreferenceChangeListener avpfRRIntervalChangedListener = private OnPreferenceChangeListener mAvpfRRIntervalChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
@ -76,82 +75,82 @@ public class AccountPreferencesFragment extends PreferencesListFragment
} }
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
} }
if (isNewAccount) { if (mIsNewAccount) {
// TODO // TODO
} else { } else {
mPrefs.setAvpfRrInterval(n, value); mPrefs.setAvpfRrInterval(mN, value);
} }
preference.setSummary(value); preference.setSummary(value);
return true; return true;
} }
}; };
OnPreferenceChangeListener escapeChangedListener = private OnPreferenceChangeListener mEscapeChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue; boolean value = (Boolean) newValue;
if (isNewAccount) { if (mIsNewAccount) {
// TODO // TODO
} else { } else {
mPrefs.setReplacePlusByZeroZero(n, value); mPrefs.setReplacePlusByZeroZero(mN, value);
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener pushNotificationListener = private OnPreferenceChangeListener mPushNotificationListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue; boolean value = (Boolean) newValue;
if (isNewAccount) { if (mIsNewAccount) {
// TODO // TODO
} else { } else {
mPrefs.enablePushNotifForProxy(n, value); mPrefs.enablePushNotifForProxy(mN, value);
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener iceChangedListener = private OnPreferenceChangeListener mIceChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue; boolean value = (Boolean) newValue;
if (isNewAccount) { if (mIsNewAccount) {
} else { } else {
mPrefs.setAccountIce(n, value); mPrefs.setAccountIce(mN, value);
((CheckBoxPreference) preference).setChecked(mPrefs.getAccountIce(n)); ((CheckBoxPreference) preference).setChecked(mPrefs.getAccountIce(mN));
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener stunTurnChangedListener = private OnPreferenceChangeListener mStunTurnChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString(); String value = newValue.toString();
if (isNewAccount) { if (mIsNewAccount) {
} else { } else {
mPrefs.setAccountStunServer(n, value); mPrefs.setAccountStunServer(mN, value);
preference.setSummary(value); preference.setSummary(value);
} }
return true; return true;
} }
}; };
private EditTextPreference mProxyPreference; private EditTextPreference mProxyPreference;
OnPreferenceChangeListener transportChangedListener = private OnPreferenceChangeListener mTransportChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = newValue.toString(); String key = newValue.toString();
if (isNewAccount) { if (mIsNewAccount) {
// TODO // TODO
// builder.setTransport(transport); // mBuilder.setTransport(transport);
} else { } else {
mPrefs.setAccountTransport(n, key); mPrefs.setAccountTransport(mN, key);
preference.setSummary(mPrefs.getAccountTransportString(n)); preference.setSummary(mPrefs.getAccountTransportString(mN));
preference.setDefaultValue(mPrefs.getAccountTransportKey(n)); preference.setDefaultValue(mPrefs.getAccountTransportKey(mN));
if (mProxyPreference != null) { if (mProxyPreference != null) {
String newProxy = mPrefs.getAccountProxy(n); String newProxy = mPrefs.getAccountProxy(mN);
mProxyPreference.setSummary(newProxy); mProxyPreference.setSummary(newProxy);
mProxyPreference.setText(newProxy); mProxyPreference.setText(newProxy);
} }
@ -160,161 +159,158 @@ public class AccountPreferencesFragment extends PreferencesListFragment
} }
}; };
private ListPreference mTransportPreference; private ListPreference mTransportPreference;
private AccountBuilder builder; private AccountBuilder mBuilder;
OnPreferenceChangeListener usernameChangedListener = private OnPreferenceChangeListener mUsernameChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isEditTextEmpty(newValue.toString())) return false; if (isEditTextEmpty(newValue.toString())) return false;
if (isNewAccount) { if (mIsNewAccount) {
builder.setUsername(newValue.toString()); mBuilder.setUsername(newValue.toString());
} else { } else {
mPrefs.setAccountUsername(n, newValue.toString()); mPrefs.setAccountUsername(mN, newValue.toString());
} }
preference.setSummary(newValue.toString()); preference.setSummary(newValue.toString());
return true; return true;
} }
}; };
OnPreferenceChangeListener useridChangedListener = private OnPreferenceChangeListener mUseridChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) { if (mIsNewAccount) {
builder.setUserid(newValue.toString()); mBuilder.setUserid(newValue.toString());
} else { } else {
mPrefs.setAccountUserId(n, newValue.toString()); mPrefs.setAccountUserId(mN, newValue.toString());
} }
preference.setSummary(newValue.toString()); preference.setSummary(newValue.toString());
return true; return true;
} }
}; };
OnPreferenceChangeListener passwordChangedListener = private OnPreferenceChangeListener mPasswordChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isEditTextEmpty(newValue.toString())) return false; if (isEditTextEmpty(newValue.toString())) return false;
if (isNewAccount) { if (mIsNewAccount) {
builder.setPassword(newValue.toString()); mBuilder.setPassword(newValue.toString());
} else { } else {
mPrefs.setAccountPassword(n, newValue.toString()); mPrefs.setAccountPassword(mN, newValue.toString());
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener domainChangedListener = private OnPreferenceChangeListener mDomainChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isEditTextEmpty(newValue.toString())) return false; if (isEditTextEmpty(newValue.toString())) return false;
if (isNewAccount) { if (mIsNewAccount) {
builder.setDomain(newValue.toString()); mBuilder.setDomain(newValue.toString());
} else { } else {
mPrefs.setAccountDomain(n, newValue.toString()); mPrefs.setAccountDomain(mN, newValue.toString());
} }
preference.setSummary(newValue.toString()); preference.setSummary(newValue.toString());
return true; return true;
} }
}; };
OnPreferenceChangeListener displayNameChangedListener = private OnPreferenceChangeListener mDisplayNameChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) { if (mIsNewAccount) {
builder.setDisplayName(newValue.toString()); mBuilder.setDisplayName(newValue.toString());
} else { } else {
mPrefs.setAccountDisplayName(n, newValue.toString()); mPrefs.setAccountDisplayName(mN, newValue.toString());
} }
preference.setSummary(newValue.toString()); preference.setSummary(newValue.toString());
return true; return true;
} }
}; };
OnPreferenceChangeListener proxyChangedListener = private OnPreferenceChangeListener mProxyChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString(); String value = newValue.toString();
if (isNewAccount) { if (mIsNewAccount) {
builder.setServerAddr(newValue.toString()); mBuilder.setServerAddr(newValue.toString());
preference.setSummary(newValue.toString()); preference.setSummary(newValue.toString());
} else { } else {
mPrefs.setAccountProxy(n, value); mPrefs.setAccountProxy(mN, value);
preference.setSummary(mPrefs.getAccountProxy(n)); preference.setSummary(mPrefs.getAccountProxy(mN));
if (mTransportPreference != null) { if (mTransportPreference != null) {
mTransportPreference.setSummary(mPrefs.getAccountTransportString(n)); mTransportPreference.setSummary(mPrefs.getAccountTransportString(mN));
mTransportPreference.setValue(mPrefs.getAccountTransportKey(n)); mTransportPreference.setValue(mPrefs.getAccountTransportKey(mN));
} }
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener outboundProxyChangedListener = private OnPreferenceChangeListener mOutboundProxyChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) { if (mIsNewAccount) {
builder.setOutboundProxyEnabled((Boolean) newValue); mBuilder.setOutboundProxyEnabled((Boolean) newValue);
} else { } else {
mPrefs.setAccountOutboundProxyEnabled(n, (Boolean) newValue); mPrefs.setAccountOutboundProxyEnabled(mN, (Boolean) newValue);
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener expiresChangedListener = private OnPreferenceChangeListener mExpiresChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) { if (mIsNewAccount) {
builder.setExpires(newValue.toString()); mBuilder.setExpires(newValue.toString());
} else { } else {
mPrefs.setExpires(n, newValue.toString()); mPrefs.setExpires(mN, newValue.toString());
} }
preference.setSummary(newValue.toString()); preference.setSummary(newValue.toString());
return true; return true;
} }
}; };
OnPreferenceChangeListener prefixChangedListener = private OnPreferenceChangeListener mPrefixChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString(); String value = newValue.toString();
preference.setSummary(value); preference.setSummary(value);
if (isNewAccount) { if (mIsNewAccount) {
builder.setPrefix(value); mBuilder.setPrefix(value);
} else { } else {
mPrefs.setPrefix(n, value); mPrefs.setPrefix(mN, value);
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener avpfChangedListener = private OnPreferenceChangeListener mAvpfChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue; boolean value = (Boolean) newValue;
if (isNewAccount) { if (!mIsNewAccount) {
builder.setAvpfEnabled(value); mPrefs.setAvpfMode(mN, value);
} else {
mPrefs.setAvpfMode(n, value);
} }
return true; return true;
} }
}; };
OnPreferenceChangeListener disableChangedListener = private OnPreferenceChangeListener mDisableChangedListener =
new OnPreferenceChangeListener() { new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue; boolean value = (Boolean) newValue;
if (isNewAccount) { if (mIsNewAccount) {
builder.setEnabled(!value); mBuilder.setEnabled(!value);
} else { } else {
mPrefs.setAccountEnabled(n, !value); mPrefs.setAccountEnabled(mN, !value);
} }
return true; return true;
} }
}; };
private AccountCreator accountCreator; private AccountCreator mAccountCreator;
private ProgressDialog progress;
public AccountPreferencesFragment() { public AccountPreferencesFragment() {
super(R.xml.account_preferences); super(R.xml.account_preferences);
@ -339,10 +335,10 @@ public class AccountPreferencesFragment extends PreferencesListFragment
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
PreferenceScreen screen = getPreferenceScreen(); PreferenceScreen screen = getPreferenceScreen();
n = getArguments().getInt("Account", 0); mN = getArguments().getInt("Account", 0);
if (n == mPrefs.getAccountCount()) { if (mN == mPrefs.getAccountCount()) {
isNewAccount = true; mIsNewAccount = true;
builder = new AccountBuilder(LinphoneManager.getLc()); mBuilder = new AccountBuilder(LinphoneManager.getLc());
} }
initAccountPreferencesFields(screen); initAccountPreferencesFields(screen);
@ -353,12 +349,12 @@ public class AccountPreferencesFragment extends PreferencesListFragment
} }
private void initAccountPreferencesFields(PreferenceScreen parent) { private void initAccountPreferencesFields(PreferenceScreen parent) {
boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == n; boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == mN;
NatPolicy natPolicy = null; NatPolicy natPolicy = null;
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null
&& LinphoneManager.getLc().getProxyConfigList() != null && LinphoneManager.getLc().getProxyConfigList() != null
&& LinphoneManager.getLc().getProxyConfigList().length > n) { && LinphoneManager.getLc().getProxyConfigList().length > mN) {
ProxyConfig proxy = LinphoneManager.getLc().getProxyConfigList()[n]; ProxyConfig proxy = LinphoneManager.getLc().getProxyConfigList()[mN];
natPolicy = proxy.getNatPolicy(); natPolicy = proxy.getNatPolicy();
if (natPolicy == null) { if (natPolicy == null) {
natPolicy = LinphoneManager.getLc().createNatPolicy(); natPolicy = LinphoneManager.getLc().createNatPolicy();
@ -368,46 +364,46 @@ public class AccountPreferencesFragment extends PreferencesListFragment
} }
} }
accountCreator = mAccountCreator =
LinphoneManager.getLc() LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl()); .createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this); mAccountCreator.setListener(this);
final PreferenceCategory account = final PreferenceCategory account =
(PreferenceCategory) (PreferenceCategory)
getPreferenceScreen() getPreferenceScreen()
.findPreference(getString(R.string.pref_sipaccount_key)); .findPreference(getString(R.string.pref_sipaccount_key));
EditTextPreference username = (EditTextPreference) account.getPreference(0); EditTextPreference username = (EditTextPreference) account.getPreference(0);
username.setOnPreferenceChangeListener(usernameChangedListener); username.setOnPreferenceChangeListener(mUsernameChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
username.setText(mPrefs.getAccountUsername(n)); username.setText(mPrefs.getAccountUsername(mN));
username.setSummary(username.getText()); username.setSummary(username.getText());
} }
EditTextPreference userid = (EditTextPreference) account.getPreference(1); EditTextPreference userid = (EditTextPreference) account.getPreference(1);
userid.setOnPreferenceChangeListener(useridChangedListener); userid.setOnPreferenceChangeListener(mUseridChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
userid.setText(mPrefs.getAccountUserId(n)); userid.setText(mPrefs.getAccountUserId(mN));
userid.setSummary(userid.getText()); userid.setSummary(userid.getText());
} }
EditTextPreference password = (EditTextPreference) account.getPreference(2); EditTextPreference password = (EditTextPreference) account.getPreference(2);
password.setOnPreferenceChangeListener(passwordChangedListener); password.setOnPreferenceChangeListener(mPasswordChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
password.setText(mPrefs.getAccountPassword(n)); password.setText(mPrefs.getAccountPassword(mN));
} }
EditTextPreference domain = (EditTextPreference) account.getPreference(3); EditTextPreference domain = (EditTextPreference) account.getPreference(3);
domain.setOnPreferenceChangeListener(domainChangedListener); domain.setOnPreferenceChangeListener(mDomainChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
domain.setText(mPrefs.getAccountDomain(n)); domain.setText(mPrefs.getAccountDomain(mN));
domain.setSummary(domain.getText()); domain.setSummary(domain.getText());
} }
EditTextPreference displayName = (EditTextPreference) account.getPreference(4); EditTextPreference displayName = (EditTextPreference) account.getPreference(4);
displayName.setOnPreferenceChangeListener(displayNameChangedListener); displayName.setOnPreferenceChangeListener(mDisplayNameChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
displayName.setText(mPrefs.getAccountDisplayName(n)); displayName.setText(mPrefs.getAccountDisplayName(mN));
displayName.setSummary(displayName.getText()); displayName.setSummary(displayName.getText());
} }
@ -416,26 +412,26 @@ public class AccountPreferencesFragment extends PreferencesListFragment
getPreferenceScreen().findPreference(getString(R.string.pref_advanced_key)); getPreferenceScreen().findPreference(getString(R.string.pref_advanced_key));
mTransportPreference = (ListPreference) advanced.getPreference(0); mTransportPreference = (ListPreference) advanced.getPreference(0);
initializeTransportPreference(mTransportPreference); initializeTransportPreference(mTransportPreference);
mTransportPreference.setOnPreferenceChangeListener(transportChangedListener); mTransportPreference.setOnPreferenceChangeListener(mTransportChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
mTransportPreference.setSummary(mPrefs.getAccountTransportString(n)); mTransportPreference.setSummary(mPrefs.getAccountTransportString(mN));
} }
CheckBoxPreference ice = (CheckBoxPreference) advanced.getPreference(1); CheckBoxPreference ice = (CheckBoxPreference) advanced.getPreference(1);
ice.setOnPreferenceChangeListener(iceChangedListener); ice.setOnPreferenceChangeListener(mIceChangedListener);
if (natPolicy != null) ice.setChecked(natPolicy.iceEnabled()); if (natPolicy != null) ice.setChecked(natPolicy.iceEnabled());
EditTextPreference stunTurn = (EditTextPreference) advanced.getPreference(2); EditTextPreference stunTurn = (EditTextPreference) advanced.getPreference(2);
stunTurn.setOnPreferenceChangeListener(stunTurnChangedListener); stunTurn.setOnPreferenceChangeListener(mStunTurnChangedListener);
if (natPolicy != null) { if (natPolicy != null) {
stunTurn.setText(natPolicy.getStunServer()); stunTurn.setText(natPolicy.getStunServer());
stunTurn.setSummary(natPolicy.getStunServer()); stunTurn.setSummary(natPolicy.getStunServer());
} }
mProxyPreference = (EditTextPreference) advanced.getPreference(3); mProxyPreference = (EditTextPreference) advanced.getPreference(3);
mProxyPreference.setOnPreferenceChangeListener(proxyChangedListener); mProxyPreference.setOnPreferenceChangeListener(mProxyChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
mProxyPreference.setText(mPrefs.getAccountProxy(n)); mProxyPreference.setText(mPrefs.getAccountProxy(mN));
mProxyPreference.setSummary( mProxyPreference.setSummary(
"".equals(mProxyPreference.getText()) || (mProxyPreference.getText() == null) "".equals(mProxyPreference.getText()) || (mProxyPreference.getText() == null)
? getString(R.string.pref_help_proxy) ? getString(R.string.pref_help_proxy)
@ -443,52 +439,52 @@ public class AccountPreferencesFragment extends PreferencesListFragment
} }
CheckBoxPreference outboundProxy = (CheckBoxPreference) advanced.getPreference(4); CheckBoxPreference outboundProxy = (CheckBoxPreference) advanced.getPreference(4);
outboundProxy.setOnPreferenceChangeListener(outboundProxyChangedListener); outboundProxy.setOnPreferenceChangeListener(mOutboundProxyChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
outboundProxy.setChecked(mPrefs.isAccountOutboundProxySet(n)); outboundProxy.setChecked(mPrefs.isAccountOutboundProxySet(mN));
} }
EditTextPreference expires = (EditTextPreference) advanced.getPreference(5); EditTextPreference expires = (EditTextPreference) advanced.getPreference(5);
expires.setOnPreferenceChangeListener(expiresChangedListener); expires.setOnPreferenceChangeListener(mExpiresChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
expires.setText(mPrefs.getExpires(n)); expires.setText(mPrefs.getExpires(mN));
expires.setSummary(mPrefs.getExpires(n)); expires.setSummary(mPrefs.getExpires(mN));
} }
EditTextPreference prefix = (EditTextPreference) advanced.getPreference(6); EditTextPreference prefix = (EditTextPreference) advanced.getPreference(6);
prefix.setOnPreferenceChangeListener(prefixChangedListener); prefix.setOnPreferenceChangeListener(mPrefixChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
String prefixValue = mPrefs.getPrefix(n); String prefixValue = mPrefs.getPrefix(mN);
prefix.setText(prefixValue); prefix.setText(prefixValue);
prefix.setSummary(prefixValue); prefix.setSummary(prefixValue);
} }
CheckBoxPreference avpf = (CheckBoxPreference) advanced.getPreference(7); CheckBoxPreference avpf = (CheckBoxPreference) advanced.getPreference(7);
avpf.setOnPreferenceChangeListener(avpfChangedListener); avpf.setOnPreferenceChangeListener(mAvpfChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
avpf.setChecked(mPrefs.avpfEnabled(n)); avpf.setChecked(mPrefs.avpfEnabled(mN));
} }
EditTextPreference avpfRRInterval = (EditTextPreference) advanced.getPreference(8); EditTextPreference avpfRRInterval = (EditTextPreference) advanced.getPreference(8);
avpfRRInterval.setOnPreferenceChangeListener(avpfRRIntervalChangedListener); avpfRRInterval.setOnPreferenceChangeListener(mAvpfRRIntervalChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
avpfRRInterval.setText(mPrefs.getAvpfRrInterval(n)); avpfRRInterval.setText(mPrefs.getAvpfRrInterval(mN));
avpfRRInterval.setSummary(mPrefs.getAvpfRrInterval(n)); avpfRRInterval.setSummary(mPrefs.getAvpfRrInterval(mN));
} }
CheckBoxPreference escape = (CheckBoxPreference) advanced.getPreference(9); CheckBoxPreference escape = (CheckBoxPreference) advanced.getPreference(9);
escape.setOnPreferenceChangeListener(escapeChangedListener); escape.setOnPreferenceChangeListener(mEscapeChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
escape.setChecked(mPrefs.getReplacePlusByZeroZero(n)); escape.setChecked(mPrefs.getReplacePlusByZeroZero(mN));
} }
Preference linkAccount = advanced.getPreference(10); Preference linkAccount = advanced.getPreference(10);
linkAccount.setOnPreferenceClickListener(linkAccountListener); linkAccount.setOnPreferenceClickListener(linkAccountListener);
CheckBoxPreference pushNotif = (CheckBoxPreference) advanced.getPreference(11); CheckBoxPreference pushNotif = (CheckBoxPreference) advanced.getPreference(11);
pushNotif.setOnPreferenceChangeListener(pushNotificationListener); pushNotif.setOnPreferenceChangeListener(mPushNotificationListener);
if (!isNewAccount) { if (!mIsNewAccount) {
pushNotif.setChecked(mPrefs.isPushNotifEnabledForProxy(n)); pushNotif.setChecked(mPrefs.isPushNotifEnabledForProxy(mN));
} }
PreferenceCategory manage = PreferenceCategory manage =
@ -496,9 +492,9 @@ public class AccountPreferencesFragment extends PreferencesListFragment
getPreferenceScreen().findPreference(getString(R.string.pref_manage_key)); getPreferenceScreen().findPreference(getString(R.string.pref_manage_key));
final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0); final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0);
disable.setEnabled(true); disable.setEnabled(true);
disable.setOnPreferenceChangeListener(disableChangedListener); disable.setOnPreferenceChangeListener(mDisableChangedListener);
if (!isNewAccount) { if (!mIsNewAccount) {
disable.setChecked(!mPrefs.isAccountEnabled(n)); disable.setChecked(!mPrefs.isAccountEnabled(mN));
} }
CheckBoxPreference mainAccount = (CheckBoxPreference) manage.getPreference(1); CheckBoxPreference mainAccount = (CheckBoxPreference) manage.getPreference(1);
@ -507,14 +503,14 @@ public class AccountPreferencesFragment extends PreferencesListFragment
mainAccount.setOnPreferenceClickListener( mainAccount.setOnPreferenceClickListener(
new OnPreferenceClickListener() { new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
mPrefs.setDefaultAccount(n); mPrefs.setDefaultAccount(mN);
disable.setEnabled(false); disable.setEnabled(false);
disable.setChecked(false); disable.setChecked(false);
preference.setEnabled(false); preference.setEnabled(false);
return true; return true;
} }
}); });
if (!isNewAccount) { if (!mIsNewAccount) {
mainAccount.setEnabled(!mainAccount.isChecked()); mainAccount.setEnabled(!mainAccount.isChecked());
} }
@ -522,11 +518,11 @@ public class AccountPreferencesFragment extends PreferencesListFragment
changePassword.setEnabled(false); changePassword.setEnabled(false);
final Preference delete = manage.getPreference(3); final Preference delete = manage.getPreference(3);
delete.setEnabled(!isNewAccount); delete.setEnabled(!mIsNewAccount);
delete.setOnPreferenceClickListener( delete.setOnPreferenceClickListener(
new OnPreferenceClickListener() { new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
mPrefs.deleteAccount(n); mPrefs.deleteAccount(mN);
LinphoneActivity.instance().displaySettings(); LinphoneActivity.instance().displaySettings();
LinphoneActivity.instance().refreshAccounts(); LinphoneActivity.instance().refreshAccounts();
return true; return true;
@ -548,10 +544,10 @@ public class AccountPreferencesFragment extends PreferencesListFragment
} }
setListPreferenceValues(pref, entries, values); setListPreferenceValues(pref, entries, values);
if (!isNewAccount) { if (!mIsNewAccount) {
pref.setSummary(mPrefs.getAccountTransportString(n)); pref.setSummary(mPrefs.getAccountTransportString(mN));
pref.setDefaultValue(mPrefs.getAccountTransportKey(n)); pref.setDefaultValue(mPrefs.getAccountTransportKey(mN));
pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(n))); pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(mN)));
} else { } else {
pref.setSummary(getString(R.string.pref_transport_udp)); pref.setSummary(getString(R.string.pref_transport_udp));
@ -574,8 +570,8 @@ public class AccountPreferencesFragment extends PreferencesListFragment
super.onPause(); super.onPause();
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
try { try {
if (isNewAccount) { if (mIsNewAccount) {
builder.saveNewAccount(); mBuilder.saveNewAccount();
} }
} catch (CoreException e) { } catch (CoreException e) {
Log.e(e); Log.e(e);
@ -589,14 +585,13 @@ public class AccountPreferencesFragment extends PreferencesListFragment
@Override @Override
public void onUpdateAccount( public void onUpdateAccount(
AccountCreator accountCreator, AccountCreator.Status status, String resp) { AccountCreator accountCreator, AccountCreator.Status status, String resp) {
if (progress != null) progress.dismiss();
if (status.equals(AccountCreator.Status.RequestOk)) { if (status.equals(AccountCreator.Status.RequestOk)) {
mPrefs.setAccountPassword(n, accountCreator.getPassword()); mPrefs.setAccountPassword(mN, accountCreator.getPassword());
PreferenceCategory account = PreferenceCategory account =
(PreferenceCategory) (PreferenceCategory)
getPreferenceScreen() getPreferenceScreen()
.findPreference(getString(R.string.pref_sipaccount_key)); .findPreference(getString(R.string.pref_sipaccount_key));
((EditTextPreference) account.getPreference(2)).setText(mPrefs.getAccountPassword(n)); ((EditTextPreference) account.getPreference(2)).setText(mPrefs.getAccountPassword(mN));
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
getString(R.string.pref_password_changed), LinphoneActivity.instance()); getString(R.string.pref_password_changed), LinphoneActivity.instance());
} else { } else {

View file

@ -52,24 +52,25 @@ import org.linphone.utils.LinphoneUtils;
public class LinphonePreferences { public class LinphonePreferences {
private static final int LINPHONE_CORE_RANDOM_PORT = -1; private static final int LINPHONE_CORE_RANDOM_PORT = -1;
private static LinphonePreferences instance; private static LinphonePreferences sInstance;
private Context mContext; private Context mContext;
private String basePath; private String mBasePath;
// Tunnel settings // Tunnel settings
private TunnelConfig tunnelConfig = null; private TunnelConfig mTunnelConfig = null;
private LinphonePreferences() {} private LinphonePreferences() {}
public static final synchronized LinphonePreferences instance() { public static final synchronized LinphonePreferences instance() {
if (instance == null) { if (sInstance == null) {
instance = new LinphonePreferences(); sInstance = new LinphonePreferences();
} }
return instance; return sInstance;
} }
public void setContext(Context c) { public void setContext(Context c) {
mContext = c; mContext = c;
basePath = mContext.getFilesDir().getAbsolutePath(); mBasePath = mContext.getFilesDir().getAbsolutePath();
} }
private String getString(int key) { private String getString(int key) {
@ -93,7 +94,7 @@ public class LinphonePreferences {
} }
if (!LinphoneManager.isInstanciated()) { if (!LinphoneManager.isInstanciated()) {
File linphonerc = new File(basePath + "/.linphonerc"); File linphonerc = new File(mBasePath + "/.linphonerc");
if (linphonerc.exists()) { if (linphonerc.exists()) {
return Factory.instance().createConfig(linphonerc.getAbsolutePath()); return Factory.instance().createConfig(linphonerc.getAbsolutePath());
} else if (mContext != null) { } else if (mContext != null) {
@ -114,15 +115,11 @@ public class LinphonePreferences {
return Factory.instance().createConfigFromString(text.toString()); return Factory.instance().createConfigFromString(text.toString());
} }
} else { } else {
return Factory.instance().createConfig(LinphoneManager.getInstance().mConfigFile); return Factory.instance().createConfig(LinphoneManager.getInstance().configFile);
} }
return null; return null;
} }
public void removePreviousVersionAuthInfoRemoval() {
getConfig().setBool("sip", "store_auth_info", true);
}
// App settings // App settings
public boolean isFirstLaunch() { public boolean isFirstLaunch() {
return getConfig().getBool("app", "first_launch", true); return getConfig().getBool("app", "first_launch", true);
@ -138,15 +135,6 @@ public class LinphonePreferences {
return ringtone; return ringtone;
} }
public void setRingtone(String ringtonePath) {
getConfig().setString("app", "ringtone", ringtonePath);
}
// End of app settings
public boolean shouldAutomaticallyAcceptFriendsRequests() {
return false; // TODO
}
// Accounts settings // Accounts settings
private ProxyConfig getProxyConfig(int n) { private ProxyConfig getProxyConfig(int n) {
if (getLc() == null) return null; if (getLc() == null) return null;
@ -324,10 +312,6 @@ public class LinphonePreferences {
setAccountPassword(n, password, null); setAccountPassword(n, password, null);
} }
public void setAccountHa1(int n, String ha1) {
setAccountPassword(n, null, ha1);
}
private void setAccountPassword(int n, String password, String ha1) { private void setAccountPassword(int n, String password, String ha1) {
if (getLc() == null) return; if (getLc() == null) return;
String user = getAccountUsername(n); String user = getAccountUsername(n);
@ -387,11 +371,6 @@ public class LinphonePreferences {
} }
} }
public String getAccountStunServer(int n) {
if (getProxyConfig(n) == null || getProxyConfig(n).getNatPolicy() == null) return "";
return getProxyConfig(n).getNatPolicy().getStunServer();
}
public void setAccountDomain(int n, String domain) { public void setAccountDomain(int n, String domain) {
String identity = "sip:" + getAccountUsername(n) + "@" + domain; String identity = "sip:" + getAccountUsername(n) + "@" + domain;
AuthInfo old_info = getAuthInfo(n); AuthInfo old_info = getAuthInfo(n);
@ -661,13 +640,6 @@ public class LinphonePreferences {
return getConfig().getInt("sound", "ec_delay", -1); return getConfig().getInt("sound", "ec_delay", -1);
} }
public boolean isEchoConfigurationUpdated() {
return getConfig().getBool("app", "ec_updated", false);
}
public void echoConfigurationUpdated() {
getConfig().setBool("app", "ec_updated", true);
}
// End of audio settings // End of audio settings
// Video settings // Video settings
@ -796,16 +768,6 @@ public class LinphonePreferences {
getLc().setIncTimeout(timeout); getLc().setIncTimeout(timeout);
} }
public int getInCallTimeout() {
if (getLc() == null) return 0;
return getLc().getInCallTimeout();
}
public void setInCallTimeout(int timeout) {
if (getLc() == null) return;
getLc().setInCallTimeout(timeout);
}
public String getVoiceMailUri() { public String getVoiceMailUri() {
return getConfig().getString("app", "voice_mail", null); return getConfig().getString("app", "voice_mail", null);
} }
@ -892,11 +854,6 @@ public class LinphonePreferences {
getLc().setNatPolicy(nat); getLc().setNatPolicy(nat);
} }
public boolean isUpnpEnabled() {
NatPolicy nat = getOrCreateNatPolicy();
return nat.upnpEnabled();
}
public void setUpnpEnabled(boolean enabled) { public void setUpnpEnabled(boolean enabled) {
if (getLc() == null) return; if (getLc() == null) return;
NatPolicy nat = getOrCreateNatPolicy(); NatPolicy nat = getOrCreateNatPolicy();
@ -1169,15 +1126,15 @@ public class LinphonePreferences {
if (getLc() == null) return null; if (getLc() == null) return null;
if (getLc().tunnelAvailable()) { if (getLc().tunnelAvailable()) {
Tunnel tunnel = getLc().getTunnel(); Tunnel tunnel = getLc().getTunnel();
if (tunnelConfig == null) { if (mTunnelConfig == null) {
TunnelConfig servers[] = tunnel.getServers(); TunnelConfig servers[] = tunnel.getServers();
if (servers.length > 0) { if (servers.length > 0) {
tunnelConfig = servers[0]; mTunnelConfig = servers[0];
} else { } else {
tunnelConfig = Factory.instance().createTunnelConfig(); mTunnelConfig = Factory.instance().createTunnelConfig();
} }
} }
return tunnelConfig; return mTunnelConfig;
} else { } else {
return null; return null;
} }
@ -1240,10 +1197,6 @@ public class LinphonePreferences {
} }
} }
public void firstRemoteProvisioningSuccessful() {
getConfig().setBool("app", "first_remote_provisioning", false);
}
public boolean isFirstRemoteProvisioning() { public boolean isFirstRemoteProvisioning() {
return getConfig().getBool("app", "first_remote_provisioning", true); return getConfig().getBool("app", "first_remote_provisioning", true);
} }
@ -1266,14 +1219,6 @@ public class LinphonePreferences {
getConfig().setInt("audio", "codec_bitrate_limit", bitrate); getConfig().setInt("audio", "codec_bitrate_limit", bitrate);
} }
public void contactsMigrationDone() {
getConfig().setBool("app", "contacts_migration_done", true);
}
public boolean isContactsMigrationDone() {
return getConfig().getBool("app", "contacts_migration_done", false);
}
public String getInAppPurchaseValidatingServerUrl() { public String getInAppPurchaseValidatingServerUrl() {
return getConfig().getString("in-app-purchase", "server_url", null); return getConfig().getString("in-app-purchase", "server_url", null);
} }
@ -1437,10 +1382,6 @@ public class LinphonePreferences {
return getConfig().getBool("app", "bis_feature", true); return getConfig().getBool("app", "bis_feature", true);
} }
public void enableBisFeature(boolean enable) {
getConfig().setBool("app", "bis_feature", enable);
}
public boolean isAutoAnswerEnabled() { public boolean isAutoAnswerEnabled() {
return getConfig().getBool("app", "auto_answer", false); return getConfig().getBool("app", "auto_answer", false);
} }
@ -1465,14 +1406,6 @@ public class LinphonePreferences {
getConfig().setBool("misc", "store_friends", false); getConfig().setBool("misc", "store_friends", false);
} }
public void enableFriendsStorage() {
getConfig().setBool("misc", "store_friends", true);
}
public boolean isFriendsStorageEnabled() {
return getConfig().getBool("misc", "store_friends", true);
}
public boolean useBasicChatRoomFor1To1() { public boolean useBasicChatRoomFor1To1() {
return getConfig().getBool("app", "prefer_basic_chat_room", false); return getConfig().getBool("app", "prefer_basic_chat_room", false);
} }
@ -1496,15 +1429,11 @@ public class LinphonePreferences {
private String tempHa1; private String tempHa1;
private String tempDomain; private String tempDomain;
private String tempProxy; private String tempProxy;
private String tempRealm;
private String tempPrefix; private String tempPrefix;
private boolean tempOutboundProxy; private boolean tempOutboundProxy;
private String tempContactsParams;
private String tempExpire; private String tempExpire;
private TransportType tempTransport; private TransportType tempTransport;
private boolean tempAvpfEnabled = false;
private int tempAvpfRRInterval = 0; private int tempAvpfRRInterval = 0;
private String tempQualityReportingCollector;
private boolean tempQualityReportingEnabled = false; private boolean tempQualityReportingEnabled = false;
private int tempQualityReportingInterval = 0; private int tempQualityReportingInterval = 0;
private boolean tempEnabled = true; private boolean tempEnabled = true;
@ -1554,11 +1483,6 @@ public class LinphonePreferences {
return this; return this;
} }
public AccountBuilder setContactParameters(String contactParams) {
tempContactsParams = contactParams;
return this;
}
public AccountBuilder setExpires(String expire) { public AccountBuilder setExpires(String expire) {
tempExpire = expire; tempExpire = expire;
return this; return this;
@ -1569,51 +1493,21 @@ public class LinphonePreferences {
return this; return this;
} }
public AccountBuilder setAvpfEnabled(boolean enable) {
tempAvpfEnabled = enable;
return this;
}
public AccountBuilder setAvpfRrInterval(int interval) { public AccountBuilder setAvpfRrInterval(int interval) {
tempAvpfRRInterval = interval; tempAvpfRRInterval = interval;
return this; return this;
} }
public AccountBuilder setRealm(String realm) {
tempRealm = realm;
return this;
}
public AccountBuilder setQualityReportingCollector(String collector) {
tempQualityReportingCollector = collector;
return this;
}
public AccountBuilder setPrefix(String prefix) { public AccountBuilder setPrefix(String prefix) {
tempPrefix = prefix; tempPrefix = prefix;
return this; return this;
} }
public AccountBuilder setQualityReportingEnabled(boolean enable) {
tempQualityReportingEnabled = enable;
return this;
}
public AccountBuilder setQualityReportingInterval(int interval) {
tempQualityReportingInterval = interval;
return this;
}
public AccountBuilder setEnabled(boolean enable) { public AccountBuilder setEnabled(boolean enable) {
tempEnabled = enable; tempEnabled = enable;
return this; return this;
} }
public AccountBuilder setNoDefault(boolean yesno) {
tempNoDefault = yesno;
return this;
}
/** /**
* Creates a new account * Creates a new account
* *
@ -1666,7 +1560,6 @@ public class LinphonePreferences {
prxCfg.setRoute(route); prxCfg.setRoute(route);
prxCfg.enableRegister(tempEnabled); prxCfg.enableRegister(tempEnabled);
if (tempContactsParams != null) prxCfg.setContactUriParameters(tempContactsParams);
if (tempExpire != null) { if (tempExpire != null) {
prxCfg.setExpires(Integer.parseInt(tempExpire)); prxCfg.setExpires(Integer.parseInt(tempExpire));
} }
@ -1674,7 +1567,6 @@ public class LinphonePreferences {
prxCfg.setAvpfMode(AVPFMode.Enabled); prxCfg.setAvpfMode(AVPFMode.Enabled);
prxCfg.setAvpfRrInterval(tempAvpfRRInterval); prxCfg.setAvpfRrInterval(tempAvpfRRInterval);
prxCfg.enableQualityReporting(tempQualityReportingEnabled); prxCfg.enableQualityReporting(tempQualityReportingEnabled);
prxCfg.setQualityReportingCollector(tempQualityReportingCollector);
prxCfg.setQualityReportingInterval(tempQualityReportingInterval); prxCfg.setQualityReportingInterval(tempQualityReportingInterval);
String regId = LinphonePreferences.instance().getPushNotificationRegistrationID(); String regId = LinphonePreferences.instance().getPushNotificationRegistrationID();
@ -1695,8 +1587,6 @@ public class LinphonePreferences {
prxCfg.setDialPrefix(tempPrefix); prxCfg.setDialPrefix(tempPrefix);
} }
if (tempRealm != null) prxCfg.setRealm(tempRealm);
AuthInfo authInfo = AuthInfo authInfo =
Factory.instance() Factory.instance()
.createAuthInfo( .createAuthInfo(
@ -1704,7 +1594,7 @@ public class LinphonePreferences {
tempUserId, tempUserId,
tempPassword, tempPassword,
tempHa1, tempHa1,
tempRealm, null,
tempDomain); tempDomain);
lc.addProxyConfig(prxCfg); lc.addProxyConfig(prxCfg);

View file

@ -48,8 +48,9 @@ public class PreferencesListFragment extends ListFragment {
private static final int FIRST_REQUEST_CODE = 100; private static final int FIRST_REQUEST_CODE = 100;
private static final int MSG_BIND_PREFERENCES = 0; private static final int MSG_BIND_PREFERENCES = 0;
private PreferenceManager mPreferenceManager; private PreferenceManager mPreferenceManager;
private ListView preferencesList; private ListView mPreferencesList;
private Handler mHandler = private Handler mHandler =
new Handler() { new Handler() {
@Override @Override
@ -61,10 +62,10 @@ public class PreferencesListFragment extends ListFragment {
} }
} }
}; };
private int xmlResID; private int mXmlResID;
public PreferencesListFragment(int xmlId) { public PreferencesListFragment(int xmlId) {
this.xmlResID = xmlId; mXmlResID = xmlId;
} }
// Must be provided // Must be provided
@ -75,13 +76,13 @@ public class PreferencesListFragment extends ListFragment {
// Hack to correctly display preferences // Hack to correctly display preferences
View view = inflater.inflate(R.layout.settings, null); View view = inflater.inflate(R.layout.settings, null);
ViewParent p = preferencesList.getParent(); ViewParent p = mPreferencesList.getParent();
if (p != null) { if (p != null) {
((ViewGroup) p).removeView(preferencesList); ((ViewGroup) p).removeView(mPreferencesList);
} }
RelativeLayout layout = view.findViewById(R.id.topLayout); RelativeLayout layout = view.findViewById(R.id.topLayout);
layout.addView(preferencesList); layout.addView(mPreferencesList);
postBindPreferences(); postBindPreferences();
return view; return view;
@ -90,9 +91,9 @@ public class PreferencesListFragment extends ListFragment {
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
ViewParent p = preferencesList.getParent(); ViewParent p = mPreferencesList.getParent();
if (p != null) { if (p != null) {
((ViewGroup) p).removeView(preferencesList); ((ViewGroup) p).removeView(mPreferencesList);
} }
} }
@ -101,16 +102,16 @@ public class PreferencesListFragment extends ListFragment {
super.onCreate(bundle); super.onCreate(bundle);
if (bundle != null) { if (bundle != null) {
xmlResID = bundle.getInt("xml"); mXmlResID = bundle.getInt("xml");
} }
mPreferenceManager = onCreatePreferenceManager(); mPreferenceManager = onCreatePreferenceManager();
preferencesList = mPreferencesList =
(ListView) (ListView)
LayoutInflater.from(getActivity()) LayoutInflater.from(getActivity())
.inflate(R.layout.preference_list_content, null); .inflate(R.layout.preference_list_content, null);
preferencesList.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); mPreferencesList.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
addPreferencesFromResource(xmlResID); addPreferencesFromResource(mXmlResID);
postBindPreferences(); postBindPreferences();
} }
@ -129,7 +130,7 @@ public class PreferencesListFragment extends ListFragment {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
preferencesList = null; mPreferencesList = null;
try { try {
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy"); Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy");
m.setAccessible(true); m.setAccessible(true);
@ -141,7 +142,7 @@ public class PreferencesListFragment extends ListFragment {
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
outState.putInt("xml", xmlResID); outState.putInt("xml", mXmlResID);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@ -172,8 +173,8 @@ public class PreferencesListFragment extends ListFragment {
private void bindPreferences() { private void bindPreferences() {
final PreferenceScreen preferenceScreen = getPreferenceScreen(); final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null && preferencesList != null) { if (preferenceScreen != null && mPreferencesList != null) {
preferenceScreen.bind(preferencesList); preferenceScreen.bind(mPreferencesList);
} }
} }

View file

@ -71,12 +71,12 @@ public class SettingsFragment extends PreferencesListFragment {
private LinphonePreferences mPrefs; private LinphonePreferences mPrefs;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private CoreListenerStub mListener; private CoreListenerStub mListener;
private PreferenceScreen currentPreferenceScreen; private PreferenceScreen mCurrentPreferenceScreen;
private Preference.OnPreferenceClickListener prefClickListener = private Preference.OnPreferenceClickListener mPrefClickListener =
new Preference.OnPreferenceClickListener() { new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
currentPreferenceScreen = (PreferenceScreen) preference; mCurrentPreferenceScreen = (PreferenceScreen) preference;
return false; return false;
} }
}; };
@ -96,9 +96,9 @@ public class SettingsFragment extends PreferencesListFragment {
} }
public void closePreferenceScreen() { public void closePreferenceScreen() {
if (currentPreferenceScreen != null && currentPreferenceScreen.getDialog() != null) { if (mCurrentPreferenceScreen != null && mCurrentPreferenceScreen.getDialog() != null) {
currentPreferenceScreen.getDialog().dismiss(); mCurrentPreferenceScreen.getDialog().dismiss();
currentPreferenceScreen = null; mCurrentPreferenceScreen = null;
} }
} }
@ -192,19 +192,19 @@ public class SettingsFragment extends PreferencesListFragment {
// Sets listener for each preference to update the matching value in linphonecore // Sets listener for each preference to update the matching value in linphonecore
private void setListeners() { private void setListeners() {
findPreference(getString(R.string.pref_tunnel_key)) findPreference(getString(R.string.pref_tunnel_key))
.setOnPreferenceClickListener(prefClickListener); .setOnPreferenceClickListener(mPrefClickListener);
findPreference(getString(R.string.pref_audio_key)) findPreference(getString(R.string.pref_audio_key))
.setOnPreferenceClickListener(prefClickListener); .setOnPreferenceClickListener(mPrefClickListener);
findPreference(getString(R.string.pref_video_key)) findPreference(getString(R.string.pref_video_key))
.setOnPreferenceClickListener(prefClickListener); .setOnPreferenceClickListener(mPrefClickListener);
findPreference(getString(R.string.pref_call_key)) findPreference(getString(R.string.pref_call_key))
.setOnPreferenceClickListener(prefClickListener); .setOnPreferenceClickListener(mPrefClickListener);
findPreference(getString(R.string.pref_chat_key)) findPreference(getString(R.string.pref_chat_key))
.setOnPreferenceClickListener(prefClickListener); .setOnPreferenceClickListener(mPrefClickListener);
findPreference(getString(R.string.pref_network_key)) findPreference(getString(R.string.pref_network_key))
.setOnPreferenceClickListener(prefClickListener); .setOnPreferenceClickListener(mPrefClickListener);
findPreference(getString(R.string.pref_advanced_key)) findPreference(getString(R.string.pref_advanced_key))
.setOnPreferenceClickListener(prefClickListener); .setOnPreferenceClickListener(mPrefClickListener);
setTunnelPreferencesListener(); setTunnelPreferencesListener();
setAudioPreferencesListener(); setAudioPreferencesListener();

View file

@ -60,23 +60,19 @@ import org.linphone.core.LoggingService;
import org.linphone.core.LoggingServiceListener; import org.linphone.core.LoggingServiceListener;
import org.linphone.core.ProxyConfig; import org.linphone.core.ProxyConfig;
import org.linphone.mediastream.Log; import org.linphone.mediastream.Log;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
import org.linphone.settings.LinphonePreferences; import org.linphone.settings.LinphonePreferences;
/** Helpers. */ /** Helpers. */
public final class LinphoneUtils { public final class LinphoneUtils {
private static Context context = null; private static Context sContext = null;
private static Handler mHandler = new Handler(Looper.getMainLooper()); private static Handler sHandler = new Handler(Looper.getMainLooper());
private LinphoneUtils() {} private LinphoneUtils() {}
public static String getDeviceName(Context context) { public static String getDeviceName(Context context) {
String name = null; String name =
if (Build.VERSION.SDK_INT > 17) { Settings.Global.getString(
name = context.getContentResolver(), Settings.Global.DEVICE_NAME);
Settings.Global.getString(
context.getContentResolver(), Settings.Global.DEVICE_NAME);
}
if (name == null) { if (name == null) {
name = BluetoothAdapter.getDefaultAdapter().getName(); name = BluetoothAdapter.getDefaultAdapter().getName();
} }
@ -131,7 +127,7 @@ public final class LinphoneUtils {
} }
public static void dispatchOnUIThread(Runnable r) { public static void dispatchOnUIThread(Runnable r) {
mHandler.post(r); sHandler.post(r);
} }
// private static final String sipAddressRegExp = // private static final String sipAddressRegExp =
@ -230,12 +226,6 @@ public final class LinphoneUtils {
} }
public static boolean onKeyVolumeAdjust(int keyCode) { public static boolean onKeyVolumeAdjust(int keyCode) {
if (!((keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
&& (Hacks.needSoftvolume())
|| Build.VERSION.SDK_INT >= 15)) {
return false; // continue
}
if (!LinphoneService.isReady()) { if (!LinphoneService.isReady()) {
Log.i("Couldn't change softvolume has service is not running"); Log.i("Couldn't change softvolume has service is not running");
return true; return true;
@ -527,8 +517,8 @@ public final class LinphoneUtils {
} }
private static Context getContext() { private static Context getContext() {
if (context == null && LinphoneManager.isInstanciated()) if (sContext == null && LinphoneManager.isInstanciated())
context = LinphoneManager.getInstance().getContext(); sContext = LinphoneManager.getInstance().getContext();
return context; return sContext;
} }
} }

View file

@ -1,18 +1,37 @@
package org.linphone.utils; package org.linphone.utils;
/*
MediaScanner.java
Copyright (C) 2018 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import android.content.Context; import android.content.Context;
import android.media.MediaScannerConnection; import android.media.MediaScannerConnection;
import android.net.Uri; import android.net.Uri;
import java.io.File; import java.io.File;
import org.linphone.mediastream.Log; import org.linphone.mediastream.Log;
public class LinphoneMediaScanner implements MediaScannerConnection.MediaScannerConnectionClient { public class MediaScanner implements MediaScannerConnection.MediaScannerConnectionClient {
private MediaScannerConnection mMediaConnection; private MediaScannerConnection mMediaConnection;
private boolean mIsConnected; private boolean mIsConnected;
private File mFileWaitingForScan; private File mFileWaitingForScan;
private MediaScannerListener mListener; private MediaScannerListener mListener;
public LinphoneMediaScanner(Context context) { public MediaScanner(Context context) {
mIsConnected = false; mIsConnected = false;
mMediaConnection = new MediaScannerConnection(context, this); mMediaConnection = new MediaScannerConnection(context, this);
mMediaConnection.connect(); mMediaConnection.connect();

View file

@ -32,9 +32,9 @@ import org.linphone.fragments.DialerFragment;
@SuppressLint("AppCompatCustomView") @SuppressLint("AppCompatCustomView")
public class AddressText extends EditText implements AddressType { public class AddressText extends EditText implements AddressType {
private String displayedName; private String mDisplayedName;
private Paint mTestPaint; private Paint mTestPaint;
private DialerFragment dialer; private DialerFragment mDialer;
public AddressText(Context context, AttributeSet attrs) { public AddressText(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
@ -44,15 +44,15 @@ public class AddressText extends EditText implements AddressType {
} }
public void clearDisplayedName() { public void clearDisplayedName() {
displayedName = null; mDisplayedName = null;
} }
public String getDisplayedName() { public String getDisplayedName() {
return displayedName; return mDisplayedName;
} }
public void setDisplayedName(String displayedName) { public void setDisplayedName(String displayedName) {
this.displayedName = displayedName; this.mDisplayedName = displayedName;
} }
private String getHintText() { private String getHintText() {
@ -69,8 +69,8 @@ public class AddressText extends EditText implements AddressType {
refitText(getWidth(), getHeight()); refitText(getWidth(), getHeight());
if (dialer != null) { if (mDialer != null) {
dialer.enableDisableAddContact(); mDialer.enableDisableAddContact();
} }
super.onTextChanged(text, start, before, after); super.onTextChanged(text, start, before, after);
@ -126,6 +126,6 @@ public class AddressText extends EditText implements AddressType {
} }
public void setDialerFragment(DialerFragment dialerFragment) { public void setDialerFragment(DialerFragment dialerFragment) {
dialer = dialerFragment; mDialer = dialerFragment;
} }
} }

View file

@ -25,14 +25,14 @@ import android.graphics.drawable.BitmapDrawable;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
public class AsyncBitmap extends BitmapDrawable { public class AsyncBitmap extends BitmapDrawable {
private final WeakReference<BitmapWorkerTask> bitmapWorkerTaskReference; private final WeakReference<BitmapWorkerTask> mBitmapWorkerTaskReference;
public AsyncBitmap(Resources res, Bitmap bitmap, BitmapWorkerTask bitmapWorkerTask) { public AsyncBitmap(Resources res, Bitmap bitmap, BitmapWorkerTask bitmapWorkerTask) {
super(res, bitmap); super(res, bitmap);
bitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask); mBitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask);
} }
public BitmapWorkerTask getBitmapWorkerTask() { public BitmapWorkerTask getBitmapWorkerTask() {
return bitmapWorkerTaskReference.get(); return mBitmapWorkerTaskReference.get();
} }
} }

View file

@ -39,8 +39,9 @@ import org.linphone.utils.FileUtils;
import org.linphone.utils.ImageUtils; import org.linphone.utils.ImageUtils;
public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> { public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
public String path; public String path;
private final WeakReference<ImageView> mImageViewReference;
private Context mContext; private Context mContext;
private Bitmap mDefaultBitmap; private Bitmap mDefaultBitmap;
@ -49,7 +50,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
mDefaultBitmap = defaultBitmap; mDefaultBitmap = defaultBitmap;
path = null; path = null;
// Use a WeakReference to ensure the ImageView can be garbage collected // Use a WeakReference to ensure the ImageView can be garbage collected
imageViewReference = new WeakReference<>(imageView); mImageViewReference = new WeakReference<>(imageView);
} }
public static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) { public static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) {
@ -93,7 +94,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
bm = BitmapFactory.decodeFile(path); bm = BitmapFactory.decodeFile(path);
} }
ImageView imageView = imageViewReference.get(); ImageView imageView = mImageViewReference.get();
try { try {
// Rotate the bitmap if possible/needed, using EXIF data // Rotate the bitmap if possible/needed, using EXIF data
@ -145,8 +146,8 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
bitmap.recycle(); bitmap.recycle();
bitmap = null; bitmap = null;
} }
if (imageViewReference != null && bitmap != null) { if (mImageViewReference != null && bitmap != null) {
final ImageView imageView = imageViewReference.get(); final ImageView imageView = mImageViewReference.get();
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
if (this == bitmapWorkerTask && imageView != null) { if (this == bitmapWorkerTask && imageView != null) {
imageView.setImageBitmap(bitmap); imageView.setImageBitmap(bitmap);

View file

@ -25,9 +25,7 @@ import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Toast;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.core.Call; import org.linphone.core.Call;
import org.linphone.core.CallLog; import org.linphone.core.CallLog;
import org.linphone.core.ProxyConfig; import org.linphone.core.ProxyConfig;
@ -83,15 +81,4 @@ public class CallButton extends ImageView implements OnClickListener, AddressAwa
} }
} }
} }
protected void onWrongDestinationAddress() {
Toast.makeText(
getContext(),
String.format(
getResources()
.getString(R.string.warning_wrong_destination_address),
mAddress.getText().toString()),
Toast.LENGTH_LONG)
.show();
}
} }

View file

@ -29,8 +29,8 @@ import org.linphone.R;
import org.linphone.contacts.ContactAddress; import org.linphone.contacts.ContactAddress;
public class ContactSelectView extends View { public class ContactSelectView extends View {
private TextView contactName; private TextView mContactName;
private ImageView deleteContact; private ImageView mDeleteContact;
public ContactSelectView(Context context) { public ContactSelectView(Context context) {
super(context); super(context);
@ -40,22 +40,22 @@ public class ContactSelectView extends View {
View view = inflater.inflate(R.layout.contact_selected, null); View view = inflater.inflate(R.layout.contact_selected, null);
contactName = view.findViewById(R.id.sipUri); mContactName = view.findViewById(R.id.sipUri);
deleteContact = view.findViewById(R.id.contactChatDelete); mDeleteContact = view.findViewById(R.id.contactChatDelete);
} }
public void setContactName(ContactAddress ca) { public void setContactName(ContactAddress ca) {
if (ca.getContact() != null) { if (ca.getContact() != null) {
contactName.setText(ca.getContact().getFirstName()); mContactName.setText(ca.getContact().getFirstName());
} else { } else {
LinphoneManager.getLc() LinphoneManager.getLc()
.createFriendWithAddress(ca.getAddressAsDisplayableString()) .createFriendWithAddress(ca.getAddressAsDisplayableString())
.getName(); .getName();
contactName.setText(ca.getAddressAsDisplayableString()); mContactName.setText(ca.getAddressAsDisplayableString());
} }
} }
public void setListener(OnClickListener listener) { public void setListener(OnClickListener listener) {
deleteContact.setOnClickListener(listener); mDeleteContact.setOnClickListener(listener);
} }
} }

View file

@ -32,7 +32,7 @@ import android.widget.ImageView;
public class EraseButton extends ImageView public class EraseButton extends ImageView
implements AddressAware, OnClickListener, OnLongClickListener, TextWatcher { implements AddressAware, OnClickListener, OnLongClickListener, TextWatcher {
private AddressText address; private AddressText mAddress;
public EraseButton(Context context, AttributeSet attrs) { public EraseButton(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
@ -41,24 +41,24 @@ public class EraseButton extends ImageView
} }
public void onClick(View v) { public void onClick(View v) {
if (address.getText().length() > 0) { if (mAddress.getText().length() > 0) {
int lBegin = address.getSelectionStart(); int lBegin = mAddress.getSelectionStart();
if (lBegin == -1) { if (lBegin == -1) {
lBegin = address.getEditableText().length() - 1; lBegin = mAddress.getEditableText().length() - 1;
} }
if (lBegin > 0) { if (lBegin > 0) {
address.getEditableText().delete(lBegin - 1, lBegin); mAddress.getEditableText().delete(lBegin - 1, lBegin);
} }
} }
} }
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
address.getEditableText().clear(); mAddress.getEditableText().clear();
return true; return true;
} }
public void setAddressWidget(AddressText view) { public void setAddressWidget(AddressText view) {
address = view; mAddress = view;
view.addTextChangedListener(this); view.addTextChangedListener(this);
} }

View file

@ -26,26 +26,26 @@ import android.widget.ImageView;
import org.linphone.R; import org.linphone.R;
public class LedPreference extends Preference { public class LedPreference extends Preference {
private int ledDrawable; private int mLedDrawable;
public LedPreference(Context context) { public LedPreference(Context context) {
super(context); super(context);
ledDrawable = R.drawable.led_disconnected; mLedDrawable = R.drawable.led_disconnected;
this.setWidgetLayoutResource(R.layout.preference_led); setWidgetLayoutResource(R.layout.preference_led);
} }
@Override @Override
protected void onBindView(final View view) { protected void onBindView(final View view) {
super.onBindView(view); super.onBindView(view);
final ImageView imageView = (ImageView) view.findViewById(R.id.led); final ImageView imageView = view.findViewById(R.id.led);
if (imageView != null) { if (imageView != null) {
imageView.setImageResource(ledDrawable); imageView.setImageResource(mLedDrawable);
} }
} }
public void setLed(int led) { public void setLed(int led) {
ledDrawable = led; mLedDrawable = led;
notifyChanged(); notifyChanged();
} }
} }

View file

@ -39,19 +39,16 @@ import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.AndroidVideoWindowImpl; import org.linphone.mediastream.video.AndroidVideoWindowImpl;
public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2JNIView { public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2JNIView {
private WindowManager wm; private WindowManager mWindowManager;
private WindowManager.LayoutParams params; private WindowManager.LayoutParams mParams;
private DisplayMetrics metrics; private DisplayMetrics mMetrics;
private float x; private float mX, mY, mTouchX, mTouchY;
private float y; private boolean mDragEnabled;
private float touchX; private AndroidVideoWindowImpl mAndroidVideoWindowImpl;
private float touchY;
private boolean dragEnabled;
private AndroidVideoWindowImpl androidVideoWindowImpl;
public LinphoneOverlay(Context context, AttributeSet attrs, int defStyle) { public LinphoneOverlay(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs); super(context, attrs);
wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int LAYOUT_FLAG; int LAYOUT_FLAG;
if (Build.VERSION.SDK_INT >= Version.API26_O_80) { if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
@ -60,18 +57,18 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_PHONE; LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_PHONE;
} }
params = mParams =
new WindowManager.LayoutParams( new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
LAYOUT_FLAG, LAYOUT_FLAG,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT); PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT; mParams.gravity = Gravity.TOP | Gravity.LEFT;
metrics = new DisplayMetrics(); mMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(metrics); mWindowManager.getDefaultDisplay().getMetrics(mMetrics);
androidVideoWindowImpl = mAndroidVideoWindowImpl =
new AndroidVideoWindowImpl( new AndroidVideoWindowImpl(
this, this,
null, null,
@ -92,9 +89,9 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
Call call = LinphoneManager.getLc().getCurrentCall(); Call call = LinphoneManager.getLc().getCurrentCall();
CallParams callParams = call.getCurrentParams(); CallParams callParams = call.getCurrentParams();
params.width = callParams.getReceivedVideoDefinition().getWidth(); mParams.width = callParams.getReceivedVideoDefinition().getWidth();
params.height = callParams.getReceivedVideoDefinition().getHeight(); mParams.height = callParams.getReceivedVideoDefinition().getHeight();
LinphoneManager.getLc().setNativeVideoWindowId(androidVideoWindowImpl); LinphoneManager.getLc().setNativeVideoWindowId(mAndroidVideoWindowImpl);
setOnClickListener( setOnClickListener(
new OnClickListener() { new OnClickListener() {
@ -111,7 +108,7 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
new OnLongClickListener() { new OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
dragEnabled = true; mDragEnabled = true;
return true; return true;
} }
}); });
@ -126,27 +123,27 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
} }
public void destroy() { public void destroy() {
androidVideoWindowImpl.release(); mAndroidVideoWindowImpl.release();
} }
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
x = event.getRawX(); mX = event.getRawX();
y = event.getRawY(); mY = event.getRawY();
switch (event.getAction()) { switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
touchX = event.getX(); mTouchX = event.getX();
touchY = event.getY(); mTouchY = event.getY();
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
if (dragEnabled) { if (mDragEnabled) {
updateViewPostion(); updateViewPostion();
} }
break; break;
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
touchX = touchY = 0; mTouchX = mTouchY = 0;
dragEnabled = false; mDragEnabled = false;
break; break;
default: default:
break; break;
@ -155,16 +152,18 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
} }
private void updateViewPostion() { private void updateViewPostion() {
params.x = mParams.x =
Math.min(Math.max(0, (int) (x - touchX)), metrics.widthPixels - getMeasuredWidth());
params.y =
Math.min( Math.min(
Math.max(0, (int) (y - touchY)), Math.max(0, (int) (mX - mTouchX)),
metrics.heightPixels - getMeasuredHeight()); mMetrics.widthPixels - getMeasuredWidth());
wm.updateViewLayout(this, params); mParams.y =
Math.min(
Math.max(0, (int) (mY - mTouchY)),
mMetrics.heightPixels - getMeasuredHeight());
mWindowManager.updateViewLayout(this, mParams);
} }
public WindowManager.LayoutParams getWindowManagerLayoutParams() { public WindowManager.LayoutParams getWindowManagerLayoutParams() {
return params; return mParams;
} }
} }

View file

@ -44,10 +44,10 @@ public class XmlRpcHelper {
public static final String CLIENT_ERROR_INVALID_SERVER_URL = "INVALID_SERVER_URL"; public static final String CLIENT_ERROR_INVALID_SERVER_URL = "INVALID_SERVER_URL";
public static final String CLIENT_ERROR_SERVER_NOT_REACHABLE = "SERVER_NOT_REACHABLE"; public static final String CLIENT_ERROR_SERVER_NOT_REACHABLE = "SERVER_NOT_REACHABLE";
private XmlRpcSession xmlRpcSession; private XmlRpcSession mXmlRpcSession;
public XmlRpcHelper() { public XmlRpcHelper() {
xmlRpcSession = mXmlRpcSession =
LinphoneManager.getLcIfManagerNotDestroyedOrNull() LinphoneManager.getLcIfManagerNotDestroyedOrNull()
.createXmlRpcSession( .createXmlRpcSession(
LinphonePreferences.instance() LinphonePreferences.instance()
@ -57,7 +57,7 @@ public class XmlRpcHelper {
public void createAccountAsync( public void createAccountAsync(
final XmlRpcListener listener, String username, String email, String password) { final XmlRpcListener listener, String username, String email, String password) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "create_account"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "create_account");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -79,13 +79,13 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(email); xmlRpcRequest.addStringArg(email);
xmlRpcRequest.addStringArg(password == null ? "" : password); xmlRpcRequest.addStringArg(password == null ? "" : password);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void getAccountExpireAsync( public void getAccountExpireAsync(
final XmlRpcListener listener, String username, String password) { final XmlRpcListener listener, String username, String password) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "get_account_expiration"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "get_account_expiration");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -106,7 +106,7 @@ public class XmlRpcHelper {
}); });
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password); xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void updateAccountExpireAsync( public void updateAccountExpireAsync(
@ -117,7 +117,7 @@ public class XmlRpcHelper {
String payload, String payload,
String signature) { String signature) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "update_expiration_date"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "update_expiration_date");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -141,13 +141,13 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(domain); xmlRpcRequest.addStringArg(domain);
xmlRpcRequest.addStringArg(payload); xmlRpcRequest.addStringArg(payload);
xmlRpcRequest.addStringArg(signature); xmlRpcRequest.addStringArg(signature);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void activateAccountAsync( public void activateAccountAsync(
final XmlRpcListener listener, String username, String password) { final XmlRpcListener listener, String username, String password) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "activate_account"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "activate_account");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -168,12 +168,12 @@ public class XmlRpcHelper {
}); });
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password); xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void isAccountActivatedAsync(final XmlRpcListener listener, String username) { public void isAccountActivatedAsync(final XmlRpcListener listener, String username) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -195,13 +195,13 @@ public class XmlRpcHelper {
} }
}); });
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void isTrialAccountAsync( public void isTrialAccountAsync(
final XmlRpcListener listener, String username, String password) { final XmlRpcListener listener, String username, String password) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "is_account_trial"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "is_account_trial");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -220,12 +220,12 @@ public class XmlRpcHelper {
}); });
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password); xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void isAccountAsync(final XmlRpcListener listener, String username) { public void isAccountAsync(final XmlRpcListener listener, String username) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -247,13 +247,13 @@ public class XmlRpcHelper {
} }
}); });
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void changeAccountEmailAsync( public void changeAccountEmailAsync(
final XmlRpcListener listener, String username, String password, String newEmail) { final XmlRpcListener listener, String username, String password, String newEmail) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "change_email"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "change_email");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -276,7 +276,7 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password); xmlRpcRequest.addStringArg(password);
xmlRpcRequest.addStringArg(newEmail); xmlRpcRequest.addStringArg(newEmail);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void changeAccountPasswordAsync( public void changeAccountPasswordAsync(
@ -285,7 +285,7 @@ public class XmlRpcHelper {
String oldPassword, String oldPassword,
String newPassword) { String newPassword) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "change_password"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "change_password");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -308,7 +308,7 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(oldPassword); xmlRpcRequest.addStringArg(oldPassword);
xmlRpcRequest.addStringArg(newPassword); xmlRpcRequest.addStringArg(newPassword);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void changeAccountHashPasswordAsync( public void changeAccountHashPasswordAsync(
@ -317,7 +317,7 @@ public class XmlRpcHelper {
String oldPassword, String oldPassword,
String newPassword) { String newPassword) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "change_hash"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "change_hash");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -340,13 +340,13 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(oldPassword); xmlRpcRequest.addStringArg(oldPassword);
xmlRpcRequest.addStringArg(newPassword); xmlRpcRequest.addStringArg(newPassword);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void sendRecoverPasswordLinkByEmailAsync( public void sendRecoverPasswordLinkByEmailAsync(
final XmlRpcListener listener, String usernameOrEmail) { final XmlRpcListener listener, String usernameOrEmail) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest( mXmlRpcSession.createRequest(
XmlRpcArgType.String, "send_reset_account_password_email"); XmlRpcArgType.String, "send_reset_account_password_email");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@ -368,13 +368,13 @@ public class XmlRpcHelper {
} }
}); });
xmlRpcRequest.addStringArg(usernameOrEmail); xmlRpcRequest.addStringArg(usernameOrEmail);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void sendActivateAccountLinkByEmailAsync( public void sendActivateAccountLinkByEmailAsync(
final XmlRpcListener listener, String usernameOrEmail) { final XmlRpcListener listener, String usernameOrEmail) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "resend_activation_email"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "resend_activation_email");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -395,12 +395,12 @@ public class XmlRpcHelper {
} }
}); });
xmlRpcRequest.addStringArg(usernameOrEmail); xmlRpcRequest.addStringArg(usernameOrEmail);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void sendUsernameByEmailAsync(final XmlRpcListener listener, String email) { public void sendUsernameByEmailAsync(final XmlRpcListener listener, String email) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "recover_username_from_email"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "recover_username_from_email");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -421,13 +421,13 @@ public class XmlRpcHelper {
} }
}); });
xmlRpcRequest.addStringArg(email); xmlRpcRequest.addStringArg(email);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void verifySignatureAsync( public void verifySignatureAsync(
final XmlRpcListener listener, String payload, String signature) { final XmlRpcListener listener, String payload, String signature) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "check_payload_signature"); mXmlRpcSession.createRequest(XmlRpcArgType.String, "check_payload_signature");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@Override @Override
@ -450,13 +450,13 @@ public class XmlRpcHelper {
}); });
xmlRpcRequest.addStringArg(payload); xmlRpcRequest.addStringArg(payload);
xmlRpcRequest.addStringArg(signature); xmlRpcRequest.addStringArg(signature);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
public void getRemoteProvisioningFilenameAsync( public void getRemoteProvisioningFilenameAsync(
final XmlRpcListener listener, String username, String domain, String password) { final XmlRpcListener listener, String username, String domain, String password) {
XmlRpcRequest xmlRpcRequest = XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest( mXmlRpcSession.createRequest(
XmlRpcArgType.String, "get_remote_provisioning_filename"); XmlRpcArgType.String, "get_remote_provisioning_filename");
xmlRpcRequest.setListener( xmlRpcRequest.setListener(
new XmlRpcRequestListener() { new XmlRpcRequestListener() {
@ -480,6 +480,6 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username); xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(domain); xmlRpcRequest.addStringArg(domain);
xmlRpcRequest.addStringArg(password); xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest); mXmlRpcSession.sendRequest(xmlRpcRequest);
} }
} }