use of com.auth0.sharelock.Secret in project sharelock-android by auth0.
the class LinkFragment method onViewCreated.
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final EventBus bus = this.bus;
TextView secretText = (TextView) view.findViewById(R.id.link_secret_text);
secretText.setText(secret.getSecret());
ShareEditText shareEditText = (ShareEditText) view.findViewById(R.id.link_share_list);
shareEditText.setFocusable(false);
shareEditText.allowDuplicates(false);
for (String viewer : secret.getAllowedViewers()) {
shareEditText.addObject(viewer);
}
linkText = (TextView) view.findViewById(R.id.link_text);
progressBar = (ProgressBar) view.findViewById(R.id.link_progress);
retryButton = (Button) view.findViewById(R.id.link_retry_button);
shareButton = (ImageButton) view.findViewById(R.id.link_share_button);
newButton = (ImageButton) view.findViewById(R.id.link_new_button);
buttons = (ViewGroup) view.findViewById(R.id.link_buttons);
retryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bus.post(new RequestLinkEvent(secret));
}
});
shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, link.toString());
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_link_chooser_title)));
}
});
newButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.new_link_prompt_title).setMessage(R.string.new_link_prompt_message).setCancelable(true).setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
bus.post(new RequestNewSecretEvent());
}
}).setNegativeButton(R.string.cancel_button, null).create();
dialog.show();
}
});
ImageView craftedBy = (ImageView) view.findViewById(R.id.crafted_by);
craftedBy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(getString(R.string.crafted_by_url)));
startActivity(intent);
}
});
}
use of com.auth0.sharelock.Secret in project sharelock-android by auth0.
the class SecretInputFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
secretField = (EditText) view.findViewById(R.id.secret_input);
nextButton = (Button) view.findViewById(R.id.next_button);
secretField.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
nextButton.setVisibility(s.length() > 0 ? View.VISIBLE : View.INVISIBLE);
SnackbarManager.dismiss();
}
});
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Secret secret = new Secret(secretField.getText().toString());
bus.post(new NewSecretEvent(secret));
}
});
ImageView craftedBy = (ImageView) view.findViewById(R.id.crafted_by);
craftedBy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(getString(R.string.crafted_by_url)));
startActivity(intent);
}
});
final Bundle arguments = getArguments();
if (arguments != null) {
secretField.setText(arguments.getString(SECRET_INPUT_FRAGMENT_SECRET_ARGUMENT));
}
}
use of com.auth0.sharelock.Secret in project sharelock-android by auth0.
the class ComposeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_compose);
Toolbar toolbar = (Toolbar) findViewById(R.id.sharelock_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
bus = EventBus.getDefault();
handler = new Handler();
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
String sharedText = null;
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
}
}
if (savedInstanceState == null) {
final SecretInputFragment fragment = new SecretInputFragment();
if (sharedText != null) {
Bundle arguments = new Bundle();
arguments.putString(SecretInputFragment.SECRET_INPUT_FRAGMENT_SECRET_ARGUMENT, sharedText);
fragment.setArguments(arguments);
}
getSupportFragmentManager().beginTransaction().replace(R.id.sharelock_compose_container, fragment).commit();
} else {
secret = savedInstanceState.getParcelable(COMPOSE_CREATED_SECRET);
}
}
use of com.auth0.sharelock.Secret in project sharelock-android by auth0.
the class ComposeActivity method onEvent.
public void onEvent(RequestLinkEvent event) {
final Secret secret = event.getSecret();
final EventBus bus = this.bus;
SharedPreferences preferences = getSharedPreferences(getPackageName(), MODE_PRIVATE);
client = new LinkAPIClient(preferences.getString(LinkAPIClient.SHARELOCK_ENDPOINT_KEY, LinkAPIClient.DEFAULT_URL));
client.generateLinkForSecret(secret, this, new LinkAPIClient.LinkCallback() {
@Override
public void onSuccess(final Uri link) {
Log.d(TAG, "Obtained link path " + link);
handler.postDelayed(new Runnable() {
@Override
public void run() {
bus.postSticky(new NewLinkEvent(link));
final ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
final ClipData clipData = ClipData.newRawUri("sharelocked-link", link);
clipboardManager.setPrimaryClip(clipData);
Snackbar snackbar = Snackbar.with(ComposeActivity.this).text(R.string.link_in_clipboard_message).duration(Snackbar.SnackbarDuration.LENGTH_SHORT);
SnackbarManager.show(snackbar);
}
}, DELAY_MILLIS);
}
@Override
public void onError(Throwable reason) {
Log.e(TAG, "Failed to generate link", reason);
bus.post(new SharelockAPIErrorEvent());
AlertDialog dialog = new AlertDialog.Builder(ComposeActivity.this).setTitle(R.string.link_generation_failed_title).setMessage(R.string.link_generation_failed).setCancelable(true).setPositiveButton(R.string.retry_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
bus.post(new RequestLinkEvent(secret));
}
}).setNegativeButton(R.string.cancel_button, null).create();
dialog.show();
}
});
}
use of com.auth0.sharelock.Secret in project sharelock-android by auth0.
the class ComposeActivity method onEvent.
public void onEvent(NewSecretEvent event) {
secret = event.getSecret();
final ShareFragment fragment = new ShareFragment();
getSupportFragmentManager().beginTransaction().setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right, android.R.anim.slide_in_left, android.R.anim.slide_out_right).replace(R.id.sharelock_compose_container, fragment).addToBackStack("Share Step").commit();
}
Aggregations