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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,28 +35,28 @@ import org.linphone.core.DialPlan;
public class CountryListFragment extends Fragment
implements AdapterView.OnItemClickListener, View.OnClickListener {
private ListView list;
private EditText search;
private ImageView clearSearchField;
private AssistantActivity.CountryListAdapter adapter;
private ListView mList;
private EditText mSearch;
private ImageView mClearSearchField;
private AssistantActivity.CountryListAdapter mAdapter;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_country_list, container, false);
adapter = AssistantActivity.instance().getCountryListAdapter();
adapter.setInflater(inflater);
mAdapter = AssistantActivity.instance().getCountryListAdapter();
mAdapter.setInflater(inflater);
search = view.findViewById(R.id.search_country);
clearSearchField = view.findViewById(R.id.clearSearchField);
clearSearchField.setOnClickListener(this);
mSearch = view.findViewById(R.id.search_country);
mClearSearchField = view.findViewById(R.id.clearSearchField);
mClearSearchField.setOnClickListener(this);
list = view.findViewById(R.id.countryList);
list.setAdapter(adapter);
list.setOnItemClickListener(this);
mList = view.findViewById(R.id.countryList);
mList.setAdapter(mAdapter);
mList.setOnItemClickListener(this);
search.addTextChangedListener(
mSearch.addTextChangedListener(
new TextWatcher() {
@Override
public void beforeTextChanged(
@ -64,13 +64,13 @@ public class CountryListFragment extends Fragment
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s);
mAdapter.getFilter().filter(s);
}
@Override
public void afterTextChanged(Editable s) {}
});
search.setText("");
mSearch.setText("");
return view;
}
@ -85,7 +85,7 @@ public class CountryListFragment extends Fragment
@Override
public void onClick(View v) {
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
implements OnClickListener, AccountCreatorListener {
private String username, password;
private Button checkAccount;
private TextView email;
private AccountCreator accountCreator;
private String mUsername, mPassword;
private Button mCheckAccount;
private TextView mEmail;
private AccountCreator mAccountCreator;
@Override
public View onCreateView(
@ -47,22 +47,22 @@ public class CreateAccountActivationFragment extends Fragment
inflater.inflate(
R.layout.assistant_account_creation_email_activation, container, false);
accountCreator =
mAccountCreator =
LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this);
mAccountCreator.setListener(this);
username = getArguments().getString("Username");
password = getArguments().getString("Password");
mUsername = getArguments().getString("Username");
mPassword = getArguments().getString("Password");
accountCreator.setUsername(username);
accountCreator.setPassword(password);
mAccountCreator.setUsername(mUsername);
mAccountCreator.setPassword(mPassword);
email = view.findViewById(R.id.send_email);
email.setText(getArguments().getString("Email"));
mEmail = view.findViewById(R.id.send_email);
mEmail.setText(getArguments().getString("Email"));
checkAccount = view.findViewById(R.id.assistant_check);
checkAccount.setOnClickListener(this);
mCheckAccount = view.findViewById(R.id.assistant_check);
mCheckAccount.setOnClickListener(this);
return view;
}
@ -70,8 +70,8 @@ public class CreateAccountActivationFragment extends Fragment
public void onClick(View v) {
int id = v.getId();
if (id == R.id.assistant_check) {
checkAccount.setEnabled(false);
accountCreator.isAccountActivated();
mCheckAccount.setEnabled(false);
mAccountCreator.isAccountActivated();
}
}
@ -109,7 +109,7 @@ public class CreateAccountActivationFragment extends Fragment
.show();
} else if (status.equals(AccountCreator.Status.AccountActivated)) {
AssistantActivity.instance().linphoneLogIn(accountCreator);
AssistantActivity.instance().isAccountVerified(username);
AssistantActivity.instance().isAccountVerified(mUsername);
} else {
Toast.makeText(
getActivity(),
@ -117,7 +117,7 @@ public class CreateAccountActivationFragment extends Fragment
Toast.LENGTH_LONG)
.show();
}
checkAccount.setEnabled(true);
mCheckAccount.setEnabled(true);
}
@Override

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -42,22 +42,22 @@ import org.linphone.settings.LinphonePreferences;
public class RemoteProvisioningActivity extends Activity {
private Handler mHandler = new Handler();
private String configUriParam = null;
private ProgressBar spinner;
private String mConfigUriParam = null;
private ProgressBar mSpinner;
private CoreListenerStub mListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.remote_provisioning);
spinner = findViewById(R.id.spinner);
mSpinner = findViewById(R.id.spinner);
mListener =
new CoreListenerStub() {
@Override
public void onConfiguringStatus(
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) {
goToLinphoneActivity();
} else if (state == ConfiguringState.Failed) {
@ -113,18 +113,19 @@ public class RemoteProvisioningActivity extends Activity {
if (openUri != null) {
// We expect something like
// linphone-config://http://linphone.org/config.xml
configUriParam =
mConfigUriParam =
openUri.getEncodedSchemeSpecificPart()
.substring(2); // Removes the linphone-config://
try {
configUriParam = URLDecoder.decode(configUriParam, "UTF-8");
mConfigUriParam =
URLDecoder.decode(mConfigUriParam, "UTF-8");
} catch (UnsupportedEncodingException 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()
.isFirstRemoteProvisioning()) {
mHandler.post(
@ -167,7 +168,7 @@ public class RemoteProvisioningActivity extends Activity {
@Override
public void run() {
setRemoteProvisioningAddressAndRestart(
configUriParam);
mConfigUriParam);
}
});
}
@ -185,7 +186,7 @@ public class RemoteProvisioningActivity extends Activity {
R.string.accept,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
setRemoteProvisioningAddressAndRestart(configUriParam);
setRemoteProvisioningAddressAndRestart(mConfigUriParam);
}
})
.setNegativeButton(
@ -199,7 +200,7 @@ public class RemoteProvisioningActivity extends Activity {
}
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().setRemoteProvisioningUrl(configUri);

View file

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

View file

@ -28,35 +28,35 @@ import android.widget.Button;
import org.linphone.R;
public class WelcomeFragment extends Fragment implements OnClickListener {
private Button createAccount, logLinphoneAccount, logGenericAccount, remoteProvisioning;
private Button mCreateAccount, mLogLinphoneAccount, mLogGenericAccount, mRemoteProvisioning;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_welcome, container, false);
createAccount = view.findViewById(R.id.create_account);
createAccount.setOnClickListener(this);
mCreateAccount = view.findViewById(R.id.create_account);
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)) {
logLinphoneAccount.setVisibility(View.GONE);
mLogLinphoneAccount.setVisibility(View.GONE);
} 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)) {
logGenericAccount.setVisibility(View.GONE);
mLogGenericAccount.setVisibility(View.GONE);
} 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)) {
remoteProvisioning.setVisibility(View.GONE);
mRemoteProvisioning.setVisibility(View.GONE);
} else {
remoteProvisioning.setOnClickListener(this);
mRemoteProvisioning.setOnClickListener(this);
}
return view;

View file

