add simple tracking (no opt-in yet!)
This commit is contained in:
@@ -50,6 +50,9 @@ dependencies {
|
|||||||
// Nordpol
|
// Nordpol
|
||||||
compile 'com.fidesmo:nordpol-android:0.1.22'
|
compile 'com.fidesmo:nordpol-android:0.1.22'
|
||||||
|
|
||||||
|
// piwik
|
||||||
|
implementation 'org.piwik.sdk:piwik-sdk:3.0.3'
|
||||||
|
|
||||||
// libs as submodules
|
// libs as submodules
|
||||||
implementation project(':libkeychain')
|
implementation project(':libkeychain')
|
||||||
implementation project(':openpgp-api-lib')
|
implementation project(':openpgp-api-lib')
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.accounts.AccountManager;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.os.Handler;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ import timber.log.Timber.DebugTree;
|
|||||||
|
|
||||||
|
|
||||||
public class KeychainApplication extends Application {
|
public class KeychainApplication extends Application {
|
||||||
|
TrackingManager trackingManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the application is starting, before any activity, service, or receiver objects
|
* Called when the application is starting, before any activity, service, or receiver objects
|
||||||
@@ -105,6 +107,9 @@ public class KeychainApplication extends Application {
|
|||||||
KeyserverSyncManager.updateKeyserverSyncScheduleAsync(this, Constants.DEBUG_KEYSERVER_SYNC);
|
KeyserverSyncManager.updateKeyserverSyncScheduleAsync(this, Constants.DEBUG_KEYSERVER_SYNC);
|
||||||
|
|
||||||
TemporaryFileProvider.scheduleCleanupImmediately();
|
TemporaryFileProvider.scheduleCleanupImmediately();
|
||||||
|
|
||||||
|
trackingManager = TrackingManager.getInstance(getApplicationContext());
|
||||||
|
trackingManager.initialize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,4 +157,8 @@ public class KeychainApplication extends Application {
|
|||||||
Timber.plant(new DebugTree());
|
Timber.plant(new DebugTree());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TrackingManager getTrackingManager() {
|
||||||
|
return trackingManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package org.sufficientlysecure.keychain;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Application;
|
||||||
|
import android.app.Application.ActivityLifecycleCallbacks;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.piwik.sdk.Piwik;
|
||||||
|
import org.piwik.sdk.Tracker;
|
||||||
|
import org.piwik.sdk.TrackerConfig;
|
||||||
|
import org.piwik.sdk.extra.DownloadTracker.Extra.ApkChecksum;
|
||||||
|
import org.piwik.sdk.extra.TrackHelper;
|
||||||
|
|
||||||
|
|
||||||
|
public class TrackingManager {
|
||||||
|
private Tracker piwikTracker;
|
||||||
|
|
||||||
|
public static TrackingManager getInstance(Context context) {
|
||||||
|
TrackerConfig trackerConfig = new TrackerConfig("https://mugenguild.com/piwik/", 1, "OpenKeychain");
|
||||||
|
Tracker tracker = Piwik.getInstance(context).newTracker(trackerConfig);
|
||||||
|
tracker.setDispatchInterval(30000);
|
||||||
|
|
||||||
|
return new TrackingManager(tracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TrackingManager(Tracker piwikTracker) {
|
||||||
|
this.piwikTracker = piwikTracker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize(Application application) {
|
||||||
|
if (piwikTracker == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TrackHelper.track().download().identifier(new ApkChecksum(application)).with(piwikTracker);
|
||||||
|
|
||||||
|
application.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityStarted(Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResumed(Activity activity) {
|
||||||
|
TrackHelper.track().screen(activity.getClass().getSimpleName()).with(piwikTracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityPaused(Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityStopped(Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityDestroyed(Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trackFragmentImpression(String opClassName, String fragmentName) {
|
||||||
|
if (piwikTracker == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackHelper.track().screen(opClassName + "/" + fragmentName).with(piwikTracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trackInternalServiceCall(String opClassName) {
|
||||||
|
if (piwikTracker == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TrackHelper.track()
|
||||||
|
.interaction("internalApiCall", opClassName)
|
||||||
|
.with(piwikTracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trackApiServiceCall(String opClassName, String currentCallingPackage) {
|
||||||
|
if (piwikTracker == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackHelper.track()
|
||||||
|
.interaction("externalApiCall", opClassName)
|
||||||
|
.piece(currentCallingPackage.replace(".", "/"))
|
||||||
|
.with(piwikTracker);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,6 +53,8 @@ import org.openintents.openpgp.OpenPgpSignatureResult.AutocryptPeerResult;
|
|||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
||||||
|
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||||
|
import org.sufficientlysecure.keychain.TrackingManager;
|
||||||
import org.sufficientlysecure.keychain.operations.BackupOperation;
|
import org.sufficientlysecure.keychain.operations.BackupOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||||
@@ -99,6 +101,7 @@ public class OpenPgpService extends Service {
|
|||||||
private ApiAppDao mApiAppDao;
|
private ApiAppDao mApiAppDao;
|
||||||
private OpenPgpServiceKeyIdExtractor mKeyIdExtractor;
|
private OpenPgpServiceKeyIdExtractor mKeyIdExtractor;
|
||||||
private ApiPendingIntentFactory mApiPendingIntentFactory;
|
private ApiPendingIntentFactory mApiPendingIntentFactory;
|
||||||
|
private TrackingManager trackingManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@@ -108,6 +111,8 @@ public class OpenPgpService extends Service {
|
|||||||
mApiPermissionHelper = new ApiPermissionHelper(this, mApiAppDao);
|
mApiPermissionHelper = new ApiPermissionHelper(this, mApiAppDao);
|
||||||
mApiPendingIntentFactory = new ApiPendingIntentFactory(getBaseContext());
|
mApiPendingIntentFactory = new ApiPendingIntentFactory(getBaseContext());
|
||||||
mKeyIdExtractor = OpenPgpServiceKeyIdExtractor.getInstance(getContentResolver(), mApiPendingIntentFactory);
|
mKeyIdExtractor = OpenPgpServiceKeyIdExtractor.getInstance(getContentResolver(), mApiPendingIntentFactory);
|
||||||
|
|
||||||
|
trackingManager = ((KeychainApplication) getApplication()).getTrackingManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent signImpl(Intent data, InputStream inputStream,
|
private Intent signImpl(Intent data, InputStream inputStream,
|
||||||
@@ -1025,6 +1030,8 @@ public class OpenPgpService extends Service {
|
|||||||
return errorResult;
|
return errorResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trackingManager.trackApiServiceCall(data.getAction(), mApiPermissionHelper.getCurrentCallingPackage());
|
||||||
|
|
||||||
Progressable progressable = null;
|
Progressable progressable = null;
|
||||||
if (data.hasExtra(OpenPgpApi.EXTRA_PROGRESS_MESSENGER)) {
|
if (data.hasExtra(OpenPgpApi.EXTRA_PROGRESS_MESSENGER)) {
|
||||||
Messenger messenger = data.getParcelableExtra(OpenPgpApi.EXTRA_PROGRESS_MESSENGER);
|
Messenger messenger = data.getParcelableExtra(OpenPgpApi.EXTRA_PROGRESS_MESSENGER);
|
||||||
|
|||||||
@@ -21,11 +21,14 @@ package org.sufficientlysecure.keychain.service;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.v4.os.CancellationSignal;
|
import android.support.v4.os.CancellationSignal;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||||
|
import org.sufficientlysecure.keychain.TrackingManager;
|
||||||
import org.sufficientlysecure.keychain.daos.KeyWritableRepository;
|
import org.sufficientlysecure.keychain.daos.KeyWritableRepository;
|
||||||
import org.sufficientlysecure.keychain.operations.BackupOperation;
|
import org.sufficientlysecure.keychain.operations.BackupOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.BaseOperation;
|
import org.sufficientlysecure.keychain.operations.BaseOperation;
|
||||||
@@ -52,13 +55,19 @@ import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
|||||||
|
|
||||||
|
|
||||||
public class KeychainServiceTask {
|
public class KeychainServiceTask {
|
||||||
public static KeychainServiceTask create(Context context) {
|
private final TrackingManager trackingManager;
|
||||||
return new KeychainServiceTask(context.getApplicationContext());
|
|
||||||
|
public static KeychainServiceTask create(Activity activity) {
|
||||||
|
Context context = activity.getApplicationContext();
|
||||||
|
TrackingManager trackingManager = ((KeychainApplication) activity.getApplication()).getTrackingManager();
|
||||||
|
|
||||||
|
return new KeychainServiceTask(context, KeyWritableRepository.create(context), trackingManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeychainServiceTask(Context context) {
|
private KeychainServiceTask(Context context, KeyWritableRepository keyRepository, TrackingManager trackingManager) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.keyRepository = KeyWritableRepository.create(context);
|
this.keyRepository = keyRepository;
|
||||||
|
this.trackingManager = trackingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@@ -121,6 +130,8 @@ public class KeychainServiceTask {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trackingManager.trackInternalServiceCall(op.getClass().getSimpleName());
|
||||||
|
|
||||||
// noinspection unchecked, we make sure it's the correct op above
|
// noinspection unchecked, we make sure it's the correct op above
|
||||||
return op.execute(inputParcel, cryptoInput);
|
return op.execute(inputParcel, cryptoInput);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ import com.mikepenz.materialdrawer.model.DividerDrawerItem;
|
|||||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.TrackingManager;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.AppsListFragment;
|
import org.sufficientlysecure.keychain.remote.ui.AppsListFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
||||||
@@ -62,6 +64,7 @@ public class MainActivity extends BaseSecurityTokenActivity implements FabContai
|
|||||||
|
|
||||||
public Drawer mDrawer;
|
public Drawer mDrawer;
|
||||||
private Toolbar mToolbar;
|
private Toolbar mToolbar;
|
||||||
|
private TrackingManager trackingManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -72,6 +75,8 @@ public class MainActivity extends BaseSecurityTokenActivity implements FabContai
|
|||||||
mToolbar.setTitle(R.string.app_name);
|
mToolbar.setTitle(R.string.app_name);
|
||||||
setSupportActionBar(mToolbar);
|
setSupportActionBar(mToolbar);
|
||||||
|
|
||||||
|
trackingManager = ((KeychainApplication) getApplication()).getTrackingManager();
|
||||||
|
|
||||||
mDrawer = new DrawerBuilder()
|
mDrawer = new DrawerBuilder()
|
||||||
.withActivity(this)
|
.withActivity(this)
|
||||||
.withHeader(R.layout.main_drawer_header)
|
.withHeader(R.layout.main_drawer_header)
|
||||||
@@ -200,6 +205,8 @@ public class MainActivity extends BaseSecurityTokenActivity implements FabContai
|
|||||||
private void setFragment(Fragment frag) {
|
private void setFragment(Fragment frag) {
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
|
|
||||||
|
trackingManager.trackFragmentImpression(getClass().getSimpleName(), frag.getClass().getSimpleName());
|
||||||
|
|
||||||
FragmentTransaction ft = fragmentManager.beginTransaction();
|
FragmentTransaction ft = fragmentManager.beginTransaction();
|
||||||
ft.replace(R.id.main_fragment_container, frag);
|
ft.replace(R.id.main_fragment_container, frag);
|
||||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||||
|
|||||||
@@ -42,11 +42,13 @@ import android.view.ViewPropertyAnimator;
|
|||||||
import android.view.animation.OvershootInterpolator;
|
import android.view.animation.OvershootInterpolator;
|
||||||
|
|
||||||
import com.astuetz.PagerSlidingTabStrip;
|
import com.astuetz.PagerSlidingTabStrip;
|
||||||
|
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.livedata.GenericLiveData;
|
import org.sufficientlysecure.keychain.livedata.GenericLiveData;
|
||||||
import org.sufficientlysecure.keychain.model.SubKey;
|
import org.sufficientlysecure.keychain.model.SubKey;
|
||||||
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
||||||
import org.sufficientlysecure.keychain.model.UserPacket.UserId;
|
import org.sufficientlysecure.keychain.model.UserPacket.UserId;
|
||||||
|
import org.sufficientlysecure.keychain.TrackingManager;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.daos.KeyRepository;
|
import org.sufficientlysecure.keychain.daos.KeyRepository;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||||
@@ -62,12 +64,13 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
KeyRepository keyRepository;
|
KeyRepository keyRepository;
|
||||||
|
|
||||||
// view
|
// view
|
||||||
private ViewPager mViewPager;
|
private ViewPager viewPager;
|
||||||
private PagerSlidingTabStrip mSlidingTabLayout;
|
private PagerSlidingTabStrip slidingTabLayout;
|
||||||
|
|
||||||
private ActionMode mActionMode;
|
private ActionMode actionMode;
|
||||||
private boolean hasSecret;
|
private boolean hasSecret;
|
||||||
private boolean mActionIconShown;
|
private boolean actionIconShown;
|
||||||
|
private PagerTabStripAdapter tabAdapter;
|
||||||
|
|
||||||
enum ViewKeyAdvTab {
|
enum ViewKeyAdvTab {
|
||||||
START(ViewKeyAdvStartFragment.class, R.string.key_view_tab_start, false),
|
START(ViewKeyAdvStartFragment.class, R.string.key_view_tab_start, false),
|
||||||
@@ -86,6 +89,8 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TrackingManager trackingManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -93,9 +98,10 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
setFullScreenDialogClose(v -> finish());
|
setFullScreenDialogClose(v -> finish());
|
||||||
|
|
||||||
keyRepository = KeyRepository.create(this);
|
keyRepository = KeyRepository.create(this);
|
||||||
|
trackingManager = ((KeychainApplication) getApplication()).getTrackingManager();
|
||||||
|
|
||||||
mViewPager = findViewById(R.id.pager);
|
viewPager = findViewById(R.id.pager);
|
||||||
mSlidingTabLayout = findViewById(R.id.sliding_tab_layout);
|
slidingTabLayout = findViewById(R.id.sliding_tab_layout);
|
||||||
|
|
||||||
if (!getIntent().hasExtra(EXTRA_MASTER_KEY_ID)) {
|
if (!getIntent().hasExtra(EXTRA_MASTER_KEY_ID)) {
|
||||||
throw new IllegalArgumentException("Missing required extra master_key_id");
|
throw new IllegalArgumentException("Missing required extra master_key_id");
|
||||||
@@ -185,7 +191,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
}
|
}
|
||||||
mToolbar.setBackgroundColor(color);
|
mToolbar.setBackgroundColor(color);
|
||||||
mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color));
|
mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color));
|
||||||
mSlidingTabLayout.setBackgroundColor(color);
|
slidingTabLayout.setBackgroundColor(color);
|
||||||
|
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
@@ -196,21 +202,21 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initTabs() {
|
private void initTabs() {
|
||||||
PagerTabStripAdapter tabAdapter = new PagerTabStripAdapter(this);
|
tabAdapter = new PagerTabStripAdapter(this);
|
||||||
mViewPager.setAdapter(tabAdapter);
|
viewPager.setAdapter(tabAdapter);
|
||||||
|
|
||||||
for (ViewKeyAdvTab tab : ViewKeyAdvTab.values()) {
|
for (ViewKeyAdvTab tab : ViewKeyAdvTab.values()) {
|
||||||
tabAdapter.addTab(tab.fragmentClass, null, getString(tab.titleRes));
|
tabAdapter.addTab(tab.fragmentClass, null, getString(tab.titleRes));
|
||||||
}
|
}
|
||||||
|
|
||||||
// update layout after operations
|
// update layout after operations
|
||||||
mSlidingTabLayout.setViewPager(mViewPager);
|
slidingTabLayout.setViewPager(viewPager);
|
||||||
mSlidingTabLayout.setOnPageChangeListener(this);
|
slidingTabLayout.setOnPageChangeListener(this);
|
||||||
|
|
||||||
// switch to tab selected by extra
|
// switch to tab selected by extra
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
int switchToTab = intent.getIntExtra(EXTRA_SELECTED_TAB, 0);
|
int switchToTab = intent.getIntExtra(EXTRA_SELECTED_TAB, 0);
|
||||||
mViewPager.setCurrentItem(switchToTab);
|
viewPager.setCurrentItem(switchToTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -234,15 +240,15 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
getMenuInflater().inflate(R.menu.action_mode_edit, menu);
|
getMenuInflater().inflate(R.menu.action_mode_edit, menu);
|
||||||
final MenuItem vActionModeItem = menu.findItem(R.id.menu_action_mode_edit);
|
final MenuItem vActionModeItem = menu.findItem(R.id.menu_action_mode_edit);
|
||||||
|
|
||||||
boolean isCurrentActionFragment = ViewKeyAdvTab.values()[mViewPager.getCurrentItem()].hasActionMode;
|
boolean isCurrentActionFragment = ViewKeyAdvTab.values()[viewPager.getCurrentItem()].hasActionMode;
|
||||||
|
|
||||||
// if the state is as it should be, never mind
|
// if the state is as it should be, never mind
|
||||||
if (isCurrentActionFragment == mActionIconShown) {
|
if (isCurrentActionFragment == actionIconShown) {
|
||||||
return isCurrentActionFragment;
|
return isCurrentActionFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// show or hide accordingly
|
// show or hide accordingly
|
||||||
mActionIconShown = isCurrentActionFragment;
|
actionIconShown = isCurrentActionFragment;
|
||||||
vActionModeItem.setEnabled(isCurrentActionFragment);
|
vActionModeItem.setEnabled(isCurrentActionFragment);
|
||||||
animateMenuItem(vActionModeItem, isCurrentActionFragment);
|
animateMenuItem(vActionModeItem, isCurrentActionFragment);
|
||||||
|
|
||||||
@@ -273,13 +279,13 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
@Override
|
@Override
|
||||||
public void onActionModeStarted(final ActionMode mode) {
|
public void onActionModeStarted(final ActionMode mode) {
|
||||||
super.onActionModeStarted(mode);
|
super.onActionModeStarted(mode);
|
||||||
mActionMode = mode;
|
actionMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActionModeFinished(ActionMode mode) {
|
public void onActionModeFinished(ActionMode mode) {
|
||||||
super.onActionModeFinished(mode);
|
super.onActionModeFinished(mode);
|
||||||
mActionMode = null;
|
actionMode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -289,11 +295,14 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
if (mActionMode != null) {
|
if (actionMode != null) {
|
||||||
mActionMode.finish();
|
actionMode.finish();
|
||||||
mActionMode = null;
|
actionMode = null;
|
||||||
}
|
}
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
|
||||||
|
String fragmentName = tabAdapter.getItem(position).getClass().getSimpleName();
|
||||||
|
trackingManager.trackFragmentImpression(getClass().getSimpleName(), fragmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user