View Javadoc
1   /*
2    * Copyright (C) 2003-2014 eXo Platform SAS.
3    *
4    * This is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU Lesser General Public License as
6    * published by the Free Software Foundation; either version 3 of
7    * the License, or (at your option) any later version.
8    *
9    * This software is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this software; if not, write to the Free
16   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18   */
19  package org.exoplatform.accountswitcher;
20  
21  import org.exoplatform.R;
22  import org.exoplatform.base.BaseActivity;
23  import org.exoplatform.ui.HomeActivity;
24  import org.exoplatform.ui.login.LoginActivity;
25  
26  import android.content.Intent;
27  import android.os.Bundle;
28  import android.support.v4.content.IntentCompat;
29  
30  /**
31   * Created by The eXo Platform SAS Author : Philippe Aristote
32   * paristote@exoplatform.com Sep 3, 2014
33   */
34  public class AccountSwitcherActivity extends BaseActivity {
35  
36    private static final String TAG = "eXo____AccountSwitcherActivity____";
37  
38    public void onCreate(Bundle savedInstanceState) {
39      super.onCreate(savedInstanceState);
40  
41      setContentView(R.layout.account_switcher_activity);
42  
43      setTitle(R.string.Server);
44  
45      getSupportFragmentManager().beginTransaction()
46                                 .add(R.id.share_extension_fragment,
47                                      new AccountSwitcherFragment(),
48                                      AccountSwitcherFragment.FRAGMENT_TAG)
49                                 .commit();
50    }
51  
52    /**
53     * Redirect to the HomeActivity (Home screen)
54     */
55    public void redirectToHomeScreenAndFinish() {
56      Intent home = new Intent(this, HomeActivity.class);
57      // IntentCompat.FLAG_ACTIVITY_CLEAR_TASK works only from API_VERSION>=11
58      home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
59      startActivity(home);
60      finish();
61    }
62  
63    /**
64     * Redirect to the LoginActivity (Authenticate screen)
65     */
66    public void redirectToLoginScreenAndFinish() {
67      Intent login = new Intent(this, LoginActivity.class);
68      // IntentCompat.FLAG_ACTIVITY_CLEAR_TASK works only from API_VERSION>=11
69      login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
70      startActivity(login);
71      finish();
72    }
73  
74  }