Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. |
| 3 | * |
| 4 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 5 | * Alexandre Savard <alexandre.savard@savoirfairelinux.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | * |
| 21 | * Additional permission under GNU GPL version 3 section 7: |
| 22 | * |
| 23 | * If you modify this program, or any covered work, by linking or |
| 24 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 25 | * modified version of that library), containing parts covered by the |
| 26 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 27 | * grants you additional permission to convey the resulting work. |
| 28 | * Corresponding Source for a non-source form of such a combination |
| 29 | * shall include the source code for the parts of OpenSSL used as well |
| 30 | * as that of the covered work. |
| 31 | */ |
| 32 | |
| 33 | package org.sflphone.client; |
| 34 | |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 35 | import java.util.ArrayList; |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 36 | import java.util.Locale; |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 37 | import java.util.Observable; |
| 38 | import java.util.Observer; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 39 | |
| 40 | import org.sflphone.R; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 41 | import org.sflphone.account.AccountDetailBasic; |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 42 | import org.sflphone.fragments.AdvancedAccountFragment; |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 43 | import org.sflphone.fragments.AudioManagementFragment; |
Alexandre Lision | 8907c1c | 2013-11-12 11:40:14 -0500 | [diff] [blame] | 44 | import org.sflphone.fragments.GeneralAccountFragment; |
Alexandre Lision | a365099 | 2013-11-13 14:19:35 -0500 | [diff] [blame] | 45 | import org.sflphone.fragments.NestedSettingsFragment; |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 46 | import org.sflphone.fragments.SecurityAccountFragment; |
Alexandre Lision | d2e9e06 | 2013-10-21 16:27:33 -0400 | [diff] [blame] | 47 | import org.sflphone.model.Account; |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 48 | import org.sflphone.service.ISipService; |
| 49 | import org.sflphone.service.SipService; |
Alexandre Lision | 8907c1c | 2013-11-12 11:40:14 -0500 | [diff] [blame] | 50 | import org.sflphone.views.PagerSlidingTabStrip; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 51 | |
| 52 | import android.app.Activity; |
| 53 | import android.app.AlertDialog; |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 54 | import android.app.Fragment; |
| 55 | import android.app.FragmentManager; |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 56 | import android.content.ComponentName; |
| 57 | import android.content.Context; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 58 | import android.content.DialogInterface; |
| 59 | import android.content.Intent; |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 60 | import android.content.ServiceConnection; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 61 | import android.os.Bundle; |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 62 | import android.os.IBinder; |
| 63 | import android.os.RemoteException; |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 64 | import android.support.v13.app.FragmentStatePagerAdapter; |
| 65 | import android.support.v4.view.ViewPager; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 66 | import android.util.Log; |
| 67 | import android.view.Menu; |
| 68 | import android.view.MenuInflater; |
| 69 | import android.view.MenuItem; |
| 70 | |
Alexandre Lision | 3f1aa68 | 2013-11-18 10:49:28 -0500 | [diff] [blame] | 71 | public class AccountEditionActivity extends Activity implements GeneralAccountFragment.Callbacks, AudioManagementFragment.Callbacks, |
Alexandre Lision | a365099 | 2013-11-13 14:19:35 -0500 | [diff] [blame] | 72 | AdvancedAccountFragment.Callbacks, SecurityAccountFragment.Callbacks, NestedSettingsFragment.Callbacks { |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 73 | private static final String TAG = AccountEditionActivity.class.getSimpleName(); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 74 | |
| 75 | public static final String KEY_MODE = "mode"; |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 76 | private boolean mBound = false; |
| 77 | private ISipService service; |
Alexandre Lision | d2e9e06 | 2013-10-21 16:27:33 -0400 | [diff] [blame] | 78 | private Account acc_selected; |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 79 | |
Alexandre Lision | 3f1aa68 | 2013-11-18 10:49:28 -0500 | [diff] [blame] | 80 | private ViewPager mViewPager; |
| 81 | |
| 82 | private NestedSettingsFragment toDisplay; |
| 83 | |
| 84 | private Observer mAccountObserver = new Observer() { |
| 85 | |
| 86 | @Override |
| 87 | public void update(Observable observable, Object data) { |
| 88 | processAccount(); |
| 89 | } |
| 90 | }; |
| 91 | |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 92 | PreferencesPagerAdapter mPreferencesPagerAdapter; |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 93 | private ServiceConnection mConnection = new ServiceConnection() { |
| 94 | |
| 95 | @Override |
| 96 | public void onServiceConnected(ComponentName className, IBinder binder) { |
| 97 | service = ISipService.Stub.asInterface(binder); |
| 98 | mBound = true; |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 99 | |
| 100 | ArrayList<Fragment> fragments = new ArrayList<Fragment>(); |
| 101 | if (acc_selected.isIP2IP()) { |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 102 | fragments.add(new AudioManagementFragment()); |
| 103 | } else { |
Alexandre Lision | 8907c1c | 2013-11-12 11:40:14 -0500 | [diff] [blame] | 104 | fragments.add(new GeneralAccountFragment()); |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 105 | fragments.add(new AudioManagementFragment()); |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 106 | fragments.add(new AdvancedAccountFragment()); |
| 107 | fragments.add(new SecurityAccountFragment()); |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 108 | } |
| 109 | |
Alexandre Lision | 3f1aa68 | 2013-11-18 10:49:28 -0500 | [diff] [blame] | 110 | mViewPager = (ViewPager) findViewById(R.id.pager); |
| 111 | |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 112 | mPreferencesPagerAdapter = new PreferencesPagerAdapter(AccountEditionActivity.this, getFragmentManager(), fragments); |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 113 | mViewPager.setAdapter(mPreferencesPagerAdapter); |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 114 | mViewPager.setOffscreenPageLimit(3); |
| 115 | |
Alexandre Lision | 8907c1c | 2013-11-12 11:40:14 -0500 | [diff] [blame] | 116 | final PagerSlidingTabStrip strip = PagerSlidingTabStrip.class.cast(findViewById(R.id.pager_sliding_strip)); |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 117 | |
Alexandre Lision | 8907c1c | 2013-11-12 11:40:14 -0500 | [diff] [blame] | 118 | strip.setViewPager(mViewPager); |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 119 | |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public void onServiceDisconnected(ComponentName arg0) { |
| 124 | |
| 125 | } |
| 126 | }; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 127 | |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 128 | @Override |
| 129 | protected void onCreate(Bundle savedInstanceState) { |
| 130 | super.onCreate(savedInstanceState); |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 131 | |
Alexandre Lision | 8907c1c | 2013-11-12 11:40:14 -0500 | [diff] [blame] | 132 | setContentView(R.layout.activity_account_settings); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 133 | |
| 134 | getActionBar().setDisplayHomeAsUpEnabled(true); |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 135 | |
Alexandre Lision | d2e9e06 | 2013-10-21 16:27:33 -0400 | [diff] [blame] | 136 | acc_selected = getIntent().getExtras().getParcelable("account"); |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 137 | |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 138 | acc_selected.addObserver(mAccountObserver); |
| 139 | |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 140 | if (!mBound) { |
| 141 | Log.i(TAG, "onCreate: Binding service..."); |
| 142 | Intent intent = new Intent(this, SipService.class); |
| 143 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
| 144 | } |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 145 | |
| 146 | } |
| 147 | |
| 148 | @Override |
| 149 | public boolean onCreateOptionsMenu(Menu menu) { |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 150 | if (acc_selected.isIP2IP()) { |
| 151 | return true; |
| 152 | } |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 153 | MenuInflater inflater = getMenuInflater(); |
| 154 | inflater.inflate(R.menu.account_edition, menu); |
| 155 | return true; |
| 156 | } |
| 157 | |
| 158 | @Override |
| 159 | public void onBackPressed() { |
| 160 | |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 161 | if (toDisplay != null) { |
Alexandre Lision | 8ad3959 | 2013-11-21 13:23:58 -0500 | [diff] [blame] | 162 | getFragmentManager().beginTransaction().setCustomAnimations(R.animator.slidein_up, R.animator.slideout_down).remove(toDisplay).commit(); |
Alexandre Lision | afff1cc | 2013-11-22 11:57:33 -0500 | [diff] [blame] | 163 | ((SecurityAccountFragment) mPreferencesPagerAdapter.getItem(3)).setCredentialSummary(); |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 164 | toDisplay = null; |
| 165 | return; |
| 166 | } |
| 167 | |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 168 | if (acc_selected.isIP2IP()) { |
| 169 | super.onBackPressed(); |
| 170 | return; |
| 171 | } |
| 172 | |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 173 | super.onBackPressed(); |
| 174 | |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | @Override |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 178 | protected void onDestroy() { |
Alexandre Lision | afff1cc | 2013-11-22 11:57:33 -0500 | [diff] [blame] | 179 | super.onDestroy(); |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 180 | if (mBound) { |
| 181 | unbindService(mConnection); |
| 182 | mBound = false; |
| 183 | } |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | @Override |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 187 | public boolean onOptionsItemSelected(MenuItem item) { |
| 188 | |
| 189 | switch (item.getItemId()) { |
| 190 | case android.R.id.home: |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 191 | if (toDisplay != null) { |
Alexandre Lision | afff1cc | 2013-11-22 11:57:33 -0500 | [diff] [blame] | 192 | getFragmentManager().beginTransaction().setCustomAnimations(R.animator.slidein_up, R.animator.slideout_down).remove(toDisplay) |
| 193 | .commit(); |
| 194 | ((SecurityAccountFragment) mPreferencesPagerAdapter.getItem(3)).setCredentialSummary(); |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 195 | toDisplay = null; |
| 196 | } else |
| 197 | finish(); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 198 | return true; |
| 199 | case R.id.menuitem_delete: |
| 200 | AlertDialog dialog = createDeleteDialog(); |
| 201 | dialog.show(); |
| 202 | break; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | return true; |
| 206 | } |
| 207 | |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 208 | private void processAccount() { |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 209 | try { |
| 210 | service.setCredentials(acc_selected.getAccountID(), acc_selected.getCredentialsHashMapList()); |
| 211 | service.setAccountDetails(acc_selected.getAccountID(), acc_selected.getDetails()); |
| 212 | } catch (RemoteException e) { |
| 213 | e.printStackTrace(); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | } |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 217 | |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 218 | public boolean validateAccountCreation(ArrayList<String> missingValue) { |
| 219 | boolean valid = true; |
| 220 | ArrayList<String> requiredFields = new ArrayList<String>(); |
| 221 | requiredFields.add(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS); |
| 222 | requiredFields.add(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME); |
| 223 | requiredFields.add(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME); |
| 224 | requiredFields.add(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD); |
| 225 | for (String s : requiredFields) { |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 226 | |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 227 | if (acc_selected.getBasicDetails().getDetailString(s).isEmpty()) { |
| 228 | valid = false; |
| 229 | missingValue.add(s); |
| 230 | } |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 231 | } |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 232 | |
| 233 | return valid; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 234 | } |
| 235 | |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 236 | private AlertDialog createDeleteDialog() { |
| 237 | Activity ownerActivity = this; |
| 238 | AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity); |
| 239 | builder.setMessage("Do you really want to delete this account").setTitle("Delete Account") |
| 240 | .setPositiveButton("Ok", new DialogInterface.OnClickListener() { |
| 241 | @Override |
| 242 | public void onClick(DialogInterface dialog, int whichButton) { |
| 243 | Bundle bundle = new Bundle(); |
Alexandre Lision | d2e9e06 | 2013-10-21 16:27:33 -0400 | [diff] [blame] | 244 | bundle.putString("AccountID", acc_selected.getAccountID()); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 245 | |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 246 | try { |
Alexandre Lision | d2e9e06 | 2013-10-21 16:27:33 -0400 | [diff] [blame] | 247 | service.removeAccount(acc_selected.getAccountID()); |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 248 | } catch (RemoteException e) { |
| 249 | e.printStackTrace(); |
| 250 | } |
| 251 | finish(); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 252 | } |
| 253 | }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { |
| 254 | @Override |
| 255 | public void onClick(DialogInterface dialog, int whichButton) { |
| 256 | /* Terminate with no action */ |
| 257 | } |
| 258 | }); |
| 259 | |
| 260 | AlertDialog alertDialog = builder.create(); |
| 261 | alertDialog.setOwnerActivity(ownerActivity); |
| 262 | |
| 263 | return alertDialog; |
| 264 | } |
| 265 | |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 266 | public class PreferencesPagerAdapter extends FragmentStatePagerAdapter { |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 267 | |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 268 | Context mContext; |
| 269 | ArrayList<Fragment> fragments; |
| 270 | |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 271 | public PreferencesPagerAdapter(Context c, FragmentManager fm, ArrayList<Fragment> items) { |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 272 | super(fm); |
| 273 | mContext = c; |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 274 | fragments = new ArrayList<Fragment>(items); |
| 275 | |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 276 | } |
| 277 | |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 278 | @Override |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 279 | public int getCount() { |
| 280 | return fragments.size(); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 281 | } |
| 282 | |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 283 | @Override |
| 284 | public Fragment getItem(int position) { |
| 285 | return fragments.get(position); |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 286 | } |
| 287 | |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 288 | @Override |
| 289 | public CharSequence getPageTitle(int position) { |
| 290 | switch (position) { |
| 291 | case 0: |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 292 | if (acc_selected.isIP2IP()) { |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 293 | return getString(R.string.account_preferences_audio_tab).toUpperCase(Locale.getDefault()); |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 294 | } else { |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 295 | return getString(R.string.account_preferences_basic_tab).toUpperCase(Locale.getDefault()); |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 296 | } |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 297 | case 1: |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 298 | return getString(R.string.account_preferences_audio_tab).toUpperCase(Locale.getDefault()); |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 299 | case 2: |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 300 | return getString(R.string.account_preferences_advanced_tab).toUpperCase(Locale.getDefault()); |
Alexandre Lision | c48c36a | 2013-11-12 16:26:10 -0500 | [diff] [blame] | 301 | case 3: |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 302 | return getString(R.string.account_preferences_security_tab).toUpperCase(Locale.getDefault()); |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 303 | default: |
| 304 | Log.e(TAG, "getPreferencePageTitle: unknown tab position " + position); |
| 305 | break; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 306 | } |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 307 | return null; |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 308 | } |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 309 | } |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 310 | |
Alexandre Lision | afd40e4 | 2013-10-15 13:48:37 -0400 | [diff] [blame] | 311 | @Override |
Alexandre Lision | 933ef0a | 2013-10-15 17:28:40 -0400 | [diff] [blame] | 312 | public ISipService getService() { |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 313 | return service; |
Alexandre Lision | 933ef0a | 2013-10-15 17:28:40 -0400 | [diff] [blame] | 314 | } |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 315 | |
Alexandre Lision | 933ef0a | 2013-10-15 17:28:40 -0400 | [diff] [blame] | 316 | @Override |
Alexandre Lision | 059da9d | 2013-10-22 11:17:25 -0400 | [diff] [blame] | 317 | public Account getAccount() { |
| 318 | return acc_selected; |
| 319 | } |
| 320 | |
Alexandre Lision | 3b7148e | 2013-11-13 17:23:06 -0500 | [diff] [blame] | 321 | @Override |
| 322 | public void displayCredentialsScreen() { |
Alexandre Lision | 3cefec2 | 2013-11-14 17:26:35 -0500 | [diff] [blame] | 323 | toDisplay = new NestedSettingsFragment(); |
Alexandre Lision | 3b7148e | 2013-11-13 17:23:06 -0500 | [diff] [blame] | 324 | Bundle b = new Bundle(); |
| 325 | b.putInt("MODE", 0); |
| 326 | toDisplay.setArguments(b); |
Alexandre Lision | 8ad3959 | 2013-11-21 13:23:58 -0500 | [diff] [blame] | 327 | getFragmentManager().beginTransaction().setCustomAnimations(R.animator.slidein_up, R.animator.slideout_down) |
| 328 | .replace(R.id.hidden_container, toDisplay).commit(); |
Alexandre Lision | 3b7148e | 2013-11-13 17:23:06 -0500 | [diff] [blame] | 329 | } |
| 330 | |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 331 | @Override |
| 332 | public void displaySRTPScreen() { |
| 333 | toDisplay = new NestedSettingsFragment(); |
| 334 | Bundle b = new Bundle(); |
| 335 | b.putInt("MODE", 1); |
| 336 | toDisplay.setArguments(b); |
Alexandre Lision | 8ad3959 | 2013-11-21 13:23:58 -0500 | [diff] [blame] | 337 | getFragmentManager().beginTransaction().setCustomAnimations(R.animator.slidein_up, R.animator.slideout_down) |
| 338 | .replace(R.id.hidden_container, toDisplay).commit(); |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | @Override |
| 342 | public void displayTLSScreen() { |
| 343 | toDisplay = new NestedSettingsFragment(); |
| 344 | Bundle b = new Bundle(); |
| 345 | b.putInt("MODE", 2); |
| 346 | toDisplay.setArguments(b); |
Alexandre Lision | 8ad3959 | 2013-11-21 13:23:58 -0500 | [diff] [blame] | 347 | getFragmentManager().beginTransaction().setCustomAnimations(R.animator.slidein_up, R.animator.slideout_down) |
| 348 | .replace(R.id.hidden_container, toDisplay).commit(); |
Alexandre Lision | c9c30b7 | 2013-11-18 16:27:26 -0500 | [diff] [blame] | 349 | } |
| 350 | |
Alexandre Lision | 227b59c | 2013-10-03 17:37:57 -0400 | [diff] [blame] | 351 | } |