Don't show splash screen when signed in

This also removes the BriarFragmentActivity that was only really used by
the NavDrawerActivity.
This commit is contained in:
Torsten Grote
2016-12-08 15:54:01 -02:00
parent 68b216d580
commit 5a522d64df
12 changed files with 64 additions and 116 deletions

View File

@@ -1,64 +0,0 @@
package org.briarproject.briar.android.activity;
import android.support.v4.app.FragmentTransaction;
import org.briarproject.briar.R;
import org.briarproject.briar.android.contact.ContactListFragment;
import org.briarproject.briar.android.fragment.BaseFragment;
import org.briarproject.briar.android.navdrawer.NavDrawerActivity;
import static android.support.v4.app.FragmentManager.POP_BACK_STACK_INCLUSIVE;
/**
* This class should be extended by classes that wish to utilise fragments in
* Briar, it encapsulates all fragment related code.
*/
public abstract class BriarFragmentActivity extends BriarActivity {
protected void clearBackStack() {
getSupportFragmentManager().popBackStackImmediate(null,
POP_BACK_STACK_INCLUSIVE);
}
@Override
public void onBackPressed() {
if (this instanceof NavDrawerActivity &&
getSupportFragmentManager().getBackStackEntryCount() == 0 &&
getSupportFragmentManager()
.findFragmentByTag(ContactListFragment.TAG) == null) {
/*
This Makes sure that the first fragment (ContactListFragment) the
user sees is the same as the last fragment the user sees before
exiting. This models the typical Google navigation behaviour such
as in Gmail/Inbox.
*/
startFragment(ContactListFragment.newInstance());
} else {
super.onBackPressed();
}
}
public void onFragmentCreated(String tag) {
}
protected void startFragment(BaseFragment fragment) {
if (getSupportFragmentManager().getBackStackEntryCount() == 0)
startFragment(fragment, false);
else startFragment(fragment, true);
}
protected void startFragment(BaseFragment fragment,
boolean isAddedToBackStack) {
FragmentTransaction trans =
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.dialog_in,
R.anim.dialog_out, R.anim.dialog_in,
R.anim.dialog_out)
.replace(R.id.fragmentContainer, fragment,
fragment.getUniqueTag());
if (isAddedToBackStack) {
trans.addToBackStack(fragment.getUniqueTag());
}
trans.commit();
}
}

View File

@@ -72,8 +72,4 @@ public class BlogActivity extends BriarActivity implements
showNextFragment(f);
}
@Override
public void onFragmentCreated(String tag) {
}
}

View File

@@ -70,6 +70,8 @@ public class FeedFragment extends BaseFragment implements
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.blogs_button);
View v = inflater.inflate(R.layout.fragment_blog, container, false);
adapter = new BlogPostAdapter(getActivity(), this);
@@ -260,4 +262,5 @@ public class FeedFragment extends BaseFragment implements
public void onBlogRemoved() {
loadBlogPosts(true);
}
}

View File

@@ -54,9 +54,4 @@ public class ReblogActivity extends BriarActivity implements
component.inject(this);
}
@Override
public void onFragmentCreated(String tag) {
}
}

View File

@@ -109,6 +109,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.contact_list_button);
View contentView = inflater.inflate(R.layout.list, container, false);
OnContactClickListener<ContactListItem> onContactClickListener =

View File

@@ -95,9 +95,5 @@ public abstract class ContactSelectorActivity
return contacts;
}
@Override
public void onFragmentCreated(String tag) {
}
}

View File

@@ -84,6 +84,8 @@ public class ForumListFragment extends BaseEventFragment implements
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.forums_button);
View contentView =
inflater.inflate(R.layout.fragment_forum_list, container,
false);

View File

@@ -40,7 +40,6 @@ public abstract class BaseFragment extends Fragment
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
injectFragment(listener.getActivityComponent());
listener.onFragmentCreated(getUniqueTag());
}
@Override
@@ -61,7 +60,6 @@ public abstract class BaseFragment extends Fragment
}
public interface BaseFragmentListener {
@Deprecated
void runOnDbThread(Runnable runnable);
@@ -73,9 +71,6 @@ public abstract class BaseFragment extends Fragment
@UiThread
void showNextFragment(BaseFragment f);
@UiThread
void onFragmentCreated(String tag);
}
@CallSuper

View File

@@ -35,9 +35,4 @@ public class IntroductionActivity extends BriarActivity
component.inject(this);
}
@Override
public void onFragmentCreated(String tag) {
}
}

View File

