mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge branch 'skip_login' of github.com:ujjwalagrawal17/apps-android-commons
This commit is contained in:
commit
f12f1d50a3
9 changed files with 178 additions and 13 deletions
|
|
@ -16,6 +16,7 @@ import android.support.annotation.StringRes;
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatDelegate;
|
import android.support.v7.app.AppCompatDelegate;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
|
@ -26,6 +27,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
@ -41,6 +43,7 @@ import fr.free.nrw.commons.PageTitle;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
import fr.free.nrw.commons.WelcomeActivity;
|
import fr.free.nrw.commons.WelcomeActivity;
|
||||||
|
import fr.free.nrw.commons.category.CategoryImagesActivity;
|
||||||
import fr.free.nrw.commons.contributions.ContributionsActivity;
|
import fr.free.nrw.commons.contributions.ContributionsActivity;
|
||||||
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
||||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||||
|
|
@ -60,6 +63,7 @@ import static fr.free.nrw.commons.auth.AccountUtil.AUTH_TOKEN_TYPE;
|
||||||
public class LoginActivity extends AccountAuthenticatorActivity {
|
public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
|
|
||||||
public static final String PARAM_USERNAME = "fr.free.nrw.commons.login.username";
|
public static final String PARAM_USERNAME = "fr.free.nrw.commons.login.username";
|
||||||
|
private static final String FEATURED_IMAGES_CATEGORY = "Category:Featured_pictures_on_Wikimedia_Commons";
|
||||||
|
|
||||||
@Inject MediaWikiApi mwApi;
|
@Inject MediaWikiApi mwApi;
|
||||||
@Inject SessionManager sessionManager;
|
@Inject SessionManager sessionManager;
|
||||||
|
|
@ -76,6 +80,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
@BindView(R.id.login_credentials) TextView loginCredentials;
|
@BindView(R.id.login_credentials) TextView loginCredentials;
|
||||||
@BindView(R.id.two_factor_container) TextInputLayout twoFactorContainer;
|
@BindView(R.id.two_factor_container) TextInputLayout twoFactorContainer;
|
||||||
@BindView(R.id.forgotPassword) HtmlTextView forgotPasswordText;
|
@BindView(R.id.forgotPassword) HtmlTextView forgotPasswordText;
|
||||||
|
@BindView(R.id.skipLogin) HtmlTextView skipLoginText;
|
||||||
|
|
||||||
ProgressDialog progressDialog;
|
ProgressDialog progressDialog;
|
||||||
private AppCompatDelegate delegate;
|
private AppCompatDelegate delegate;
|
||||||
|
|
@ -125,6 +130,15 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
signupButton.setOnClickListener(view -> signUp());
|
signupButton.setOnClickListener(view -> signUp());
|
||||||
|
|
||||||
forgotPasswordText.setOnClickListener(view -> forgotPassword());
|
forgotPasswordText.setOnClickListener(view -> forgotPassword());
|
||||||
|
skipLoginText.setOnClickListener(view -> new AlertDialog.Builder(this).setTitle(R.string.skip_login_title)
|
||||||
|
.setMessage(R.string.skip_login_message)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||||
|
dialog.cancel();
|
||||||
|
skipLogin();
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.no, (dialog, which) -> dialog.cancel())
|
||||||
|
.show());
|
||||||
|
|
||||||
if(BuildConfig.FLAVOR.equals("beta")){
|
if(BuildConfig.FLAVOR.equals("beta")){
|
||||||
loginCredentials.setText(getString(R.string.login_credential));
|
loginCredentials.setText(getString(R.string.login_credential));
|
||||||
|
|
@ -133,6 +147,17 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called when user skips the login.
|
||||||
|
* It redirects the user to Explore Activity.
|
||||||
|
*/
|
||||||
|
private void skipLogin() {
|
||||||
|
prefs.edit().putBoolean("login_skipped", true).apply();
|
||||||
|
CategoryImagesActivity.startYourself(this, getString(R.string.title_activity_explore), FEATURED_IMAGES_CATEGORY);
|
||||||
|
finish();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void forgotPassword() {
|
private void forgotPassword() {
|
||||||
Utils.handleWebUrl(this, Uri.parse(BuildConfig.FORGOT_PASSWORD_URL));
|
Utils.handleWebUrl(this, Uri.parse(BuildConfig.FORGOT_PASSWORD_URL));
|
||||||
}
|
}
|
||||||
|
|
@ -159,9 +184,15 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
if (sessionManager.getCurrentAccount() != null
|
if (sessionManager.getCurrentAccount() != null
|
||||||
&& sessionManager.isUserLoggedIn()
|
&& sessionManager.isUserLoggedIn()
|
||||||
&& sessionManager.getCachedAuthCookie() != null) {
|
&& sessionManager.getCachedAuthCookie() != null) {
|
||||||
|
prefs.edit().putBoolean("login_skipped", false).apply();
|
||||||
sessionManager.revalidateAuthToken();
|
sessionManager.revalidateAuthToken();
|
||||||
startMainActivity();
|
startMainActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefs.getBoolean("login_skipped", false)){
|
||||||
|
skipLogin();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.BottomSheetBehavior;
|
import android.support.design.widget.BottomSheetBehavior;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
@ -51,8 +50,10 @@ import timber.log.Timber;
|
||||||
import uk.co.deanwild.materialshowcaseview.IShowcaseListener;
|
import uk.co.deanwild.materialshowcaseview.IShowcaseListener;
|
||||||
import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView;
|
import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView;
|
||||||
|
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.*;
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
||||||
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SLIGHTLY_CHANGED;
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.MAP_UPDATED;
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.MAP_UPDATED;
|
||||||
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.PERMISSION_JUST_GRANTED;
|
||||||
|
|
||||||
|
|
||||||
public class NearbyActivity extends NavigationBaseActivity implements LocationUpdateListener,
|
public class NearbyActivity extends NavigationBaseActivity implements LocationUpdateListener,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.BottomSheetBehavior;
|
import android.support.design.widget.BottomSheetBehavior;
|
||||||
import android.support.design.widget.CoordinatorLayout;
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
@ -53,8 +54,10 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import dagger.android.support.DaggerFragment;
|
import dagger.android.support.DaggerFragment;
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
|
import fr.free.nrw.commons.auth.LoginActivity;
|
||||||
import fr.free.nrw.commons.contributions.ContributionController;
|
import fr.free.nrw.commons.contributions.ContributionController;
|
||||||
import fr.free.nrw.commons.utils.ContributionUtils;
|
import fr.free.nrw.commons.utils.ContributionUtils;
|
||||||
import fr.free.nrw.commons.utils.UriDeserializer;
|
import fr.free.nrw.commons.utils.UriDeserializer;
|
||||||
|
|
@ -68,6 +71,8 @@ import static fr.free.nrw.commons.wikidata.WikidataConstants.WIKIDATA_ENTITY_ID_
|
||||||
|
|
||||||
public class NearbyMapFragment extends DaggerFragment {
|
public class NearbyMapFragment extends DaggerFragment {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("application_preferences") SharedPreferences applicationPrefs;
|
||||||
public MapView mapView;
|
public MapView mapView;
|
||||||
private List<NearbyBaseMarker> baseMarkerOptions;
|
private List<NearbyBaseMarker> baseMarkerOptions;
|
||||||
private fr.free.nrw.commons.location.LatLng curLatLng;
|
private fr.free.nrw.commons.location.LatLng curLatLng;
|
||||||
|
|
@ -373,7 +378,23 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListeners() {
|
private void setListeners() {
|
||||||
fabPlus.setOnClickListener(view -> animateFAB(isFabOpen));
|
fabPlus.setOnClickListener(view -> {
|
||||||
|
if (applicationPrefs.getBoolean("login_skipped", true)) {
|
||||||
|
// prompt the user to login
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setMessage(R.string.login_alert_message)
|
||||||
|
.setPositiveButton(R.string.login, (dialog, which) -> {
|
||||||
|
// logout of the app
|
||||||
|
BaseLogoutListener logoutListener = new BaseLogoutListener();
|
||||||
|
CommonsApplication app = (CommonsApplication) getActivity().getApplication();
|
||||||
|
app.clearApplicationData(getContext(), logoutListener);
|
||||||
|
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}else {
|
||||||
|
animateFAB(isFabOpen);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
bottomSheetDetails.setOnClickListener(view -> {
|
bottomSheetDetails.setOnClickListener(view -> {
|
||||||
if (bottomSheetDetailsBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (bottomSheetDetailsBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
|
|
@ -491,6 +512,21 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
mapView.setStyleUrl("asset://mapstyle.json");
|
mapView.setStyleUrl("asset://mapstyle.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onLogoutComplete is called after shared preferences and data stored in local database are cleared.
|
||||||
|
*/
|
||||||
|
private class BaseLogoutListener implements CommonsApplication.LogoutListener {
|
||||||
|
@Override
|
||||||
|
public void onLogoutComplete() {
|
||||||
|
Timber.d("Logout complete callback received.");
|
||||||
|
Intent nearbyIntent = new Intent( getActivity(), LoginActivity.class);
|
||||||
|
nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(nearbyIntent);
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a marker for the user's current position. Adds a
|
* Adds a marker for the user's current position. Adds a
|
||||||
* circle which uses the accuracy * 2, to draw a circle
|
* circle which uses the accuracy * 2, to draw a circle
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import android.net.Uri;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.transition.TransitionManager;
|
import android.support.transition.TransitionManager;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
@ -27,12 +28,17 @@ import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
|
import fr.free.nrw.commons.auth.LoginActivity;
|
||||||
import fr.free.nrw.commons.contributions.ContributionController;
|
import fr.free.nrw.commons.contributions.ContributionController;
|
||||||
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
import static fr.free.nrw.commons.theme.NavigationBaseActivity.startActivityWithFlags;
|
||||||
|
|
||||||
public class PlaceRenderer extends Renderer<Place> {
|
public class PlaceRenderer extends Renderer<Place> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("application_preferences") SharedPreferences applicationPrefs;
|
||||||
@BindView(R.id.tvName) TextView tvName;
|
@BindView(R.id.tvName) TextView tvName;
|
||||||
@BindView(R.id.tvDesc) TextView tvDesc;
|
@BindView(R.id.tvDesc) TextView tvDesc;
|
||||||
@BindView(R.id.distance) TextView distance;
|
@BindView(R.id.distance) TextView distance;
|
||||||
|
|
@ -88,9 +94,9 @@ public class PlaceRenderer extends Renderer<Place> {
|
||||||
Log.d("Renderer", "clicked");
|
Log.d("Renderer", "clicked");
|
||||||
TransitionManager.beginDelayedTransition(buttonLayout);
|
TransitionManager.beginDelayedTransition(buttonLayout);
|
||||||
|
|
||||||
if(buttonLayout.isShown()){
|
if (buttonLayout.isShown()) {
|
||||||
closeLayout(buttonLayout);
|
closeLayout(buttonLayout);
|
||||||
}else {
|
} else {
|
||||||
openLayout(buttonLayout);
|
openLayout(buttonLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,18 +112,46 @@ public class PlaceRenderer extends Renderer<Place> {
|
||||||
});
|
});
|
||||||
|
|
||||||
cameraButton.setOnClickListener(view2 -> {
|
cameraButton.setOnClickListener(view2 -> {
|
||||||
Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
if (applicationPrefs.getBoolean("login_skipped", true)) {
|
||||||
DirectUpload directUpload = new DirectUpload(fragment, controller);
|
// prompt the user to login
|
||||||
storeSharedPrefs();
|
new AlertDialog.Builder(getContext())
|
||||||
directUpload.initiateCameraUpload();
|
.setMessage(R.string.login_alert_message)
|
||||||
|
.setPositiveButton(R.string.login, (dialog, which) -> {
|
||||||
|
startActivityWithFlags( getContext(), LoginActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||||
|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
prefs.edit().putBoolean("login_skipped", false).apply();
|
||||||
|
fragment.getActivity().finish();
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
} else {
|
||||||
|
Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
||||||
|
DirectUpload directUpload = new DirectUpload(fragment, controller);
|
||||||
|
storeSharedPrefs();
|
||||||
|
directUpload.initiateCameraUpload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
galleryButton.setOnClickListener(view3 -> {
|
galleryButton.setOnClickListener(view3 -> {
|
||||||
Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
if (applicationPrefs.getBoolean("login_skipped", true)) {
|
||||||
DirectUpload directUpload = new DirectUpload(fragment, controller);
|
// prompt the user to login
|
||||||
storeSharedPrefs();
|
new AlertDialog.Builder(getContext())
|
||||||
directUpload.initiateGalleryUpload();
|
.setMessage(R.string.login_alert_message)
|
||||||
|
.setPositiveButton(R.string.login, (dialog, which) -> {
|
||||||
|
startActivityWithFlags( getContext(), LoginActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||||
|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
prefs.edit().putBoolean("login_skipped", false).apply();
|
||||||
|
fragment.getActivity().finish();
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}else {
|
||||||
|
Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
||||||
|
DirectUpload directUpload = new DirectUpload(fragment, controller);
|
||||||
|
storeSharedPrefs();
|
||||||
|
directUpload.initiateGalleryUpload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeSharedPrefs() {
|
private void storeSharedPrefs() {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import android.accounts.AccountManager;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.NavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
|
|
@ -12,6 +13,7 @@ import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -19,6 +21,9 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import fr.free.nrw.commons.AboutActivity;
|
import fr.free.nrw.commons.AboutActivity;
|
||||||
import fr.free.nrw.commons.BuildConfig;
|
import fr.free.nrw.commons.BuildConfig;
|
||||||
|
|
@ -46,6 +51,8 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
||||||
NavigationView navigationView;
|
NavigationView navigationView;
|
||||||
@BindView(R.id.drawer_layout)
|
@BindView(R.id.drawer_layout)
|
||||||
DrawerLayout drawerLayout;
|
DrawerLayout drawerLayout;
|
||||||
|
@Inject @Named("application_preferences") SharedPreferences prefs;
|
||||||
|
|
||||||
|
|
||||||
private ActionBarDrawerToggle toggle;
|
private ActionBarDrawerToggle toggle;
|
||||||
|
|
||||||
|
|
@ -61,6 +68,24 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
||||||
toggle.syncState();
|
toggle.syncState();
|
||||||
setDrawerPaneWidth();
|
setDrawerPaneWidth();
|
||||||
setUserName();
|
setUserName();
|
||||||
|
Menu nav_Menu = navigationView.getMenu();
|
||||||
|
View headerLayout = navigationView.getHeaderView(0);
|
||||||
|
ImageView userIcon = headerLayout.findViewById(R.id.user_icon);
|
||||||
|
if (prefs.getBoolean("login_skipped", false)) {
|
||||||
|
userIcon.setVisibility(View.GONE);
|
||||||
|
nav_Menu.findItem(R.id.action_login).setVisible(true);
|
||||||
|
nav_Menu.findItem(R.id.action_home).setVisible(false);
|
||||||
|
nav_Menu.findItem(R.id.action_notifications).setVisible(false);
|
||||||
|
nav_Menu.findItem(R.id.action_settings).setVisible(false);
|
||||||
|
nav_Menu.findItem(R.id.action_logout).setVisible(false);
|
||||||
|
}else {
|
||||||
|
userIcon.setVisibility(View.VISIBLE);
|
||||||
|
nav_Menu.findItem(R.id.action_login).setVisible(false);
|
||||||
|
nav_Menu.findItem(R.id.action_home).setVisible(true);
|
||||||
|
nav_Menu.findItem(R.id.action_notifications).setVisible(true);
|
||||||
|
nav_Menu.findItem(R.id.action_settings).setVisible(true);
|
||||||
|
nav_Menu.findItem(R.id.action_logout).setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -120,6 +145,14 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
||||||
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
|
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
|
||||||
final int itemId = item.getItemId();
|
final int itemId = item.getItemId();
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
|
case R.id.action_login:
|
||||||
|
drawerLayout.closeDrawer(navigationView);
|
||||||
|
startActivityWithFlags(
|
||||||
|
this, LoginActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||||
|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
prefs.edit().putBoolean("login_skipped", false).apply();
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
case R.id.action_home:
|
case R.id.action_home:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
startActivityWithFlags(
|
startActivityWithFlags(
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
|
@ -103,6 +104,7 @@ public class ShareActivity
|
||||||
ModifierSequenceDao modifierSequenceDao;
|
ModifierSequenceDao modifierSequenceDao;
|
||||||
@Inject
|
@Inject
|
||||||
CategoryApi apiCall;
|
CategoryApi apiCall;
|
||||||
|
@Inject @Named("application_preferences") SharedPreferences applicationPrefs;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default_preferences")
|
@Named("default_preferences")
|
||||||
SharedPreferences prefs;
|
SharedPreferences prefs;
|
||||||
|
|
@ -341,6 +343,12 @@ public class ShareActivity
|
||||||
checkIfFileExists();
|
checkIfFileExists();
|
||||||
gpsObj = fileObj.processFileCoordinates(locationPermitted);
|
gpsObj = fileObj.processFileCoordinates(locationPermitted);
|
||||||
decimalCoords = fileObj.getDecimalCoords();
|
decimalCoords = fileObj.getDecimalCoords();
|
||||||
|
if (sessionManager.getCurrentAccount() == null) {
|
||||||
|
Toast.makeText(this, getString(R.string.login_alert_message), Toast.LENGTH_SHORT).show();
|
||||||
|
applicationPrefs.edit().putBoolean("login_skipped", false).apply();
|
||||||
|
Intent loginIntent = new Intent(ShareActivity.this, LoginActivity.class);
|
||||||
|
startActivity(loginIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,16 @@
|
||||||
android:layout_marginBottom="@dimen/standard_gap"
|
android:layout_marginBottom="@dimen/standard_gap"
|
||||||
android:text="@string/forgot_password" />
|
android:text="@string/forgot_password" />
|
||||||
|
|
||||||
|
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
||||||
|
android:visibility="visible"
|
||||||
|
android:id="@+id/skipLogin"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/forgotPassword"
|
||||||
|
android:layout_marginBottom="@dimen/standard_gap"
|
||||||
|
android:text="@string/skip_login" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,11 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<group android:id="@+id/drawer_login">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_login"
|
||||||
|
android:visible="false"
|
||||||
|
android:icon="@drawable/ic_person_black_24dp"
|
||||||
|
android:title="@string/navigation_item_login" />
|
||||||
|
</group>
|
||||||
<group android:id="@+id/drawer_main">
|
<group android:id="@+id/drawer_main">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_home"
|
android:id="@+id/action_home"
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,11 @@
|
||||||
<string name="nominated_for_deletion">This image has been nominated for deletion.</string>
|
<string name="nominated_for_deletion">This image has been nominated for deletion.</string>
|
||||||
<string name="nominated_see_more"><u>See webpage for details</u></string>
|
<string name="nominated_see_more"><u>See webpage for details</u></string>
|
||||||
<string name="view_browser">View in Browser</string>
|
<string name="view_browser">View in Browser</string>
|
||||||
|
<string name="skip_login">Skip</string>
|
||||||
|
<string name="navigation_item_login">Log in</string>
|
||||||
|
<string name="skip_login_title">Do you really want to skip login?</string>
|
||||||
|
<string name="skip_login_message">You will not be able to upload pictures.</string>
|
||||||
|
<string name="login_alert_message">Please log in to use this feature</string>
|
||||||
|
|
||||||
<string name="nearby_location_has_not_changed">Location has not changed.</string>
|
<string name="nearby_location_has_not_changed">Location has not changed.</string>
|
||||||
<string name="nearby_location_not_available">Location not available.</string>
|
<string name="nearby_location_not_available">Location not available.</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue