This commit is contained in:
Jon Atkins 2013-07-31 16:14:41 +01:00
commit 09103db579
3 changed files with 30 additions and 4 deletions

View File

@ -258,7 +258,8 @@ if buildMobile:
# do not include desktop-only plugins to mobile assets # do not include desktop-only plugins to mobile assets
ignore=shutil.ignore_patterns('*.meta.js', ignore=shutil.ignore_patterns('*.meta.js',
'force-https*', 'privacy-view*', 'speech-search*', 'force-https*', 'privacy-view*', 'speech-search*',
'basemap-cloudmade*', 'scroll-wheel-zoom-disable*')) 'basemap-cloudmade*', 'scroll-wheel-zoom-disable*',
'sync*'))
if buildMobile != 'copyonly': if buildMobile != 'copyonly':

View File

@ -107,7 +107,7 @@ public class IITC_Mobile extends Activity {
return; return;
} }
// no reload needed // 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; return;
reload_needed = true; reload_needed = true;

View File

@ -3,8 +3,10 @@ package com.cradle.iitc_mobile.share;
import android.app.ActionBar; import android.app.ActionBar;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils; import android.support.v4.app.NavUtils;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
@ -15,6 +17,7 @@ import com.cradle.iitc_mobile.R;
public class ShareActivity extends FragmentActivity implements ActionBar.TabListener { public class ShareActivity extends FragmentActivity implements ActionBar.TabListener {
private boolean mIsPortal; private boolean mIsPortal;
private String mLl; private String mLl;
private SharedPreferences mSharedPrefs = null;
private String mTitle; private String mTitle;
private int mZoom; private int mZoom;
IntentFragmentAdapter mFragmentAdapter; IntentFragmentAdapter mFragmentAdapter;
@ -38,6 +41,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
return url; 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() { private void setupIntents() {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 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); intent.putExtra(Intent.EXTRA_SUBJECT, mTitle);
addTab(intent, R.string.tab_share, R.drawable.share); 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)); intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(geoUri));
addTab(intent, R.string.tab_map, R.drawable.location_map); addTab(intent, R.string.tab_map, R.drawable.location_map);
@ -79,6 +93,7 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position); actionBar.setSelectedNavigationItem(position);
setSelected(position);
} }
}); });
@ -91,6 +106,14 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
.setIcon(fragment.getIcon()) .setIcon(fragment.getIcon())
.setTabListener(this)); .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 @Override
@ -109,7 +132,9 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
@Override @Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
mViewPager.setCurrentItem(tab.getPosition()); int position = tab.getPosition();
mViewPager.setCurrentItem(position);
setSelected(position);
} }
@Override @Override