| | |
| | | |
| | | import android.Manifest; |
| | | import android.app.AlertDialog; |
| | | import android.app.ProgressDialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.net.Uri; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.os.Environment; |
| | | import android.provider.Settings; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.WindowManager; |
| | | import android.view.inputmethod.InputMethodManager; |
| | | import android.widget.EditText; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import androidx.annotation.ColorRes; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.annotation.StringRes; |
| | | import androidx.appcompat.app.AppCompatActivity; |
| | | import androidx.core.content.FileProvider; |
| | | import androidx.lifecycle.ViewModelProvider; |
| | | import androidx.viewbinding.ViewBinding; |
| | | |
| | |
| | | import com.runt.open.mvvm.R; |
| | | import com.runt.open.mvvm.base.model.BaseViewModel; |
| | | import com.runt.open.mvvm.base.model.ViewModelFactory; |
| | | import com.runt.open.mvvm.data.ApkUpGradeResult; |
| | | import com.runt.open.mvvm.util.MyLog; |
| | | import com.runt.open.mvvm.util.SpUtils; |
| | | import com.permissionx.guolindev.PermissionX; |
| | | import com.permissionx.guolindev.callback.ExplainReasonCallbackWithBeforeParam; |
| | | import com.permissionx.guolindev.callback.ForwardToSettingsCallback; |
| | | import com.permissionx.guolindev.callback.RequestCallback; |
| | | import com.permissionx.guolindev.request.ExplainScope; |
| | | import com.permissionx.guolindev.request.ForwardScope; |
| | | import com.runt.open.mvvm.listener.ResPonse; |
| | | import com.runt.open.mvvm.util.PreferencesUtils; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.ParameterizedType; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import dmax.dialog.SpotsDialog; |
| | | import okhttp3.Call; |
| | | import okhttp3.Callback; |
| | | import okhttp3.OkHttpClient; |
| | | import okhttp3.Request; |
| | | import okhttp3.Response; |
| | | import okhttp3.ResponseBody; |
| | | |
| | | /** |
| | | * activity 封装 |
| | |
| | | public final String[] LOCATION_PERMISSIONS = new String []{Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION}; |
| | | public final String[] CAMERA_PERMISSIONS = new String[]{ FILE_PERMISSIONS[0],FILE_PERMISSIONS[1], Manifest.permission.CAMERA}; |
| | | public final String[] CAMERA_RECORD_PERMISSIONS = new String[]{ FILE_PERMISSIONS[0],FILE_PERMISSIONS[1], Manifest.permission.CAMERA,Manifest.permission.RECORD_AUDIO}; |
| | | |
| | | public static final String PARAMS_TITLE = "title"; |
| | | public static final String PARAMS_URL = "url"; |
| | | |
| | | public static final int RESULT_LOGIN = 100,RESULT_LOGIN_RECREATE = 103,RESULT_BIND = 101,RESULT_SENDEDFILES = 105,RESULT_DISSCONNECT = 104, |
| | | RESULT_UPDATEUSER = 115,RESULT_LOGOUT = 113, REQUEST_CODE_ACTIVITY = 333; |
| | |
| | | |
| | | public abstract void initViews(); |
| | | |
| | | |
| | | public boolean isNull(Object object){ |
| | | return object == null || object.toString().trim().equals("") || object.equals("null"); |
| | | } |
| | | |
| | | |
| | | AlertDialog dialog; |
| | | /** |
| | | * 显示弹框 |
| | | * @param title |
| | | * @param msg |
| | | * @param btnOk |
| | | * @param btnCancel |
| | | * @param resPonse |
| | | */ |
| | | public void showDialog(String title, String msg, String btnOk,String btnCancel,final ResPonse resPonse){ |
| | | showDialog(title,msg,null,btnOk,btnCancel,resPonse,false); |
| | | } |
| | | |
| | | private void showDialog(String title, String msg, String hint,String btnOk,String btnCancel,final ResPonse resPonse,boolean isEdit){ |
| | | |
| | | AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.TransparentDialog); |
| | | builder.setCancelable(false); |
| | | final View view = LayoutInflater.from(this).inflate(R.layout.layout_dialog,null); |
| | | TextView titleView = view.findViewById(R.id.txt_title); |
| | | TextView cancelView = view.findViewById(R.id.txt_cancel); |
| | | final TextView textView = view.findViewById(R.id.msg); |
| | | if(isEdit){ |
| | | textView.setEnabled(true); |
| | | }else{ |
| | | textView.setBackground(null); |
| | | } |
| | | cancelView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | dialog.dismiss(); |
| | | if(resPonse !=null){ |
| | | resPonse.doError(null); |
| | | } |
| | | } |
| | | }); |
| | | cancelView.setText(btnCancel); |
| | | TextView confirmView = view.findViewById(R.id.txt_confirm); |
| | | confirmView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | dialog.dismiss(); |
| | | if(resPonse !=null){ |
| | | resPonse.doSuccess(textView.getText().toString()); |
| | | } |
| | | } |
| | | }); |
| | | confirmView.setText(btnOk); |
| | | confirmView.requestFocus(); |
| | | if(hint != null){ |
| | | textView.setHint(hint); |
| | | } |
| | | if(msg != null){ |
| | | textView.setText(msg); |
| | | } |
| | | titleView.setText(title); |
| | | builder.setView(view); |
| | | dialog = builder.create(); |
| | | dialog.show(); |
| | | } |
| | | |
| | | AlertDialog loadingDialog; |
| | | /** |
| | | * 显示加载弹框 |
| | |
| | | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | //透明导航栏 |
| | | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
| | | |
| | | setStatusBarTextColor(isBlack); |
| | | } |
| | | |
| | | /** |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public boolean getBooleanUserPrefrence(String key){ |
| | | return PreferencesUtils.getBoolean(this,key,false,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public boolean getBooleanProjectPrefrence(String key){ |
| | | return PreferencesUtils.getBoolean(this,key,false,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public String getStringUserPrefrence(String key){ |
| | | return PreferencesUtils.getString(this,key,"",PreferencesUtils.USER); |
| | | } |
| | | |
| | | public String getStringProjectPrefrence(String key){ |
| | | return PreferencesUtils.getString(this,key,"",PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public Integer getIntProjectPrefrence(String key){ |
| | | return PreferencesUtils.getInt(this,key,0,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public Long getLongProjectPrefrence(String key){ |
| | | return PreferencesUtils.getLong(this,key,0,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public float getFloatProjectPrefrence(String key){ |
| | | return PreferencesUtils.getFloat(this,key,0,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public Set getStringSetProjectPrefrence(String key){ |
| | | return PreferencesUtils.getStringSet(this,key,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public Integer getIntUserPrefrence(String key){ |
| | | return PreferencesUtils.getInt(this,key,0,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public Long getLongUserPrefrence(String key){ |
| | | return PreferencesUtils.getLong(this,key,0,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public float getFloatUserPrefrence(String key){ |
| | | return PreferencesUtils.getFloat(this,key,0,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public Set getStringSetUserPrefrence(String key){ |
| | | return PreferencesUtils.getStringSet(this,key,PreferencesUtils.USER); |
| | | } |
| | | |
| | | |
| | | public void putBooleanUserPrefrence(String key ,Boolean value){ |
| | | PreferencesUtils.putBoolean(this,key,value,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public void putBooleanProjectPrefrence(String key,Boolean value){ |
| | | PreferencesUtils.putBoolean(this,key,value,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public void putStringUserPrefrence(String key,String value){ |
| | | PreferencesUtils.putString(this,key,value,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public void putStringProjectPrefrence(String key,String value){ |
| | | PreferencesUtils.putString(this,key,value,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public void putIntProjectPrefrence(String key,int value){ |
| | | PreferencesUtils.putInt(this,key,value,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public void putLongProjectPrefrence(String key,long value){ |
| | | PreferencesUtils.putLong(this,key,value,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public void putFloatProjectPrefrence(String key,float value){ |
| | | PreferencesUtils.putFloat(this,key,value,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public void putStringSetProjectPrefrence(String key, Set value){ |
| | | PreferencesUtils.putStringSet(this,key,value,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public void putIntUserPrefrence(String key,int value){ |
| | | PreferencesUtils.putInt(this,key,value,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public void putLongUserPrefrence(String key,long value){ |
| | | PreferencesUtils.putLong(this,key,value,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public void putFloatUserPrefrence(String key,float value){ |
| | | PreferencesUtils.putFloat(this,key,value,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public void putStringSetUserPrefrence(String key, Set value){ |
| | | PreferencesUtils.putStringSet(this,key,value,PreferencesUtils.USER); |
| | | } |
| | | |
| | | |
| | | public void removeUserKey(String key){ |
| | | PreferencesUtils.removeKey(this,key,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public void removeProjectKey(String key){ |
| | | PreferencesUtils.removeKey(this,key,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | public void removeUserValue(String Value){ |
| | | PreferencesUtils.removeValue(this,Value,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public void removeProjectValue(String Value){ |
| | | PreferencesUtils.removeValue(this,Value,PreferencesUtils.PROJECT); |
| | | } |
| | | |
| | | |
| | | public void clearProjectData(){ |
| | | PreferencesUtils.clearData(this,PreferencesUtils.PROJECT); |
| | | } |
| | | public void clearUserData(){ |
| | | PreferencesUtils.clearData(this,PreferencesUtils.USER); |
| | | } |
| | | |
| | | |
| | | } |