Skip to content

Commit

Permalink
Merge pull request #22 from talk2cerlin/master
Browse files Browse the repository at this point in the history
Added option to hide and show share button
  • Loading branch information
sarriaroman committed Mar 23, 2016
2 parents b0a2193 + cf7e01e commit 059253b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/android/PhotoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import com.squareup.picasso.Picasso;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -35,6 +38,9 @@ public class PhotoActivity extends Activity {

private TextView titleTxt;

private JSONObject options;
private int shareBtnVisibility;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -44,8 +50,13 @@ protected void onCreate(Bundle savedInstanceState) {
// Load the Views
findViews();

// Hide the Share Button
shareBtn.setVisibility(View.INVISIBLE);
try {
options = new JSONObject(this.getIntent().getStringExtra("options"));
shareBtnVisibility = options.getBoolean("share") ? View.VISIBLE : View.INVISIBLE;
} catch(JSONException exception) {
shareBtnVisibility = View.VISIBLE;
}
shareBtn.setVisibility(shareBtnVisibility);

// Change the Activity Title
String actTitle = this.getIntent().getStringExtra("title");
Expand Down Expand Up @@ -113,7 +124,8 @@ private Activity getActivity() {
*/
private void hideLoadingAndUpdate() {
photo.setVisibility(View.VISIBLE);
shareBtn.setVisibility(View.VISIBLE);

shareBtn.setVisibility(shareBtnVisibility);

mAttacher.update();
}
Expand Down
1 change: 1 addition & 0 deletions src/android/PhotoViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo

i.putExtra("url", args.getString(0));
i.putExtra("title", args.getString(1));
i.putExtra("options", args.optJSONObject(2).toString());

this.cordova.getActivity().startActivity(i);

Expand Down
8 changes: 6 additions & 2 deletions www/PhotoViewer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
var exec = require('cordova/exec');

exports.show = function(url, title) {
exports.show = function(url, title, options) {
if( title == undefined ) {
title = '';
}

exec(function(){}, function(){}, "PhotoViewer", "show", [url, title]);
if(typeof options == "undefined"){
options = {};
}

exec(function(){}, function(){}, "PhotoViewer", "show", [url, title, options]);
};

0 comments on commit 059253b

Please sign in to comment.