Allow images to be opened via long-press. (#195)

This commit is contained in:
dosiecki 2014-05-02 03:03:32 -07:00
parent 527e9dc99e
commit a170b30461
2 changed files with 18 additions and 2 deletions

View file

@ -70,6 +70,8 @@
<string name="alert_dialog_ok">Okay</string>
<string name="alert_dialog_cancel">Cancel</string>
<string name="alert_dialog_close">Close</string>
<string name="alert_dialog_done">Done</string>
<string name="alert_dialog_openimage">Open image</string>
<string name="profile">Profile</string>
<string name="profile_location_icon">Location icon</string>

View file

@ -5,6 +5,7 @@ import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
@ -252,11 +253,24 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
// if the long-pressed item was an image, see if we can pop up a little dialogue
// that presents the alt text. Note that images wrapped in links tend to get detected
// as anchors, not images, and may not point to the corresponding image URL.
String altText = imageAltTexts.get(result.getExtra());
final String imageURL = result.getExtra();
final String altText = imageAltTexts.get(imageURL);
if (altText != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(result.getExtra());
builder.setTitle(imageURL);
builder.setMessage(altText);
builder.setPositiveButton(R.string.alert_dialog_openimage, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(imageURL));
startActivity(i);
}
});
builder.setNegativeButton(R.string.alert_dialog_done, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
; // do nothing
}
});
builder.show();
}
} else {