Commit 988aa750 authored by Grigory Fedorov's avatar Grigory Fedorov

AccountInfoEditor: toolbar changed during vCard saving - title changed and menu option disabled.

parent b3c980be
......@@ -17,10 +17,11 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
public class AccountInfoEditor extends ManagedActivity implements Toolbar.OnMenuItemClickListener {
public class AccountInfoEditor extends ManagedActivity implements Toolbar.OnMenuItemClickListener, AccountInfoEditorFragment.Lister {
public static final String ARG_VCARD = "com.xabber.android.ui.AccountInfoEditor.ARG_VCARD";
public static final int SAVE_MENU = R.menu.save;
private Toolbar toolbar;
public static Intent createIntent(Context context, String account, String vCard) {
......@@ -50,7 +51,7 @@ public class AccountInfoEditor extends ManagedActivity implements Toolbar.OnMenu
finish();
}
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
......@@ -104,4 +105,16 @@ public class AccountInfoEditor extends ManagedActivity implements Toolbar.OnMenu
getFragmentManager().findFragmentById(R.id.fragment_container).onActivityResult(requestCode,
resultCode, data);
}
@Override
public void onVCardSavingStarted() {
toolbar.setTitle(R.string.saving);
toolbar.getMenu().findItem(R.id.action_save).setEnabled(false);
}
@Override
public void onVCardSavingFinished() {
toolbar.setTitle(R.string.edit_account_user_info);
toolbar.getMenu().findItem(R.id.action_save).setEnabled(true);
}
}
......@@ -69,6 +69,13 @@ public class AccountInfoEditorFragment extends Fragment implements OnVCardSaveLi
private LinearLayout fields;
private TextView avatarSize;
private Lister lister;
interface Lister {
void onVCardSavingStarted();
void onVCardSavingFinished();
}
public static AccountInfoEditorFragment newInstance(String account, String vCard) {
AccountInfoEditorFragment fragment = new AccountInfoEditorFragment();
......@@ -82,6 +89,12 @@ public class AccountInfoEditorFragment extends Fragment implements OnVCardSaveLi
public AccountInfoEditorFragment() {
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
lister = (Lister) activity;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -165,6 +178,12 @@ public class AccountInfoEditorFragment extends Fragment implements OnVCardSaveLi
Application.getInstance().removeUIListener(OnVCardSaveListener.class, this);
}
@Override
public void onDetach() {
super.onDetach();
lister = null;
}
private void setFieldsFromVCard() {
formattedName.setText(vCard.getField(VCardProperty.FN.name()));
prefixName.setText(vCard.getPrefix());
......@@ -308,11 +327,13 @@ public class AccountInfoEditorFragment extends Fragment implements OnVCardSaveLi
public void enableProgressMode() {
setEnabledRecursive(false, fields);
progressBar.setVisibility(View.VISIBLE);
lister.onVCardSavingStarted();
}
public void disableProgressMode() {
progressBar.setVisibility(View.GONE);
setEnabledRecursive(true, fields);
lister.onVCardSavingFinished();
}
private void setEnabledRecursive(boolean enabled, ViewGroup viewGroup){
......
......@@ -53,4 +53,5 @@
<string name="account_user_info_save_success">Account user info saved successfully</string>
<string name="account_user_info_save_fail">Could not save account user info</string>
<string name="account_user_info_save_started">Saving account user info…</string>
<string name="saving">Saving…</string>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment