| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package org.las2mile.okio.utils;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import android.content.Context;
- import android.util.Log;
- import java.lang.reflect.Method;
- import android.os.Handler;
- import android.os.Looper;
- import android.os.ResultReceiver;
- import java.lang.reflect.Field;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import org.las2mile.scrcpy.BuildConfig;
- import android.app.AlertDialog;
- import android.content.DialogInterface;
- import android.widget.CheckBox;
- import android.widget.TextView;
- import android.app.Activity;
- import org.las2mile.scrcpy.R;
- import android.view.View;
- import android.widget.Button;
- public class SystemUtils {
- private static final String LOG_TAG = "TelephonyManagerSub";
- private static final String PREFERENCE_KEY = "default";
- public static boolean isDateValid(){
- String buildTime = BuildConfig.BUILD_TIME;
- long day = 0;
- SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
- try {
- Date buildDate = format.parse(buildTime);
- Date curDate = new Date();
- day = (curDate.getTime()-buildDate.getTime())/(24*60*60*1000);
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
- if(day == 0){
- day = 1;
- }
- boolean isValid = false;
- if(day < 0){
- isValid = false;
- } else if(0 <= day && day <=60){
- isValid = true;
- } else {
- isValid = false;
- }
- Log.d(LOG_TAG,"no need update "+isValid+" "+day);
- return isValid;
- }
- public static void enableStartLegalNotice(Activity activity,Button startButton){
- CheckBox checkBox = activity.findViewById(R.id.cb_legal_notice);
- checkBox.setClickable(false);
- boolean agree = activity.getSharedPreferences(PREFERENCE_KEY, 0).getBoolean("agree notice", false);
- checkBox.setChecked(agree);
- startButton.setEnabled(agree);
- activity.findViewById(R.id.ll_legal_notice).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Log.d("OkioMain","onClick");
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
- builder.setTitle("深圳恺恩科技有限公司法律声明");
- builder.setMessage(R.string.legal_notice);
- builder.setCancelable(false);
- builder.setPositiveButton("同意",new DialogInterface.OnClickListener(){
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- activity.getSharedPreferences(PREFERENCE_KEY, 0).edit().putBoolean("agree notice", true).apply();
- checkBox.setChecked(true);
- startButton.setEnabled(true);
- dialogInterface.dismiss();
- }
- });
- builder.setNegativeButton("不同意",new DialogInterface.OnClickListener(){
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- activity.getSharedPreferences(PREFERENCE_KEY, 0).edit().putBoolean("agree notice", false).apply();
- checkBox.setChecked(false);
- startButton.setEnabled(false);
- dialogInterface.dismiss();
- }
- });
- AlertDialog dialog = builder.create();
- dialog.show();
- }
- });
- }
- }
|