Add topbar in settings and about menu

add option for portrait orientation only
This commit is contained in:
Margaux Clerc 2015-11-17 10:15:06 +01:00
parent 9b8b32d06f
commit 756a183436
12 changed files with 100 additions and 118 deletions

View file

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.linphone"
android:versionCode="2510" android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="23"/>
android:versionCode="2599" android:installLocation="auto">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23"/>
<!-- Permissions for Push Notification -->
<permission android:name="org.linphone.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <!-- Change package ! -->

View file

@ -5,32 +5,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/top_bar"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="70dp">
<TextView
android:text="@string/about"
style="@style/font1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center_vertical"/>
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:contentDescription="@string/content_description_dialer"
android:layout_width="70dp"
android:layout_height="match_parent"
android:padding="20dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<ImageView
android:src="@drawable/linphone_orange"
android:layout_width="wrap_content"

View file

@ -22,11 +22,40 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/top_bar"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"
android:visibility="gone"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/menu_name"
style="@style/font1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center_vertical"/>
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:contentDescription="@string/content_description_dialer"
android:layout_width="70dp"
android:layout_height="match_parent"
android:padding="15dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_above="@id/footer">
android:layout_above="@id/footer"
android:layout_below="@id/top_bar">
<FrameLayout
android:layout_width="match_parent"

View file

@ -1,9 +1,6 @@
[net]
mtu=1300
[app]
animations=0
[sip]
guess_hostname=1
inc_timeout=15

View file

@ -6,6 +6,9 @@
<string name="default_domain">sip.linphone.org</string>
<string name="default_stun">stun.linphone.org</string>
<bool name="use_linphone_friend">false</bool>
<bool name="orientation_portrait_only">false</bool>
<bool name="show_statusbar_only_on_dialer">false</bool>
<string name="wizard_url">https://www.linphone.org/wizard.php</string>

View file

@ -20,6 +20,9 @@
<string name="deny">Deny</string>
<string name="no_account">No account configured</string>
<string name="search">Search</string>
<string name="outgoing">outgoing</string>
<string name="incoming">incoming</string>
<string name="missed">missed</string>
<!-- splashscreen -->
<string name="app_description">free SIP VOIP client</string>

View file

@ -37,7 +37,6 @@ import android.widget.TextView;
public class AboutFragment extends Fragment implements OnClickListener {
View sendLogButton = null;
View resetLogButton = null;
private ImageView cancel;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -50,9 +49,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
Log.e(e, "cannot get version name");
}
cancel = (ImageView) view.findViewById(R.id.cancel);
cancel.setOnClickListener(this);
sendLogButton = view.findViewById(R.id.send_log);
sendLogButton.setOnClickListener(this);
sendLogButton.setVisibility(org.linphone.LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
@ -70,10 +66,10 @@ public class AboutFragment extends Fragment implements OnClickListener {
if (org.linphone.LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().hideTabBar(true);
LinphoneActivity.instance().displayTopBar(true,"About");
}
}
@Override
public void onClick(View v) {
if (org.linphone.LinphoneActivity.isInstanciated()) {
@ -86,8 +82,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
if (lc != null) {
lc.resetLogCollection();
}
} else if (v == cancel) {
getFragmentManager().popBackStackImmediate();
}
}
}

View file

@ -240,7 +240,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
}
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHATLIST);
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT_LIST);
LinphoneActivity.instance().updateChatListFragment(this);
LinphoneActivity.instance().hideTabBar(false);
}

View file

