Skip to content
Snippets Groups Projects
Verified Commit 5a522d64 authored by Torsten Grote's avatar Torsten Grote
Browse files

Don't show splash screen when signed in

This also removes the BriarFragmentActivity that was only really used by
the NavDrawerActivity.
parent 68b216d5
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 116 deletions
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();
}
}
...@@ -72,8 +72,4 @@ public class BlogActivity extends BriarActivity implements ...@@ -72,8 +72,4 @@ public class BlogActivity extends BriarActivity implements
showNextFragment(f); showNextFragment(f);
} }
@Override
public void onFragmentCreated(String tag) {
}
} }
...@@ -70,6 +70,8 @@ public class FeedFragment extends BaseFragment implements ...@@ -70,6 +70,8 @@ public class FeedFragment extends BaseFragment implements
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.blogs_button);
View v = inflater.inflate(R.layout.fragment_blog, container, false); View v = inflater.inflate(R.layout.fragment_blog, container, false);
adapter = new BlogPostAdapter(getActivity(), this); adapter = new BlogPostAdapter(getActivity(), this);
...@@ -260,4 +262,5 @@ public class FeedFragment extends BaseFragment implements ...@@ -260,4 +262,5 @@ public class FeedFragment extends BaseFragment implements
public void onBlogRemoved() { public void onBlogRemoved() {
loadBlogPosts(true); loadBlogPosts(true);
} }
} }
...@@ -54,9 +54,4 @@ public class ReblogActivity extends BriarActivity implements ...@@ -54,9 +54,4 @@ public class ReblogActivity extends BriarActivity implements
component.inject(this); component.inject(this);
} }
@Override
public void onFragmentCreated(String tag) {
}
} }
...@@ -109,6 +109,8 @@ public class ContactListFragment extends BaseFragment implements EventListener { ...@@ -109,6 +109,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.contact_list_button);
View contentView = inflater.inflate(R.layout.list, container, false); View contentView = inflater.inflate(R.layout.list, container, false);
OnContactClickListener<ContactListItem> onContactClickListener = OnContactClickListener<ContactListItem> onContactClickListener =
......
...@@ -95,9 +95,5 @@ public abstract class ContactSelectorActivity ...@@ -95,9 +95,5 @@ public abstract class ContactSelectorActivity
return contacts; return contacts;
} }
@Override
public void onFragmentCreated(String tag) {
}
} }
...@@ -84,6 +84,8 @@ public class ForumListFragment extends BaseEventFragment implements ...@@ -84,6 +84,8 @@ public class ForumListFragment extends BaseEventFragment implements
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.forums_button);
View contentView = View contentView =
inflater.inflate(R.layout.fragment_forum_list, container, inflater.inflate(R.layout.fragment_forum_list, container,
false); false);
......
...@@ -40,7 +40,6 @@ public abstract class BaseFragment extends Fragment ...@@ -40,7 +40,6 @@ public abstract class BaseFragment extends Fragment
public void onActivityCreated(@Nullable Bundle savedInstanceState) { public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
injectFragment(listener.getActivityComponent()); injectFragment(listener.getActivityComponent());
listener.onFragmentCreated(getUniqueTag());
} }
@Override @Override
...@@ -61,7 +60,6 @@ public abstract class BaseFragment extends Fragment ...@@ -61,7 +60,6 @@ public abstract class BaseFragment extends Fragment
} }
public interface BaseFragmentListener { public interface BaseFragmentListener {
@Deprecated @Deprecated
void runOnDbThread(Runnable runnable); void runOnDbThread(Runnable runnable);
...@@ -73,9 +71,6 @@ public abstract class BaseFragment extends Fragment ...@@ -73,9 +71,6 @@ public abstract class BaseFragment extends Fragment
@UiThread @UiThread
void showNextFragment(BaseFragment f); void showNextFragment(BaseFragment f);
@UiThread
void onFragmentCreated(String tag);
} }
@CallSuper @CallSuper
......
...@@ -35,9 +35,4 @@ public class IntroductionActivity extends BriarActivity ...@@ -35,9 +35,4 @@ public class IntroductionActivity extends BriarActivity
component.inject(this); component.inject(this);
} }
@Override
public void onFragmentCreated(String tag) {
}
} }
...@@ -20,7 +20,7 @@ import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault; ...@@ -20,7 +20,7 @@ import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault; import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
import org.briarproject.briar.R; import org.briarproject.briar.R;
import org.briarproject.briar.android.activity.ActivityComponent; 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;
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener; import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
import org.briarproject.briar.android.keyagreement.IntroFragment.IntroScreenSeenListener; import org.briarproject.briar.android.keyagreement.IntroFragment.IntroScreenSeenListener;
...@@ -35,7 +35,7 @@ import static java.util.logging.Level.WARNING; ...@@ -35,7 +35,7 @@ import static java.util.logging.Level.WARNING;
@MethodsNotNullByDefault @MethodsNotNullByDefault
@ParametersNotNullByDefault @ParametersNotNullByDefault
public class KeyAgreementActivity extends BriarFragmentActivity implements public class KeyAgreementActivity extends BriarActivity implements
BaseFragmentListener, IntroScreenSeenListener, EventListener, BaseFragmentListener, IntroScreenSeenListener, EventListener,
ContactExchangeListener { ContactExchangeListener {
...@@ -189,4 +189,5 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements ...@@ -189,4 +189,5 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
} }
}); });
} }
} }
...@@ -5,9 +5,9 @@ import android.content.res.Configuration; ...@@ -5,9 +5,9 @@ import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.design.widget.NavigationView.OnNavigationItemSelectedListener; import android.support.design.widget.NavigationView.OnNavigationItemSelectedListener;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -25,10 +25,11 @@ import org.briarproject.bramble.api.plugin.TorConstants; ...@@ -25,10 +25,11 @@ import org.briarproject.bramble.api.plugin.TorConstants;
import org.briarproject.bramble.api.plugin.TransportId; import org.briarproject.bramble.api.plugin.TransportId;
import org.briarproject.briar.R; import org.briarproject.briar.R;
import org.briarproject.briar.android.activity.ActivityComponent; 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.blog.FeedFragment;
import org.briarproject.briar.android.contact.ContactListFragment; import org.briarproject.briar.android.contact.ContactListFragment;
import org.briarproject.briar.android.forum.ForumListFragment; 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.BaseFragment.BaseFragmentListener;
import org.briarproject.briar.android.fragment.SignOutFragment; import org.briarproject.briar.android.fragment.SignOutFragment;
import org.briarproject.briar.android.privategroup.list.GroupListFragment; import org.briarproject.briar.android.privategroup.list.GroupListFragment;
...@@ -40,10 +41,11 @@ import java.util.logging.Logger; ...@@ -40,10 +41,11 @@ import java.util.logging.Logger;
import javax.inject.Inject; 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.view.GravityCompat.START;
import static android.support.v4.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED; 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, BaseFragmentListener, TransportStateListener,
OnNavigationItemSelectedListener { OnNavigationItemSelectedListener {
...@@ -160,24 +162,6 @@ public class NavDrawerActivity extends BriarFragmentActivity implements ...@@ -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 @Override
public boolean onNavigationItemSelected(MenuItem item) { public boolean onNavigationItemSelected(MenuItem item) {
drawerLayout.closeDrawer(START); drawerLayout.closeDrawer(START);
...@@ -192,14 +176,29 @@ public class NavDrawerActivity extends BriarFragmentActivity implements ...@@ -192,14 +176,29 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0 if (drawerLayout.isDrawerOpen(START)) {
&& drawerLayout.isDrawerOpen(START)) {
drawerLayout.closeDrawer(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 @Override
...@@ -221,6 +220,32 @@ public class NavDrawerActivity extends BriarFragmentActivity implements ...@@ -221,6 +220,32 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
super.signOut(); 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) { private void initializeTransports(final LayoutInflater inflater) {
transports = new ArrayList<>(3); transports = new ArrayList<>(3);
......
...@@ -63,6 +63,8 @@ public class GroupListFragment extends BaseFragment implements ...@@ -63,6 +63,8 @@ public class GroupListFragment extends BaseFragment implements
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
getActivity().setTitle(R.string.groups_button);
View v = inflater.inflate(R.layout.list, container, false); View v = inflater.inflate(R.layout.list, container, false);
adapter = new GroupListAdapter(getContext(), this); adapter = new GroupListAdapter(getContext(), this);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment