use of com.afollestad.materialdialogs.MaterialDialog in project AnimeTaste by daimajia.
the class ShareHelper method showUp.
public static void showUp(final Context context, final Animation animation) {
View v = LayoutInflater.from(context).inflate(R.layout.layout_share, null, false);
final MaterialDialog dialog = new MaterialDialog.Builder(context).customView(v, false).build();
dialog.show();
ShareSDK.initSDK(context);
ShareButton weibo = (ShareButton) v.findViewById(R.id.action_share_weibo);
ShareButton wechat = (ShareButton) v.findViewById(R.id.action_share_wechat);
ShareButton wechatTimeline = (ShareButton) v.findViewById(R.id.action_share_wechat_timeline);
ShareButton qq = (ShareButton) v.findViewById(R.id.action_share_qq);
ShareButton link = (ShareButton) v.findViewById(R.id.action_share_link);
ShareButton qzone = (ShareButton) v.findViewById(R.id.action_share_qzone);
TextView cancel = (TextView) v.findViewById(R.id.cancel);
final Handler showMsg = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
Toast.makeText(context, msg.obj.toString(), Toast.LENGTH_SHORT).show();
return true;
}
});
final PlatformActionListener platformActionListener = new PlatformActionListener() {
@Override
public void onComplete(Platform platform, int i, HashMap<String, Object> stringObjectHashMap) {
Message msg = Message.obtain(showMsg);
msg.obj = "(๑•̀ㅂ•́)و分享成功!Ye";
msg.sendToTarget();
}
@Override
public void onError(Platform platform, int i, Throwable throwable) {
Log.e("Error", throwable.getMessage());
Message msg = Message.obtain(showMsg);
msg.obj = "(⊙﹏⊙) 好像出了错误";
msg.sendToTarget();
}
@Override
public void onCancel(Platform platform, int i) {
Message msg = Message.obtain(showMsg);
msg.obj = "o(TヘTo) 取消了耶...";
msg.sendToTarget();
}
};
weibo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SinaWeibo.ShareParams sp = new SinaWeibo.ShareParams();
Platform pf = ShareSDK.getPlatform(context, SinaWeibo.NAME);
String toSend = "「" + animation.Name + "」 " + animation.OriginVideoUrl + " " + animation.Brief;
toSend = toSend.substring(0, 140);
sp.setText(toSend);
sp.setUrl(animation.OriginVideoUrl);
sp.setImageUrl(animation.DetailPic);
pf.setPlatformActionListener(platformActionListener);
pf.share(sp);
shareAction(context, dialog);
}
});
wechat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, Wechat.NAME);
Wechat.ShareParams sp = new Wechat.ShareParams();
sp.setTitle(animation.Name);
sp.setText(animation.Brief);
sp.setImageUrl(animation.HomePic);
sp.setUrl(animation.getShareUrl());
sp.setShareType(Platform.SHARE_WEBPAGE);
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
wechatTimeline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, WechatMoments.NAME);
WechatMoments.ShareParams sp = new WechatMoments.ShareParams();
sp.title = animation.Name;
sp.text = animation.Brief;
sp.imageUrl = animation.HomePic;
sp.url = animation.getShareUrl();
sp.shareType = Platform.SHARE_WEBPAGE;
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
qq.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, QQ.NAME);
QQ.ShareParams sp = new QQ.ShareParams();
sp.setTitle(animation.Name);
sp.setText(animation.Brief);
sp.setImageUrl(animation.HomePic);
sp.setTitleUrl(animation.getShareUrl());
sp.setShareType(QQ.SHARE_WEBPAGE);
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
qzone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, QZone.NAME);
QZone.ShareParams sp = new QZone.ShareParams();
sp.setTitle(animation.Name);
sp.setText(animation.Brief);
sp.setImageUrl(animation.HomePic);
sp.setTitleUrl(animation.getShareUrl());
sp.setShareType(QZone.SHARE_WEBPAGE);
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
link.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(animation.getShareUrl());
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("data", animation.getShareUrl());
clipboard.setPrimaryClip(clip);
}
dialog.dismiss();
Toast.makeText(context, "复制完成,快快分享给你的好朋友们!", Toast.LENGTH_LONG).show();
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
}
use of com.afollestad.materialdialogs.MaterialDialog in project XposedInstaller by rovo89.
the class DownloadsUtil method showDownloadDialog.
private static void showDownloadDialog(final Builder b, final long id) {
final Context context = b.mContext;
final DownloadDialog dialog = new DownloadDialog(new MaterialDialog.Builder(context).title(b.mTitle).content(R.string.download_view_waiting).progress(false, 0, true).progressNumberFormat(context.getString(R.string.download_progress)).canceledOnTouchOutside(false).negativeText(R.string.download_view_cancel).onNegative(new SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.cancel();
}
}).cancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
removeById(context, id);
}
}));
dialog.setShowProcess(false);
dialog.show();
new Thread("DownloadDialog") {
@Override
public void run() {
while (true) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
return;
}
final DownloadInfo info = getById(context, id);
if (info == null) {
dialog.cancel();
return;
} else if (info.status == DownloadManager.STATUS_FAILED) {
dialog.cancel();
XposedApp.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, context.getString(R.string.download_view_failed, info.reason), Toast.LENGTH_LONG).show();
}
});
return;
} else if (info.status == DownloadManager.STATUS_SUCCESSFUL) {
dialog.dismiss();
// Hack to reset stat information.
new File(info.localFilename).setExecutable(false);
if (b.mCallback != null) {
b.mCallback.onDownloadFinished(context, info);
}
return;
}
XposedApp.runOnUiThread(new Runnable() {
@Override
public void run() {
if (info.totalSize <= 0 || info.status != DownloadManager.STATUS_RUNNING) {
dialog.setContent(R.string.download_view_waiting);
dialog.setShowProcess(false);
} else {
dialog.setContent(R.string.download_running);
dialog.setProgress(info.bytesDownloaded / 1024);
dialog.setMaxProgress(info.totalSize / 1024);
dialog.setShowProcess(true);
}
}
});
}
}
}.start();
}
use of com.afollestad.materialdialogs.MaterialDialog in project XposedInstaller by rovo89.
the class StatusInstallerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.status_installer, container, false);
// Available ZIPs
final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swiperefreshlayout);
refreshLayout.setColorSchemeColors(getResources().getColor(R.color.colorPrimary));
ONLINE_ZIP_LOADER.setSwipeRefreshLayout(refreshLayout);
ONLINE_ZIP_LOADER.addListener(mOnlineZipListener);
ONLINE_ZIP_LOADER.triggerFirstLoadIfNecessary();
LOCAL_ZIP_LOADER.addListener(mLocalZipListener);
LOCAL_ZIP_LOADER.triggerFirstLoadIfNecessary();
refreshZipViews(v);
// Disable switch
final SwitchCompat disableSwitch = (SwitchCompat) v.findViewById(R.id.disableSwitch);
disableSwitch.setChecked(!DISABLE_FILE.exists());
disableSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (DISABLE_FILE.exists()) {
DISABLE_FILE.delete();
Snackbar.make(disableSwitch, R.string.xposed_on_next_reboot, Snackbar.LENGTH_LONG).show();
} else {
try {
DISABLE_FILE.createNewFile();
Snackbar.make(disableSwitch, R.string.xposed_off_next_reboot, Snackbar.LENGTH_LONG).show();
} catch (IOException e) {
Log.e(XposedApp.TAG, "Could not create " + DISABLE_FILE, e);
}
}
}
});
// Device info
TextView androidSdk = (TextView) v.findViewById(R.id.android_version);
TextView manufacturer = (TextView) v.findViewById(R.id.ic_manufacturer);
TextView cpu = (TextView) v.findViewById(R.id.cpu);
androidSdk.setText(getString(R.string.android_sdk, Build.VERSION.RELEASE, getAndroidVersion(), Build.VERSION.SDK_INT));
manufacturer.setText(getUIFramework());
cpu.setText(FrameworkZips.ARCH);
// Known issues
refreshKnownIssue(v);
// Display warning dialog to new users
if (!XposedApp.getPreferences().getBoolean("hide_install_warning", false)) {
new MaterialDialog.Builder(getActivity()).title(R.string.install_warning_title).content(R.string.install_warning).positiveText(android.R.string.ok).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (dialog.isPromptCheckBoxChecked()) {
XposedApp.getPreferences().edit().putBoolean("hide_install_warning", true).apply();
}
}
}).checkBoxPromptRes(R.string.dont_show_again, false, null).cancelable(false).show();
}
return v;
}
use of com.afollestad.materialdialogs.MaterialDialog in project material-dialogs by afollestad.
the class ChangelogDialog method onCreateDialog.
@SuppressLint("InflateParams")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View customView;
try {
customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
} catch (InflateException e) {
throw new IllegalStateException("This device does not support Web Views.");
}
MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).theme(getArguments().getBoolean("dark_theme") ? Theme.DARK : Theme.LIGHT).title(R.string.changelog).customView(customView, false).positiveText(android.R.string.ok).build();
final WebView webView = (WebView) customView.findViewById(R.id.webview);
try {
// Load from changelog.html in the assets folder
StringBuilder buf = new StringBuilder();
InputStream json = getActivity().getAssets().open("changelog.html");
BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
String str;
while ((str = in.readLine()) != null) {
buf.append(str);
}
in.close();
// Inject color values for WebView body background and links
final int accentColor = getArguments().getInt("accent_color");
webView.loadData(buf.toString().replace("{style-placeholder}", getArguments().getBoolean("dark_theme") ? "body { background-color: #444444; color: #fff; }" : "body { background-color: #fff; color: #000; }").replace("{link-color}", colorToHex(shiftColor(accentColor, true))).replace("{link-color-active}", colorToHex(accentColor)), "text/html", "UTF-8");
} catch (Throwable e) {
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
}
return dialog;
}
use of com.afollestad.materialdialogs.MaterialDialog in project material-dialogs by afollestad.
the class MainActivity method showCustomView.
@SuppressWarnings("ResourceAsColor")
@OnClick(R.id.customView)
public void showCustomView() {
MaterialDialog dialog = new MaterialDialog.Builder(this).title(R.string.googleWifi).customView(R.layout.dialog_customview, true).positiveText(R.string.connect).negativeText(android.R.string.cancel).onPositive((dialog1, which) -> showToast("Password: " + passwordInput.getText().toString())).build();
positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
//noinspection ConstantConditions
passwordInput = (EditText) dialog.getCustomView().findViewById(R.id.password);
passwordInput.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) {
positiveAction.setEnabled(s.toString().trim().length() > 0);
}
@Override
public void afterTextChanged(Editable s) {
}
});
// Toggling the show password CheckBox will mask or unmask the password input EditText
CheckBox checkbox = (CheckBox) dialog.getCustomView().findViewById(R.id.showPassword);
checkbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
passwordInput.setInputType(!isChecked ? InputType.TYPE_TEXT_VARIATION_PASSWORD : InputType.TYPE_CLASS_TEXT);
passwordInput.setTransformationMethod(!isChecked ? PasswordTransformationMethod.getInstance() : null);
});
int widgetColor = ThemeSingleton.get().widgetColor;
MDTintHelper.setTint(checkbox, widgetColor == 0 ? ContextCompat.getColor(this, R.color.accent) : widgetColor);
MDTintHelper.setTint(passwordInput, widgetColor == 0 ? ContextCompat.getColor(this, R.color.accent) : widgetColor);
dialog.show();
// disabled by default
positiveAction.setEnabled(false);
}
Aggregations