@ -31,7 +31,7 @@ public enum FragmentsAvailable {
ABOUT,
ACCOUNT_SETTINGS,
SETTINGS,
CHATLIST,
CHAT_LIST,
CHAT;
public boolean shouldAnimate() {
@ -58,18 +58,18 @@ public enum FragmentsAvailable {
case DIALER:
return CONTACT_EDITOR.isRightOf(fragment) || fragment == CONTACT_EDITOR;
case CHATLIST:
case CHAT_LIST:
return DIALER.isRightOf(fragment) || fragment == DIALER;
case SETTINGS:
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
return CHAT_LIST.isRightOf(fragment) || fragment == CHAT_LIST;
case ABOUT:
case ACCOUNT_SETTINGS:
return SETTINGS.isRightOf(fragment) || fragment == SETTINGS;
case CHAT:
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
return CHAT_LIST.isRightOf(fragment) || fragment == CHAT_LIST;
default:
return false;
@ -88,7 +88,7 @@ public enum FragmentsAvailable {
return fragment == CONTACT_DETAIL || fragment == CONTACTS_LIST;
case CHAT:
return fragment == CHATLIST;
return fragment == CHAT_LIST;
default:
return false;

View file

@ -98,11 +98,11 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
contactAddress.setText(sipUri);
}
if (status.equals("Missed")) {
if (status.equals(getResources().getString(R.string.missed))) {
callDirection.setImageResource(R.drawable.call_missed);
} else if (status.equals("Incoming")) {
} else if (status.equals(getResources().getString(R.string.incoming))) {
callDirection.setImageResource(R.drawable.call_incoming);
} else if (status.equals("Outgoing")) {
} else if (status.equals(getResources().getString(R.string.outgoing))) {
callDirection.setImageResource(R.drawable.call_outgoing);
}

View file

@ -57,7 +57,6 @@ import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@ -101,9 +100,11 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
private TextView missedCalls, missedChats;
private RelativeLayout contacts, history, dialer, chat;
private RelativeLayout contacts_selected, history_selected, dialer_selected, chat_selected;
private RelativeLayout mTopBar;
private ImageView cancel;
private FragmentsAvailable currentFragment, nextFragment;
private List<FragmentsAvailable> fragmentsHistory;
private Fragment dialerFragment, messageListFragment, friendStatusListenerFragment;
private Fragment dialerFragment, messageListFragment;
private ChatFragment chatFragment;
private Fragment.SavedState dialerSavedState;
private boolean newProxyConfig;
@ -118,7 +119,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
private ListView accountsList, sideMenuItemList;
private ImageView menu;
static final boolean isInstanciated() {
return instance != null;
}
@ -135,13 +135,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (isTablet() && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else if (!isTablet() && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (!isTablet() && getResources().getBoolean(R.bool.orientation_portrait_only)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
if (!LinphoneManager.isInstanciated()) {
Log.e("No service running: avoid crash by starting the launch", this.getClass().getName());
// super.onCreate called earlier
finish();
startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class));
return;
@ -161,6 +160,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
}
//TODO rework
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
} else {
@ -172,7 +172,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
fragmentsHistory = new ArrayList<FragmentsAvailable>();
initButtons();
createSideMenu();
initSideMenu();
currentFragment = nextFragment = FragmentsAvailable.DIALER;
fragmentsHistory.add(currentFragment);
@ -226,7 +226,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
@Override
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
if (state == State.IncomingReceived) {
//finish();
startActivity(new Intent(LinphoneActivity.instance(), CallIncomingActivity.class));
} else if (state == State.OutgoingInit || state == State.OutgoingProgress) {
startActivity(new Intent(LinphoneActivity.instance(), CallOutgoingActivity.class));
@ -279,24 +278,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
updateAnimationsState();
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
//mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Pass any configuration change to the drawer toggls
//mDrawerToggle.onConfigurationChanged(newConfig);
}
private void initButtons() {
mTabBar = (LinearLayout) findViewById(R.id.footer);
mTopBar = (RelativeLayout) findViewById(R.id.top_bar);
cancel = (ImageView) findViewById(R.id.cancel);
cancel.setOnClickListener(this);
history = (RelativeLayout) findViewById(R.id.history);
history.setOnClickListener(this);
@ -335,12 +322,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
if (statusFragment != null && !statusFragment.isVisible()) {
// Hack to ensure statusFragment is visible after coming back to
// dialer from chat
statusFragment.getView().setVisibility(View.VISIBLE);
}
findViewById(R.id.status).setVisibility(View.VISIBLE);
//findViewById(R.id.fragmentContainer).setPadding(0, LinphoneUtils.pixelsToDpi(getResources(), 40), 0, 0);
}
public void isNewProxyConfig(){
@ -375,7 +359,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
break;
case CONTACTS_LIST:
newFragment = new ContactsListFragment();
friendStatusListenerFragment = newFragment;
break;
case CONTACT_DETAIL:
newFragment = new ContactDetailsFragment();
@ -399,7 +382,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
case ABOUT:
newFragment = new AboutFragment();
break;
case CHATLIST:
case CHAT_LIST:
newFragment = new ChatListFragment();
messageListFragment = newFragment;
break;
@ -429,11 +412,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
/*if (statusFragment != null) {
statusFragment.closeStatusBar();
}*/
FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
@ -452,7 +430,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (newFragmentType != FragmentsAvailable.DIALER
|| newFragmentType != FragmentsAvailable.CONTACTS_LIST
|| newFragmentType != FragmentsAvailable.CHATLIST
|| newFragmentType != FragmentsAvailable.CHAT_LIST
|| newFragmentType != FragmentsAvailable.HISTORY_LIST) {
transaction.addToBackStack(newFragmentType.toString());
}
@ -464,16 +442,13 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
private void changeFragmentForTablets(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
// if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
// if (newFragmentType == FragmentsAvailable.DIALER) {
// showStatusBar();
// } else {
// hideStatusBar();
// }
// }
/*if (statusFragment != null) {
statusFragment.closeStatusBar();
}*/
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
if (newFragmentType == FragmentsAvailable.DIALER) {
showStatusBar();
} else {
hideStatusBar();
}
}
LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2);
@ -500,7 +475,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
transaction.setCustomAnimations(R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
}
}
transaction.replace(R.id.fragmentContainer, newFragment);
}
transaction.commitAllowingStateLoss();
@ -510,7 +484,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (newFragmentType == FragmentsAvailable.DIALER
|| newFragmentType == FragmentsAvailable.SETTINGS
|| newFragmentType == FragmentsAvailable.CONTACTS_LIST
|| newFragmentType == FragmentsAvailable.CHATLIST
|| newFragmentType == FragmentsAvailable.CHAT_LIST
|| newFragmentType == FragmentsAvailable.HISTORY_LIST) {
try {
getFragmentManager().popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
@ -527,6 +501,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
} catch (LinphoneCoreException e) {
Log.e("Cannot display history details",e);
//TODO display error message
return;
}
Contact c = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
@ -536,12 +511,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
String status;
if (log.getDirection() == CallDirection.Outgoing) {
status = "Outgoing";
status = getString(R.string.outgoing);
} else {
if (log.getStatus() == CallStatus.Missed) {
status = "Missed";
status = getString(R.string.missed);
} else {
status = "Incoming";
status = getString(R.string.incoming);
}
}
@ -601,7 +576,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
public void displayChatList() {
Bundle extras = new Bundle();
changeCurrentFragment(FragmentsAvailable.CHATLIST, extras);
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, extras);
}
public void displayContactsForEdition(String sipAddress) {
@ -613,7 +588,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
public void displayAbout() {
changeCurrentFragment(FragmentsAvailable.ABOUT, null);
//settings.setSelected(true);
}
public void displayAssistant() {
@ -649,8 +623,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
} else {
LinphoneAddress lAddress;
try {
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
lAddress = LinphoneManager.getLc().interpretUrl(sipUri);
} catch (LinphoneCoreException e) {
//TODO display error message
Log.e("Cannot display chat",e);
return;
}
@ -664,7 +639,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
thumbnailUri = contact.getThumbnailUri().toString();
}
if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT) {
if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.CHAT) {
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
ChatFragment chatFragment = (ChatFragment) fragment2;
@ -717,8 +692,11 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
changeCurrentFragment(FragmentsAvailable.DIALER, null);
dialer_selected.setVisibility(View.VISIBLE);
} else if (id == R.id.chat) {
changeCurrentFragment(FragmentsAvailable.CHATLIST, null);
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
chat_selected.setVisibility(View.VISIBLE);
} else if (id == R.id.cancel) {
displayTopBar(false,"");
getFragmentManager().popBackStackImmediate();
}
}
@ -737,6 +715,17 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
}
public void displayTopBar(Boolean display, String name) {
TextView menuName = (TextView) findViewById(R.id.menu_name);
if(display){
menuName.setText(name);
mTopBar.setVisibility(View.VISIBLE);
} else {
menuName.setText("");
mTopBar.setVisibility(View.GONE);
}
}
@SuppressWarnings("incomplete-switch")
public void selectMenu(FragmentsAvailable menuToSelect) {
currentFragment = menuToSelect;
@ -757,9 +746,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
break;
case SETTINGS:
case ACCOUNT_SETTINGS:
//settings.setSelected(true);
displayTopBar(true,"settings");
break;
case CHATLIST:
case CHAT_LIST:
case CHAT:
chat_selected.setVisibility(View.VISIBLE);
break;
@ -1213,8 +1202,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (call != null && call.getState() != LinphoneCall.State.IncomingReceived) {
if (call.getCurrentParamsCopy().getVideoEnabled()) {
startVideoActivity(call);
//startVideoActivity(call);
} else {
Log.w("outgoing call");
//startIncallActivity(call);
}
}
@ -1239,7 +1229,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (currentFragment == FragmentsAvailable.DIALER
|| currentFragment == FragmentsAvailable.CONTACTS_LIST
|| currentFragment == FragmentsAvailable.HISTORY_LIST
|| currentFragment == FragmentsAvailable.CHATLIST) {
|| currentFragment == FragmentsAvailable.CHAT_LIST) {
boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled();
if (!isBackgroundModeActive) {
stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
@ -1254,16 +1244,11 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
}
}
} /*else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
if (event.getRepeatCount() < 1) {
statusFragment.openOrCloseStatusBar(true);
}
}*/
}
return super.onKeyDown(keyCode, event);
}
//SIDE MENU
public void openOrCloseSideMenu(boolean open) {
if(open) {
sideMenu.openDrawer(sideMenuContent);
@ -1272,7 +1257,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
}
public void createSideMenu() {
public void initSideMenu() {
sideMenu = (DrawerLayout) findViewById(R.id.side_menu);
sideMenuItems = getResources().getStringArray(R.array.side_menu_item);
sideMenuContent = (RelativeLayout) findViewById(R.id.side_menu_content);
@ -1320,7 +1305,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
private int getStatusIconResource(LinphoneCore.RegistrationState state) {
try {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (state == RegistrationState.RegistrationOk) {
return R.drawable.led_connected;
} else if (state == RegistrationState.RegistrationProgress) {
@ -1396,8 +1380,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
accountsList = (ListView) findViewById(R.id.accounts_list);
defaultAccount = (RelativeLayout) findViewById(R.id.default_account);
displayMainAccount();
refreshAccounts();
}