@@ -20,7 +20,7 @@ import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
import org.briarproject.briar.R;
import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.activity.BriarFragmentActivity;
import org.briarproject.briar.android.activity.BriarActivity;
import org.briarproject.briar.android.fragment.BaseFragment;
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
import org.briarproject.briar.android.keyagreement.IntroFragment.IntroScreenSeenListener;
@@ -35,7 +35,7 @@ import static java.util.logging.Level.WARNING;
@MethodsNotNullByDefault
@ParametersNotNullByDefault
public class KeyAgreementActivity extends BriarFragmentActivity implements
public class KeyAgreementActivity extends BriarActivity implements
BaseFragmentListener, IntroScreenSeenListener, EventListener,
ContactExchangeListener {
@@ -189,4 +189,5 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
}
});
}
}

View File

@@ -5,9 +5,9 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.design.widget.NavigationView.OnNavigationItemSelectedListener;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
@@ -25,10 +25,11 @@ import org.briarproject.bramble.api.plugin.TorConstants;
import org.briarproject.bramble.api.plugin.TransportId;
import org.briarproject.briar.R;
import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.activity.BriarFragmentActivity;
import org.briarproject.briar.android.activity.BriarActivity;
import org.briarproject.briar.android.blog.FeedFragment;
import org.briarproject.briar.android.contact.ContactListFragment;
import org.briarproject.briar.android.forum.ForumListFragment;
import org.briarproject.briar.android.fragment.BaseFragment;
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
import org.briarproject.briar.android.fragment.SignOutFragment;
import org.briarproject.briar.android.privategroup.list.GroupListFragment;
@@ -40,10 +41,11 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static android.support.v4.app.FragmentManager.POP_BACK_STACK_INCLUSIVE;
import static android.support.v4.view.GravityCompat.START;
import static android.support.v4.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
public class NavDrawerActivity extends BriarFragmentActivity implements
public class NavDrawerActivity extends BriarActivity implements
BaseFragmentListener, TransportStateListener,
OnNavigationItemSelectedListener {
@@ -160,24 +162,6 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
}
}
@Override
public void onFragmentCreated(String tag) {
super.onFragmentCreated(tag);
ActionBar actionBar = getSupportActionBar();
if (actionBar == null) return;
if (tag.equals(ContactListFragment.TAG)) {
actionBar.setTitle(R.string.contact_list_button);
} else if (tag.equals(GroupListFragment.TAG)) {
actionBar.setTitle(R.string.groups_button);
} else if (tag.equals(ForumListFragment.TAG)) {
actionBar.setTitle(R.string.forums_button);
} else if (tag.equals(FeedFragment.TAG)) {
actionBar.setTitle(R.string.blogs_button);
}
}
@Override
public boolean onNavigationItemSelected(MenuItem item) {
drawerLayout.closeDrawer(START);
@@ -192,14 +176,29 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
@Override
public void onBackPressed() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0
&& drawerLayout.isDrawerOpen(START)) {
if (drawerLayout.isDrawerOpen(START)) {
drawerLayout.closeDrawer(START);
return;
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
getSupportFragmentManager()
.findFragmentByTag(ContactListFragment.TAG) != null) {
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
getSupportFragmentManager()
.findFragmentByTag(ContactListFragment.TAG) == null) {
/**
* This Makes sure that the first fragment (ContactListFragment) the
* user sees is the same as the last fragment the user sees before
* exiting. This models the typical Google navigation behaviour such
* as in Gmail/Inbox.
*/
navigation.setCheckedItem(R.id.nav_btn_contacts);
startFragment(ContactListFragment.newInstance());
} else {
super.onBackPressed();
}
// Check the Contacts item because we always return to Contacts here
navigation.setCheckedItem(R.id.nav_btn_contacts);
super.onBackPressed();
}
@Override
@@ -221,6 +220,32 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
super.signOut();
}
private void startFragment(BaseFragment fragment) {
if (getSupportFragmentManager().getBackStackEntryCount() == 0)
startFragment(fragment, false);
else startFragment(fragment, true);
}
private void startFragment(BaseFragment fragment,
boolean isAddedToBackStack) {
FragmentTransaction trans =
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.dialog_in,
R.anim.dialog_out, R.anim.dialog_in,
R.anim.dialog_out)
.replace(R.id.fragmentContainer, fragment,
fragment.getUniqueTag());
if (isAddedToBackStack) {
trans.addToBackStack(fragment.getUniqueTag());
}
trans.commit();
}
private void clearBackStack() {
getSupportFragmentManager().popBackStackImmediate(null,
POP_BACK_STACK_INCLUSIVE);
}
private void initializeTransports(final LayoutInflater inflater) {
transports = new ArrayList<>(3);

View File

@@ -63,6 +63,8 @@ public class GroupListFragment extends BaseFragment implements
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.groups_button);
View v = inflater.inflate(R.layout.list, container, false);
adapter = new GroupListAdapter(getContext(), this);