修复没有登录后的播放问题

This commit is contained in:
muqing 2024-01-12 13:16:05 +08:00
parent 62f3634fe7
commit dfcb99848e
13 changed files with 228 additions and 214 deletions

View File

@ -18,7 +18,7 @@ android {
//noinspection OldTargetApi //noinspection OldTargetApi
targetSdk 31 targetSdk 31
versionCode 1 versionCode 1
versionName "1.9.0" versionName "1.9.1"
} }
compileOptions { compileOptions {

View File

@ -19,9 +19,8 @@ public class resource {
public static void recommend(List<XM> list) { public static void recommend(List<XM> list) {
try { try {
list.clear(); list.clear();
String hq;
JSONObject json; JSONObject json;
hq = wl.hq("/recommend/resource?cookie=" + wl.Cookie); String hq = wl.hq("/recommend/resource?cookie=" + wl.Cookie);
if (hq == null) { if (hq == null) {
hq = wj.dqwb(wj.gd_json); hq = wj.dqwb(wj.gd_json);
if (hq != null) { if (hq != null) {

View File

@ -5,6 +5,7 @@ import com.mpatric.mp3agic.Mp3File;
import com.muqingbfq.MP3; import com.muqingbfq.MP3;
import com.muqingbfq.bfq; import com.muqingbfq.bfq;
import com.muqingbfq.fragment.Media; import com.muqingbfq.fragment.Media;
import com.muqingbfq.home;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj; import com.muqingbfq.mq.wj;
import com.muqingbfq.mq.wl; import com.muqingbfq.mq.wl;
@ -54,6 +55,11 @@ public class url extends Thread {
return null; return null;
} }
JSONObject json = new JSONObject(hq); JSONObject json = new JSONObject(hq);
if (json.getInt("code") == -460) {
String message = json.getString("message");
gj.xcts(home.appCompatActivity, message + "-可能需要登录网易云");
return null;
}
JSONArray data = json.getJSONArray("data"); JSONArray data = json.getJSONArray("data");
JSONObject jsonObject = data.getJSONObject(0); JSONObject jsonObject = data.getJSONObject(0);
String url = jsonObject.getString("url"); String url = jsonObject.getString("url");

View File

@ -19,13 +19,10 @@ import androidx.media.MediaBrowserServiceCompat;
import com.muqingbfq.api.url; import com.muqingbfq.api.url;
import com.muqingbfq.mq.BluetoothMusicController; import com.muqingbfq.mq.BluetoothMusicController;
import com.muqingbfq.mq.FloatingLyricsService;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random;
public class bfqkz extends MediaBrowserServiceCompat { public class bfqkz extends MediaBrowserServiceCompat {
public static MediaPlayer mt = new MediaPlayer(); public static MediaPlayer mt = new MediaPlayer();
@ -52,6 +49,10 @@ public class bfqkz extends MediaBrowserServiceCompat {
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
public static void mp3(String id) { public static void mp3(String id) {
try { try {
if (id == null) {
return;
}
if (TextUtils.isEmpty(id)) { if (TextUtils.isEmpty(id)) {
//针对错误进行相应的处理 //针对错误进行相应的处理
bfqkz.list.remove(bfqkz.xm); bfqkz.list.remove(bfqkz.xm);

View File

@ -2,14 +2,19 @@ package com.muqingbfq.fragment;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.view.GestureDetector;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -19,17 +24,20 @@ import com.muqingbfq.api.url;
import com.muqingbfq.bfq; import com.muqingbfq.bfq;
import com.muqingbfq.bfq_an; import com.muqingbfq.bfq_an;
import com.muqingbfq.bfqkz; import com.muqingbfq.bfqkz;
import com.muqingbfq.home; import com.muqingbfq.main;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj; import com.muqingbfq.mq.wj;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List; import java.util.List;
public class bfq_db extends Fragment { public class bfq_db extends Fragment implements GestureDetector.OnGestureListener {
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
public static View view; public static View view;
private GestureDetector gestureDetector;
@SuppressLint("ClickableViewAccessibility")
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -45,7 +53,7 @@ public class bfq_db extends Fragment {
bfqkz.xm = wj.getMP3FromFile(); bfqkz.xm = wj.getMP3FromFile();
if (bfqkz.xm != null) { if (bfqkz.xm != null) {
new Thread(){ new Thread() {
@Override @Override
public void run() { public void run() {
super.run(); super.run();
@ -67,7 +75,18 @@ public class bfq_db extends Fragment {
TextView name = view.findViewById(R.id.name); TextView name = view.findViewById(R.id.name);
view.findViewById(R.id.kg).setOnClickListener(new bfq_an.kz()); view.findViewById(R.id.kg).setOnClickListener(new bfq_an.kz());
view.findViewById(R.id.txb).setOnClickListener(view -> bflb_db.start(getContext())); view.findViewById(R.id.txb).setOnClickListener(view -> bflb_db.start(getContext()));
view.setOnClickListener(vw -> bfq.start(home.appCompatActivity)); // view.setOnClickListener(vw -> bfq.start(getContext()));
gestureDetector = new GestureDetector(getContext(), this);
view.setOnTouchListener((view, motionEvent) -> {
/* if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.bj));
return true;
}*/
return gestureDetector.onTouchEvent(motionEvent);
});
// 恢复列表数据 // 恢复列表数据
if (bfqkz.xm != null) { if (bfqkz.xm != null) {
name.setText(bfqkz.xm.name + "/" + bfqkz.xm.zz); name.setText(bfqkz.xm.name + "/" + bfqkz.xm.zz);
@ -99,4 +118,53 @@ public class bfq_db extends Fragment {
textView.setText(str); textView.setText(str);
} }
} }
@Override
public boolean onDown(@NonNull MotionEvent motionEvent) {
view.setBackgroundColor(Color.parseColor("#80F2ECF6"));
return true;
}
@Override
public void onShowPress(@NonNull MotionEvent motionEvent) {
}
@Override
public boolean onSingleTapUp(@NonNull MotionEvent motionEvent) {
bfq.start(getContext());
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
// view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
return true;
}
@Override
public boolean onScroll(@Nullable MotionEvent motionEvent, @NonNull MotionEvent motionEvent1,
float v, float v1) {
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
return false;
}
@Override
public void onLongPress(@NonNull MotionEvent motionEvent) {
}
@Override
public boolean onFling(@Nullable MotionEvent e1,
@NonNull MotionEvent e2, float v, float v1) {
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
float distance = e1.getX() - e2.getX();
float threshold = main.k / 2.0f;
// 判断手势方向并限制滑动距离
if (distance > threshold) {
// 向左滑动
// 在这里添加你的逻辑代码
bfq_an.xyq();
} else if (distance < -threshold) {
// 向右滑动
// 在这里添加你的逻辑代码
bfq_an.syq();
}
return true;
}
} }

View File

@ -8,7 +8,6 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;

View File

@ -19,19 +19,21 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.Gson;
import com.muqingbfq.R; import com.muqingbfq.R;
import com.muqingbfq.XM;
import com.muqingbfq.databinding.FragmentWdBinding; import com.muqingbfq.databinding.FragmentWdBinding;
import com.muqingbfq.login.user_editing;
import com.muqingbfq.login.user_logs; import com.muqingbfq.login.user_logs;
import com.muqingbfq.login.user_message;
import com.muqingbfq.main; import com.muqingbfq.main;
import com.muqingbfq.mq.EditViewDialog; import com.muqingbfq.mq.EditViewDialog;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj; import com.muqingbfq.mq.wj;
import com.muqingbfq.XM;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -57,19 +59,52 @@ public class wode extends Fragment {
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
binding = FragmentWdBinding.inflate(inflater, container, false); binding = FragmentWdBinding.inflate(inflater, container, false);
name = binding.text1; name = binding.text1;
jieshao = binding.text2; jieshao = binding.text2;
imageView = binding.imageView; imageView = binding.imageView;
binding.cardview.setOnClickListener(v -> { binding.cardview.setOnClickListener(v -> {
if (main.getToken() == null) {
startActivity(new Intent(getContext(), user_logs.class));
File file = new File(wj.filesdri, "user.mq");
// user_logs.USER.user;
if (file.exists()) {
String[] a = new String[]{"退出登录"};
new MaterialAlertDialogBuilder(getContext())
.setItems(a, (dialogInterface, i) -> {
file.delete();
new com.muqingbfq.login.user_message();
}).show();
} else { } else {
startActivity(new Intent(getContext(), user_editing.class)); startActivity(new Intent(getContext(), user_logs.class));
} }
/*
v.setEnabled(false);
new Thread() {
@Override
public void run() {
super.run();
String hq = wl.hq("/login/status?cookie=" + wl.Cookie);
if (hq != null) {
try {
JSONObject jsonObject = new JSONObject(hq);
JSONObject jsonObject1 = jsonObject.getJSONObject("data").getJSONObject("profile");
if (TextUtils.isEmpty(jsonObject1.toString())) {
} else {
main.handler.post(() -> {
});
}
} catch (JSONException e) {
gj.sc(e);
}
}
main.handler.post(() -> v.setEnabled(true));
}
}.start();*/
}); });
new user_message(); // new user_message();
// int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f); // int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f);
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 4) { GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 4) {
@Override @Override
@ -78,7 +113,6 @@ public class wode extends Fragment {
} }
}; };
binding.recyclerview1.setLayoutManager(gridLayoutManager); binding.recyclerview1.setLayoutManager(gridLayoutManager);
binding.recyclerview1.setFocusable(false); binding.recyclerview1.setFocusable(false);
binding.recyclerview1.setAdapter(new RecyclerView.Adapter<VH>() { binding.recyclerview1.setAdapter(new RecyclerView.Adapter<VH>() {
@NonNull @NonNull
@ -92,7 +126,7 @@ public class wode extends Fragment {
public void onBindViewHolder(@NonNull VH holder, int position) { public void onBindViewHolder(@NonNull VH holder, int position) {
String s = lista[position][1].toString(); String s = lista[position][1].toString();
holder.textView.setText(s); holder.textView.setText(s);
holder.imageView.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.text))); holder.imageView.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.text)));
Glide.with(getContext()) Glide.with(getContext())
.load(lista[position][0]) .load(lista[position][0])
.into(holder.imageView); .into(holder.imageView);
@ -124,7 +158,7 @@ public class wode extends Fragment {
} else { } else {
gj.ts(getContext(), "更换成功"); gj.ts(getContext(), "更换成功");
main.api = str; main.api = str;
wj.xrwb(wj.filesdri+"API.mq", main.api); wj.xrwb(wj.filesdri + "API.mq", main.api);
editViewDialog.dismiss(); editViewDialog.dismiss();
} }
}).show(); }).show();
@ -148,6 +182,7 @@ public class wode extends Fragment {
binding.recyclerview2.setFocusable(false); binding.recyclerview2.setFocusable(false);
binding.recyclerview2.setAdapter(new gd.baseadapter(getContext(), list, true)); binding.recyclerview2.setAdapter(new gd.baseadapter(getContext(), list, true));
sx(); sx();
denglu();
return binding.getRoot(); return binding.getRoot();
} }
@ -193,4 +228,17 @@ public class wode extends Fragment {
} }
}); });
} }
public void denglu() {
if (!wj.cz(wj.filesdri + "user.mq")) {
return;
}
String dqwb = wj.dqwb(wj.filesdri + "user.mq");
user_logs.USER user = new Gson().fromJson(dqwb, user_logs.USER.class);
setname(user.name);
setqianming(user.qianming);
Glide.with(getContext())
.load(user.picUrl)
.into(binding.imageView);
}
} }

View File

@ -5,17 +5,13 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.session.MediaSessionManager;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings; import android.os.Process;
import android.support.v4.media.MediaBrowserCompat; import android.support.v4.media.MediaBrowserCompat;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -29,7 +25,6 @@ import com.muqingbfq.databinding.ActivityHomeBinding;
import com.muqingbfq.fragment.bfq_db; import com.muqingbfq.fragment.bfq_db;
import com.muqingbfq.fragment.gd_adapter; import com.muqingbfq.fragment.gd_adapter;
import com.muqingbfq.fragment.wode; import com.muqingbfq.fragment.wode;
import com.muqingbfq.mq.FloatingLyricsService;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import java.util.ArrayList; import java.util.ArrayList;
@ -259,4 +254,15 @@ public class home extends AppCompatActivity {
gj.sc("onChildrenLoaded------"); gj.sc("onChildrenLoaded------");
} }
}; };
@Override
public void finish() {
super.finish();
// 断开连接并释放资源
if (mBrowser != null && mBrowser.isConnected()) {
mBrowser.disconnect();
}
int i = Process.myPid();
android.os.Process.killProcess(i);
}
} }

View File

@ -98,10 +98,8 @@ public class user_editing extends FragmentActivity {
public void run() { public void run() {
super.run(); super.run();
try { try {
user_message.string string = user_message.get(); // user_message.string string = user_message.get();
if (string == null) { /*
return;
}
main.handler.post(() -> { main.handler.post(() -> {
Glide.with(user_editing.this) Glide.with(user_editing.this)
.load(string.headIcon()) .load(string.headIcon())
@ -118,7 +116,7 @@ public class user_editing extends FragmentActivity {
gender = ""; gender = "";
} }
binding.autoComplete.setText(gender); binding.autoComplete.setText(gender);
}); });*/
} catch (Exception e) { } catch (Exception e) {
gj.sc(e); gj.sc(e);
} }
@ -151,7 +149,7 @@ public class user_editing extends FragmentActivity {
imageViewb.setOnClickListener(onClickListener); imageViewb.setOnClickListener(onClickListener);
binding.userEnd.setOnClickListener(view ->{ binding.userEnd.setOnClickListener(view ->{
finish(); finish();
main.settoken(null, null); // main.settoken(null, null);
com.muqingbfq.fragment.wode.setname("未登录"); com.muqingbfq.fragment.wode.setname("未登录");
com.muqingbfq.fragment.wode.setqianming(null); com.muqingbfq.fragment.wode.setqianming(null);
com.muqingbfq.fragment.wode.imageView.setImageResource(R.drawable.icon); com.muqingbfq.fragment.wode.imageView.setImageResource(R.drawable.icon);
@ -211,7 +209,7 @@ public class user_editing extends FragmentActivity {
break; break;
} }
} else if (code == 0) { } else if (code == 0) {
new user_message(); // new user_message();
} }
gj.xcts(user_editing.this, jsonObject.getString("message")); gj.xcts(user_editing.this, jsonObject.getString("message"));
} catch (JSONException e) { } catch (JSONException e) {

View File

@ -1,11 +1,9 @@
package com.muqingbfq.login; package com.muqingbfq.login;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.view.MenuItem; import android.view.MenuItem;
@ -17,9 +15,8 @@ import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts; import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.muqingbfq.R; import com.muqingbfq.databinding.ActivityUserLogsBinding;
import com.muqingbfq.main; import com.muqingbfq.main;
import com.muqingbfq.mq.EditViewDialog; import com.muqingbfq.mq.EditViewDialog;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
@ -28,12 +25,20 @@ import com.muqingbfq.mq.wl;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.regex.Pattern;
public class user_logs extends AppCompatActivity { public class user_logs extends AppCompatActivity {
public static class USER {
public String name, qianming;
public Object picUrl;
public USER(String user, String qianming, Object picUrl) {
this.name = user;
this.qianming = qianming;
this.picUrl = picUrl;
}
}
EditText edituser, editpassword; EditText edituser, editpassword;
Toolbar toolbar;
public static String UUID; public static String UUID;
ActivityResultLauncher<Intent> enroll = ActivityResultLauncher<Intent> enroll =
@ -50,29 +55,25 @@ public class user_logs extends AppCompatActivity {
} }
} }
}); });
@SuppressLint("HardwareIds") ActivityUserLogsBinding binding;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_logs); binding = ActivityUserLogsBinding.inflate(getLayoutInflater());
toolbar = findViewById(R.id.toolbar); setContentView(binding.getRoot());
setSupportActionBar(toolbar); setSupportActionBar(binding.toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
UUID = Settings.Secure.getString(getContentResolver(), // UUID = Settings.Secure.getString(getContentResolver(),
Settings.Secure.ANDROID_ID); // Settings.Secure.ANDROID_ID);
binding.login.setOnClickListener(view -> new CloudUser());
edituser = findViewById(R.id.edit_user); /* findViewById(R.id.enroll).setOnClickListener(view -> {
editpassword = findViewById(R.id.edit_password);
findViewById(R.id.login).setOnClickListener(view -> new CloudUser(edituser.getText().toString()
, editpassword.getText().toString()));
findViewById(R.id.enroll).setOnClickListener(view -> {
Intent intent = new Intent(user_logs.this, enroll.class); Intent intent = new Intent(user_logs.this, enroll.class);
intent.putExtra("user", edituser.getText().toString()); intent.putExtra("user", edituser.getText().toString());
intent.putExtra("appID", UUID); intent.putExtra("appID", UUID);
enroll.launch(intent); enroll.launch(intent);
}); });*/
} }
//some statement //some statement
@ -100,22 +101,16 @@ public class user_logs extends AppCompatActivity {
return bitmap; return bitmap;
} }
String isEmail="false";
public String account, password; public String account, password;
class CloudUser extends Thread { class CloudUser extends Thread {
public CloudUser() {
public CloudUser(String account, String password) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
View v = getWindow().peekDecorView(); View v = getWindow().peekDecorView();
if (null != v) { if (null != v) {
imm.hideSoftInputFromWindow(v.getWindowToken(), 0); imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
} }
user_logs.this.account = account; user_logs.this.account = binding.editUser.getText().toString();
user_logs.this.password = password; user_logs.this.password = binding.editPassword.getText().toString();
Pattern pattern = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
if (pattern.matcher(account).matches()) {
isEmail = "true";
}
start(); start();
} }
@ -123,89 +118,26 @@ public class user_logs extends AppCompatActivity {
public void run() { public void run() {
super.run(); super.run();
try { try {
String post = wl.post("/php/user.php?action=login", String hq = wl.hq("/login/cellphone?phone=" + account + "&password=" + password);
new String[]{ if (TextUtils.isEmpty(hq)) {
"account", "passWord", "appID", "isEmail"
},
new String[]{
account, password, UUID, isEmail
});
gj.sc(post);
if (TextUtils.isEmpty(post)) {
return; return;
} }
JSONObject jsonObject = new JSONObject(post); JSONObject jsonObject = new JSONObject(hq);
if (jsonObject.getInt("code") == 0) { int code = jsonObject.getInt("code");
JSONObject data = jsonObject.getJSONObject("data"); if (code == 200) {
gj.sc(data); JSONObject data = jsonObject.getJSONObject("profile");
//用户token String nickname = data.getString("nickname");//用户名
String token = data.getString("token"); String avatarUrl = data.getString("avatarUrl");//用户头像
//用户名称account String signature = data.getString("signature");//用户签名
String account = data.getString("account"); String cookie = jsonObject.getString("cookie");
main.settoken(token, account); gj.xcts(user_logs.this, "登录成功");
new user_message(account); wl.setcookie(cookie);
new user_message(nickname,signature,avatarUrl);
user_logs.this.finish(); user_logs.this.finish();
} else if (code == 502) {
gj.xcts(user_logs.this, jsonObject.getString("message"));
} else { } else {
String message = jsonObject.getString("message"); gj.xcts(user_logs.this, "找不到此账号");
gj.xcts(user_logs.this, message);
if (message.equals("请更改登录设备")) {
JSONObject jsonpost = wl.jsonpost("/php/user.php?action=verification",
new String[]{
"account", "passWord", "appID", "isEmail"
},
new String[]{
account, password, UUID, isEmail
});
gj.sc(jsonpost);
if (!TextUtils.isEmpty(jsonpost.toString()) &&
jsonpost.getInt("code") != 0) {
return;
}
String message1 = jsonpost.getString("message");
gj.xcts(user_logs.this, message1);
main.handler.post(() -> {
EditViewDialog editViewDialog = new EditViewDialog(user_logs.this,
"请输入验证码");
editViewDialog.setMessage("验证码在你账号锁绑定的邮箱绘制垃圾桶中请及时查看");
editViewDialog.setPositive(view -> {
new Thread() {
@Override
public void run() {
JSONObject jsonpost = wl.jsonpost("/php/user.php?action=changeAppId",
new String[]{
"account", "key", "appID", "isEmail"
},
new String[]{
account, editViewDialog.getEditText(), UUID, isEmail
});
gj.sc(jsonpost.toString());
if (!TextUtils.isEmpty(jsonpost.toString())) {
try {
int code = jsonpost.getInt("code");
if (code == 0) {
gj.xcts(user_logs.this,
"验证成功请重新登录");
editViewDialog.dismiss();
} else {
gj.xcts(user_logs.this,
jsonpost.getString("message"));
}
} catch (JSONException e) {
editViewDialog.dismiss();
gj.sc(e);
}
}
}
}.start();
// editViewDialog.dismiss();
});
editViewDialog.setEditinputType("number");
editViewDialog.show();
});
} else if (message.equals("请先激活您的账户")) {
jihuo();
}
} }
} catch (Exception e) { } catch (Exception e) {
gj.sc(e); gj.sc(e);
@ -213,7 +145,8 @@ public class user_logs extends AppCompatActivity {
} }
} }
public void jihuo() { @Deprecated
private void jihuo() {
main.handler.post(new Runnable() { main.handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -1,28 +1,26 @@
package com.muqingbfq.login; package com.muqingbfq.login;
import android.text.TextUtils; import com.google.gson.Gson;
import com.muqingbfq.R; import com.muqingbfq.R;
import com.muqingbfq.main; import com.muqingbfq.main;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wl; import com.muqingbfq.mq.wj;
import org.json.JSONObject;
public class user_message extends Thread { public class user_message extends Thread {
public user_message(String account) { public String name,qiangming, picurl;
main.account = account;
main.token = main.getToken(); public user_message() {
wj.sc(wj.filesdri + "user.mq");
}
public user_message(String nickname, String signature, String avatarUrl) {
name = nickname;
qiangming = signature;
picurl = avatarUrl;
String s = new Gson().toJson(new user_logs.USER(name, qiangming, picurl));
wj.xrwb(wj.filesdri + "user.mq", s);
start(); start();
} }
public user_message() {
main.account = main.getAccount();
main.token = main.getToken();
if (!TextUtils.isEmpty(main.account)) {
start();
}
}
@Override @Override
public void run() { public void run() {
super.run(); super.run();
@ -32,10 +30,10 @@ public class user_message extends Thread {
com.muqingbfq.fragment. com.muqingbfq.fragment.
wode.setname(strings.userName()); wode.setname(strings.userName());
com.muqingbfq.fragment. com.muqingbfq.fragment.
wode.setqianming(strings.introduce()); wode.setqianming(strings.qianming());
com.bumptech.glide.Glide.with(com.muqingbfq.fragment. com.bumptech.glide.Glide.with(com.muqingbfq.fragment.
wode.imageView) wode.imageView)
.load(strings.headIcon()) .load(strings.picurl())
.placeholder(R.drawable.icon)//图片加载出来前显示的图片 .placeholder(R.drawable.icon)//图片加载出来前显示的图片
.error(R.drawable.icon)//图片加载失败后显示的图片 .error(R.drawable.icon)//图片加载失败后显示的图片
.into(com.muqingbfq.fragment. .into(com.muqingbfq.fragment.
@ -46,8 +44,8 @@ public class user_message extends Thread {
} }
} }
public static string get() throws Exception { public string get() throws Exception {
JSONObject post = wl.jsonpost("/php/user.php?action=getSpaceInfo", /* JSONObject post = wl.jsonpost("/php/user.php?action=getSpaceInfo",
new String[]{ new String[]{
"account" "account"
}, },
@ -69,12 +67,10 @@ public class user_message extends Thread {
if (cover.startsWith("..")) { if (cover.startsWith("..")) {
cover = "https://rust.coldmint.top" + cover.substring(2); cover = "https://rust.coldmint.top" + cover.substring(2);
} }
String gender = data.getString("gender"); String gender = data.getString("gender");*/
return new string(new String[]{ return new string(new String[]{
headIcon, account, userName, introduce, cover, gender name, qiangming, picurl
}); });
}
return null;
} }
static class string { static class string {
@ -83,27 +79,16 @@ public class user_message extends Thread {
this.strings = strings; this.strings = strings;
} }
public String headIcon() { public String picurl() {
return strings[0]; return strings[2];
} }
public String account() { public String qianming() {
return strings[1]; return strings[1];
} }
public String userName() { public String userName() {
return strings[2]; return strings[0];
}
public String introduce() {
return strings[3];
}
public String cover() {
return strings[4];
}
public String gender() {
return strings[5];
} }
} }
} }

View File

@ -156,25 +156,4 @@ public class main extends Application {
} }
}); });
} }
public static SharedPreferences getSharedPreferences(String string) {
return application.getSharedPreferences(string, MODE_PRIVATE);
}
public static String getToken() {
SharedPreferences token1 = getSharedPreferences("token");
return token1.getString("token", null);
}
public static String getAccount() {
SharedPreferences token1 = getSharedPreferences("token");
return token1.getString("account", null);
}
public static void settoken(String token, String account) {
SharedPreferences token1 = getSharedPreferences("token");
SharedPreferences.Editor edit1 = token1.edit();
edit1.putString("token", token);
edit1.putString("account", account);
edit1.apply();
}
} }

View File

@ -33,7 +33,7 @@
android:layout_marginEnd="16dp"> android:layout_marginEnd="16dp">
<EditText <EditText
android:id="@+id/edit_user" android:id="@+id/edit_user"
android:hint="铁锈助手账号" android:hint="网易云音乐账号/手机号"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"
@ -86,18 +86,10 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="30dp" android:layout_marginTop="30dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/login" android:text="@string/login"
tools:ignore="ButtonStyle,DuplicateSpeakableTextCheck" /> tools:ignore="ButtonStyle,DuplicateSpeakableTextCheck" />
<Button
android:id="@+id/enroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@string/enroll"
tools:ignore="ButtonStyle" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>