29
29
import butterknife.ButterKnife;
30
30
import fr.free.nrw.commons.BuildConfig;
31
31
import fr.free.nrw.commons.R;
32
- import fr.free.nrw.commons.auth.AuthenticatedActivity;
33
32
import fr.free.nrw.commons.auth.SessionManager;
34
33
import fr.free.nrw.commons.location.LocationServiceManager;
35
34
import fr.free.nrw.commons.nearby.NearbyFragment;
38
37
import fr.free.nrw.commons.notification.NotificationActivity;
39
38
import fr.free.nrw.commons.notification.NotificationController;
40
39
import fr.free.nrw.commons.quiz.QuizChecker;
40
+ import fr.free.nrw.commons.theme.NavigationBaseActivity;
41
41
import fr.free.nrw.commons.upload.UploadService;
42
42
import io.reactivex.android.schedulers.AndroidSchedulers;
43
43
import io.reactivex.schedulers.Schedulers;
44
44
import timber.log.Timber;
45
45
46
46
import static android.content.ContentResolver.requestSync;
47
47
48
- public class MainActivity extends AuthenticatedActivity implements FragmentManager.OnBackStackChangedListener {
48
+ public class MainActivity extends NavigationBaseActivity implements FragmentManager.OnBackStackChangedListener {
49
49
50
50
@Inject
51
51
SessionManager sessionManager;
@@ -63,7 +63,6 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
63
63
64
64
65
65
public Intent uploadServiceIntent;
66
- public boolean isAuthCookieAcquired = false;
67
66
68
67
public ContributionsActivityPagerAdapter contributionsActivityPagerAdapter;
69
68
public static final int CONTRIBUTIONS_TAB_POSITION = 0;
@@ -82,10 +81,10 @@ public void onCreate(Bundle savedInstanceState) {
82
81
setContentView(R.layout.activity_contributions);
83
82
ButterKnife.bind(this);
84
83
85
- requestAuthToken();
86
84
initDrawer();
87
85
setTitle(getString(R.string.navigation_item_home)); // Should I create a new string variable with another name instead?
88
86
87
+ initMain();
89
88
90
89
if (savedInstanceState != null ) {
91
90
onOrientationChanged = true; // Will be used in nearby fragment to determine significant update of map
@@ -103,16 +102,13 @@ protected void onSaveInstanceState(Bundle outState) {
103
102
outState.putInt("viewPagerCurrentItem", viewPager.getCurrentItem());
104
103
}
105
104
106
- @Override
107
- protected void onAuthCookieAcquired(String authCookie) {
108
- // Do a sync everytime we get here!
105
+ private void initMain() {
109
106
requestSync(sessionManager.getCurrentAccount(), BuildConfig.CONTRIBUTION_AUTHORITY, new Bundle());
110
107
uploadServiceIntent = new Intent(this, UploadService.class);
111
108
uploadServiceIntent.setAction(UploadService.ACTION_START_SERVICE);
112
109
startService(uploadServiceIntent);
113
110
114
111
addTabsAndFragments();
115
- isAuthCookieAcquired = true;
116
112
if (contributionsActivityPagerAdapter.getItem(0) != null) {
117
113
((ContributionsFragment)contributionsActivityPagerAdapter.getItem(0)).onAuthCookieAcquired(uploadServiceIntent);
118
114
}
@@ -232,14 +228,9 @@ public void showTabs() {
232
228
}
233
229
}
234
230
235
- @Override
236
- protected void onAuthFailure() {
237
-
238
- }
239
-
240
231
@Override
241
232
public void onBackPressed() {
242
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
233
+ DrawerLayout drawer = findViewById(R.id.drawer_layout);
243
234
String contributionsFragmentTag = ((ContributionsActivityPagerAdapter) viewPager.getAdapter()).makeFragmentName(R.id.pager, 0);
244
235
String nearbyFragmentTag = ((ContributionsActivityPagerAdapter) viewPager.getAdapter()).makeFragmentName(R.id.pager, 1);
245
236
if (drawer.isDrawerOpen(GravityCompat.START)) {
0 commit comments