better cookie dialog
This commit is contained in:
parent
2d0437a834
commit
8d5df9c9eb
|
@ -87,15 +87,16 @@ public class HSActionsDialog extends DialogFragment {
|
|||
showAuth.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
String auth_cookie_value = arguments.getString("auth_cookie_value");
|
||||
|
||||
if (arguments.getInt("auth_cookie") == 1) {
|
||||
if (auth_cookie_value == null || auth_cookie_value.length() < 1) {
|
||||
Toast.makeText(
|
||||
v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
|
||||
).show();
|
||||
} else {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(auth_cookie_value)
|
||||
.show();
|
||||
HSCookieDialog dialog = new HSCookieDialog();
|
||||
dialog.setArguments(arguments);
|
||||
dialog.show(getFragmentManager(), "HSCookieDialog");
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package org.torproject.android.ui.hiddenservices.dialogs;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.torproject.android.R;
|
||||
|
||||
public class HSCookieDialog extends DialogFragment {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final View dialog_view = getActivity().getLayoutInflater().inflate(R.layout.layout_hs_cookie, null);
|
||||
|
||||
final Bundle arguments = getArguments();
|
||||
final String auth_cookie_value = arguments.getString("auth_cookie_value");
|
||||
|
||||
final AlertDialog cookieDialog = new AlertDialog.Builder(getActivity())
|
||||
.setView(dialog_view)
|
||||
.create();
|
||||
|
||||
TextView cookie = (TextView) dialog_view.findViewById(R.id.hs_cookie);
|
||||
cookie.setText(auth_cookie_value);
|
||||
|
||||
Button clipboard = (Button) dialog_view.findViewById(R.id.hs_cookie_to_clipboard);
|
||||
clipboard.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Context mContext = v.getContext();
|
||||
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("cookie", auth_cookie_value);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(mContext, R.string.done, Toast.LENGTH_LONG).show();
|
||||
cookieDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
Button cancel = (Button) dialog_view.findViewById(R.id.hs_cookie_cancel);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
cookieDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return cookieDialog;
|
||||
}
|
||||
}
|
|
@ -47,6 +47,9 @@ public class HSDataDialog extends DialogFragment {
|
|||
|
||||
if (checkInput(serverName, localPort, onionPort)) {
|
||||
saveData(serverName, localPort, onionPort, authCookie);
|
||||
Toast.makeText(
|
||||
v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
|
||||
).show();
|
||||
serviceDataDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/hs_cookie"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp" />
|
||||
|
||||
<Button
|
||||
android:text="@string/copy_cookie_to_clipboard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/hs_cookie_to_clipboard" />
|
||||
|
||||
<Button
|
||||
android:text="@string/btn_cancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/hs_cookie_cancel" />
|
||||
</LinearLayout>
|
|
@ -364,6 +364,7 @@
|
|||
<string name="click_again_for_backup">Click again for backup</string>
|
||||
<string name="service_type">Service type</string>
|
||||
<string name="auth_cookie">Auth cookie</string>
|
||||
<string name="copy_cookie_to_clipboard">Copy cookie to clipboard</string>
|
||||
<string name="auth_cookie_was_not_configured">Auth cookie was not configured</string>
|
||||
<string name="please_restart_Orbot_to_enable_the_changes">Please restart Orbot to enable the changes</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue