mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Integrated navigation drawer in the contributions activity
This commit is contained in:
parent
e40d2aabb2
commit
09cd596ff6
12 changed files with 297 additions and 165 deletions
|
|
@ -1,12 +1,13 @@
|
|||
package fr.free.nrw.commons;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
import fr.free.nrw.commons.theme.BaseActivity;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.theme.BaseActivity;
|
||||
|
||||
public class AboutActivity extends BaseActivity {
|
||||
@BindView(R.id.about_version) TextView versionText;
|
||||
|
|
@ -20,4 +21,9 @@ public class AboutActivity extends BaseActivity {
|
|||
|
||||
versionText.setText(BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
public static void startYourself(Context context) {
|
||||
Intent settingsIntent = new Intent(context, AboutActivity.class);
|
||||
context.startActivity(settingsIntent);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ import android.support.v4.content.Loader;
|
|||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
|
@ -28,6 +29,8 @@ import android.widget.RelativeLayout;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.HandlerService;
|
||||
import fr.free.nrw.commons.Media;
|
||||
|
|
@ -60,8 +63,14 @@ public class ContributionsActivity
|
|||
private ArrayList<DataSetObserver> observersWaitingForLoad = new ArrayList<>();
|
||||
private String CONTRIBUTION_SELECTION = "";
|
||||
|
||||
private DrawerLayout drawerLayout;
|
||||
private RelativeLayout drawerPane;
|
||||
@BindView(R.id.contributions_toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
@BindView(R.id.drawer_layout)
|
||||
DrawerLayout drawerLayout;
|
||||
|
||||
@BindView(R.id.drawer_pane)
|
||||
RelativeLayout drawerPane;
|
||||
|
||||
/*
|
||||
This sorts in the following order:
|
||||
|
|
@ -133,6 +142,11 @@ public class ContributionsActivity
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_contributions);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
initSubviews();
|
||||
|
||||
|
|
@ -158,15 +172,21 @@ public class ContributionsActivity
|
|||
}
|
||||
|
||||
private void initSubviews() {
|
||||
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawerPane = (RelativeLayout) findViewById(R.id.drawer_pane);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this,
|
||||
drawerLayout,
|
||||
toolbar,
|
||||
R.string.navigation_drawer_open,
|
||||
R.string.navigation_drawer_close);
|
||||
drawerLayout.setDrawerListener(toggle);
|
||||
toggle.setDrawerIndicatorEnabled(true);
|
||||
toggle.syncState();
|
||||
setDrawerPaneWidth();
|
||||
}
|
||||
|
||||
private void setDrawerPaneWidth() {
|
||||
ViewGroup.LayoutParams params = drawerPane.getLayoutParams();
|
||||
// set width to lowerBound of 80% of the screen size
|
||||
params.width = (getResources().getDisplayMetrics().widthPixels * 80) / 100;
|
||||
params.width = (getResources().getDisplayMetrics().widthPixels * 70) / 100;
|
||||
drawerPane.setLayoutParams(params);
|
||||
}
|
||||
|
||||
|
|
@ -371,4 +391,9 @@ public class ContributionsActivity
|
|||
public boolean isDrawerVisible() {
|
||||
return drawerLayout.isDrawerVisible(START);
|
||||
}
|
||||
|
||||
public static void startYourself(Context context) {
|
||||
Intent settingsIntent = new Intent(context, ContributionsActivity.class);
|
||||
context.startActivity(settingsIntent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,46 +126,46 @@ public class ContributionsListFragment extends Fragment {
|
|||
case R.id.menu_from_camera:
|
||||
controller.startCameraCapture();
|
||||
return true;
|
||||
case R.id.menu_settings:
|
||||
Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class);
|
||||
startActivity(settingsIntent);
|
||||
return true;
|
||||
case R.id.menu_about:
|
||||
Intent aboutIntent = new Intent(getActivity(), AboutActivity.class);
|
||||
startActivity(aboutIntent);
|
||||
return true;
|
||||
case R.id.menu_feedback:
|
||||
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
|
||||
feedbackIntent.setType("message/rfc822");
|
||||
feedbackIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { CommonsApplication.FEEDBACK_EMAIL });
|
||||
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, BuildConfig.VERSION_NAME));
|
||||
try {
|
||||
startActivity(feedbackIntent);
|
||||
}
|
||||
catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.menu_nearby:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(this.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
//See http://stackoverflow.com/questions/33169455/onrequestpermissionsresult-not-being-called-in-dialog-fragment
|
||||
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 2);
|
||||
return true;
|
||||
} else {
|
||||
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
||||
startActivity(nearbyIntent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
||||
startActivity(nearbyIntent);
|
||||
return true;
|
||||
}
|
||||
case R.id.menu_refresh:
|
||||
((SourceRefresher)getActivity()).refreshSource();
|
||||
return true;
|
||||
// case R.id.menu_settings:
|
||||
// Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class);
|
||||
// startActivity(settingsIntent);
|
||||
// return true;
|
||||
// case R.id.menu_about:
|
||||
// Intent aboutIntent = new Intent(getActivity(), AboutActivity.class);
|
||||
// startActivity(aboutIntent);
|
||||
// return true;
|
||||
// case R.id.menu_feedback:
|
||||
// Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
|
||||
// feedbackIntent.setType("message/rfc822");
|
||||
// feedbackIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { CommonsApplication.FEEDBACK_EMAIL });
|
||||
// feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, BuildConfig.VERSION_NAME));
|
||||
// try {
|
||||
// startActivity(feedbackIntent);
|
||||
// }
|
||||
// catch (ActivityNotFoundException e) {
|
||||
// Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
// return true;
|
||||
// case R.id.menu_nearby:
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// if (ContextCompat.checkSelfPermission(this.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
// //See http://stackoverflow.com/questions/33169455/onrequestpermissionsresult-not-being-called-in-dialog-fragment
|
||||
// requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 2);
|
||||
// return true;
|
||||
// } else {
|
||||
// Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
||||
// startActivity(nearbyIntent);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
||||
// startActivity(nearbyIntent);
|
||||
// return true;
|
||||
// }
|
||||
// case R.id.menu_refresh:
|
||||
// ((SourceRefresher)getActivity()).refreshSource();
|
||||
// return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ public class ContributionsListFragment extends Fragment {
|
|||
menu.findItem(R.id.menu_from_camera).setEnabled(false);
|
||||
}
|
||||
|
||||
menu.findItem(R.id.menu_refresh).setVisible(false);
|
||||
//menu.findItem(R.id.menu_refresh).setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package fr.free.nrw.commons.hamburger;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
|
|
@ -7,16 +9,27 @@ import android.support.v7.app.ActionBarDrawerToggle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import fr.free.nrw.commons.AboutActivity;
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.contributions.ContributionsActivity;
|
||||
import fr.free.nrw.commons.nearby.NearbyActivity;
|
||||
import fr.free.nrw.commons.settings.SettingsActivity;
|
||||
|
||||
|
||||
public class NavigationBaseFragment extends Fragment {
|
||||
@BindView(R.id.pictureOfTheDay)
|
||||
ImageView pictureOfTheDay;
|
||||
|
||||
@BindView(R.id.home_item)
|
||||
TextView homeItem;
|
||||
|
||||
|
|
@ -42,13 +55,20 @@ public class NavigationBaseFragment extends Fragment {
|
|||
private RelativeLayout drawerPane;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View hamburgerView = inflater.inflate(R.layout.navigation_drawer_menu, container, false);
|
||||
ButterKnife.bind(this, hamburgerView);
|
||||
showPictureOfTheDay();
|
||||
setupHamburgerMenu();
|
||||
return hamburgerView;
|
||||
}
|
||||
|
||||
private void showPictureOfTheDay() {
|
||||
pictureOfTheDay.setImageDrawable(getResources().getDrawable(R.drawable.commons_logo_large));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
@ -62,9 +82,45 @@ public class NavigationBaseFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.home_item)
|
||||
protected void onProfileLayoutClick() {
|
||||
@OnClick(R.id.upload_item)
|
||||
protected void onHomeItemClicked() {
|
||||
closeDrawer();
|
||||
ContributionsActivity.startYourself(getActivity());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_item)
|
||||
protected void onSettingsItemClicked() {
|
||||
closeDrawer();
|
||||
SettingsActivity.startYourself(getActivity());
|
||||
}
|
||||
|
||||
@OnClick(R.id.about_item)
|
||||
protected void onAboutItemClicked() {
|
||||
closeDrawer();
|
||||
AboutActivity.startYourself(getActivity());
|
||||
}
|
||||
|
||||
@OnClick(R.id.nearby_item)
|
||||
protected void onNearbyItemClicked() {
|
||||
closeDrawer();
|
||||
NearbyActivity.startYourself(getActivity());
|
||||
}
|
||||
|
||||
@OnClick(R.id.feedback_item)
|
||||
protected void onFeedbackItemClicked() {
|
||||
closeDrawer();
|
||||
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
|
||||
feedbackIntent.setType("message/rfc822");
|
||||
feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
|
||||
new String[]{CommonsApplication.FEEDBACK_EMAIL});
|
||||
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT,
|
||||
String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT,
|
||||
BuildConfig.VERSION_NAME));
|
||||
try {
|
||||
startActivity(feedbackIntent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void closeDrawer() {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
package fr.free.nrw.commons.nearby;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.location.LocationManager;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -20,22 +17,20 @@ import android.view.View;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||
import fr.free.nrw.commons.theme.BaseActivity;
|
||||
import fr.free.nrw.commons.utils.UriSerializer;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NearbyActivity extends BaseActivity {
|
||||
@BindView(R.id.progressBar)
|
||||
ProgressBar progressBar;
|
||||
|
|
@ -251,4 +246,9 @@ public class NearbyActivity extends BaseActivity {
|
|||
fragmentTransaction.replace(R.id.container, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
public static void startYourself(Context context) {
|
||||
Intent settingsIntent = new Intent(context, NearbyActivity.class);
|
||||
context.startActivity(settingsIntent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package fr.free.nrw.commons.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
|
|
@ -51,4 +53,9 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startYourself(Context context) {
|
||||
Intent settingsIntent = new Intent(context, SettingsActivity.class);
|
||||
context.startActivity(settingsIntent);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
package fr.free.nrw.commons.theme;
|
||||
|
||||
public class NavigationBaseActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue