User preference to disable animation + about in settings + different animation for incall options if landscape

This commit is contained in:
Sylvain Berfini 2012-09-21 11:27:22 +02:00
parent c26ad9c0b1
commit db485c4679
20 changed files with 230 additions and 63 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -104,6 +104,7 @@
<string name="pref_video_initiate_call_with_video_title">Initier les appels en vidéo</string>
<string name="pref_video_initiate_call_with_video"></string>
<string name="pref_video_enable_title">Activer la vidéo</string>
<string name="pref_animation_enable_title">Activer les animations</string>
<string name="pref_escape_plus">Remplacer + par 00</string>
<string name="pref_ilbc_summary">iLBC peut être indisponible suivant le processeur ARM et la version d\'Android.</string>
<string name="pref_echo_cancellation">Annulateur d\'écho</string>

View file

@ -13,6 +13,7 @@
<bool name="use_simple_history">true</bool>
<bool name="replace_settings_by_about">false</bool>
<bool name="replace_chat_by_about">false</bool>
<bool name="display_about_in_settings">true</bool>
<bool name="hide_camera_settings">false</bool>
<bool name="hide_wizard">false</bool>

View file

@ -56,6 +56,7 @@
<string name="pref_video_automatically_accept_video_key">pref_video_automatically_accept_video_key</string>
<string name="pref_video_initiate_call_with_video_key">pref_video_initiate_call_with_video_key</string>
<string name="pref_video_enable_key">pref_video_enable_key</string>
<string name="pref_animation_enable_key">pref_animation_enable_key</string>
<string name="pref_escape_plus_key">pref_escape_plus_key</string>
<string name="pref_echo_cancellation_key">pref_echo_cancellation_key</string>
<string name="pref_autostart_key">pref_autostart_key</string>

View file

@ -136,6 +136,7 @@
<string name="pref_video_initiate_call_with_video_title">Initiate video calls</string>
<string name="pref_video_initiate_call_with_video"></string>
<string name="pref_video_enable_title">Enable Video</string>
<string name="pref_animation_enable_title">Enable Animations</string>
<string name="pref_escape_plus">Replace + by 00</string>
<string name="pref_ilbc_summary">iLBC might be unavailable depending on ARM processor and Android OS version.</string>
<string name="pref_echo_cancellation">Echo cancellation</string>

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:title="@string/menu_about"/>
<PreferenceCategory
android:title="@string/pref_sipaccounts"/>
@ -41,6 +44,11 @@
android:defaultValue="true"
android:title="@string/pref_video_enable_title"
android:key="@string/pref_video_enable_key" />
<CheckBoxPreference
android:defaultValue="true"
android:title="@string/pref_animation_enable_title"
android:key="@string/pref_animation_enable_key" />
<EditTextPreference
android:title="@string/pref_stun_server"

View file

