/** * Copyright (C) 2010-2012 Regis Montoya (aka r3gis - www.r3gis.fr) * This file is part of CSipSimple. * * CSipSimple 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 3 of the License, or * (at your option) any later version. * If you own a pjsip commercial license you can also redistribute it * and/or modify it under the terms of the GNU Lesser General Public License * as an android library. * * CSipSimple 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 CSipSimple. If not, see <http://www.gnu.org/licenses/>. */ package com.csipsimple.wizards.impl; import android.text.InputType; import android.view.View; import android.view.ViewGroup; import com.csipsimple.R; import com.csipsimple.api.SipConfigManager; import com.csipsimple.api.SipProfile; import com.csipsimple.utils.PreferencesWrapper; import com.csipsimple.wizards.utils.AccountCreationFirstView; import com.csipsimple.wizards.utils.AccountCreationFirstView.OnAccountCreationFirstViewListener; import com.csipsimple.wizards.utils.AccountCreationWebview; import com.csipsimple.wizards.utils.AccountCreationWebview.OnAccountCreationDoneListener; public class Ingetel extends SimpleImplementation implements OnAccountCreationDoneListener, OnAccountCreationFirstViewListener { private static final String webCreationPage = "http://app.ingetel.com/subscriber/newSubscriberFree/newUser"; private AccountCreationWebview extAccCreator; private AccountCreationFirstView firstView; private ViewGroup validationBar; private ViewGroup settingsContainer; @Override protected String getDomain() { return "sip2.ingetel.com"; } @Override protected String getDefaultName() { return "Ingetel Mobile"; } @Override protected boolean canTcp() { return false; } @Override public void fillLayout(SipProfile account) { super.fillLayout(account); accountUsername.getEditText().setInputType(InputType.TYPE_CLASS_PHONE); settingsContainer = (ViewGroup) parent.findViewById(R.id.settings_container); validationBar = (ViewGroup) parent.findViewById(R.id.validation_bar); extAccCreator = new AccountCreationWebview(parent, webCreationPage, this); updateAccountInfos(account); } @Override public void setDefaultParams(PreferencesWrapper prefs) { super.setDefaultParams(prefs); prefs.setCodecPriority("g729/8000/1", SipConfigManager.CODEC_NB, "240"); prefs.setCodecPriority("g729/8000/1", SipConfigManager.CODEC_WB, "240"); } @Override public boolean needRestart() { return true; } private void setFirstViewVisibility(boolean visible) { if(firstView != null) { firstView.setVisibility(visible ? View.VISIBLE : View.GONE); } validationBar.setVisibility(visible ? View.GONE : View.VISIBLE); settingsContainer.setVisibility(visible ? View.GONE : View.VISIBLE); } private void updateAccountInfos(final SipProfile acc) { if (acc != null && acc.id != SipProfile.INVALID_ID) { setFirstViewVisibility(false); } else { if(firstView == null) { firstView = new AccountCreationFirstView(parent); ViewGroup globalContainer = (ViewGroup) settingsContainer.getParent(); firstView.setOnAccountCreationFirstViewListener(this); globalContainer.addView(firstView); } setFirstViewVisibility(true); } } @Override public void onAccountCreationDone(String username, String password) { setUsername(username); setPassword(password); } /** * {@inheritDoc} */ @Override public void onAccountCreationDone(String username, String password, String extra) { onAccountCreationDone(username, password); } @Override public boolean saveAndQuit() { if(canSave()) { parent.saveAndFinish(); return true; } return false; } @Override public void onCreateAccountRequested() { setFirstViewVisibility(false); extAccCreator.show(); } @Override public void onEditAccountRequested() { setFirstViewVisibility(false); } }