Implement the functionality of the 'share' button of the ShareBoardDialogFragment, which is to share a board's code with other apps.
This commit is contained in:
parent
5a098d8ac5
commit
9c9a0c1221
2 changed files with 17 additions and 7 deletions
|
@ -296,12 +296,12 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
|
||||
case R.id.menu_share:
|
||||
ShareBoardDialog shareDialog = new ShareBoardDialog();
|
||||
shareDialog.setDisplayCode(gameController.getFieldAsString());
|
||||
shareDialog.setDisplayCode("sudoku://" + gameController.getCodeOfField());
|
||||
shareDialog.setCopyClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// remember to include alternate code for older android versions
|
||||
String codeForClipboard = gameController.getFieldAsString().toString();
|
||||
String codeForClipboard = "sudoku://" + gameController.getCodeOfField();
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
|
||||
if (clipboard != null) {
|
||||
|
@ -310,7 +310,9 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
Toast.makeText(GameActivity.this, R.string.copy_code_confirmation_toast,
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
//
|
||||
//remember to replace hardcoded string
|
||||
Toast.makeText(GameActivity.this, "Cannot access clipboard",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -465,8 +467,14 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onShareDialogPositiveClick() {
|
||||
gameController.resetLevel();
|
||||
public void onShareDialogPositiveClick(String input) {
|
||||
Intent sendBoardIntent = new Intent();
|
||||
sendBoardIntent.setAction(Intent.ACTION_SEND);
|
||||
sendBoardIntent.putExtra(Intent.EXTRA_TEXT, input);
|
||||
sendBoardIntent.setType("text/plain");
|
||||
|
||||
Intent shareBoardIntent = Intent.createChooser(sendBoardIntent, null);
|
||||
startActivity(shareBoardIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -520,7 +528,7 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
builder.setPositiveButton(R.string.share_confirmation_confirm, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
for(IShareDialogFragmentListener l : listeners) {
|
||||
l.onShareDialogPositiveClick();
|
||||
l.onShareDialogPositiveClick(binding.ver3DisplaySudokuTextView.getText().toString());
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package org.secuso.privacyfriendlysudoku.ui.listener;
|
||||
|
||||
import org.secuso.privacyfriendlysudoku.ui.view.databinding.DialogFragmentShareBoardBinding;
|
||||
|
||||
/**
|
||||
* Created by Chris on 19.01.2016.
|
||||
*/
|
||||
public interface IShareDialogFragmentListener {
|
||||
public void onShareDialogPositiveClick();
|
||||
public void onShareDialogPositiveClick(String input);
|
||||
public void onDialogNegativeClick();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue