FairEmail/app/src/main/java/eu/faircode/email/ActivityCompose.java

69 lines
2.4 KiB
Java
Raw Normal View History

2018-08-02 13:33:06 +00:00
package eu.faircode.email;
/*
This file is part of Safe email.
Safe email is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NetGuard 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 NetGuard. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018 by Marcel Bokhorst (M66B)
*/
import android.os.Bundle;
2018-08-04 16:54:57 +00:00
import android.view.MenuItem;
2018-08-02 13:33:06 +00:00
2018-08-08 06:55:47 +00:00
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
2018-08-02 13:33:06 +00:00
public class ActivityCompose extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
2018-08-03 07:39:43 +00:00
static final int REQUEST_CONTACT_TO = 1;
static final int REQUEST_CONTACT_CC = 2;
static final int REQUEST_CONTACT_BCC = 3;
2018-08-10 17:13:42 +00:00
static final int REQUEST_ATTACHMENT = 4;
2018-08-02 13:33:06 +00:00
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compose);
2018-08-04 16:54:57 +00:00
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
2018-08-02 13:33:06 +00:00
getSupportFragmentManager().addOnBackStackChangedListener(this);
if (getSupportFragmentManager().getFragments().size() == 0) {
2018-08-03 09:58:44 +00:00
FragmentCompose fragment = new FragmentCompose();
fragment.setArguments(getIntent().getExtras());
2018-08-03 09:58:44 +00:00
2018-08-02 13:33:06 +00:00
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("compose");
fragmentTransaction.commit();
}
}
2018-08-04 16:54:57 +00:00
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
2018-08-05 16:36:38 +00:00
getSupportFragmentManager().popBackStack();
2018-08-04 16:54:57 +00:00
return true;
}
return super.onOptionsItemSelected(item);
}
2018-08-02 13:33:06 +00:00
@Override
public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0)
finish();
}
}