@ -27,6 +27,7 @@ public enum FragmentsAvailable {
HISTORY_DETAIL,
CONTACTS,
CONTACT,
ABOUT,
ABOUT_INSTEAD_OF_SETTINGS,
ABOUT_INSTEAD_OF_CHAT,
ACCOUNT_SETTINGS,
@ -66,6 +67,7 @@ public enum FragmentsAvailable {
case CHAT:
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
case ABOUT:
case ABOUT_INSTEAD_OF_SETTINGS:
case SETTINGS:
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST || fragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;

View file

@ -255,7 +255,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil
return;
}
if (getActivity().getResources().getBoolean(R.bool.disable_animations)) {
if (LinphoneActivity.instance().isAnimationDisabled()) {
deleteAll.setVisibility(View.INVISIBLE);
} else {
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_right_to_left);
@ -285,7 +285,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil
return;
}
if (getActivity().getResources().getBoolean(R.bool.disable_animations)) {
if (LinphoneActivity.instance().isAnimationDisabled()) {
deleteAll.setVisibility(View.VISIBLE);
} else {
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left_to_right);

View file

@ -179,7 +179,7 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener,
return;
}
if (getActivity().getResources().getBoolean(R.bool.disable_animations)) {
if (LinphoneActivity.instance().isAnimationDisabled()) {
deleteAll.setVisibility(View.INVISIBLE);
} else {
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_right_to_left);
@ -209,7 +209,7 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener,
return;
}
if (getActivity().getResources().getBoolean(R.bool.disable_animations)) {
if (LinphoneActivity.instance().isAnimationDisabled()) {
deleteAll.setVisibility(View.VISIBLE);
} else {
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left_to_right);

View file

@ -32,6 +32,7 @@ import org.linphone.ui.Numpad;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
@ -91,7 +92,9 @@ public class InCallActivity extends FragmentActivity implements
isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled");
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !prefs.getBoolean(getString(R.string.pref_animation_enable_key), true);
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
if (findViewById(R.id.fragmentContainer) != null) {
@ -180,6 +183,9 @@ public class InCallActivity extends FragmentActivity implements
}
private void refreshInCallActions() {
if (mHandler == null) {
mHandler = new Handler();
}
mHandler.post(new Runnable() {
@Override
public void run() {
@ -224,6 +230,9 @@ public class InCallActivity extends FragmentActivity implements
}
private void enableAndRefreshInCallActions() {
if (mHandler == null) {
mHandler = new Handler();
}
mHandler.post(new Runnable() {
@Override
public void run() {
@ -604,7 +613,154 @@ public class InCallActivity extends FragmentActivity implements
}
}
private void hideAnimatedPortraitCallOptions() {
Animation animation = slideOutLeftToRight;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (isTransferAllowed) {
transfer.setVisibility(View.INVISIBLE);
}
addCall.setVisibility(View.INVISIBLE);
animation.setAnimationListener(null);
}
});
if (isTransferAllowed) {
transfer.startAnimation(animation);
}
addCall.startAnimation(animation);
}
private void hideAnimatedLandscapeCallOptions() {
Animation animation = slideOutTopToBottom;
if (isTransferAllowed) {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
transfer.setAnimation(null);
transfer.setVisibility(View.INVISIBLE);
animation = AnimationUtils.loadAnimation(InCallActivity.this, R.anim.slide_out_top_to_bottom); // Reload animation to prevent transfer button to blink
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
addCall.setVisibility(View.INVISIBLE);
}
});
addCall.startAnimation(animation);
}
});
transfer.startAnimation(animation);
} else {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
addCall.setVisibility(View.INVISIBLE);
}
});
addCall.startAnimation(animation);
}
}
private void showAnimatedPortraitCallOptions() {
Animation animation = slideInRightToLeft;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
options.setImageResource(R.drawable.options_alt);
if (isTransferAllowed) {
transfer.setVisibility(View.VISIBLE);
}
addCall.setVisibility(View.VISIBLE);
animation.setAnimationListener(null);
}
});
if (isTransferAllowed) {
transfer.startAnimation(animation);
}
addCall.startAnimation(animation);
}
private void showAnimatedLandscapeCallOptions() {
Animation animation = slideInBottomToTop;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
addCall.setAnimation(null);
options.setImageResource(R.drawable.options_alt);
addCall.setVisibility(View.VISIBLE);
if (isTransferAllowed) {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
transfer.setVisibility(View.VISIBLE);
}
});
transfer.startAnimation(animation);
}
}
});
addCall.startAnimation(animation);
}
private void hideOrDisplayCallOptions() {
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
if (addCall.getVisibility() == View.VISIBLE) {
options.setImageResource(R.drawable.options);
if (isAnimationDisabled) {
@ -613,66 +769,25 @@ public class InCallActivity extends FragmentActivity implements
}
addCall.setVisibility(View.INVISIBLE);
} else {
Animation animation = slideOutLeftToRight;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (isTransferAllowed) {
transfer.setVisibility(View.INVISIBLE);
}
addCall.setVisibility(View.INVISIBLE);
animation.setAnimationListener(null);
}
});
if (isTransferAllowed) {
transfer.startAnimation(animation);
if (isOrientationLandscape) {
hideAnimatedLandscapeCallOptions();
} else {
hideAnimatedPortraitCallOptions();
}
addCall.startAnimation(animation);
}
} else {
if (getResources().getBoolean(R.bool.disable_animations)) {
if (isAnimationDisabled) {
if (isTransferAllowed) {
transfer.setVisibility(View.VISIBLE);
}
addCall.setVisibility(View.VISIBLE);
options.setImageResource(R.drawable.options_alt);
} else {
Animation animation = slideInRightToLeft;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
options.setImageResource(R.drawable.options_alt);
if (isTransferAllowed) {
transfer.setVisibility(View.VISIBLE);
}
addCall.setVisibility(View.VISIBLE);
animation.setAnimationListener(null);
}
});
if (isTransferAllowed) {
transfer.startAnimation(animation);
if (isOrientationLandscape) {
showAnimatedLandscapeCallOptions();
} else {
showAnimatedPortraitCallOptions();
}
addCall.startAnimation(animation);
}
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
}

View file

