Updated status bar
This commit is contained in:
parent
995d9ea594
commit
7985be5a75
4 changed files with 71 additions and 17 deletions
|
@ -2,7 +2,7 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.linphone"
|
package="org.linphone"
|
||||||
android:versionCode="2000" android:versionName="2.0" android:installLocation="auto">
|
android:versionCode="2000" android:versionName="2.0" android:installLocation="auto">
|
||||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
|
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16"/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||||
|
|
|
@ -19,12 +19,14 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:stackFromBottom="true"
|
android:stackFromBottom="true"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
android:background="@android:color/black"/>
|
android:background="@android:color/black"/>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@id/handle"
|
android:id="@id/handle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -47,6 +49,14 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/moreStatusLed"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_toRightOf="@id/statusLed"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/content_description_call_quality"
|
android:contentDescription="@string/content_description_call_quality"
|
||||||
android:id="@+id/callQuality"
|
android:id="@+id/callQuality"
|
||||||
|
|
|
@ -208,6 +208,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
|
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
|
||||||
|
if (statusFragment != null) {
|
||||||
|
statusFragment.closeStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
if (!withoutAnimation && !getResources().getBoolean(R.bool.disable_animations) && currentFragment.shouldAnimate()) {
|
if (!withoutAnimation && !getResources().getBoolean(R.bool.disable_animations) && currentFragment.shouldAnimate()) {
|
||||||
|
|
|
@ -40,9 +40,9 @@ import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ public class StatusFragment extends Fragment {
|
||||||
private ImageView statusLed, callQuality, encryption;
|
private ImageView statusLed, callQuality, encryption;
|
||||||
private ListView sliderContent;
|
private ListView sliderContent;
|
||||||
private SlidingDrawer drawer;
|
private SlidingDrawer drawer;
|
||||||
|
private LinearLayout allAccountsLed;
|
||||||
private Runnable mCallQualityUpdater;
|
private Runnable mCallQualityUpdater;
|
||||||
private boolean isInCall, isAttached = false;
|
private boolean isInCall, isAttached = false;
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ public class StatusFragment extends Fragment {
|
||||||
statusLed = (ImageView) view.findViewById(R.id.statusLed);
|
statusLed = (ImageView) view.findViewById(R.id.statusLed);
|
||||||
callQuality = (ImageView) view.findViewById(R.id.callQuality);
|
callQuality = (ImageView) view.findViewById(R.id.callQuality);
|
||||||
encryption = (ImageView) view.findViewById(R.id.encryption);
|
encryption = (ImageView) view.findViewById(R.id.encryption);
|
||||||
|
allAccountsLed = (LinearLayout) view.findViewById(R.id.moreStatusLed);
|
||||||
|
|
||||||
drawer = (SlidingDrawer) view.findViewById(R.id.statusBar);
|
drawer = (SlidingDrawer) view.findViewById(R.id.statusBar);
|
||||||
drawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
|
drawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
|
||||||
|
@ -76,7 +78,9 @@ public class StatusFragment extends Fragment {
|
||||||
populateSliderContent();
|
populateSliderContent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sliderContent = (ListView) view.findViewById(R.id.content);
|
sliderContent = (ListView) view.findViewById(R.id.content);
|
||||||
|
|
||||||
exit = (TextView) view.findViewById(R.id.exit);
|
exit = (TextView) view.findViewById(R.id.exit);
|
||||||
exit.setOnClickListener(new OnClickListener() {
|
exit.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,7 +117,6 @@ public class StatusFragment extends Fragment {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
populateSliderContent();
|
|
||||||
if (getResources().getBoolean(R.bool.disable_animations)) {
|
if (getResources().getBoolean(R.bool.disable_animations)) {
|
||||||
drawer.toggle();
|
drawer.toggle();
|
||||||
} else {
|
} else {
|
||||||
|
@ -121,6 +124,18 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void closeStatusBar() {
|
||||||
|
if (getResources().getBoolean(R.bool.lock_statusbar)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getResources().getBoolean(R.bool.disable_animations)) {
|
||||||
|
drawer.close();
|
||||||
|
} else {
|
||||||
|
drawer.animateClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void populateSliderContent() {
|
private void populateSliderContent() {
|
||||||
sliderContent.setDividerHeight(0);
|
sliderContent.setDividerHeight(0);
|
||||||
AccountsListAdapter adapter = new AccountsListAdapter(LinphoneManager.getLc().getProxyConfigList());
|
AccountsListAdapter adapter = new AccountsListAdapter(LinphoneManager.getLc().getProxyConfigList());
|
||||||
|
@ -134,15 +149,32 @@ public class StatusFragment extends Fragment {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
statusLed.setImageResource(getStatusIconResource(state));
|
statusLed.setImageResource(getStatusIconResource(state, true));
|
||||||
statusText.setText(getStatusIconText(state));
|
statusText.setText(getStatusIconText(state));
|
||||||
|
setMiniLedsForEachAccount();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getStatusIconResource(LinphoneCore.RegistrationState state) {
|
private void setMiniLedsForEachAccount() {
|
||||||
|
if (allAccountsLed == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
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) {
|
||||||
try {
|
try {
|
||||||
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) {
|
boolean defaultAccountConnected = (isDefaultAccount && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) || !isDefaultAccount;
|
||||||
|
if (state == RegistrationState.RegistrationOk && defaultAccountConnected) {
|
||||||
return R.drawable.led_connected;
|
return R.drawable.led_connected;
|
||||||
} else if (state == RegistrationState.RegistrationProgress) {
|
} else if (state == RegistrationState.RegistrationProgress) {
|
||||||
return R.drawable.led_inprogress;
|
return R.drawable.led_inprogress;
|
||||||
|
@ -291,21 +323,26 @@ public class StatusFragment extends Fragment {
|
||||||
checkboxes = new ArrayList<CheckBox>();
|
checkboxes = new ArrayList<CheckBox>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private OnCheckedChangeListener defaultListener = new OnCheckedChangeListener() {
|
private OnClickListener defaultListener = new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onClick(View v) {
|
||||||
if (isChecked) {
|
CheckBox checkBox = (CheckBox) v;
|
||||||
|
if (checkBox.isChecked()) {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putInt(getString(R.string.pref_default_account), (Integer) buttonView.getTag());
|
int selectedPosition = (Integer) checkBox.getTag();
|
||||||
|
editor.putInt(getString(R.string.pref_default_account), selectedPosition);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
sliderContent.invalidate();
|
|
||||||
|
|
||||||
for (CheckBox cb : checkboxes) {
|
for (CheckBox cb : checkboxes) {
|
||||||
cb.setChecked(false);
|
cb.setChecked(false);
|
||||||
cb.setEnabled(true);
|
cb.setEnabled(true);
|
||||||
}
|
}
|
||||||
buttonView.setChecked(true);
|
checkBox.setChecked(true);
|
||||||
buttonView.setEnabled(false);
|
checkBox.setEnabled(false);
|
||||||
|
|
||||||
|
LinphoneManager.getLc().setDefaultProxyConfig(accounts[selectedPosition]);
|
||||||
|
LinphoneManager.getLc().refreshRegisters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -333,13 +370,13 @@ public class StatusFragment extends Fragment {
|
||||||
LinphoneProxyConfig lpc = (LinphoneProxyConfig) getItem(position);
|
LinphoneProxyConfig lpc = (LinphoneProxyConfig) getItem(position);
|
||||||
|
|
||||||
ImageView status = (ImageView) view.findViewById(R.id.State);
|
ImageView status = (ImageView) view.findViewById(R.id.State);
|
||||||
status.setImageResource(getStatusIconResource(lpc.getState()));
|
|
||||||
|
|
||||||
TextView identity = (TextView) view.findViewById(R.id.Identity);
|
TextView identity = (TextView) view.findViewById(R.id.Identity);
|
||||||
identity.setText(lpc.getIdentity().split("sip:")[1]);
|
identity.setText(lpc.getIdentity().split("sip:")[1]);
|
||||||
|
|
||||||
CheckBox isDefault = (CheckBox) view.findViewById(R.id.Default);
|
CheckBox isDefault = (CheckBox) view.findViewById(R.id.Default);
|
||||||
checkboxes.add(isDefault);
|
checkboxes.add(isDefault);
|
||||||
|
|
||||||
isDefault.setTag(position);
|
isDefault.setTag(position);
|
||||||
isDefault.setChecked(false);
|
isDefault.setChecked(false);
|
||||||
isDefault.setEnabled(true);
|
isDefault.setEnabled(true);
|
||||||
|
@ -347,8 +384,11 @@ public class StatusFragment extends Fragment {
|
||||||
if (prefs.getInt(getString(R.string.pref_default_account), 0) == position) {
|
if (prefs.getInt(getString(R.string.pref_default_account), 0) == position) {
|
||||||
isDefault.setChecked(true);
|
isDefault.setChecked(true);
|
||||||
isDefault.setEnabled(false);
|
isDefault.setEnabled(false);
|
||||||
|
status.setImageResource(getStatusIconResource(lpc.getState(), true));
|
||||||
|
} else {
|
||||||
|
status.setImageResource(getStatusIconResource(lpc.getState(), false));
|
||||||
}
|
}
|
||||||
isDefault.setOnCheckedChangeListener(defaultListener);
|
isDefault.setOnClickListener(defaultListener);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue