mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Move Up button handling into BaseFragment
This commit is contained in:
@@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
import org.briarproject.android.DestroyableContext;
|
||||
@@ -27,6 +28,9 @@ public abstract class BaseFragment extends Fragment
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// allow for "up" button to act as back button
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +41,17 @@ public abstract class BaseFragment extends Fragment
|
||||
listener.onFragmentCreated(getUniqueTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
listener.onBackPressed();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
protected void finish() {
|
||||
getActivity().supportFinishAfterTransition();
|
||||
@@ -47,6 +62,9 @@ public abstract class BaseFragment extends Fragment
|
||||
@Deprecated
|
||||
void runOnDbThread(Runnable runnable);
|
||||
|
||||
@UiThread
|
||||
void onBackPressed();
|
||||
|
||||
@UiThread
|
||||
ActivityComponent getActivityComponent();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user