mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Merge branch 'hide-ui-during-shutdown' into 'maintenance-0.16'
Backport: Hide UI during shutdown See merge request akwizgran/briar!750
This commit is contained in:
@@ -12,7 +12,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class SignOutFragment extends BaseFragment {
|
public class SignOutFragment extends BaseFragment {
|
||||||
|
|
||||||
private static final String TAG = SignOutFragment.class.getName();
|
public static final String TAG = SignOutFragment.class.getName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater,
|
public View onCreateView(LayoutInflater inflater,
|
||||||
@@ -30,5 +30,4 @@ public class SignOutFragment extends BaseFragment {
|
|||||||
public void injectFragment(ActivityComponent component) {
|
public void injectFragment(ActivityComponent component) {
|
||||||
// no need to inject
|
// no need to inject
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
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.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
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;
|
||||||
@@ -22,6 +23,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||||
import org.briarproject.bramble.api.plugin.BluetoothConstants;
|
import org.briarproject.bramble.api.plugin.BluetoothConstants;
|
||||||
import org.briarproject.bramble.api.plugin.LanTcpConstants;
|
import org.briarproject.bramble.api.plugin.LanTcpConstants;
|
||||||
import org.briarproject.bramble.api.plugin.TorConstants;
|
import org.briarproject.bramble.api.plugin.TorConstants;
|
||||||
@@ -51,6 +53,7 @@ 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;
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
|
import static org.briarproject.bramble.api.lifecycle.LifecycleManager.LifecycleState.RUNNING;
|
||||||
import static org.briarproject.briar.android.BriarService.EXTRA_STARTUP_FAILED;
|
import static org.briarproject.briar.android.BriarService.EXTRA_STARTUP_FAILED;
|
||||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD;
|
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD;
|
||||||
import static org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning.NO;
|
import static org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning.NO;
|
||||||
@@ -73,6 +76,8 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NavDrawerController controller;
|
NavDrawerController controller;
|
||||||
|
@Inject
|
||||||
|
LifecycleManager lifecycleManager;
|
||||||
|
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
private NavigationView navigation;
|
private NavigationView navigation;
|
||||||
@@ -128,7 +133,9 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
initializeTransports(getLayoutInflater());
|
initializeTransports(getLayoutInflater());
|
||||||
transportsView.setAdapter(transportsAdapter);
|
transportsView.setAdapter(transportsAdapter);
|
||||||
|
|
||||||
if (state == null) {
|
if (lifecycleManager.getLifecycleState().isAfter(RUNNING)) {
|
||||||
|
showSignOutFragment();
|
||||||
|
} else if (state == null) {
|
||||||
startFragment(ContactListFragment.newInstance(),
|
startFragment(ContactListFragment.newInstance(),
|
||||||
R.id.nav_btn_contacts);
|
R.id.nav_btn_contacts);
|
||||||
}
|
}
|
||||||
@@ -212,19 +219,23 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (drawerLayout.isDrawerOpen(START)) {
|
if (drawerLayout.isDrawerOpen(START)) {
|
||||||
drawerLayout.closeDrawer(START);
|
drawerLayout.closeDrawer(START);
|
||||||
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
|
} else {
|
||||||
getSupportFragmentManager()
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
.findFragmentByTag(ContactListFragment.TAG) == null) {
|
if (fm.findFragmentByTag(SignOutFragment.TAG) != null) {
|
||||||
|
finish();
|
||||||
|
} else if (fm.getBackStackEntryCount() == 0
|
||||||
|
&& fm.findFragmentByTag(ContactListFragment.TAG) == null) {
|
||||||
/*
|
/*
|
||||||
* This makes sure that the first fragment (ContactListFragment) the
|
* This makes sure that the first fragment (ContactListFragment) the
|
||||||
* user sees is the same as the last fragment the user sees before
|
* user sees is the same as the last fragment the user sees before
|
||||||
* exiting. This models the typical Google navigation behaviour such
|
* exiting. This models the typical Google navigation behaviour such
|
||||||
* as in Gmail/Inbox.
|
* as in Gmail/Inbox.
|
||||||
*/
|
*/
|
||||||
startFragment(ContactListFragment.newInstance(),
|
startFragment(ContactListFragment.newInstance(),
|
||||||
R.id.nav_btn_contacts);
|
R.id.nav_btn_contacts);
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,10 +251,15 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
drawerToggle.onConfigurationChanged(newConfig);
|
drawerToggle.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void signOut() {
|
private void showSignOutFragment() {
|
||||||
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
|
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
|
||||||
startFragment(new SignOutFragment());
|
startFragment(new SignOutFragment());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void signOut() {
|
||||||
|
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
|
||||||
signOut(false);
|
signOut(false);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startFragment(BaseFragment fragment, int itemId) {
|
private void startFragment(BaseFragment fragment, int itemId) {
|
||||||
|
|||||||
@@ -1,23 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<android.support.constraint.ConstraintLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_width="128dp"
|
||||||
|
android:layout_height="128dp"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/startup_lock"
|
||||||
|
android:tint="@color/briar_primary"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textView"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.5"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
|
tools:ignore="ContentDescription"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleLarge"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:layout_centerInParent="true"/>
|
app:layout_constraintBottom_toBottomOf="@+id/imageView"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/imageView"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/imageView"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/imageView"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title_progress_bar"
|
android:id="@+id/textView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/progressBar"
|
android:layout_margin="8dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:text="@string/progress_title_logout"
|
||||||
android:paddingTop="@dimen/margin_large"
|
android:textSize="@dimen/text_size_large"
|
||||||
android:text="@string/progress_title_logout"/>
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/imageView"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user