Merge pull request #695 from maskaravivek/welcome

Fixes #671: Ability to launch welcome activity again
This commit is contained in:
Josephine Lim 2017-05-30 16:18:52 +10:00 committed by GitHub
commit 0b39a12d2f
6 changed files with 48 additions and 13 deletions

View file

@ -1,5 +1,7 @@
package fr.free.nrw.commons;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
@ -7,12 +9,14 @@ import com.viewpagerindicator.CirclePageIndicator;
import butterknife.BindView;
import butterknife.ButterKnife;
import fr.free.nrw.commons.contributions.ContributionsActivity;
import fr.free.nrw.commons.theme.BaseActivity;
public class WelcomeActivity extends BaseActivity {
@BindView(R.id.welcomePager) ViewPager pager;
@BindView(R.id.welcomePagerIndicator) CirclePageIndicator indicator;
private WelcomePagerAdapter adapter = new WelcomePagerAdapter();
@Override
@ -20,9 +24,6 @@ public class WelcomeActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
ButterKnife.bind(this);
pager.setAdapter(adapter);
@ -40,4 +41,9 @@ public class WelcomeActivity extends BaseActivity {
adapter.setCallback(null);
super.onDestroy();
}
public static void startYourself(Context context) {
Intent welcomeIntent = new Intent(context, WelcomeActivity.class);
context.startActivity(welcomeIntent);
}
}

View file

@ -113,7 +113,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
protected void onResume() {
super.onResume();
if (prefs.getBoolean("firstrun", true)) {
startWelcomeIntent();
WelcomeActivity.startYourself(this);
prefs.edit().putBoolean("firstrun", false).apply();
}
if (app.getCurrentAccount() != null) {
@ -121,11 +121,6 @@ public class LoginActivity extends AccountAuthenticatorActivity {
}
}
private void startWelcomeIntent() {
Intent welcomeIntent = new Intent(this, WelcomeActivity.class);
startActivity(welcomeIntent);
}
@Override
protected void onDestroy() {
try {
@ -215,8 +210,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
}
public void startMainActivity() {
Intent intent = new Intent(this, ContributionsActivity.class);
startActivity(intent);
ContributionsActivity.startYourself(this);
finish();
}

View file

@ -341,7 +341,7 @@ public class ContributionsActivity
}
public static void startYourself(Context context) {
Intent settingsIntent = new Intent(context, ContributionsActivity.class);
context.startActivity(settingsIntent);
Intent contributionsIntent = new Intent(context, ContributionsActivity.class);
context.startActivity(contributionsIntent);
}
}

View file

@ -23,6 +23,7 @@ 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.WelcomeActivity;
import fr.free.nrw.commons.auth.LoginActivity;
import fr.free.nrw.commons.contributions.ContributionsActivity;
import fr.free.nrw.commons.nearby.NearbyActivity;
@ -51,6 +52,9 @@ public class NavigationBaseFragment extends Fragment {
@BindView(R.id.logout_item)
LinearLayout logoutItem;
@BindView(R.id.introduction_item)
LinearLayout introductionItem;
private DrawerLayout drawerLayout;
private RelativeLayout drawerPane;
@ -106,6 +110,12 @@ public class NavigationBaseFragment extends Fragment {
NearbyActivity.startYourself(getActivity());
}
@OnClick(R.id.introduction_item)
protected void onInfoItemClicked() {
closeDrawer();
WelcomeActivity.startYourself(getActivity());
}
@OnClick(R.id.feedback_item)
protected void onFeedbackItemClicked() {
closeDrawer();