@ -28,7 +28,7 @@ public class BandwidthManager {
public static final int LOW_RESOLUTION = 1;
public static final int LOW_BANDWIDTH = 2;
private static BandwidthManager instance;
private static BandwidthManager sInstance;
private int currentProfile = HIGH_RESOLUTION;
@ -40,8 +40,8 @@ public class BandwidthManager {
}
public static final synchronized BandwidthManager getInstance() {
if (instance == null) instance = new BandwidthManager();
return instance;
if (sInstance == null) sInstance = new BandwidthManager();
return sInstance;
}
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;
public class CallAudioFragment extends Fragment {
private CallActivity incallActvityInstance;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -39,14 +37,11 @@ public class CallAudioFragment extends Fragment {
@Override
public void onStart() {
super.onStart();
incallActvityInstance = (CallActivity) getActivity();
CallActivity incallActvityInstance = (CallActivity) getActivity();
if (incallActvityInstance != null) {
incallActvityInstance.bindAudioFragment(this);
}
// Just to be sure we have incall controls
if (incallActvityInstance != null) {
// Just to be sure we have incall controls
incallActvityInstance.removeCallbacks();
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -24,16 +24,16 @@ import androidx.recyclerview.widget.RecyclerView;
public abstract class ChatScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// before mLoading more.
private int mVisibleThreshold = 5;
// 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
private int previousTotalItemCount = 0;
private int mPreviousTotalItemCount = 0;
// 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
private int startingPageIndex = 0;
private int mStartingPageIndex = 0;
private LinearLayoutManager mLayoutManager;
@ -41,18 +41,6 @@ public abstract class ChatScrollListener extends RecyclerView.OnScrollListener {
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.
// 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.
@ -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
// list is invalidated and should be reset back to initial state
if (totalItemCount < previousTotalItemCount) {
this.currentPage = this.startingPageIndex;
this.previousTotalItemCount = totalItemCount;
if (totalItemCount < mPreviousTotalItemCount) {
this.mCurrentPage = this.mStartingPageIndex;
this.mPreviousTotalItemCount = totalItemCount;
if (totalItemCount == 0) {
this.loading = true;
this.mLoading = true;
}
}
// If its still loading, we check to see if the dataset count has
// changed, if so we conclude it has finished loading and update the current page
// If its still mLoading, we check to see if the dataset count has
// changed, if so we conclude it has finished mLoading and update the current page
// number and total item count.
if (loading && (totalItemCount > previousTotalItemCount)) {
loading = false;
previousTotalItemCount = totalItemCount;
if (mLoading && (totalItemCount > mPreviousTotalItemCount)) {
mLoading = false;
mPreviousTotalItemCount = totalItemCount;
}
// If it isnt currently loading, we check to see if we have breached
// the visibleThreshold and need to reload more data.
// If it isnt currently mLoading, we check to see if we have breached
// the mVisibleThreshold and need to reload more 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
if (!loading && (lastVisibleItemPosition + visibleThreshold) > totalItemCount) {
currentPage++;
onLoadMore(currentPage, totalItemCount, view);
loading = true;
if (!mLoading && (lastVisibleItemPosition + mVisibleThreshold) > totalItemCount) {
mCurrentPage++;
onLoadMore(mCurrentPage, totalItemCount, view);
mLoading = true;
}
}
// Call this method whenever performing new searches
public void resetState() {
this.currentPage = this.startingPageIndex;
this.previousTotalItemCount = 0;
this.loading = true;
}
// Defines the process for actually loading more data based on page
// Defines the process for actually mLoading more data based on page
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.View;
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.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
@ -37,25 +33,7 @@ import org.linphone.core.ChatRoom;
import org.linphone.core.Participant;
import org.linphone.views.ContactAvatar;
public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.ViewHolder> {
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);
}
}
public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoViewHolder> {
private List<ContactAddress> mItems;
private View.OnClickListener mDeleteListener;
private boolean mHideAdminFeatures;
@ -69,15 +47,15 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
public GroupInfoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.chat_infos_cell, parent, false);
return new ViewHolder(v);
return new GroupInfoViewHolder(v);
}
@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);
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;
public class ContactAddress implements Serializable {
private LinphoneContact contact;
private SearchResult result;
private String address;
private String phoneNumber;
private boolean isLinphoneContact;
private boolean isSelect = false;
private boolean isAdmin = false;
private transient View view;
private LinphoneContact mContact;
private SearchResult mResult;
private String mAddress;
private String mPhoneNumber;
private boolean mIsLinphoneContact;
private boolean mIsSelect = false;
private boolean mIsAdmin = false;
private transient View mView;
public ContactAddress(LinphoneContact c, String a, String pn, boolean 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) {
init(c, a, pn, isLC);
this.isAdmin = isAdmin;
mIsAdmin = isAdmin;
}
public boolean isAdmin() {
return isAdmin;
return mIsAdmin;
}
public void setAdmin(boolean admin) {
isAdmin = admin;
mIsAdmin = admin;
}
public boolean isSelect() {
return isSelect;
return mIsSelect;
}
public void setSelect(boolean select) {
isSelect = select;
mIsSelect = select;
}
public View getView() {
return view;
return mView;
}
public void setView(View v) {
view = v;
mView = v;
}
public LinphoneContact getContact() {
return contact;
return mContact;
}
public SearchResult getResult() {
return result;
return mResult;
}
public void setResult(SearchResult result) {
this.result = result;
this.mResult = result;
}
public String getAddressAsDisplayableString() {
Address addr = getAddress();
if (addr != null && addr.getUsername() != null) return addr.asStringUriOnly();
return address;
return mAddress;
}
public Address getAddress() {
String presence =
contact.getPresenceModelForUriOrTel(
(phoneNumber != null && !phoneNumber.isEmpty()) ? phoneNumber : address);
Address addr = Factory.instance().createAddress(presence != null ? presence : address);
mContact.getPresenceModelForUriOrTel(
(mPhoneNumber != null && !mPhoneNumber.isEmpty())
? mPhoneNumber
: mAddress);
Address addr = Factory.instance().createAddress(presence != null ? presence : mAddress);
// Remove the user=phone URI param if existing, it will break everything otherwise
if (addr.hasUriParam("user")) {
addr.removeUriParam("user");
@ -99,8 +101,8 @@ public class ContactAddress implements Serializable {
}
public String getDisplayName() {
if (address != null) {
Address addr = Factory.instance().createAddress(address);
if (mAddress != null) {
Address addr = Factory.instance().createAddress(mAddress);
if (addr != null) {
return addr.getDisplayName();
}
@ -109,8 +111,8 @@ public class ContactAddress implements Serializable {
}
public String getUsername() {
if (address != null) {
Address addr = Factory.instance().createAddress(address);
if (mAddress != null) {
Address addr = Factory.instance().createAddress(mAddress);
if (addr != null) {
return addr.getUsername();
}
@ -119,18 +121,18 @@ public class ContactAddress implements Serializable {
}
public String getPhoneNumber() {
return phoneNumber;
return mPhoneNumber;
}
public boolean isLinphoneContact() {
return isLinphoneContact;
return mIsLinphoneContact;
}
private void init(LinphoneContact c, String a, String pn, boolean isLC) {
contact = c;
address = a;
phoneNumber = pn;
isLinphoneContact = isLC;
mContact = c;
mAddress = a;
mPhoneNumber = pn;
mIsLinphoneContact = isLC;
}
@Override

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,12 +23,12 @@ import android.graphics.Bitmap;
import android.net.Uri;
public class NotifiableMessage {
String mMessage;
String mSender;
long mTime;
Bitmap mSenderBitmap;
Uri mFilePath;
String mFileMime;
private String mMessage;
private String mSender;
private long mTime;
private Bitmap mSenderBitmap;
private Uri mFilePath;
private String mFileMime;
public NotifiableMessage(
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
implements InAppPurchaseListener, OnClickListener {
private static InAppPurchaseActivity instance;
private InAppPurchaseHelper inAppPurchaseHelper;
private ImageView cancel, back;
private ProgressBar inProgress;
private static InAppPurchaseActivity sInstance;
private List<Purchasable> purchasedItems;
private Fragment fragment;
private InAppPurchaseHelper mInAppPurchaseHelper;
private ImageView mCancel, mBack;
private ProgressBar mInProgress;
private List<Purchasable> mPurchasedItems;
private Fragment mFragment;
private Handler mHandler = new Handler();
public static InAppPurchaseActivity instance() {
return instance;
return sInstance;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
inAppPurchaseHelper = new InAppPurchaseHelper(this, this);
mInAppPurchaseHelper = new InAppPurchaseHelper(this, this);
setContentView(R.layout.in_app);
inProgress = findViewById(R.id.purchaseItemsFetchInProgress);
inProgress.setVisibility(View.VISIBLE);
mInProgress = findViewById(R.id.purchaseItemsFetchInProgress);
mInProgress.setVisibility(View.VISIBLE);
back = findViewById(R.id.back);
back.setOnClickListener(this);
back.setVisibility(View.INVISIBLE);
cancel = findViewById(R.id.cancel);
cancel.setOnClickListener(this);
mBack = findViewById(R.id.back);
mBack.setOnClickListener(this);
mBack.setVisibility(View.INVISIBLE);
mCancel = findViewById(R.id.cancel);
mCancel.setOnClickListener(this);
instance = this;
sInstance = this;
}
private void changeFragment(Fragment newFragment) {
@ -78,44 +79,44 @@ public class InAppPurchaseActivity extends Activity
}
public void displayInappList() {
fragment = new InAppPurchaseListFragment();
changeFragment(fragment);
mFragment = new InAppPurchaseListFragment();
changeFragment(mFragment);
}
public void displayPurchase(Purchasable item) {
Bundle extra = new Bundle();
extra.putString("item_id", item.getId());
fragment = new InAppPurchaseFragment();
fragment.setArguments(extra);
changeFragment(fragment);
mFragment = new InAppPurchaseFragment();
mFragment.setArguments(extra);
changeFragment(mFragment);
}
public void buyInapp(String username, Purchasable item) {
LinphonePreferences.instance().setInAppPurchasedItem(item);
inAppPurchaseHelper.purchaseItemAsync(item.getId(), username);
mInAppPurchaseHelper.purchaseItemAsync(item.getId(), username);
}
public String getGmailAccount() {
return inAppPurchaseHelper.getGmailAccount();
return mInAppPurchaseHelper.getGmailAccount();
}
@Override
protected void onDestroy() {
instance = null;
inAppPurchaseHelper.destroy();
sInstance = null;
mInAppPurchaseHelper.destroy();
super.onDestroy();
}
public List<Purchasable> getPurchasedItems() {
if (purchasedItems == null || purchasedItems.size() == 0) {
if (mPurchasedItems == null || mPurchasedItems.size() == 0) {
Log.w("nul");
}
return purchasedItems;
return mPurchasedItems;
}
public Purchasable getPurchasedItem(String id) {
for (Purchasable item : purchasedItems) {
for (Purchasable item : mPurchasedItems) {
if (item.getId().equals(id)) {
return item;
}
@ -125,32 +126,32 @@ public class InAppPurchaseActivity extends Activity
@Override
public void onServiceAvailableForQueries() {
// email.setText(inAppPurchaseHelper.getGmailAccount());
// email.setText(mInAppPurchaseHelper.getGmailAccount());
// email.setEnabled(false);
// inAppPurchaseHelper.getPurchasedItemsAsync();
inAppPurchaseHelper.getAvailableItemsForPurchaseAsync();
// mInAppPurchaseHelper.getPurchasedItemsAsync();
mInAppPurchaseHelper.getAvailableItemsForPurchaseAsync();
}
@Override
public void onAvailableItemsForPurchaseQueryFinished(ArrayList<Purchasable> items) {
// purchasableItemsLayout.removeAllViews();
inProgress.setVisibility(View.GONE);
purchasedItems = new ArrayList<>();
mInProgress.setVisibility(View.GONE);
mPurchasedItems = new ArrayList<>();
for (Purchasable item : items) {
purchasedItems.add(item);
mPurchasedItems.add(item);
}
displayInappList();
}
@Override
public void onPurchasedItemsQueryFinished(ArrayList<Purchasable> items) {
purchasedItems = items;
mPurchasedItems = items;
if (items == null || items.size() == 0) {
inAppPurchaseHelper.getAvailableItemsForPurchaseAsync();
mInAppPurchaseHelper.getAvailableItemsForPurchaseAsync();
} else {
for (Purchasable purchasedItem : purchasedItems) {
for (Purchasable purchasedItem : mPurchasedItems) {
Log.d(
"[In-app purchase] Found already bought item, expires "
+ purchasedItem.getExpireDate());
@ -194,7 +195,7 @@ public class InAppPurchaseActivity extends Activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
inAppPurchaseHelper.parseAndVerifyPurchaseItemResultAsync(requestCode, resultCode, data);
mInAppPurchaseHelper.parseAndVerifyPurchaseItemResultAsync(requestCode, resultCode, data);
}
@Override
@ -207,7 +208,7 @@ public class InAppPurchaseActivity extends Activity
new Runnable() {
@Override
public void run() {
inProgress.setVisibility(View.GONE);
mInProgress.setVisibility(View.GONE);
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;
public class InAppPurchaseFragment extends Fragment implements View.OnClickListener {
private LinearLayout usernameLayout;
private EditText username, email;
private TextView errorMessage;
private LinearLayout mUsernameLayout;
private EditText mUsername, mEmail;
private TextView mErrorMessage;
private boolean usernameOk = false, emailOk = false;
private String defaultUsername, defaultEmail;
private Button buyItemButton;
private boolean mUsernameOk = false, mEmailOk = false;
private String mDefaultUsername, mDefaultEmail;
private Button mBuyItemButton;
@Override
public View onCreateView(
@ -54,41 +54,41 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
String id = getArguments().getString("item_id");
Purchasable item = InAppPurchaseActivity.instance().getPurchasedItem(id);
buyItemButton = view.findViewById(R.id.inapp_button);
mBuyItemButton = view.findViewById(R.id.inapp_button);
displayBuySubscriptionButton(item);
defaultEmail = InAppPurchaseActivity.instance().getGmailAccount();
defaultUsername =
mDefaultEmail = InAppPurchaseActivity.instance().getGmailAccount();
mDefaultUsername =
LinphonePreferences.instance()
.getAccountUsername(
LinphonePreferences.instance().getDefaultAccountIndex());
usernameLayout = view.findViewById(R.id.username_layout);
username = view.findViewById(R.id.username);
mUsernameLayout = view.findViewById(R.id.username_layout);
mUsername = view.findViewById(R.id.username);
if (!getResources().getBoolean(R.bool.hide_username_in_inapp)) {
usernameLayout.setVisibility(View.VISIBLE);
username.setText(
mUsernameLayout.setVisibility(View.VISIBLE);
mUsername.setText(
LinphonePreferences.instance()
.getAccountUsername(
LinphonePreferences.instance().getDefaultAccountIndex()));
addUsernameHandler(username, errorMessage);
addUsernameHandler(mUsername, mErrorMessage);
} else {
if (defaultUsername != null) {
usernameLayout.setVisibility(View.GONE);
usernameOk = true;
if (mDefaultUsername != null) {
mUsernameLayout.setVisibility(View.GONE);
mUsernameOk = true;
}
}
email = view.findViewById(R.id.email);
if (defaultEmail != null) {
email.setText(defaultEmail);
emailOk = true;
mEmail = view.findViewById(R.id.email);
if (mDefaultEmail != null) {
mEmail.setText(mDefaultEmail);
mEmailOk = true;
}
buyItemButton.setEnabled(emailOk && usernameOk);
errorMessage = view.findViewById(R.id.username_error);
mBuyItemButton.setEnabled(mEmailOk && mUsernameOk);
mErrorMessage = view.findViewById(R.id.username_error);
return view;
}
@ -102,15 +102,15 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
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();
if (isUsernameCorrect(username)) {
usernameOk = true;
mUsernameOk = true;
errorMessage.setText("");
} else {
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) {
buyItemButton.setText("Buy account (" + item.getPrice() + ")");
buyItemButton.setTag(item);
buyItemButton.setOnClickListener(this);
buyItemButton.setEnabled(usernameOk && emailOk);
mBuyItemButton.setText("Buy account (" + item.getPrice() + ")");
mBuyItemButton.setTag(item);
mBuyItemButton.setOnClickListener(this);
mBuyItemButton.setEnabled(mUsernameOk && mEmailOk);
}
@Override
@ -134,7 +134,7 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
}
private String getUsername() {
String username = this.username.getText().toString();
String username = this.mUsername.getText().toString();
ProxyConfig lpc = LinphoneManager.getLc().createProxyConfig();
username = lpc.normalizePhoneNumber(username);
return username.toLowerCase(Locale.getDefault());

View file

@ -32,7 +32,7 @@ import java.util.List;
import org.linphone.R;
public class InAppPurchaseListFragment extends Fragment implements AdapterView.OnItemClickListener {
private ListView inappList;
private ListView mInappList;
private LayoutInflater mInflater;
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);
mPurchasableItems = InAppPurchaseActivity.instance().getPurchasedItems();
inappList = view.findViewById(R.id.inapp_list);
mInappList = view.findViewById(R.id.inapp_list);
if (mPurchasableItems != null) {
inappList.setAdapter(new InAppListAdapter());
inappList.setOnItemClickListener(this);
mInappList.setAdapter(new InAppListAdapter());
mInappList.setOnItemClickListener(this);
}
return view;
}

View file

@ -25,81 +25,81 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
public class Purchasable {
private String id, title, description, price;
private long expire;
private String purchasePayload, purchasePayloadSignature;
private String userData;
private String mId, mTitle, mDescription, mPrice;
private long mExpire;
private String mPurchasePayload, mPurchasePayloadSignature;
private String mUserData;
public Purchasable(String id) {
this.id = id;
this.mId = id;
}
public String getId() {
return id;
return mId;
}
public String getTitle() {
return title;
return mTitle;
}
public Purchasable setTitle(String title) {
this.title = title;
this.mTitle = title;
return this;
}
public String getDescription() {
return description;
return mDescription;
}
public Purchasable setDescription(String description) {
this.description = description;
this.mDescription = description;
return this;
}
public String getPrice() {
return price;
return mPrice;
}
public Purchasable setPrice(String price) {
this.price = price;
this.mPrice = price;
return this;
}
public long getExpire() {
return expire;
return mExpire;
}
public Purchasable setExpire(long expire) {
this.expire = expire;
this.mExpire = expire;
return this;
}
public String getExpireDate() {
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);
}
public Purchasable setPayloadAndSignature(String payload, String signature) {
this.purchasePayload = payload;
this.purchasePayloadSignature = signature;
this.mPurchasePayload = payload;
this.mPurchasePayloadSignature = signature;
return this;
}
public String getPayload() {
return this.purchasePayload;
return this.mPurchasePayload;
}
public String getPayloadSignature() {
return this.purchasePayloadSignature;
return this.mPurchasePayloadSignature;
}
public String getUserData() {
return this.userData;
return this.mUserData;
}
public Purchasable setUserData(String data) {
this.userData = data;
this.mUserData = data;
return this;
}
}

View file

@ -34,7 +34,7 @@ import org.linphone.LinphoneService;
import org.linphone.call.CallActivity;
public class BluetoothManager extends BroadcastReceiver {
private static BluetoothManager instance;
private static BluetoothManager sInstance;
private Context mContext;
private AudioManager mAudioManager;
@ -42,24 +42,24 @@ public class BluetoothManager extends BroadcastReceiver {
private BluetoothHeadset mBluetoothHeadset;
private BluetoothDevice mBluetoothDevice;
private BluetoothProfile.ServiceListener mProfileListener;
private boolean isBluetoothConnected;
private boolean isScoConnected;
private boolean mIsBluetoothConnected;
private boolean mIsScoConnected;
public BluetoothManager() {
isBluetoothConnected = false;
mIsBluetoothConnected = false;
if (!ensureInit()) {
android.util.Log.w(
"BluetoothManager",
"[Bluetooth] Manager tried to init but LinphoneService not ready yet...");
}
instance = this;
sInstance = this;
}
public static BluetoothManager getInstance() {
if (instance == null) {
instance = new BluetoothManager();
if (sInstance == null) {
sInstance = new BluetoothManager();
}
return instance;
return sInstance;
}
public void initBluetooth() {
@ -85,7 +85,7 @@ public class BluetoothManager extends BroadcastReceiver {
}
private void startBluetooth() {
if (isBluetoothConnected) {
if (mIsBluetoothConnected) {
android.util.Log.e("BluetoothManager", "[Bluetooth] Already started, skipping...");
return;
}
@ -107,14 +107,14 @@ public class BluetoothManager extends BroadcastReceiver {
android.util.Log.d(
"BluetoothManager", "[Bluetooth] Headset connected");
mBluetoothHeadset = (BluetoothHeadset) proxy;
isBluetoothConnected = true;
mIsBluetoothConnected = true;
}
}
public void onServiceDisconnected(int profile) {
if (profile == BluetoothProfile.HEADSET) {
mBluetoothHeadset = null;
isBluetoothConnected = false;
mIsBluetoothConnected = false;
android.util.Log.d(
"BluetoothManager", "[Bluetooth] Headset disconnected");
LinphoneManager.getInstance().routeAudioToReceiver();
@ -211,7 +211,7 @@ public class BluetoothManager extends BroadcastReceiver {
public boolean isUsingBluetoothAudioRoute() {
return mBluetoothHeadset != null
&& mBluetoothHeadset.isAudioConnected(mBluetoothDevice)
&& isScoConnected;
&& mIsScoConnected;
}
public boolean isBluetoothHeadsetAvailable() {
@ -251,7 +251,7 @@ public class BluetoothManager extends BroadcastReceiver {
// Hack to ensure bluetooth sco is really stopped
int retries = 0;
while (isScoConnected && retries < 10) {
while (mIsScoConnected && retries < 10) {
retries++;
try {
@ -268,7 +268,7 @@ public class BluetoothManager extends BroadcastReceiver {
public void stopBluetooth() {
android.util.Log.w("BluetoothManager", "[Bluetooth] Stopping...");
isBluetoothConnected = false;
mIsBluetoothConnected = false;
disableBluetoothSCO();
@ -310,15 +310,15 @@ public class BluetoothManager extends BroadcastReceiver {
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: connected");
// LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
isScoConnected = true;
mIsScoConnected = true;
} else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: disconnected");
// LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER);
isScoConnected = false;
mIsScoConnected = false;
} else if (state == AudioManager.SCO_AUDIO_STATE_CONNECTING) {
android.util.Log.d("BluetoothManager", "[Bluetooth] SCO state: connecting");
// LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
isScoConnected = true;
mIsScoConnected = true;
} else {
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 {
private static final String TAG = "CallHandler";
private final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
private LinphonePreferences mPrefs;
private static final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
@Override
public void onReceive(Context context, Intent intent) {
mPrefs = LinphonePreferences.instance();
LinphonePreferences mPrefs = LinphonePreferences.instance();
Log.e(TAG, "===>>>> Linphone OutgoingCallReceiver ");
if (intent.getAction().equals(Intent.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 static final Pattern RECORD_PATTERN =
Pattern.compile(".*/(.*)_(\\d{2}-\\d{2}-\\d{4}-\\d{2}-\\d{2}-\\d{2})\\..*");
private String mRecordPath, mName;
private Date mRecordDate;
private Player mPlayer;

View file

@ -36,9 +36,9 @@ import org.linphone.utils.SelectableAdapter;
import org.linphone.utils.SelectableHelper;
public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
private List<Recording> recordings;
private Context context;
private RecordingViewHolder.ClickListener clickListener;
private List<Recording> mRecordings;
private Context mContext;
private RecordingViewHolder.ClickListener mClickListener;
public RecordingsAdapter(
Context context,
@ -47,14 +47,14 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
SelectableHelper helper) {
super(helper);
this.recordings = recordings;
this.context = context;
this.clickListener = listener;
mRecordings = recordings;
mContext = context;
mClickListener = listener;
}
@Override
public Object getItem(int position) {
return recordings.get(position);
return mRecordings.get(position);
}
@NonNull
@ -63,13 +63,13 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
View v =
LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.recording_cell, viewGroup, false);
return new RecordingViewHolder(v, clickListener);
return new RecordingViewHolder(v, mClickListener);
}
@SuppressLint("SimpleDateFormat")
@Override
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
@ -80,7 +80,7 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
viewHolder.select.setChecked(isSelected(i));
if (i > 0) {
Recording previousRecord = recordings.get(i - 1);
Recording previousRecord = mRecordings.get(i - 1);
Date previousRecordDate = previousRecord.getRecordDate();
Calendar previousRecordTime = Calendar.getInstance();
previousRecordTime.setTime(previousRecordDate);
@ -198,20 +198,20 @@ public class RecordingsAdapter extends SelectableAdapter<RecordingViewHolder> {
@Override
public int getItemCount() {
return recordings.size();
return mRecordings.size();
}
@SuppressLint("SimpleDateFormat")
private String DateToHumanDate(Calendar cal) {
SimpleDateFormat dateFormat;
if (isToday(cal)) {
return context.getString(R.string.today);
return mContext.getString(R.string.today);
} else if (isYesterday(cal)) {
return context.getString(R.string.yesterday);
return mContext.getString(R.string.yesterday);
} else {
dateFormat =
new SimpleDateFormat(
context.getResources().getString(R.string.history_date_format));
mContext.getResources().getString(R.string.history_date_format));
}
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.
*/
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@ -48,8 +47,8 @@ import org.linphone.utils.LinphoneUtils;
public class AccountPreferencesFragment extends PreferencesListFragment
implements AccountCreatorListener {
private int n;
OnPreferenceClickListener linkAccountListener =
private int mN;
private OnPreferenceClickListener linkAccountListener =
new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
@ -57,14 +56,14 @@ public class AccountPreferencesFragment extends PreferencesListFragment
assistant.setClass(LinphoneActivity.instance(), AssistantActivity.class);
assistant.putExtra("LinkPhoneNumber", true);
assistant.putExtra("FromPref", true);
assistant.putExtra("AccountNumber", n);
assistant.putExtra("AccountNumber", mN);
startActivity(assistant);
return true;
}
};
private boolean isNewAccount = false;
private boolean mIsNewAccount = false;
private LinphonePreferences mPrefs;
OnPreferenceChangeListener avpfRRIntervalChangedListener =
private OnPreferenceChangeListener mAvpfRRIntervalChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@ -76,82 +75,82 @@ public class AccountPreferencesFragment extends PreferencesListFragment
}
} catch (NumberFormatException nfe) {
}
if (isNewAccount) {
if (mIsNewAccount) {
// TODO
} else {
mPrefs.setAvpfRrInterval(n, value);
mPrefs.setAvpfRrInterval(mN, value);
}
preference.setSummary(value);
return true;
}
};
OnPreferenceChangeListener escapeChangedListener =
private OnPreferenceChangeListener mEscapeChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue;
if (isNewAccount) {
if (mIsNewAccount) {
// TODO
} else {
mPrefs.setReplacePlusByZeroZero(n, value);
mPrefs.setReplacePlusByZeroZero(mN, value);
}
return true;
}
};
OnPreferenceChangeListener pushNotificationListener =
private OnPreferenceChangeListener mPushNotificationListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue;
if (isNewAccount) {
if (mIsNewAccount) {
// TODO
} else {
mPrefs.enablePushNotifForProxy(n, value);
mPrefs.enablePushNotifForProxy(mN, value);
}
return true;
}
};
OnPreferenceChangeListener iceChangedListener =
private OnPreferenceChangeListener mIceChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue;
if (isNewAccount) {
if (mIsNewAccount) {
} else {
mPrefs.setAccountIce(n, value);
((CheckBoxPreference) preference).setChecked(mPrefs.getAccountIce(n));
mPrefs.setAccountIce(mN, value);
((CheckBoxPreference) preference).setChecked(mPrefs.getAccountIce(mN));
}
return true;
}
};
OnPreferenceChangeListener stunTurnChangedListener =
private OnPreferenceChangeListener mStunTurnChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
if (isNewAccount) {
if (mIsNewAccount) {
} else {
mPrefs.setAccountStunServer(n, value);
mPrefs.setAccountStunServer(mN, value);
preference.setSummary(value);
}
return true;
}
};
private EditTextPreference mProxyPreference;
OnPreferenceChangeListener transportChangedListener =
private OnPreferenceChangeListener mTransportChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = newValue.toString();
if (isNewAccount) {
if (mIsNewAccount) {
// TODO
// builder.setTransport(transport);
// mBuilder.setTransport(transport);
} else {
mPrefs.setAccountTransport(n, key);
preference.setSummary(mPrefs.getAccountTransportString(n));
preference.setDefaultValue(mPrefs.getAccountTransportKey(n));
mPrefs.setAccountTransport(mN, key);
preference.setSummary(mPrefs.getAccountTransportString(mN));
preference.setDefaultValue(mPrefs.getAccountTransportKey(mN));
if (mProxyPreference != null) {
String newProxy = mPrefs.getAccountProxy(n);
String newProxy = mPrefs.getAccountProxy(mN);
mProxyPreference.setSummary(newProxy);
mProxyPreference.setText(newProxy);
}
@ -160,161 +159,158 @@ public class AccountPreferencesFragment extends PreferencesListFragment
}
};
private ListPreference mTransportPreference;
private AccountBuilder builder;
OnPreferenceChangeListener usernameChangedListener =
private AccountBuilder mBuilder;
private OnPreferenceChangeListener mUsernameChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isEditTextEmpty(newValue.toString())) return false;
if (isNewAccount) {
builder.setUsername(newValue.toString());
if (mIsNewAccount) {
mBuilder.setUsername(newValue.toString());
} else {
mPrefs.setAccountUsername(n, newValue.toString());
mPrefs.setAccountUsername(mN, newValue.toString());
}
preference.setSummary(newValue.toString());
return true;
}
};
OnPreferenceChangeListener useridChangedListener =
private OnPreferenceChangeListener mUseridChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) {
builder.setUserid(newValue.toString());
if (mIsNewAccount) {
mBuilder.setUserid(newValue.toString());
} else {
mPrefs.setAccountUserId(n, newValue.toString());
mPrefs.setAccountUserId(mN, newValue.toString());
}
preference.setSummary(newValue.toString());
return true;
}
};
OnPreferenceChangeListener passwordChangedListener =
private OnPreferenceChangeListener mPasswordChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isEditTextEmpty(newValue.toString())) return false;
if (isNewAccount) {
builder.setPassword(newValue.toString());
if (mIsNewAccount) {
mBuilder.setPassword(newValue.toString());
} else {
mPrefs.setAccountPassword(n, newValue.toString());
mPrefs.setAccountPassword(mN, newValue.toString());
}
return true;
}
};
OnPreferenceChangeListener domainChangedListener =
private OnPreferenceChangeListener mDomainChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isEditTextEmpty(newValue.toString())) return false;
if (isNewAccount) {
builder.setDomain(newValue.toString());
if (mIsNewAccount) {
mBuilder.setDomain(newValue.toString());
} else {
mPrefs.setAccountDomain(n, newValue.toString());
mPrefs.setAccountDomain(mN, newValue.toString());
}
preference.setSummary(newValue.toString());
return true;
}
};
OnPreferenceChangeListener displayNameChangedListener =
private OnPreferenceChangeListener mDisplayNameChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) {
builder.setDisplayName(newValue.toString());
if (mIsNewAccount) {
mBuilder.setDisplayName(newValue.toString());
} else {
mPrefs.setAccountDisplayName(n, newValue.toString());
mPrefs.setAccountDisplayName(mN, newValue.toString());
}
preference.setSummary(newValue.toString());
return true;
}
};
OnPreferenceChangeListener proxyChangedListener =
private OnPreferenceChangeListener mProxyChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
if (isNewAccount) {
builder.setServerAddr(newValue.toString());
if (mIsNewAccount) {
mBuilder.setServerAddr(newValue.toString());
preference.setSummary(newValue.toString());
} else {
mPrefs.setAccountProxy(n, value);
preference.setSummary(mPrefs.getAccountProxy(n));
mPrefs.setAccountProxy(mN, value);
preference.setSummary(mPrefs.getAccountProxy(mN));
if (mTransportPreference != null) {
mTransportPreference.setSummary(mPrefs.getAccountTransportString(n));
mTransportPreference.setValue(mPrefs.getAccountTransportKey(n));
mTransportPreference.setSummary(mPrefs.getAccountTransportString(mN));
mTransportPreference.setValue(mPrefs.getAccountTransportKey(mN));
}
}
return true;
}
};
OnPreferenceChangeListener outboundProxyChangedListener =
private OnPreferenceChangeListener mOutboundProxyChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) {
builder.setOutboundProxyEnabled((Boolean) newValue);
if (mIsNewAccount) {
mBuilder.setOutboundProxyEnabled((Boolean) newValue);
} else {
mPrefs.setAccountOutboundProxyEnabled(n, (Boolean) newValue);
mPrefs.setAccountOutboundProxyEnabled(mN, (Boolean) newValue);
}
return true;
}
};
OnPreferenceChangeListener expiresChangedListener =
private OnPreferenceChangeListener mExpiresChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (isNewAccount) {
builder.setExpires(newValue.toString());
if (mIsNewAccount) {
mBuilder.setExpires(newValue.toString());
} else {
mPrefs.setExpires(n, newValue.toString());
mPrefs.setExpires(mN, newValue.toString());
}
preference.setSummary(newValue.toString());
return true;
}
};
OnPreferenceChangeListener prefixChangedListener =
private OnPreferenceChangeListener mPrefixChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
preference.setSummary(value);
if (isNewAccount) {
builder.setPrefix(value);
if (mIsNewAccount) {
mBuilder.setPrefix(value);
} else {
mPrefs.setPrefix(n, value);
mPrefs.setPrefix(mN, value);
}
return true;
}
};
OnPreferenceChangeListener avpfChangedListener =
private OnPreferenceChangeListener mAvpfChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue;
if (isNewAccount) {
builder.setAvpfEnabled(value);
} else {
mPrefs.setAvpfMode(n, value);
if (!mIsNewAccount) {
mPrefs.setAvpfMode(mN, value);
}
return true;
}
};
OnPreferenceChangeListener disableChangedListener =
private OnPreferenceChangeListener mDisableChangedListener =
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue;
if (isNewAccount) {
builder.setEnabled(!value);
if (mIsNewAccount) {
mBuilder.setEnabled(!value);
} else {
mPrefs.setAccountEnabled(n, !value);
mPrefs.setAccountEnabled(mN, !value);
}
return true;
}
};
private AccountCreator accountCreator;
private ProgressDialog progress;
private AccountCreator mAccountCreator;
public AccountPreferencesFragment() {
super(R.xml.account_preferences);
@ -339,10 +335,10 @@ public class AccountPreferencesFragment extends PreferencesListFragment
super.onCreate(savedInstanceState);
PreferenceScreen screen = getPreferenceScreen();
n = getArguments().getInt("Account", 0);
if (n == mPrefs.getAccountCount()) {
isNewAccount = true;
builder = new AccountBuilder(LinphoneManager.getLc());
mN = getArguments().getInt("Account", 0);
if (mN == mPrefs.getAccountCount()) {
mIsNewAccount = true;
mBuilder = new AccountBuilder(LinphoneManager.getLc());
}
initAccountPreferencesFields(screen);
@ -353,12 +349,12 @@ public class AccountPreferencesFragment extends PreferencesListFragment
}
private void initAccountPreferencesFields(PreferenceScreen parent) {
boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == n;
boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == mN;
NatPolicy natPolicy = null;
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null
&& LinphoneManager.getLc().getProxyConfigList() != null
&& LinphoneManager.getLc().getProxyConfigList().length > n) {
ProxyConfig proxy = LinphoneManager.getLc().getProxyConfigList()[n];
&& LinphoneManager.getLc().getProxyConfigList().length > mN) {
ProxyConfig proxy = LinphoneManager.getLc().getProxyConfigList()[mN];
natPolicy = proxy.getNatPolicy();
if (natPolicy == null) {
natPolicy = LinphoneManager.getLc().createNatPolicy();
@ -368,46 +364,46 @@ public class AccountPreferencesFragment extends PreferencesListFragment
}
}
accountCreator =
mAccountCreator =
LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this);
mAccountCreator.setListener(this);
final PreferenceCategory account =
(PreferenceCategory)
getPreferenceScreen()
.findPreference(getString(R.string.pref_sipaccount_key));
EditTextPreference username = (EditTextPreference) account.getPreference(0);
username.setOnPreferenceChangeListener(usernameChangedListener);
if (!isNewAccount) {
username.setText(mPrefs.getAccountUsername(n));
username.setOnPreferenceChangeListener(mUsernameChangedListener);
if (!mIsNewAccount) {
username.setText(mPrefs.getAccountUsername(mN));
username.setSummary(username.getText());
}
EditTextPreference userid = (EditTextPreference) account.getPreference(1);
userid.setOnPreferenceChangeListener(useridChangedListener);
if (!isNewAccount) {
userid.setText(mPrefs.getAccountUserId(n));
userid.setOnPreferenceChangeListener(mUseridChangedListener);
if (!mIsNewAccount) {
userid.setText(mPrefs.getAccountUserId(mN));
userid.setSummary(userid.getText());
}
EditTextPreference password = (EditTextPreference) account.getPreference(2);
password.setOnPreferenceChangeListener(passwordChangedListener);
if (!isNewAccount) {
password.setText(mPrefs.getAccountPassword(n));
password.setOnPreferenceChangeListener(mPasswordChangedListener);
if (!mIsNewAccount) {
password.setText(mPrefs.getAccountPassword(mN));
}
EditTextPreference domain = (EditTextPreference) account.getPreference(3);
domain.setOnPreferenceChangeListener(domainChangedListener);
if (!isNewAccount) {
domain.setText(mPrefs.getAccountDomain(n));
domain.setOnPreferenceChangeListener(mDomainChangedListener);
if (!mIsNewAccount) {
domain.setText(mPrefs.getAccountDomain(mN));
domain.setSummary(domain.getText());
}
EditTextPreference displayName = (EditTextPreference) account.getPreference(4);
displayName.setOnPreferenceChangeListener(displayNameChangedListener);
if (!isNewAccount) {
displayName.setText(mPrefs.getAccountDisplayName(n));
displayName.setOnPreferenceChangeListener(mDisplayNameChangedListener);
if (!mIsNewAccount) {
displayName.setText(mPrefs.getAccountDisplayName(mN));
displayName.setSummary(displayName.getText());
}
@ -416,26 +412,26 @@ public class AccountPreferencesFragment extends PreferencesListFragment
getPreferenceScreen().findPreference(getString(R.string.pref_advanced_key));
mTransportPreference = (ListPreference) advanced.getPreference(0);
initializeTransportPreference(mTransportPreference);
mTransportPreference.setOnPreferenceChangeListener(transportChangedListener);
if (!isNewAccount) {
mTransportPreference.setSummary(mPrefs.getAccountTransportString(n));
mTransportPreference.setOnPreferenceChangeListener(mTransportChangedListener);
if (!mIsNewAccount) {
mTransportPreference.setSummary(mPrefs.getAccountTransportString(mN));
}
CheckBoxPreference ice = (CheckBoxPreference) advanced.getPreference(1);
ice.setOnPreferenceChangeListener(iceChangedListener);
ice.setOnPreferenceChangeListener(mIceChangedListener);
if (natPolicy != null) ice.setChecked(natPolicy.iceEnabled());
EditTextPreference stunTurn = (EditTextPreference) advanced.getPreference(2);
stunTurn.setOnPreferenceChangeListener(stunTurnChangedListener);
stunTurn.setOnPreferenceChangeListener(mStunTurnChangedListener);
if (natPolicy != null) {
stunTurn.setText(natPolicy.getStunServer());
stunTurn.setSummary(natPolicy.getStunServer());
}
mProxyPreference = (EditTextPreference) advanced.getPreference(3);
mProxyPreference.setOnPreferenceChangeListener(proxyChangedListener);
if (!isNewAccount) {
mProxyPreference.setText(mPrefs.getAccountProxy(n));
mProxyPreference.setOnPreferenceChangeListener(mProxyChangedListener);
if (!mIsNewAccount) {
mProxyPreference.setText(mPrefs.getAccountProxy(mN));
mProxyPreference.setSummary(
"".equals(mProxyPreference.getText()) || (mProxyPreference.getText() == null)
? getString(R.string.pref_help_proxy)
@ -443,52 +439,52 @@ public class AccountPreferencesFragment extends PreferencesListFragment
}
CheckBoxPreference outboundProxy = (CheckBoxPreference) advanced.getPreference(4);
outboundProxy.setOnPreferenceChangeListener(outboundProxyChangedListener);
if (!isNewAccount) {
outboundProxy.setChecked(mPrefs.isAccountOutboundProxySet(n));
outboundProxy.setOnPreferenceChangeListener(mOutboundProxyChangedListener);
if (!mIsNewAccount) {
outboundProxy.setChecked(mPrefs.isAccountOutboundProxySet(mN));
}
EditTextPreference expires = (EditTextPreference) advanced.getPreference(5);
expires.setOnPreferenceChangeListener(expiresChangedListener);
if (!isNewAccount) {
expires.setText(mPrefs.getExpires(n));
expires.setSummary(mPrefs.getExpires(n));
expires.setOnPreferenceChangeListener(mExpiresChangedListener);
if (!mIsNewAccount) {
expires.setText(mPrefs.getExpires(mN));
expires.setSummary(mPrefs.getExpires(mN));
}
EditTextPreference prefix = (EditTextPreference) advanced.getPreference(6);
prefix.setOnPreferenceChangeListener(prefixChangedListener);
if (!isNewAccount) {
String prefixValue = mPrefs.getPrefix(n);
prefix.setOnPreferenceChangeListener(mPrefixChangedListener);
if (!mIsNewAccount) {
String prefixValue = mPrefs.getPrefix(mN);
prefix.setText(prefixValue);
prefix.setSummary(prefixValue);
}
CheckBoxPreference avpf = (CheckBoxPreference) advanced.getPreference(7);
avpf.setOnPreferenceChangeListener(avpfChangedListener);
if (!isNewAccount) {
avpf.setChecked(mPrefs.avpfEnabled(n));
avpf.setOnPreferenceChangeListener(mAvpfChangedListener);
if (!mIsNewAccount) {
avpf.setChecked(mPrefs.avpfEnabled(mN));
}
EditTextPreference avpfRRInterval = (EditTextPreference) advanced.getPreference(8);
avpfRRInterval.setOnPreferenceChangeListener(avpfRRIntervalChangedListener);
if (!isNewAccount) {
avpfRRInterval.setText(mPrefs.getAvpfRrInterval(n));
avpfRRInterval.setSummary(mPrefs.getAvpfRrInterval(n));
avpfRRInterval.setOnPreferenceChangeListener(mAvpfRRIntervalChangedListener);
if (!mIsNewAccount) {
avpfRRInterval.setText(mPrefs.getAvpfRrInterval(mN));
avpfRRInterval.setSummary(mPrefs.getAvpfRrInterval(mN));
}
CheckBoxPreference escape = (CheckBoxPreference) advanced.getPreference(9);
escape.setOnPreferenceChangeListener(escapeChangedListener);
if (!isNewAccount) {
escape.setChecked(mPrefs.getReplacePlusByZeroZero(n));
escape.setOnPreferenceChangeListener(mEscapeChangedListener);
if (!mIsNewAccount) {
escape.setChecked(mPrefs.getReplacePlusByZeroZero(mN));
}
Preference linkAccount = advanced.getPreference(10);
linkAccount.setOnPreferenceClickListener(linkAccountListener);
CheckBoxPreference pushNotif = (CheckBoxPreference) advanced.getPreference(11);
pushNotif.setOnPreferenceChangeListener(pushNotificationListener);
if (!isNewAccount) {
pushNotif.setChecked(mPrefs.isPushNotifEnabledForProxy(n));
pushNotif.setOnPreferenceChangeListener(mPushNotificationListener);
if (!mIsNewAccount) {
pushNotif.setChecked(mPrefs.isPushNotifEnabledForProxy(mN));
}
PreferenceCategory manage =
@ -496,9 +492,9 @@ public class AccountPreferencesFragment extends PreferencesListFragment
getPreferenceScreen().findPreference(getString(R.string.pref_manage_key));
final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0);
disable.setEnabled(true);
disable.setOnPreferenceChangeListener(disableChangedListener);
if (!isNewAccount) {
disable.setChecked(!mPrefs.isAccountEnabled(n));
disable.setOnPreferenceChangeListener(mDisableChangedListener);
if (!mIsNewAccount) {
disable.setChecked(!mPrefs.isAccountEnabled(mN));
}
CheckBoxPreference mainAccount = (CheckBoxPreference) manage.getPreference(1);
@ -507,14 +503,14 @@ public class AccountPreferencesFragment extends PreferencesListFragment
mainAccount.setOnPreferenceClickListener(
new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
mPrefs.setDefaultAccount(n);
mPrefs.setDefaultAccount(mN);
disable.setEnabled(false);
disable.setChecked(false);
preference.setEnabled(false);
return true;
}
});
if (!isNewAccount) {
if (!mIsNewAccount) {
mainAccount.setEnabled(!mainAccount.isChecked());
}
@ -522,11 +518,11 @@ public class AccountPreferencesFragment extends PreferencesListFragment
changePassword.setEnabled(false);
final Preference delete = manage.getPreference(3);
delete.setEnabled(!isNewAccount);
delete.setEnabled(!mIsNewAccount);
delete.setOnPreferenceClickListener(
new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
mPrefs.deleteAccount(n);
mPrefs.deleteAccount(mN);
LinphoneActivity.instance().displaySettings();
LinphoneActivity.instance().refreshAccounts();
return true;
@ -548,10 +544,10 @@ public class AccountPreferencesFragment extends PreferencesListFragment
}
setListPreferenceValues(pref, entries, values);
if (!isNewAccount) {
pref.setSummary(mPrefs.getAccountTransportString(n));
pref.setDefaultValue(mPrefs.getAccountTransportKey(n));
pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(n)));
if (!mIsNewAccount) {
pref.setSummary(mPrefs.getAccountTransportString(mN));
pref.setDefaultValue(mPrefs.getAccountTransportKey(mN));
pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(mN)));
} else {
pref.setSummary(getString(R.string.pref_transport_udp));
@ -574,8 +570,8 @@ public class AccountPreferencesFragment extends PreferencesListFragment
super.onPause();
if (LinphoneActivity.isInstanciated()) {
try {
if (isNewAccount) {
builder.saveNewAccount();
if (mIsNewAccount) {
mBuilder.saveNewAccount();
}
} catch (CoreException e) {
Log.e(e);
@ -589,14 +585,13 @@ public class AccountPreferencesFragment extends PreferencesListFragment
@Override
public void onUpdateAccount(
AccountCreator accountCreator, AccountCreator.Status status, String resp) {
if (progress != null) progress.dismiss();
if (status.equals(AccountCreator.Status.RequestOk)) {
mPrefs.setAccountPassword(n, accountCreator.getPassword());
mPrefs.setAccountPassword(mN, accountCreator.getPassword());
PreferenceCategory account =
(PreferenceCategory)
getPreferenceScreen()
.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(
getString(R.string.pref_password_changed), LinphoneActivity.instance());
} else {

View file

@ -52,24 +52,25 @@ import org.linphone.utils.LinphoneUtils;
public class LinphonePreferences {
private static final int LINPHONE_CORE_RANDOM_PORT = -1;
private static LinphonePreferences instance;
private static LinphonePreferences sInstance;
private Context mContext;
private String basePath;
private String mBasePath;
// Tunnel settings
private TunnelConfig tunnelConfig = null;
private TunnelConfig mTunnelConfig = null;
private LinphonePreferences() {}
public static final synchronized LinphonePreferences instance() {
if (instance == null) {
instance = new LinphonePreferences();
if (sInstance == null) {
sInstance = new LinphonePreferences();
}
return instance;
return sInstance;
}
public void setContext(Context c) {
mContext = c;
basePath = mContext.getFilesDir().getAbsolutePath();
mBasePath = mContext.getFilesDir().getAbsolutePath();
}
private String getString(int key) {
@ -93,7 +94,7 @@ public class LinphonePreferences {
}
if (!LinphoneManager.isInstanciated()) {
File linphonerc = new File(basePath + "/.linphonerc");
File linphonerc = new File(mBasePath + "/.linphonerc");
if (linphonerc.exists()) {
return Factory.instance().createConfig(linphonerc.getAbsolutePath());
} else if (mContext != null) {
@ -114,15 +115,11 @@ public class LinphonePreferences {
return Factory.instance().createConfigFromString(text.toString());
}
} else {
return Factory.instance().createConfig(LinphoneManager.getInstance().mConfigFile);
return Factory.instance().createConfig(LinphoneManager.getInstance().configFile);
}
return null;
}
public void removePreviousVersionAuthInfoRemoval() {
getConfig().setBool("sip", "store_auth_info", true);
}
// App settings
public boolean isFirstLaunch() {
return getConfig().getBool("app", "first_launch", true);
@ -138,15 +135,6 @@ public class LinphonePreferences {
return ringtone;
}
public void setRingtone(String ringtonePath) {
getConfig().setString("app", "ringtone", ringtonePath);
}
// End of app settings
public boolean shouldAutomaticallyAcceptFriendsRequests() {
return false; // TODO
}
// Accounts settings
private ProxyConfig getProxyConfig(int n) {
if (getLc() == null) return null;
@ -324,10 +312,6 @@ public class LinphonePreferences {
setAccountPassword(n, password, null);
}
public void setAccountHa1(int n, String ha1) {
setAccountPassword(n, null, ha1);
}
private void setAccountPassword(int n, String password, String ha1) {
if (getLc() == null) return;
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) {
String identity = "sip:" + getAccountUsername(n) + "@" + domain;
AuthInfo old_info = getAuthInfo(n);
@ -661,13 +640,6 @@ public class LinphonePreferences {
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
// Video settings
@ -796,16 +768,6 @@ public class LinphonePreferences {
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() {
return getConfig().getString("app", "voice_mail", null);
}
@ -892,11 +854,6 @@ public class LinphonePreferences {
getLc().setNatPolicy(nat);
}
public boolean isUpnpEnabled() {
NatPolicy nat = getOrCreateNatPolicy();
return nat.upnpEnabled();
}
public void setUpnpEnabled(boolean enabled) {
if (getLc() == null) return;
NatPolicy nat = getOrCreateNatPolicy();
@ -1169,15 +1126,15 @@ public class LinphonePreferences {
if (getLc() == null) return null;
if (getLc().tunnelAvailable()) {
Tunnel tunnel = getLc().getTunnel();
if (tunnelConfig == null) {
if (mTunnelConfig == null) {
TunnelConfig servers[] = tunnel.getServers();
if (servers.length > 0) {
tunnelConfig = servers[0];
mTunnelConfig = servers[0];
} else {
tunnelConfig = Factory.instance().createTunnelConfig();
mTunnelConfig = Factory.instance().createTunnelConfig();
}
}
return tunnelConfig;
return mTunnelConfig;
} else {
return null;
}
@ -1240,10 +1197,6 @@ public class LinphonePreferences {
}
}
public void firstRemoteProvisioningSuccessful() {
getConfig().setBool("app", "first_remote_provisioning", false);
}
public boolean isFirstRemoteProvisioning() {
return getConfig().getBool("app", "first_remote_provisioning", true);
}
@ -1266,14 +1219,6 @@ public class LinphonePreferences {
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() {
return getConfig().getString("in-app-purchase", "server_url", null);
}
@ -1437,10 +1382,6 @@ public class LinphonePreferences {
return getConfig().getBool("app", "bis_feature", true);
}
public void enableBisFeature(boolean enable) {
getConfig().setBool("app", "bis_feature", enable);
}
public boolean isAutoAnswerEnabled() {
return getConfig().getBool("app", "auto_answer", false);
}
@ -1465,14 +1406,6 @@ public class LinphonePreferences {
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() {
return getConfig().getBool("app", "prefer_basic_chat_room", false);
}
@ -1496,15 +1429,11 @@ public class LinphonePreferences {
private String tempHa1;
private String tempDomain;
private String tempProxy;
private String tempRealm;
private String tempPrefix;
private boolean tempOutboundProxy;
private String tempContactsParams;
private String tempExpire;
private TransportType tempTransport;
private boolean tempAvpfEnabled = false;
private int tempAvpfRRInterval = 0;
private String tempQualityReportingCollector;
private boolean tempQualityReportingEnabled = false;
private int tempQualityReportingInterval = 0;
private boolean tempEnabled = true;
@ -1554,11 +1483,6 @@ public class LinphonePreferences {
return this;
}
public AccountBuilder setContactParameters(String contactParams) {
tempContactsParams = contactParams;
return this;
}
public AccountBuilder setExpires(String expire) {
tempExpire = expire;
return this;
@ -1569,51 +1493,21 @@ public class LinphonePreferences {
return this;
}
public AccountBuilder setAvpfEnabled(boolean enable) {
tempAvpfEnabled = enable;
return this;
}
public AccountBuilder setAvpfRrInterval(int interval) {
tempAvpfRRInterval = interval;
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) {
tempPrefix = prefix;
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) {
tempEnabled = enable;
return this;
}
public AccountBuilder setNoDefault(boolean yesno) {
tempNoDefault = yesno;
return this;
}
/**
* Creates a new account
*
@ -1666,7 +1560,6 @@ public class LinphonePreferences {
prxCfg.setRoute(route);
prxCfg.enableRegister(tempEnabled);
if (tempContactsParams != null) prxCfg.setContactUriParameters(tempContactsParams);
if (tempExpire != null) {
prxCfg.setExpires(Integer.parseInt(tempExpire));
}
@ -1674,7 +1567,6 @@ public class LinphonePreferences {
prxCfg.setAvpfMode(AVPFMode.Enabled);
prxCfg.setAvpfRrInterval(tempAvpfRRInterval);
prxCfg.enableQualityReporting(tempQualityReportingEnabled);
prxCfg.setQualityReportingCollector(tempQualityReportingCollector);
prxCfg.setQualityReportingInterval(tempQualityReportingInterval);
String regId = LinphonePreferences.instance().getPushNotificationRegistrationID();
@ -1695,8 +1587,6 @@ public class LinphonePreferences {
prxCfg.setDialPrefix(tempPrefix);
}
if (tempRealm != null) prxCfg.setRealm(tempRealm);
AuthInfo authInfo =
Factory.instance()
.createAuthInfo(
@ -1704,7 +1594,7 @@ public class LinphonePreferences {
tempUserId,
tempPassword,
tempHa1,
tempRealm,
null,
tempDomain);
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 MSG_BIND_PREFERENCES = 0;
private PreferenceManager mPreferenceManager;
private ListView preferencesList;
private ListView mPreferencesList;
private Handler mHandler =
new Handler() {
@Override
@ -61,10 +62,10 @@ public class PreferencesListFragment extends ListFragment {
}
}
};
private int xmlResID;
private int mXmlResID;
public PreferencesListFragment(int xmlId) {
this.xmlResID = xmlId;
mXmlResID = xmlId;
}
// Must be provided
@ -75,13 +76,13 @@ public class PreferencesListFragment extends ListFragment {
// Hack to correctly display preferences
View view = inflater.inflate(R.layout.settings, null);
ViewParent p = preferencesList.getParent();
ViewParent p = mPreferencesList.getParent();
if (p != null) {
((ViewGroup) p).removeView(preferencesList);
((ViewGroup) p).removeView(mPreferencesList);
}
RelativeLayout layout = view.findViewById(R.id.topLayout);
layout.addView(preferencesList);
layout.addView(mPreferencesList);
postBindPreferences();
return view;
@ -90,9 +91,9 @@ public class PreferencesListFragment extends ListFragment {
@Override
public void onDestroyView() {
super.onDestroyView();
ViewParent p = preferencesList.getParent();
ViewParent p = mPreferencesList.getParent();
if (p != null) {
((ViewGroup) p).removeView(preferencesList);
((ViewGroup) p).removeView(mPreferencesList);
}
}
@ -101,16 +102,16 @@ public class PreferencesListFragment extends ListFragment {
super.onCreate(bundle);
if (bundle != null) {
xmlResID = bundle.getInt("xml");
mXmlResID = bundle.getInt("xml");
}
mPreferenceManager = onCreatePreferenceManager();
preferencesList =
mPreferencesList =
(ListView)
LayoutInflater.from(getActivity())
.inflate(R.layout.preference_list_content, null);
preferencesList.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
addPreferencesFromResource(xmlResID);
mPreferencesList.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
addPreferencesFromResource(mXmlResID);
postBindPreferences();
}
@ -129,7 +130,7 @@ public class PreferencesListFragment extends ListFragment {
@Override
public void onDestroy() {
super.onDestroy();
preferencesList = null;
mPreferencesList = null;
try {
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy");
m.setAccessible(true);
@ -141,7 +142,7 @@ public class PreferencesListFragment extends ListFragment {
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putInt("xml", xmlResID);
outState.putInt("xml", mXmlResID);
super.onSaveInstanceState(outState);
}
@ -172,8 +173,8 @@ public class PreferencesListFragment extends ListFragment {
private void bindPreferences() {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null && preferencesList != null) {
preferenceScreen.bind(preferencesList);
if (preferenceScreen != null && mPreferencesList != null) {
preferenceScreen.bind(mPreferencesList);
}
}

View file

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

View file

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

View file

@ -1,18 +1,37 @@
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.media.MediaScannerConnection;
import android.net.Uri;
import java.io.File;
import org.linphone.mediastream.Log;
public class LinphoneMediaScanner implements MediaScannerConnection.MediaScannerConnectionClient {
public class MediaScanner implements MediaScannerConnection.MediaScannerConnectionClient {
private MediaScannerConnection mMediaConnection;
private boolean mIsConnected;
private File mFileWaitingForScan;
private MediaScannerListener mListener;
public LinphoneMediaScanner(Context context) {
public MediaScanner(Context context) {
mIsConnected = false;
mMediaConnection = new MediaScannerConnection(context, this);
mMediaConnection.connect();

View file

@ -32,9 +32,9 @@ import org.linphone.fragments.DialerFragment;
@SuppressLint("AppCompatCustomView")
public class AddressText extends EditText implements AddressType {
private String displayedName;
private String mDisplayedName;
private Paint mTestPaint;
private DialerFragment dialer;
private DialerFragment mDialer;
public AddressText(Context context, AttributeSet attrs) {
super(context, attrs);
@ -44,15 +44,15 @@ public class AddressText extends EditText implements AddressType {
}
public void clearDisplayedName() {
displayedName = null;
mDisplayedName = null;
}
public String getDisplayedName() {
return displayedName;
return mDisplayedName;
}
public void setDisplayedName(String displayedName) {
this.displayedName = displayedName;
this.mDisplayedName = displayedName;
}
private String getHintText() {
@ -69,8 +69,8 @@ public class AddressText extends EditText implements AddressType {
refitText(getWidth(), getHeight());
if (dialer != null) {
dialer.enableDisableAddContact();
if (mDialer != null) {
mDialer.enableDisableAddContact();
}
super.onTextChanged(text, start, before, after);
@ -126,6 +126,6 @@ public class AddressText extends EditText implements AddressType {
}
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;
public class AsyncBitmap extends BitmapDrawable {
private final WeakReference<BitmapWorkerTask> bitmapWorkerTaskReference;
private final WeakReference<BitmapWorkerTask> mBitmapWorkerTaskReference;
public AsyncBitmap(Resources res, Bitmap bitmap, BitmapWorkerTask bitmapWorkerTask) {
super(res, bitmap);
bitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask);
mBitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask);
}
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;
public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
public String path;
private final WeakReference<ImageView> mImageViewReference;
private Context mContext;
private Bitmap mDefaultBitmap;
@ -49,7 +50,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
mDefaultBitmap = defaultBitmap;
path = null;
// 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) {
@ -93,7 +94,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
bm = BitmapFactory.decodeFile(path);
}
ImageView imageView = imageViewReference.get();
ImageView imageView = mImageViewReference.get();
try {
// Rotate the bitmap if possible/needed, using EXIF data
@ -145,8 +146,8 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
bitmap.recycle();
bitmap = null;
}
if (imageViewReference != null && bitmap != null) {
final ImageView imageView = imageViewReference.get();
if (mImageViewReference != null && bitmap != null) {
final ImageView imageView = mImageViewReference.get();
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
if (this == bitmapWorkerTask && imageView != null) {
imageView.setImageBitmap(bitmap);

View file

@ -25,9 +25,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.core.Call;
import org.linphone.core.CallLog;
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;
public class ContactSelectView extends View {
private TextView contactName;
private ImageView deleteContact;
private TextView mContactName;
private ImageView mDeleteContact;
public ContactSelectView(Context context) {
super(context);
@ -40,22 +40,22 @@ public class ContactSelectView extends View {
View view = inflater.inflate(R.layout.contact_selected, null);
contactName = view.findViewById(R.id.sipUri);
deleteContact = view.findViewById(R.id.contactChatDelete);
mContactName = view.findViewById(R.id.sipUri);
mDeleteContact = view.findViewById(R.id.contactChatDelete);
}
public void setContactName(ContactAddress ca) {
if (ca.getContact() != null) {
contactName.setText(ca.getContact().getFirstName());
mContactName.setText(ca.getContact().getFirstName());
} else {
LinphoneManager.getLc()
.createFriendWithAddress(ca.getAddressAsDisplayableString())
.getName();
contactName.setText(ca.getAddressAsDisplayableString());
mContactName.setText(ca.getAddressAsDisplayableString());
}
}
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
implements AddressAware, OnClickListener, OnLongClickListener, TextWatcher {
private AddressText address;
private AddressText mAddress;
public EraseButton(Context context, AttributeSet attrs) {
super(context, attrs);
@ -41,24 +41,24 @@ public class EraseButton extends ImageView
}
public void onClick(View v) {
if (address.getText().length() > 0) {
int lBegin = address.getSelectionStart();
if (mAddress.getText().length() > 0) {
int lBegin = mAddress.getSelectionStart();
if (lBegin == -1) {
lBegin = address.getEditableText().length() - 1;
lBegin = mAddress.getEditableText().length() - 1;
}
if (lBegin > 0) {
address.getEditableText().delete(lBegin - 1, lBegin);
mAddress.getEditableText().delete(lBegin - 1, lBegin);
}
}
}
public boolean onLongClick(View v) {
address.getEditableText().clear();
mAddress.getEditableText().clear();
return true;
}
public void setAddressWidget(AddressText view) {
address = view;
mAddress = view;
view.addTextChangedListener(this);
}

View file

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

View file

@ -39,19 +39,16 @@ import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2JNIView {
private WindowManager wm;
private WindowManager.LayoutParams params;
private DisplayMetrics metrics;
private float x;
private float y;
private float touchX;
private float touchY;
private boolean dragEnabled;
private AndroidVideoWindowImpl androidVideoWindowImpl;
private WindowManager mWindowManager;
private WindowManager.LayoutParams mParams;
private DisplayMetrics mMetrics;
private float mX, mY, mTouchX, mTouchY;
private boolean mDragEnabled;
private AndroidVideoWindowImpl mAndroidVideoWindowImpl;
public LinphoneOverlay(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs);
wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int LAYOUT_FLAG;
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;
}
params =
mParams =
new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
LAYOUT_FLAG,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
metrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(metrics);
mParams.gravity = Gravity.TOP | Gravity.LEFT;
mMetrics = new DisplayMetrics();
mWindowManager.getDefaultDisplay().getMetrics(mMetrics);
androidVideoWindowImpl =
mAndroidVideoWindowImpl =
new AndroidVideoWindowImpl(
this,
null,
@ -92,9 +89,9 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
Call call = LinphoneManager.getLc().getCurrentCall();
CallParams callParams = call.getCurrentParams();
params.width = callParams.getReceivedVideoDefinition().getWidth();
params.height = callParams.getReceivedVideoDefinition().getHeight();
LinphoneManager.getLc().setNativeVideoWindowId(androidVideoWindowImpl);
mParams.width = callParams.getReceivedVideoDefinition().getWidth();
mParams.height = callParams.getReceivedVideoDefinition().getHeight();
LinphoneManager.getLc().setNativeVideoWindowId(mAndroidVideoWindowImpl);
setOnClickListener(
new OnClickListener() {
@ -111,7 +108,7 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
dragEnabled = true;
mDragEnabled = true;
return true;
}
});
@ -126,27 +123,27 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
}
public void destroy() {
androidVideoWindowImpl.release();
mAndroidVideoWindowImpl.release();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
x = event.getRawX();
y = event.getRawY();
mX = event.getRawX();
mY = event.getRawY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
touchX = event.getX();
touchY = event.getY();
mTouchX = event.getX();
mTouchY = event.getY();
break;
case MotionEvent.ACTION_MOVE:
if (dragEnabled) {
if (mDragEnabled) {
updateViewPostion();
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
touchX = touchY = 0;
dragEnabled = false;
mTouchX = mTouchY = 0;
mDragEnabled = false;
break;
default:
break;
@ -155,16 +152,18 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
}
private void updateViewPostion() {
params.x =
Math.min(Math.max(0, (int) (x - touchX)), metrics.widthPixels - getMeasuredWidth());
params.y =
mParams.x =
Math.min(
Math.max(0, (int) (y - touchY)),
metrics.heightPixels - getMeasuredHeight());
wm.updateViewLayout(this, params);
Math.max(0, (int) (mX - mTouchX)),
mMetrics.widthPixels - getMeasuredWidth());
mParams.y =
Math.min(
Math.max(0, (int) (mY - mTouchY)),
mMetrics.heightPixels - getMeasuredHeight());
mWindowManager.updateViewLayout(this, mParams);
}
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_SERVER_NOT_REACHABLE = "SERVER_NOT_REACHABLE";
private XmlRpcSession xmlRpcSession;
private XmlRpcSession mXmlRpcSession;
public XmlRpcHelper() {
xmlRpcSession =
mXmlRpcSession =
LinphoneManager.getLcIfManagerNotDestroyedOrNull()
.createXmlRpcSession(
LinphonePreferences.instance()
@ -57,7 +57,7 @@ public class XmlRpcHelper {
public void createAccountAsync(
final XmlRpcListener listener, String username, String email, String password) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "create_account");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "create_account");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -79,13 +79,13 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(email);
xmlRpcRequest.addStringArg(password == null ? "" : password);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void getAccountExpireAsync(
final XmlRpcListener listener, String username, String password) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "get_account_expiration");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "get_account_expiration");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -106,7 +106,7 @@ public class XmlRpcHelper {
});
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void updateAccountExpireAsync(
@ -117,7 +117,7 @@ public class XmlRpcHelper {
String payload,
String signature) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "update_expiration_date");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "update_expiration_date");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -141,13 +141,13 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(domain);
xmlRpcRequest.addStringArg(payload);
xmlRpcRequest.addStringArg(signature);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void activateAccountAsync(
final XmlRpcListener listener, String username, String password) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "activate_account");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "activate_account");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -168,12 +168,12 @@ public class XmlRpcHelper {
});
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void isAccountActivatedAsync(final XmlRpcListener listener, String username) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -195,13 +195,13 @@ public class XmlRpcHelper {
}
});
xmlRpcRequest.addStringArg(username);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void isTrialAccountAsync(
final XmlRpcListener listener, String username, String password) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "is_account_trial");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "is_account_trial");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -220,12 +220,12 @@ public class XmlRpcHelper {
});
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void isAccountAsync(final XmlRpcListener listener, String username) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "check_account_activated");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -247,13 +247,13 @@ public class XmlRpcHelper {
}
});
xmlRpcRequest.addStringArg(username);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void changeAccountEmailAsync(
final XmlRpcListener listener, String username, String password, String newEmail) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "change_email");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "change_email");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -276,7 +276,7 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(password);
xmlRpcRequest.addStringArg(newEmail);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void changeAccountPasswordAsync(
@ -285,7 +285,7 @@ public class XmlRpcHelper {
String oldPassword,
String newPassword) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "change_password");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "change_password");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -308,7 +308,7 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(oldPassword);
xmlRpcRequest.addStringArg(newPassword);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void changeAccountHashPasswordAsync(
@ -317,7 +317,7 @@ public class XmlRpcHelper {
String oldPassword,
String newPassword) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "change_hash");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "change_hash");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -340,13 +340,13 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(oldPassword);
xmlRpcRequest.addStringArg(newPassword);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void sendRecoverPasswordLinkByEmailAsync(
final XmlRpcListener listener, String usernameOrEmail) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(
mXmlRpcSession.createRequest(
XmlRpcArgType.String, "send_reset_account_password_email");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@ -368,13 +368,13 @@ public class XmlRpcHelper {
}
});
xmlRpcRequest.addStringArg(usernameOrEmail);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void sendActivateAccountLinkByEmailAsync(
final XmlRpcListener listener, String usernameOrEmail) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "resend_activation_email");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "resend_activation_email");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -395,12 +395,12 @@ public class XmlRpcHelper {
}
});
xmlRpcRequest.addStringArg(usernameOrEmail);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void sendUsernameByEmailAsync(final XmlRpcListener listener, String email) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "recover_username_from_email");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "recover_username_from_email");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -421,13 +421,13 @@ public class XmlRpcHelper {
}
});
xmlRpcRequest.addStringArg(email);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void verifySignatureAsync(
final XmlRpcListener listener, String payload, String signature) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "check_payload_signature");
mXmlRpcSession.createRequest(XmlRpcArgType.String, "check_payload_signature");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@Override
@ -450,13 +450,13 @@ public class XmlRpcHelper {
});
xmlRpcRequest.addStringArg(payload);
xmlRpcRequest.addStringArg(signature);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
public void getRemoteProvisioningFilenameAsync(
final XmlRpcListener listener, String username, String domain, String password) {
XmlRpcRequest xmlRpcRequest =
xmlRpcSession.createRequest(
mXmlRpcSession.createRequest(
XmlRpcArgType.String, "get_remote_provisioning_filename");
xmlRpcRequest.setListener(
new XmlRpcRequestListener() {
@ -480,6 +480,6 @@ public class XmlRpcHelper {
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(domain);
xmlRpcRequest.addStringArg(password);
xmlRpcSession.sendRequest(xmlRpcRequest);
mXmlRpcSession.sendRequest(xmlRpcRequest);
}
}