Update share provider

master
Chris Baughman 2014-02-09 13:26:08 -05:00
parent 8d0e617893
commit d820c3cf01
7 changed files with 78 additions and 51 deletions

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -8,4 +8,5 @@
# project structure. # project structure.
# Project target. # Project target.
target=android-10 target=android-19
android.library.reference.1=../../workspace/gridlayout_v7

View File

@ -6,29 +6,22 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Settings" android:text="@string/action_settings"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge" />
android:layout_width="wrap_content"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal">
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<TextView <TextView
android:layout_height="wrap_content" android:id="@+id/textView1"
android:text="Check for updates"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:padding="5dp" android:layout_height="wrap_content"
android:layout_marginStart="80dp"/> android:text="@string/choose_source"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout> <Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>

View File

@ -2,11 +2,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Refresh --> <!-- Refresh -->
<item android:id="@+id/action_refresh" <group android:id="@+id/group1" android:enabled="true" android:menuCategory="container" android:visible="true">
android:icon="@drawable/ic_action_refresh" <item android:id="@+id/settings" android:actionLayout="@layout/settings_activity" android:title="@string/action_settings" android:menuCategory="secondary" android:enabled="true" android:showAsAction="ifRoom"></item>
android:title="@string/action_refresh" </group>
android:showAsAction="ifRoom" />
<!-- Location Found --> <!-- Location Found -->
<item android:id="@+id/action_help" <item android:id="@+id/action_help"
android:icon="@drawable/ic_action_help" android:icon="@drawable/ic_action_help"
@ -18,5 +16,6 @@
android:icon="@drawable/ic_action_share" android:icon="@drawable/ic_action_share"
android:title="@string/action_share" android:title="@string/action_share"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:actionProviderClass="android.widget.ShareActionProvider" /> android:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
</menu> </menu>

View File

@ -18,5 +18,8 @@
<string name="action_refresh">Refresh</string> <string name="action_refresh">Refresh</string>
<string name="action_about">About</string> <string name="action_about">About</string>
<string name="action_share">Share</string> <string name="action_share">Share</string>
<string name="action_settings">Settings</string>
<string name="spinner_prompt">Select</string>
<string name="choose_source">Choose Source</string>
</resources> </resources>

View File

@ -21,12 +21,16 @@ public class MainActivity extends Activity
ArrayAdapter<String> adapter; ArrayAdapter<String> adapter;
List<String> list= null; List<String> list= null;
private ShareActionProvider mShare; private ShareActionProvider mShare;
protected String dorkSelected = "";
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflator = getMenuInflater(); MenuInflater inflator = getMenuInflater();
inflator.inflate(R.menu.menu, menu); inflator.inflate(R.menu.menu, menu);
// Set up shareactionprovider
MenuItem shareItem = menu.findItem(R.id.action_share);
mShare = (ShareActionProvider)shareItem.getActionProvider();
mShare.setShareIntent(getShareItem());
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@ -83,6 +87,17 @@ public class MainActivity extends Activity
} }
}); });
listV.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View view,
int pos, long arg3) {
dorkSelected = list.get(pos).toString();
return false;
}
});
listV.setOnItemClickListener(new OnItemClickListener() { listV.setOnItemClickListener(new OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int pos, long idt) { public void onItemClick(AdapterView<?> parent, View view, int pos, long idt) {
@ -109,7 +124,7 @@ public class MainActivity extends Activity
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click // Take appropriate action for each action item click
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_refresh: case R.id.settings:
// search action // search action
Intent intent_settings = new Intent(this, SettingsActivity.class); Intent intent_settings = new Intent(this, SettingsActivity.class);
this.startActivity(intent_settings); this.startActivity(intent_settings);
@ -120,9 +135,6 @@ public class MainActivity extends Activity
sh.setTitle("About Google Dorks by CMB"); sh.setTitle("About Google Dorks by CMB");
sh.show(); sh.show();
return true; return true;
case R.id.action_share:
mShare = (ShareActionProvider)item.getActionProvider();
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -135,4 +147,18 @@ public class MainActivity extends Activity
Intent i = new Intent(MainActivity.this, ShowHelp.class); Intent i = new Intent(MainActivity.this, ShowHelp.class);
startActivity(i); startActivity(i);
} }
private void setShareIntent(Intent shareIntent) {
if (mShare != null) {
mShare.setShareIntent(shareIntent);
}
}
private Intent getShareItem() {
Intent inten = new Intent(Intent.ACTION_SEND);
inten.putExtra(Intent.EXTRA_TEXT, dorkSelected);
inten.setType("text/plain");
return inten;
}
} }