@ -99,7 +99,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
private Fragment dialerFragment, messageListenerFragment;
private SavedState dialerSavedState;
private ChatStorage chatStorage;
private boolean preferLinphoneContacts = false;
private boolean preferLinphoneContacts = false, isAnimationDisabled = false;
private Handler mHandler = new Handler();
private List<Contact> contactList, sipContactList;
private Cursor contactCursor, sipContactCursor;
@ -159,6 +159,8 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
LinphoneManager.getLc().setDeviceRotation(rotation);
mAlwaysChangingPhoneAngle = rotation;
updateAnimationsState();
}
private void initButtons() {
@ -255,6 +257,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
case ACCOUNT_SETTINGS:
newFragment = new AccountPreferencesFragment();
break;
case ABOUT:
case ABOUT_INSTEAD_OF_CHAT:
case ABOUT_INSTEAD_OF_SETTINGS:
newFragment = new AboutFragment();
@ -278,6 +281,15 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
}
}
private void updateAnimationsState() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !prefs.getBoolean(getString(R.string.pref_animation_enable_key), true);
}
public boolean isAnimationDisabled() {
return isAnimationDisabled;
}
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
if (newFragmentType == FragmentsAvailable.DIALER) {
@ -293,7 +305,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (!withoutAnimation && !getResources().getBoolean(R.bool.disable_animations) && currentFragment.shouldAnimate()) {
if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
if (newFragmentType.isRightOf(currentFragment)) {
transaction.setCustomAnimations(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right);
} else {
@ -344,7 +356,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
ll.setVisibility(View.INVISIBLE);
}
if (!withoutAnimation && !getResources().getBoolean(R.bool.disable_animations) && currentFragment.shouldAnimate()) {
if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
if (newFragmentType.isRightOf(currentFragment)) {
transaction.setCustomAnimations(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right);
} else {
@ -445,6 +457,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
changeCurrentFragment(FragmentsAvailable.CONTACTS, extras);
}
public void displayAbout() {
changeCurrentFragment(FragmentsAvailable.ABOUT, null);
}
public void displayChat(String sipUri) {
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver());
@ -592,6 +608,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
public void applyConfigChangesIfNeeded() {
if (nextFragment != FragmentsAvailable.SETTINGS && nextFragment != FragmentsAvailable.ACCOUNT_SETTINGS) {
reloadConfig();
updateAnimationsState();
}
}
@ -709,7 +726,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
if (missedCallsCount > 0) {
missedCalls.setText(missedCallsCount + "");
missedCalls.setVisibility(View.VISIBLE);
if (!getResources().getBoolean(R.bool.disable_animations)) {
if (!isAnimationDisabled) {
missedCalls.startAnimation(AnimationUtils.loadAnimation(LinphoneActivity.this, R.anim.bounce));
}
} else {
@ -732,7 +749,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
missedChats.setTextSize(20);
}
missedChats.setVisibility(View.VISIBLE);
if (!getResources().getBoolean(R.bool.disable_animations)) {
if (!isAnimationDisabled) {
missedChats.startAnimation(AnimationUtils.loadAnimation(LinphoneActivity.this, R.anim.bounce));
}
} else {
@ -1087,6 +1104,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
if (currentFragment == FragmentsAvailable.SETTINGS) {
reloadConfig();
updateAnimationsState();
}
}
} else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {

View file

@ -71,9 +71,10 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
private int nbAccounts = 1;
private PreferenceCategory accounts;
private static final int ACCOUNTS_SETTINGS_ID = 0;
private static final int WIZARD_SETTINGS_ID = 1;
private static final int CAMERA_SETTINGS_ID = 5;
private static final int ABOUT_SETTINGS_ID = 0;
private static final int ACCOUNTS_SETTINGS_ID = 1;
private static final int WIZARD_SETTINGS_ID = 2;
private static final int CAMERA_SETTINGS_ID = 6;
private static final int WIZARD_INTENT = 1;
public PreferencesFragment() {
@ -99,6 +100,10 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
addWizardPreferenceButton();
}
if (getResources().getBoolean(R.bool.disable_animations)) {
uncheckDisableAndHideCheckbox(R.string.pref_animation_enable_key);
}
addTransportChecboxesListener();
ecCalibratePref = (CheckBoxPreference) findPreference(pref_echo_canceller_calibration_key);
@ -174,6 +179,21 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
Preference enableVideo = findPreference(R.string.pref_video_enable_key);
enableVideo.setLayoutResource(R.layout.hidden);
}
if (getResources().getBoolean(R.bool.display_about_in_settings)) {
getPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().displayAbout();
return true;
}
return false;
}
});
} else {
getPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setLayoutResource(R.layout.hidden);
}
}
private void hidePreferenceCategory(int key) {