[Modify]修改綁定和邀請粉絲

This commit is contained in:
wushaocheng
2022-12-02 15:02:41 +08:00
parent a8924d73c4
commit 31d34f5df0
5 changed files with 35 additions and 414 deletions

View File

@@ -112,7 +112,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
addRoomPKAction(optAdapter);
addSingleRoomPKAction(optAdapter);
addSendBroadcastAction(optAdapter);
addInviteFansOptAdapter();
// addInviteFansOptAdapter();
addVipSendBroadcastAction(optAdapter);
addRedPacketAction(optAdapter);
addRoomSettingAction(optAdapter);

View File

@@ -1,336 +0,0 @@
package com.yizhuan.erban.ui.gift.util;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashSet;
public class FileUtil {
private static String path="";
static{
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
path= Environment.getExternalStorageDirectory()+"/QQ";
}else{
path= Environment.getDataDirectory().getAbsolutePath()+"/QQ";
}
}
public static String getRecentChatPath(){
File file=new File(path+"/RecentChat/");
if(!file.exists()){
file.mkdirs();
}
return path+"/RecentChat/";
}
public static String getWaterPhotoPath(){
File file=new File(path+"/WaterPhoto/");
if(!file.exists()){
file.mkdirs();
}
return path+"/WaterPhoto/";
}
////////////////////////////////////////////////////////////
private static String ANDROID_SECURE = "/mnt/sdcard/.android_secure";
private static final String LOG_TAG = "Util";
public static boolean isSDCardReady() {
return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
}
public static String makePath(String path1, String path2) {
if (path1.endsWith(File.separator))
return path1 + path2;
return path1 + File.separator + path2;
}
public static String getSdDirectory() {
return Environment.getExternalStorageDirectory().getPath();
}
public static boolean isNormalFile(String fullName) {
return !fullName.equals(ANDROID_SECURE);
}
/*
* 采用了新的办法获取APK图标之前的失败是因为android中存在的一个BUG,通过
* appInfo.publicSourceDir = apkPath;来修正这个问题,详情参见:
* http://code.google.com/p/android/issues/detail?id=9151
*/
public static Drawable getApkIcon(Context context, String apkPath) {
PackageManager pm = context.getPackageManager();
PackageInfo info = pm.getPackageArchiveInfo(apkPath,
PackageManager.GET_ACTIVITIES);
if (info != null) {
ApplicationInfo appInfo = info.applicationInfo;
appInfo.sourceDir = apkPath;
appInfo.publicSourceDir = apkPath;
try {
return appInfo.loadIcon(pm);
} catch (OutOfMemoryError e) {
Log.e(LOG_TAG, e.toString());
}
}
return null;
}
public static String getExtFromFilename(String filename) {
int dotPosition = filename.lastIndexOf('.');
if (dotPosition != -1) {
return filename.substring(dotPosition + 1, filename.length());
}
return "";
}
public static String getNameFromFilename(String filename) {
int dotPosition = filename.lastIndexOf('.');
if (dotPosition != -1) {
return filename.substring(0, dotPosition);
}
return "";
}
public static String getPathFromFilepath(String filepath) {
int pos = filepath.lastIndexOf('/');
if (pos != -1) {
return filepath.substring(0, pos);
}
return "";
}
public static String getNameFromFilepath(String filepath) {
int pos = filepath.lastIndexOf('/');
if (pos != -1) {
return filepath.substring(pos + 1);
}
return "";
}
// return new file path if successful, or return null
public static String copyFile(String src, String dest) {
File file = new File(src);
if (!file.exists() || file.isDirectory()) {
Log.v(LOG_TAG, "copyFile: file not checkExist or is directory, " + src);
return null;
}
FileInputStream fi = null;
FileOutputStream fo = null;
try {
fi = new FileInputStream(file);
File destPlace = new File(dest);
if (!destPlace.exists()) {
if (!destPlace.mkdirs())
return null;
}
String destPath = FileUtil.makePath(dest, file.getName());
File destFile = new File(destPath);
int i = 1;
while (destFile.exists()) {
String destName = FileUtil.getNameFromFilename(file.getName()) + " " + i++ + "."
+ FileUtil.getExtFromFilename(file.getName());
destPath = FileUtil.makePath(dest, destName);
destFile = new File(destPath);
}
if (!destFile.createNewFile())
return null;
fo = new FileOutputStream(destFile);
int count = 102400;
byte[] buffer = new byte[count];
int read = 0;
while ((read = fi.read(buffer, 0, count)) != -1) {
fo.write(buffer, 0, read);
}
// TODO: set access privilege
return destPath;
} catch (FileNotFoundException e) {
Log.e(LOG_TAG, "copyFile: file not found, " + src);
e.printStackTrace();
} catch (IOException e) {
Log.e(LOG_TAG, "copyFile: " + e.toString());
} finally {
try {
if (fi != null)
fi.close();
if (fo != null)
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
// does not include sd card folder
private static String[] SysFileDirs = new String[] {
"miren_browser/imagecaches"
};
/* public static ArrayList<FavoriteItem> getDefaultFavorites(Context context) {
ArrayList<FavoriteItem> list = new ArrayList<FavoriteItem>();
list.add(new FavoriteItem(context.getString(R.string.favorite_photo), makePath(getSdDirectory(), "DCIM/Camera")));
list.add(new FavoriteItem(context.getString(R.string.favorite_sdcard), getSdDirectory()));
//list.add(new FavoriteItem(context.getString(R.string.favorite_root), getSdDirectory()));
list.add(new FavoriteItem(context.getString(R.string.favorite_screen_cap), makePath(getSdDirectory(), "MIUI/screen_cap")));
list.add(new FavoriteItem(context.getString(R.string.favorite_ringtone), makePath(getSdDirectory(), "MIUI/ringtone")));
return list;
}*/
public static boolean setText(View view, int id, String text) {
TextView textView = (TextView) view.findViewById(id);
if (textView == null)
return false;
textView.setText(text);
return true;
}
public static boolean setText(View view, int id, int text) {
TextView textView = (TextView) view.findViewById(id);
if (textView == null)
return false;
textView.setText(text);
return true;
}
// comma separated number
public static String convertNumber(long number) {
return String.format("%,d", number);
}
// storage, G M K B
public static String convertStorage(long size) {
long kb = 1024;
long mb = kb * 1024;
long gb = mb * 1024;
if (size >= gb) {
return String.format("%.1f GB", (float) size / gb);
} else if (size >= mb) {
float f = (float) size / mb;
return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
} else if (size >= kb) {
float f = (float) size / kb;
return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
} else
return String.format("%d B", size);
}
public static class SDCardInfo {
public long total;
public long free;
}
public static SDCardInfo getSDCardInfo() {
String sDcString = Environment.getExternalStorageState();
if (sDcString.equals(Environment.MEDIA_MOUNTED)) {
File pathFile = Environment.getExternalStorageDirectory();
try {
android.os.StatFs statfs = new android.os.StatFs(pathFile.getPath());
// 获取SDCard上BLOCK总数
long nTotalBlocks = statfs.getBlockCount();
// 获取SDCard上每个block的SIZE
long nBlocSize = statfs.getBlockSize();
// 获取可供程序使用的Block的数量
long nAvailaBlock = statfs.getAvailableBlocks();
// 获取剩下的所有Block的数量(包括预留的一般程序无法使用的块)
long nFreeBlock = statfs.getFreeBlocks();
SDCardInfo info = new SDCardInfo();
// 计算SDCard 总容量大小MB
info.total = nTotalBlocks * nBlocSize;
// 计算 SDCard 剩余大小MB
info.free = nAvailaBlock * nBlocSize;
return info;
} catch (IllegalArgumentException e) {
Log.e(LOG_TAG, e.toString());
}
}
return null;
}
/* public static void showNotification(Context context, Intent intent, String title, String body, int drawableId) {
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(drawableId, body, System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND;
if (intent == null) {
// FIXEME: category tab is disabled
intent = new Intent(context, FileViewActivity.class);
}
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
notification.setLatestEventInfo(context, title, body, contentIntent);
manager.notify(drawableId, notification);
}*/
public static String formatDateString(Context context, long time) {
DateFormat dateFormat = android.text.format.DateFormat
.getDateFormat(context);
DateFormat timeFormat = android.text.format.DateFormat
.getTimeFormat(context);
Date date = new Date(time);
return dateFormat.format(date) + " " + timeFormat.format(date);
}
/*public static void updateActionModeTitle(ActionMode mode, Context context, int selectedNum) {
if (mode != null) {
mode.setTitle(context.getString(R.string.multi_select_title,selectedNum));
if(selectedNum == 0){
mode.finish();
}
}
}
*/
public static HashSet<String> sDocMimeTypesSet = new HashSet<String>() {
{
add("text/plain");
add("text/plain");
add("application/pdf");
add("application/msword");
add("application/vnd.ms-excel");
add("application/vnd.ms-excel");
}
};
public static String sZipFileMimeType = "application/zip";
public static int CATEGORY_TAB_INDEX = 0;
public static int SDCARD_TAB_INDEX = 1;
}

View File

@@ -86,8 +86,10 @@ public class SettingActivity extends BaseActivity implements View.OnClickListene
case R.id.rly_bind_phone:
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
if(userInfo != null && userInfo.isBindPhone()){
settingBinding.tvBindPhone.setText(getString(R.string.text_modify_bind_phone));
ShowBindPhoneActivity.start(context);
}else {
settingBinding.tvBindPhone.setText(getString(R.string.text_bind_phone));
BindPhoneActivity.start(this);
}
break;

View File

@@ -11,7 +11,6 @@ import android.text.TextWatcher
import android.view.View
import androidx.core.content.ContextCompat
import com.netease.nim.uikit.StatusBarUtil
import com.trello.rxlifecycle3.android.ActivityEvent
import com.yizhuan.erban.R
import com.yizhuan.erban.base.BaseViewBindingActivity
import com.yizhuan.erban.databinding.ActivityVerifyPhoneBinding
@@ -20,8 +19,6 @@ import com.yizhuan.erban.ui.login.BindPhoneActivity
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.code.CodeType
import com.yizhuan.xchat_android_core.pay.PayModel
import com.yizhuan.xchat_android_core.user.UserModel
import com.yizhuan.xchat_android_core.user.bean.UserInfo
import com.yizhuan.xchat_android_core.utils.net.BeanObserver
import com.yizhuan.xchat_android_library.utils.ResUtil
@@ -32,8 +29,6 @@ class VerifyPhoneActivity : BaseViewBindingActivity<ActivityVerifyPhoneBinding>(
private var cdt: CountDownTimer? = null
private var type = CodeType.UNBIND_PHONE
private var isVerify = false
companion object {
const val REQUEST_CHECK_VALID_PHONE = 1001
@@ -122,81 +117,40 @@ class VerifyPhoneActivity : BaseViewBindingActivity<ActivityVerifyPhoneBinding>(
}
private fun clickNextButton() {
if (isVerify) {
dialogManager.showProgressDialog(
this,
ResUtil.getString(R.string.ui_login_bindcodeactivity_02)
)
AuthModel.get().bindPhone(
binding.tvAreaCode.text.toString().substring(1),
binding.tvAreaCode.text.toString()
.substring(1) + binding.etAccount.text.toString(),
binding.etCode.text.toString()
)
.compose(bindUntilEvent(ActivityEvent.DESTROY))
.doOnSuccess { s: String? ->
toast(ResUtil.getString(R.string.ui_login_bindcodeactivity_03))
setResult(RESULT_OK)
dialogManager.showProgressDialog(
this,
ResUtil.getString(R.string.ui_setting_verifyphoneactivity_08)
)
PayModel.get().verifyCode(
binding.tvAreaCode.text.toString().substring(1),
binding.tvAreaCode.text.toString()
.substring(1) + binding.etAccount.text.toString(),
binding.etCode.text.toString(),
)
.compose(bindToLifecycle())
.subscribe(object : BeanObserver<String?>() {
override fun onErrorMsg(error: String) {
dialogManager.dismissDialog()
toast(error)
}
.doOnError { throwable: Throwable ->
toast(
throwable.message
)
}
.flatMap { s: String? ->
UserModel.get().updateCurrentUserInfo()
}
.doOnSuccess { s: UserInfo? ->
setResult(RESULT_OK)
finish()
}
.doFinally { dialogManager.dismissDialog() }
.subscribe()
} else {
dialogManager.showProgressDialog(
this,
ResUtil.getString(R.string.ui_setting_verifyphoneactivity_08)
)
PayModel.get().verifyCode(
binding.tvAreaCode.text.toString().substring(1),
binding.tvAreaCode.text.toString()
.substring(1) + binding.etAccount.text.toString(),
binding.etCode.text.toString(),
)
.compose(bindToLifecycle())
.subscribe(object : BeanObserver<String?>() {
override fun onErrorMsg(error: String) {
dialogManager.dismissDialog()
toast(error)
}
override fun onSuccess(s: String) {
dialogManager.dismissDialog()
type = CodeType.BIND_PHONE
if (resetPwd) {
ModifyPwdActivity.start(
this@VerifyPhoneActivity,
ModifyPwdActivity.RESET_PAY_PWD
)
finish()
} else if (isForgetPwd) {
setResult(RESULT_OK)
finish()
} else {
showModifyView()
}
override fun onSuccess(s: String) {
dialogManager.dismissDialog()
type = CodeType.BIND_PHONE
if (resetPwd) {
ModifyPwdActivity.start(
this@VerifyPhoneActivity,
ModifyPwdActivity.RESET_PAY_PWD
)
finish()
} else if (isForgetPwd) {
setResult(RESULT_OK)
finish()
} else {
BindPhoneActivity.start(context)
}
})
}
}
private fun showModifyView() {
isVerify = true
initWhiteTitleBar(ResUtil.getString(R.string.text_bind_phone))
binding.etAccount.setText("")
binding.etCode.setText("")
resetBtn()
binding.btnNext.text = ResUtil.getString(R.string.ui_setting_verifyphoneactivity_011)
}
})
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

View File

@@ -5004,5 +5004,6 @@
<string name="login_input_code">輸入驗證碼</string>
<string name="bound_auth_code_is_empty">授权號不能為空</string>
<string name="only_can_see_three_month_data">只能查看前3個月的結算統計</string>
<string name="text_modify_bind_phone">更換綁定</string>
</resources>