diff --git a/build.py b/build.py index f3ae396a..984b7c8e 100755 --- a/build.py +++ b/build.py @@ -258,7 +258,8 @@ if buildMobile: # do not include desktop-only plugins to mobile assets ignore=shutil.ignore_patterns('*.meta.js', 'force-https*', 'privacy-view*', 'speech-search*', - 'basemap-cloudmade*', 'scroll-wheel-zoom-disable*')) + 'basemap-cloudmade*', 'scroll-wheel-zoom-disable*', + 'sync*')) if buildMobile != 'copyonly': diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 11251010..e61faf7b 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -107,7 +107,7 @@ public class IITC_Mobile extends Activity { return; } // no reload needed - if (key.equals("pref_press_twice_to_exit")) + if (key.equals("pref_press_twice_to_exit") || key.equals("pref_share_selected_tab")) return; reload_needed = true; diff --git a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java index 8f9ff784..494e9c82 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java @@ -3,8 +3,10 @@ package com.cradle.iitc_mobile.share; import android.app.ActionBar; import android.app.FragmentTransaction; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.app.FragmentActivity; import android.support.v4.app.NavUtils; import android.support.v4.view.ViewPager; @@ -15,6 +17,7 @@ import com.cradle.iitc_mobile.R; public class ShareActivity extends FragmentActivity implements ActionBar.TabListener { private boolean mIsPortal; private String mLl; + private SharedPreferences mSharedPrefs = null; private String mTitle; private int mZoom; IntentFragmentAdapter mFragmentAdapter; @@ -38,6 +41,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList return url; } + private void setSelected(int position) { + // Activity not fully loaded yet (may occur during tab creation) + if (mSharedPrefs == null) + return; + + mSharedPrefs + .edit() + .putInt("pref_share_selected_tab", position) + .apply(); + } + private void setupIntents() { Intent intent = new Intent(Intent.ACTION_SEND); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); @@ -46,7 +60,7 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList intent.putExtra(Intent.EXTRA_SUBJECT, mTitle); addTab(intent, R.string.tab_share, R.drawable.share); - String geoUri = "geo:" + mLl; + String geoUri = "http://maps.google.com/maps?q=loc:" + mLl + " (" + mTitle + ")"; intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(geoUri)); addTab(intent, R.string.tab_map, R.drawable.location_map); @@ -79,6 +93,7 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); + setSelected(position); } }); @@ -91,6 +106,14 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList .setIcon(fragment.getIcon()) .setTabListener(this)); } + + mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); + int selected = mSharedPrefs.getInt("pref_share_selected_tab", 0); + if (selected < mFragmentAdapter.getCount()) + { + mViewPager.setCurrentItem(selected); + actionBar.setSelectedNavigationItem(selected); + } } @Override @@ -109,7 +132,9 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { - mViewPager.setCurrentItem(tab.getPosition()); + int position = tab.getPosition(); + mViewPager.setCurrentItem(position); + setSelected(position); } @Override