alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. |
| 3 | * |
| 4 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | * |
| 20 | * Additional permission under GNU GPL version 3 section 7: |
| 21 | * |
| 22 | * If you modify this program, or any covered work, by linking or |
| 23 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 24 | * modified version of that library), containing parts covered by the |
| 25 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 26 | * grants you additional permission to convey the resulting work. |
| 27 | * Corresponding Source for a non-source form of such a combination |
| 28 | * shall include the source code for the parts of OpenSSL used as well |
| 29 | * as that of the covered work. |
| 30 | */ |
| 31 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 32 | package org.sflphone.client; |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 33 | |
| 34 | import java.util.ArrayList; |
Alexandre Lision | 6e8931e | 2013-09-19 16:49:34 -0400 | [diff] [blame] | 35 | import java.util.Locale; |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 36 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 37 | import org.sflphone.R; |
| 38 | import org.sflphone.fragments.AccountCreationFragment; |
| 39 | import org.sflphone.interfaces.AccountsInterface; |
| 40 | |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 41 | import android.app.Activity; |
| 42 | import android.app.Fragment; |
| 43 | import android.app.FragmentManager; |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 44 | import android.content.Context; |
| 45 | import android.content.Intent; |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 46 | import android.os.Bundle; |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 47 | import android.support.v13.app.FragmentStatePagerAdapter; |
| 48 | import android.support.v4.view.ViewPager; |
| 49 | import android.util.Log; |
| 50 | import android.view.MenuItem; |
| 51 | |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 52 | public class AccountWizard extends Activity implements AccountsInterface { |
| 53 | static final String TAG = "AccountWizard"; |
| 54 | |
| 55 | public static final int ACCOUNT_CREATED = Activity.RESULT_OK; |
| 56 | |
| 57 | ViewPager mViewPager; |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 58 | private SectionsPagerAdapter mSectionsPagerAdapter; |
| 59 | |
| 60 | @Override |
| 61 | public void onCreate(Bundle savedInstanceState) { |
| 62 | super.onCreate(savedInstanceState); |
| 63 | |
| 64 | setContentView(R.layout.activity_wizard); |
| 65 | mViewPager = (ViewPager) findViewById(R.id.pager); |
| 66 | |
| 67 | getActionBar().setDisplayHomeAsUpEnabled(true); |
| 68 | getActionBar().setHomeButtonEnabled(true); |
Alexandre Lision | 6e8931e | 2013-09-19 16:49:34 -0400 | [diff] [blame] | 69 | mSectionsPagerAdapter = new SectionsPagerAdapter(AccountWizard.this, getFragmentManager()); |
| 70 | mViewPager.setAdapter(mSectionsPagerAdapter); |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 71 | |
| 72 | } |
| 73 | |
| 74 | /* activity finishes itself or is being killed by the system */ |
| 75 | @Override |
| 76 | protected void onDestroy() { |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 77 | super.onDestroy(); |
| 78 | } |
| 79 | |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 80 | @Override |
| 81 | public boolean onOptionsItemSelected(MenuItem item) { |
| 82 | switch (item.getItemId()) { |
| 83 | case android.R.id.home: |
| 84 | finish(); |
| 85 | return true; |
| 86 | default: |
| 87 | return true; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public void accountsChanged() { |
| 93 | // TODO Auto-generated method stub |
| 94 | |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public void accountStateChanged(Intent accountState) { |
| 99 | // TODO Auto-generated method stub |
| 100 | |
| 101 | } |
| 102 | |
| 103 | public class SectionsPagerAdapter extends FragmentStatePagerAdapter { |
| 104 | |
| 105 | Context mContext; |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 106 | ArrayList<Fragment> fragments; |
| 107 | |
| 108 | public SectionsPagerAdapter(Context c, FragmentManager fm) { |
| 109 | super(fm); |
| 110 | mContext = c; |
| 111 | fragments = new ArrayList<Fragment>(); |
| 112 | fragments.add(new AccountCreationFragment()); |
| 113 | |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public Fragment getItem(int i) { |
| 118 | |
| 119 | return fragments.get(i); |
| 120 | } |
| 121 | |
| 122 | public String getClassName(int i) { |
| 123 | String name; |
| 124 | |
| 125 | switch (i) { |
| 126 | case 0: |
| 127 | name = AccountCreationFragment.class.getName(); |
| 128 | break; |
| 129 | |
| 130 | default: |
| 131 | Log.e(TAG, "getClassName: unknown fragment position " + i); |
| 132 | return null; |
| 133 | } |
| 134 | |
| 135 | // Log.w(TAG, "getClassName: name=" + name); |
| 136 | return name; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public int getCount() { |
| 141 | return 1; |
| 142 | } |
| 143 | |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 144 | @Override |
| 145 | public CharSequence getPageTitle(int position) { |
| 146 | switch (position) { |
| 147 | case 0: |
Alexandre Lision | 6e8931e | 2013-09-19 16:49:34 -0400 | [diff] [blame] | 148 | return mContext.getString(R.string.title_section0).toUpperCase(Locale.getDefault()); |
alision | 5cfc35d | 2013-07-11 15:11:39 -0400 | [diff] [blame] | 149 | default: |
| 150 | Log.e(TAG, "getPageTitle: unknown tab position " + position); |
| 151 | break; |
| 152 | } |
| 153 | return null; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | } |