added possibility to share strings from javascript to iitc share activity (see #482)
This commit is contained in:
parent
0ee98355bd
commit
d822d56377
2
mobile/.idea/misc.xml
generated
2
mobile/.idea/misc.xml
generated
@ -3,7 +3,7 @@
|
|||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<entry_points version="2.0" />
|
<entry_points version="2.0" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android 4.2.2" project-jdk-type="Android SDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android 4.3 Platform" project-jdk-type="Android SDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
@ -51,6 +51,15 @@ public class IITC_JSInterface {
|
|||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// share a string to the IITC share activity. only uses the share tab.
|
||||||
|
@JavascriptInterface
|
||||||
|
public void shareString(String str) {
|
||||||
|
Intent intent = new Intent(mContext, ShareActivity.class);
|
||||||
|
intent.putExtra("shareString", str);
|
||||||
|
intent.putExtra("onlyShare", true);
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
// disable javascript injection while spinner is enabled
|
// disable javascript injection while spinner is enabled
|
||||||
// prevent the spinner from closing automatically
|
// prevent the spinner from closing automatically
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
|
@ -64,13 +64,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
|||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupIntents() {
|
private void setupShareIntent(String str) {
|
||||||
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);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, getUrl());
|
intent.putExtra(Intent.EXTRA_TEXT, str);
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupIntents() {
|
||||||
|
setupShareIntent(getUrl());
|
||||||
|
|
||||||
// we merge gmaps intents with geo intents since it is not possible
|
// we merge gmaps intents with geo intents since it is not possible
|
||||||
// anymore to set a labeled marker on geo intents
|
// anymore to set a labeled marker on geo intents
|
||||||
@ -95,7 +99,7 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
|||||||
intents.add(geoIntent);
|
intents.add(geoIntent);
|
||||||
addTab(intents, R.string.tab_map, R.drawable.location_map);
|
addTab(intents, R.string.tab_map, R.drawable.location_map);
|
||||||
|
|
||||||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getUrl()));
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getUrl()));
|
||||||
addTab(intent, R.string.tab_browser, R.drawable.browser);
|
addTab(intent, R.string.tab_browser, R.drawable.browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,18 +108,25 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_share);
|
setContentView(R.layout.activity_share);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
mFragmentAdapter = new IntentFragmentAdapter(getSupportFragmentManager());
|
||||||
mTitle = intent.getStringExtra("title");
|
|
||||||
mLl = intent.getDoubleExtra("lat", 0) + "," + intent.getDoubleExtra("lng", 0);
|
|
||||||
mZoom = intent.getIntExtra("zoom", 0);
|
|
||||||
mIsPortal = intent.getBooleanExtra("isPortal", false);
|
|
||||||
|
|
||||||
final ActionBar actionBar = getActionBar();
|
final ActionBar actionBar = getActionBar();
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
mFragmentAdapter = new IntentFragmentAdapter(getSupportFragmentManager());
|
Intent intent = getIntent();
|
||||||
setupIntents();
|
// from portallinks/permalinks we build 3 intents (share / geo / vanilla-intel-link)
|
||||||
|
if (intent.getBooleanExtra("onlyShare", false) == false) {
|
||||||
|
mTitle = intent.getStringExtra("title");
|
||||||
|
mLl = intent.getDoubleExtra("lat", 0) + "," + intent.getDoubleExtra("lng", 0);
|
||||||
|
mZoom = intent.getIntExtra("zoom", 0);
|
||||||
|
mIsPortal = intent.getBooleanExtra("isPortal", false);
|
||||||
|
|
||||||
|
setupIntents();
|
||||||
|
} else {
|
||||||
|
mTitle = getString(R.string.app_name);
|
||||||
|
setupShareIntent(intent.getStringExtra("shareString"));
|
||||||
|
}
|
||||||
|
|
||||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
mViewPager.setAdapter(mFragmentAdapter);
|
mViewPager.setAdapter(mFragmentAdapter);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user