/** * Copyright (c) 2013, Redsolution LTD. All rights reserved. * * This file is part of Xabber project; you can redistribute it and/or * modify it under the terms of the GNU General Public License, Version 3. * * Xabber 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 this program. If not, see http://www.gnu.org/licenses/. */ package com.xabber.android.ui.preferences; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.NavUtils; import android.support.v7.widget.Toolbar; import android.view.View; import com.xabber.android.R; import com.xabber.android.data.Application; import com.xabber.android.data.account.AccountItem; import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.entity.AccountJid; import com.xabber.android.data.entity.UserJid; import com.xabber.android.data.intent.EntityIntentBuilder; import com.xabber.android.ui.activity.ManagedActivity; import com.xabber.android.ui.color.BarPainter; public class ChatContactSettings extends ManagedActivity implements ChatContactSettingsFragment.ChatEditorFragmentInteractionListener { private AccountJid account; private UserJid user; private AccountItem accountItem; public static Intent createIntent(Context context, AccountJid account, UserJid user) { return new EntityIntentBuilder(context, ChatContactSettings.class).setAccount(account).setUser(user).build(); } private static AccountJid getAccount(Intent intent) { return EntityIntentBuilder.getAccount(intent); } private static UserJid getUser(Intent intent) { return EntityIntentBuilder.getUser(intent); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); account = getAccount(getIntent()); user = getUser(getIntent()); accountItem = AccountManager.getInstance().getAccount(account); if (accountItem == null || user == null) { Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); finish(); return; } setContentView(R.layout.activity_with_toolbar_and_container); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default); toolbar.setTitle(getTitle()); toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NavUtils.navigateUpFromSameTask(ChatContactSettings.this); } }); BarPainter barPainter = new BarPainter(this, toolbar); barPainter.updateWithAccountName(account); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.fragment_container, new ChatContactSettingsFragment()).commit(); } } @Override public AccountJid getAccount() { return account; } @Override public AccountItem getAccountItem() { return accountItem; } @Override public UserJid getUser() { return user; } }