Update status fragment
This commit is contained in:
parent
8bbf7097b3
commit
75b4322a20
1 changed files with 35 additions and 87 deletions
|
@ -17,15 +17,11 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import org.linphone.assistant.AssistantActivity;
|
import org.linphone.assistant.AssistantActivity;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCallParams;
|
|
||||||
import org.linphone.core.LinphoneCallStats;
|
|
||||||
import org.linphone.core.LinphoneContent;
|
import org.linphone.core.LinphoneContent;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
|
@ -33,10 +29,7 @@ import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneEvent;
|
import org.linphone.core.LinphoneEvent;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.PayloadType;
|
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.SlidingDrawer;
|
|
||||||
import org.linphone.ui.SlidingDrawer.OnDrawerOpenListener;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
@ -49,11 +42,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TableLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,9 +51,8 @@ import android.widget.TextView;
|
||||||
public class StatusFragment extends Fragment {
|
public class StatusFragment extends Fragment {
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Handler refreshHandler = new Handler();
|
private Handler refreshHandler = new Handler();
|
||||||
private TextView statusText, exit, voicemailCount;
|
private TextView statusText, voicemailCount;
|
||||||
private ImageView statusLed, callQuality, encryption, menu;
|
private ImageView statusLed, callQuality, encryption, menu, voicemail;
|
||||||
// private LinearLayout allAccountsLed;
|
|
||||||
private Runnable mCallQualityUpdater;
|
private Runnable mCallQualityUpdater;
|
||||||
private boolean isInCall, isAttached = false;
|
private boolean isInCall, isAttached = false;
|
||||||
private Timer mTimer;
|
private Timer mTimer;
|
||||||
|
@ -76,27 +64,14 @@ public class StatusFragment extends Fragment {
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.status, container, false);
|
View view = inflater.inflate(R.layout.status, container, false);
|
||||||
|
|
||||||
statusText = (TextView) view.findViewById(R.id.statusText);
|
statusText = (TextView) view.findViewById(R.id.status_text);
|
||||||
statusLed = (ImageView) view.findViewById(R.id.statusLed);
|
statusLed = (ImageView) view.findViewById(R.id.status_led);
|
||||||
callQuality = (ImageView) view.findViewById(R.id.callQuality);
|
callQuality = (ImageView) view.findViewById(R.id.call_quality);
|
||||||
encryption = (ImageView) view.findViewById(R.id.encryption);
|
encryption = (ImageView) view.findViewById(R.id.encryption);
|
||||||
menu = (ImageView) view.findViewById(R.id.menu_icon);
|
menu = (ImageView) view.findViewById(R.id.side_menu_button);
|
||||||
// allAccountsLed = (LinearLayout) view.findViewById(R.id.moreStatusLed);
|
voicemail = (ImageView) view.findViewById(R.id.voicemail);
|
||||||
|
voicemailCount = (TextView) view.findViewById(R.id.voicemail_count);
|
||||||
|
|
||||||
voicemailCount = (TextView) view.findViewById(R.id.voicemailCount);
|
|
||||||
|
|
||||||
exit = (TextView) view.findViewById(R.id.exit);
|
|
||||||
exit.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
|
||||||
LinphoneActivity.instance().exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (getResources().getBoolean(R.bool.exit_button_on_dialer))
|
|
||||||
exit.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
// We create it once to not delay the first display
|
// We create it once to not delay the first display
|
||||||
populateSliderContent();
|
populateSliderContent();
|
||||||
|
|
||||||
|
@ -110,6 +85,8 @@ public class StatusFragment extends Fragment {
|
||||||
if(lc.getProxyConfigList() == null){
|
if(lc.getProxyConfigList() == null){
|
||||||
statusLed.setVisibility(View.INVISIBLE);
|
statusLed.setVisibility(View.INVISIBLE);
|
||||||
statusText.setText("");
|
statusText.setText("");
|
||||||
|
} else {
|
||||||
|
statusLed.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lc.getDefaultProxyConfig() != null && lc.getDefaultProxyConfig().equals(proxy)) {
|
if (lc.getDefaultProxyConfig() != null && lc.getDefaultProxyConfig().equals(proxy)) {
|
||||||
|
@ -121,15 +98,12 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (getResources().getBoolean(R.bool.lock_statusbar)) {
|
statusText.setOnClickListener(new OnClickListener() {
|
||||||
statusText.setOnClickListener(new OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
lc.refreshRegisters();
|
||||||
lc.refreshRegisters();
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
// setMiniLedsForEachAccount();
|
|
||||||
} catch (IllegalStateException ise) {}
|
} catch (IllegalStateException ise) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +122,11 @@ public class StatusFragment extends Fragment {
|
||||||
|
|
||||||
unreadCount = Integer.parseInt(intToParse[0]);
|
unreadCount = Integer.parseInt(intToParse[0]);
|
||||||
if (unreadCount > 0) {
|
if (unreadCount > 0) {
|
||||||
voicemailCount.setText(unreadCount + " " + getResources().getString(R.string.voicemail_unread));
|
voicemailCount.setText(unreadCount);
|
||||||
|
voicemail.setVisibility(View.VISIBLE);
|
||||||
voicemailCount.setVisibility(View.VISIBLE);
|
voicemailCount.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
voicemail.setVisibility(View.GONE);
|
||||||
voicemailCount.setVisibility(View.GONE);
|
voicemailCount.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,12 +156,15 @@ public class StatusFragment extends Fragment {
|
||||||
} else if (activity instanceof InCallActivity) {
|
} else if (activity instanceof InCallActivity) {
|
||||||
((InCallActivity) activity).updateStatusFragment(this);
|
((InCallActivity) activity).updateStatusFragment(this);
|
||||||
isInCall = true;
|
isInCall = true;
|
||||||
} else if (activity instanceof ChatActivity) {
|
|
||||||
((ChatActivity) activity).updateStatusFragment(this);
|
|
||||||
isInCall = false;
|
|
||||||
} else if (activity instanceof AssistantActivity) {
|
} else if (activity instanceof AssistantActivity) {
|
||||||
((AssistantActivity) activity).updateStatusFragment(this);
|
((AssistantActivity) activity).updateStatusFragment(this);
|
||||||
isInCall = false;
|
isInCall = false;
|
||||||
|
} else if (activity instanceof IncomingCallActivity) {
|
||||||
|
((IncomingCallActivity) activity).updateStatusFragment(this);
|
||||||
|
isInCall = true;
|
||||||
|
} else if (activity instanceof OutgoingCallActivity) {
|
||||||
|
((OutgoingCallActivity) activity).updateStatusFragment(this);
|
||||||
|
isInCall = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,24 +173,9 @@ public class StatusFragment extends Fragment {
|
||||||
super.onDetach();
|
super.onDetach();
|
||||||
isAttached = false;
|
isAttached = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openOrCloseStatusBar() {
|
|
||||||
openOrCloseStatusBar(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openOrCloseStatusBar(boolean force) {
|
|
||||||
if (getResources().getBoolean(R.bool.lock_statusbar) && !force) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
//NORMAL STATUS BAR
|
||||||
|
|
||||||
public void closeStatusBar() {
|
|
||||||
if (getResources().getBoolean(R.bool.lock_statusbar)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateSliderContent() {
|
private void populateSliderContent() {
|
||||||
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) {
|
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) {
|
||||||
voicemailCount.setVisibility(View.GONE);
|
voicemailCount.setVisibility(View.GONE);
|
||||||
|
@ -230,27 +194,10 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableLeftMenu(boolean enabled) {
|
public void enableSideMenu(boolean enabled) {
|
||||||
menu.setEnabled(enabled);
|
menu.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void setMiniLedsForEachAccount() {
|
|
||||||
// if (allAccountsLed == null)
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) {
|
|
||||||
// allAccountsLed.removeAllViews();
|
|
||||||
// for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
|
|
||||||
// ImageView led = new ImageView(getActivity());
|
|
||||||
// LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
|
||||||
// led.setLayoutParams(params);
|
|
||||||
// led.setAdjustViewBounds(true);
|
|
||||||
// led.setImageResource(getStatusIconResource(lpc.getState(), false));
|
|
||||||
// allAccountsLed.addView(led);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private int getStatusIconResource(LinphoneCore.RegistrationState state, boolean isDefaultAccount) {
|
private int getStatusIconResource(LinphoneCore.RegistrationState state, boolean isDefaultAccount) {
|
||||||
try {
|
try {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
@ -294,7 +241,8 @@ public class StatusFragment extends Fragment {
|
||||||
|
|
||||||
return context.getString(R.string.status_not_connected);
|
return context.getString(R.string.status_not_connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//INCALL STATUS BAR
|
||||||
private void startCallQuality() {
|
private void startCallQuality() {
|
||||||
callQuality.setVisibility(View.VISIBLE);
|
callQuality.setVisibility(View.VISIBLE);
|
||||||
refreshHandler.postDelayed(mCallQualityUpdater = new Runnable() {
|
refreshHandler.postDelayed(mCallQualityUpdater = new Runnable() {
|
||||||
|
@ -353,12 +301,12 @@ public class StatusFragment extends Fragment {
|
||||||
LinphoneCall call = lc.getCurrentCall();
|
LinphoneCall call = lc.getCurrentCall();
|
||||||
if (isInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) {
|
if (isInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) {
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
//startCallQuality();
|
startCallQuality();
|
||||||
//refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
|
refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
|
||||||
}
|
}
|
||||||
|
menu.setVisibility(View.INVISIBLE);
|
||||||
statusText.setVisibility(View.GONE);
|
|
||||||
encryption.setVisibility(View.VISIBLE);
|
encryption.setVisibility(View.VISIBLE);
|
||||||
|
callQuality.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
// We are obviously connected
|
// We are obviously connected
|
||||||
statusLed.setImageResource(R.drawable.led_connected);
|
statusLed.setImageResource(R.drawable.led_connected);
|
||||||
|
|
Loading…
Reference in a new issue