92 lines
3.9 KiB
Java
92 lines
3.9 KiB
Java
package com.rubenvandeven.emotionhero;
|
|
|
|
import android.app.Dialog;
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.support.v4.app.DialogFragment;
|
|
import android.support.v4.widget.TextViewCompat;
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.Button;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
|
|
/**
|
|
* Created by ruben on 21/09/16.
|
|
*/
|
|
|
|
public class SnapshotDialogFragment extends DialogFragment {
|
|
|
|
Player player;
|
|
|
|
public static SnapshotDialogFragment newInstance() {
|
|
SnapshotDialogFragment frag = new SnapshotDialogFragment();
|
|
return frag;
|
|
}
|
|
|
|
@Override
|
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
player = Player.getInstance(getContext());
|
|
|
|
View v = getActivity().getLayoutInflater().inflate(R.layout.snapshot_check, null);
|
|
|
|
if(player.hasSetSnapshotConfirm()) {
|
|
String statusString = player.allowsSnapshots() ? "share" : "not share";
|
|
TextView statusText = new TextView(getContext());
|
|
statusText.setText("You have currently set to "+statusString+" the snapshots.");
|
|
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
params.addRule(RelativeLayout.BELOW, R.id.lastText);
|
|
int margin = getResources().getDimensionPixelSize(R.dimen.fab_margin);
|
|
params.setMargins(margin, margin/2, margin, 0);
|
|
((RelativeLayout) v.findViewById(R.id.snapshotLayout)).addView(statusText,params);
|
|
}
|
|
|
|
return new AlertDialog.Builder(getActivity())
|
|
// .setIcon(R.drawable.alert_dialog_icon)
|
|
.setTitle("Contribute")
|
|
.setView(v)
|
|
.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
@Override
|
|
public void onDismiss(DialogInterface dialogInterface) {
|
|
// Set nothing, load website (triggers thing the next time
|
|
}
|
|
})
|
|
.setPositiveButton("Yes!",
|
|
new DialogInterface.OnClickListener() {
|
|
public void onClick(DialogInterface dialog, int whichButton) {
|
|
// ((FragmentAlertDialog)getActivity()).doPositiveClick();
|
|
player.setAllowsSnapshots(true);
|
|
Toast.makeText(getContext(), "Thanks!", Toast.LENGTH_LONG).show();
|
|
}
|
|
}
|
|
)
|
|
.setNeutralButton("See website",
|
|
new DialogInterface.OnClickListener() {
|
|
public void onClick(DialogInterface dialog, int whichButton) {
|
|
// Set nothing, load website (triggers thing the next time
|
|
Intent i = new Intent(Intent.ACTION_VIEW);
|
|
i.setData(Uri.parse("https://emotionhero.com/faces"));
|
|
startActivity(i);
|
|
}
|
|
}
|
|
)
|
|
.setNegativeButton("Nope",
|
|
new DialogInterface.OnClickListener() {
|
|
public void onClick(DialogInterface dialog, int whichButton) {
|
|
// ((FragmentAlertDialog)getActivity()).doNegativeClick();
|
|
player.setAllowsSnapshots(false);
|
|
Toast.makeText(getContext(), "Don't worry, we get it!", Toast.LENGTH_LONG).show();
|
|
}
|
|
}
|
|
)
|
|
.create();
|
|
}
|
|
|
|
|
|
}
|