mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add proper 'up' affordance behavior
This commit is contained in:
parent
f5279d634e
commit
700bfee178
2 changed files with 18 additions and 5 deletions
|
|
@ -5,6 +5,7 @@ import android.net.Uri;
|
|||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
|
|
@ -30,7 +31,8 @@ public class ContributionsActivity
|
|||
extends AuthenticatedActivity
|
||||
implements LoaderManager.LoaderCallbacks<Cursor>,
|
||||
AdapterView.OnItemClickListener,
|
||||
MediaDetailPagerFragment.MediaDetailProvider {
|
||||
MediaDetailPagerFragment.MediaDetailProvider,
|
||||
FragmentManager.OnBackStackChangedListener {
|
||||
|
||||
private final static int SELECT_FROM_GALLERY = 1;
|
||||
private final static int SELECT_FROM_CAMERA = 2;
|
||||
|
|
@ -97,8 +99,6 @@ public class ContributionsActivity
|
|||
allContributions = getContentResolver().query(ContributionsContentProvider.BASE_URI, Contribution.Table.ALL_FIELDS, CONTRIBUTION_SELECTION, null, CONTRIBUTION_SORT);
|
||||
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -109,6 +109,8 @@ public class ContributionsActivity
|
|||
|
||||
contributionsList = (ContributionsListFragment)getSupportFragmentManager().findFragmentById(R.id.contributionsListFragment);
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
|
||||
requestAuthToken();
|
||||
}
|
||||
|
||||
|
|
@ -210,6 +212,11 @@ public class ContributionsActivity
|
|||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, lastGeneratedCaptureURI);
|
||||
startActivityForResult(takePictureIntent, SELECT_FROM_CAMERA);
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
if(mediaDetails.isVisible()) {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
@ -258,4 +265,12 @@ public class ContributionsActivity
|
|||
}
|
||||
return allContributions.getCount();
|
||||
}
|
||||
|
||||
public void onBackStackChanged() {
|
||||
if(mediaDetails.isVisible()) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
} else {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,6 @@ public class MediaDetailPagerFragment extends SherlockFragment {
|
|||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue