Skip to content

Commit

Permalink
Add share URL option to context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nning committed May 22, 2017
1 parent f2c92bd commit 882cbb3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
29 changes: 20 additions & 9 deletions app/src/main/java/net/orgizm/imgshr/GalleryListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,32 +95,31 @@ public boolean onContextItemSelected(MenuItem item) {
break;

case R.id.open_url:
Gallery gallery1 = galleriesList.get(position);
String url = "https://imgshr.space/!" + gallery1.getSlug();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(intent);
String url1 = "https://imgshr.space/!" + galleriesList.get(position).getSlug();
Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse(url1));
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent1);

break;

case R.id.update_details:
final Gallery gallery2 = galleriesList.get(position);
final Gallery gallery1 = galleriesList.get(position);

new Thread(new Runnable() {
public void run() {
try {
final Connection conn = new Connection(context, gallery2.getSlug());
final Connection conn = new Connection(context, gallery1.getSlug());
final String json = conn.discoverGallery();

Log.d(LOG_TARGET, json);

gallery2.updateDetails(json);
gallery1.updateDetails(json);
}
catch(Exception e) {
Log.d(LOG_TARGET, Log.getStackTraceString(e));
}

preferences.setLastSlugs(gallery2);
preferences.setLastSlugs(gallery1);

runOnUiThread(new Runnable() {
public void run() {
Expand All @@ -131,6 +130,18 @@ public void run() {
}
}).start();

break;

case R.id.share_url:
Intent intent2 = new Intent();
String url2 = "https://imgshr.space/!" + galleriesList.get(position).getSlug();

intent2.setAction(Intent.ACTION_SEND);
intent2.putExtra(Intent.EXTRA_TEXT, url2);
intent2.setType("text/plain");

startActivity(intent2);

break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.Context
menu.setHeaderTitle(gallery.getSlug());
menu.add(Menu.NONE, R.id.delete_from_list, Menu.NONE, R.string.delete_from_list);
menu.add(Menu.NONE, R.id.open_url, Menu.NONE, R.string.open_url);
menu.add(Menu.NONE, R.id.share_url, Menu.NONE, R.string.share_url);
menu.add(Menu.NONE, R.id.update_details, Menu.NONE, R.string.update_details);
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/menu/gallery_context_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/delete_from_list" android:title="@string/delete_from_list"/>
<item android:id="@+id/open_url" android:title="@string/open_url"/>
<item android:id="@+id/share_url" android:title="@string/share_url"/>
<item android:id="@+id/update_details" android:title="@string/update_details"/>
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
<string name="save_button">Save</string>
<string name="add_gallery">Add gallery</string>
<string name="update_details">Update details</string>
<string name="share_url">Share URL</string>
</resources>

0 comments on commit 882cbb3

Please sign in to comment.