Java Code Examples for com.blankj.utilcode.util.AppUtils

The following examples show how to use com.blankj.utilcode.util.AppUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FloatWindow   Source File: FloatWindowService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    int what = msg.what;
    switch (what) {
        case HANDLER_DETECT_PERMISSION:
            if (FloatWindowParamManager.checkPermission(getApplicationContext())) {
                //对沙雕VIVO机型特殊处理,应用处于后台检查悬浮窗权限成功才能确认真的获取了悬浮窗权限
                if (RomUtils.isVivoRom() && AppUtils.isAppForeground()) {
                    Log.e(TAG, "悬浮窗权限检查成功,但App处于前台状态,特殊机型会允许App获取权限,特殊机型就是指Vivo这个沙雕");
                    mHandler.sendEmptyMessageDelayed(HANDLER_DETECT_PERMISSION, 500);
                    return;
                }

                mHandler.removeMessages(HANDLER_DETECT_PERMISSION);
                Log.e(TAG, "悬浮窗权限检查成功");
                showFloatPermissionWindow();
            } else {
                Log.e(TAG, "悬浮窗权限检查失败");
                mHandler.sendEmptyMessageDelayed(HANDLER_DETECT_PERMISSION, 500);
            }
            break;
    }
}
 
Example 2
Source Project: FloatWindow   Source File: FloatWindowParamManager.java    License: Apache License 2.0 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static boolean checkOps(Context context) {
    try {
        Object object = context.getSystemService(Context.APP_OPS_SERVICE);
        if (object == null) {
            return false;
        }
        Class localClass = object.getClass();
        Class[] arrayOfClass = new Class[3];
        arrayOfClass[0] = Integer.TYPE;
        arrayOfClass[1] = Integer.TYPE;
        arrayOfClass[2] = String.class;
        Method method = localClass.getMethod("checkOp", arrayOfClass);
        if (method == null) {
            return false;
        }
        Object[] arrayOfObject1 = new Object[3];
        arrayOfObject1[0] = 24;
        arrayOfObject1[1] = Binder.getCallingUid();
        arrayOfObject1[2] = AppUtils.getAppPackageName();
        int m = (Integer) method.invoke(object, arrayOfObject1);
        return m == AppOpsManager.MODE_ALLOWED || !RomUtils.isDomesticSpecialRom();
    } catch (Exception ignore) {
    }
    return false;
}
 
Example 3
Source Project: YCAudioPlayer   Source File: InitializeService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化腾讯bug管理平台
 */
private void initBugly() {
    /* Bugly SDK初始化
    * 参数1:上下文对象
    * 参数2:APPID,平台注册时得到,注意替换成你的appId
    * 参数3:是否开启调试模式,调试模式下会输出'CrashReport'tag的日志
    * 注意:如果您之前使用过Bugly SDK,请将以下这句注释掉。
    */
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(getApplicationContext());
    // 设置版本号
    strategy.setAppVersion(AppUtils.getAppVersionName());
    // 设置版本名称
    String appPackageName = AppUtils.getAppPackageName();
    strategy.setAppPackageName(appPackageName);
    // 获取当前进程名
    String processName = AppToolUtils.getProcessName(android.os.Process.myPid());
    // 设置是否为上报进程
    strategy.setUploadProcess(processName == null || processName.equals(appPackageName));
    //Bugly会在启动20s后联网同步数据
    strategy.setAppReportDelay(20000);
    //正式版
    CrashReport.initCrashReport(getApplicationContext(), "521262bdd7", false, strategy);
}
 
Example 4
Source Project: V2EX   Source File: AppService.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void checkNotifycation(String errorLog,ResponseListener<String> responseListener){

        Map<String, String> form = new HashMap<String,String>(){{
            put("version", AppUtils.getAppVersionName() + AppUtils.getAppVersionCode());
            put("deviceModel", DeviceUtils.getModel());
            put("sdkVersion", String.valueOf(DeviceUtils.getSDKVersionCode()));
            put("screen",  ScreenUtils.getScreenDensity() +
                    " " + ScreenUtils.getScreenHeight() +
                    "x" + ScreenUtils.getScreenWidth());
            put("errorLog", errorLog);
        }};
        RetrofitManager.create(AppApi.class)
                .checkNotifycation(form)
                .compose(RxUtil.io2main())
                .subscribe(new RxObserver<JsonObject>() {
                    @Override
                    public void _onNext(JsonObject jsonObject) {

                    }
                });
    }
 
Example 5
Source Project: FloatWindow   Source File: FloatWindowService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    int what = msg.what;
    switch (what) {
        case HANDLER_DETECT_PERMISSION:
            if (FloatWindowParamManager.checkPermission(getApplicationContext())) {
                //对沙雕VIVO机型特殊处理,应用处于后台检查悬浮窗权限成功才能确认真的获取了悬浮窗权限
                if (RomUtils.isVivoRom() && AppUtils.isAppForeground()) {
                    Log.e(TAG, "悬浮窗权限检查成功,但App处于前台状态,特殊机型会允许App获取权限,特殊机型就是指Vivo这个沙雕");
                    mHandler.sendEmptyMessageDelayed(HANDLER_DETECT_PERMISSION, 500);
                    return;
                }

                mHandler.removeMessages(HANDLER_DETECT_PERMISSION);
                Log.e(TAG, "悬浮窗权限检查成功");
                showFloatPermissionWindow();
            } else {
                Log.e(TAG, "悬浮窗权限检查失败");
                mHandler.sendEmptyMessageDelayed(HANDLER_DETECT_PERMISSION, 500);
            }
            break;
    }
}
 
Example 6
Source Project: FloatWindow   Source File: FloatWindowParamManager.java    License: Apache License 2.0 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static boolean checkOps(Context context) {
    try {
        Object object = context.getSystemService(Context.APP_OPS_SERVICE);
        if (object == null) {
            return false;
        }
        Class localClass = object.getClass();
        Class[] arrayOfClass = new Class[3];
        arrayOfClass[0] = Integer.TYPE;
        arrayOfClass[1] = Integer.TYPE;
        arrayOfClass[2] = String.class;
        Method method = localClass.getMethod("checkOp", arrayOfClass);
        if (method == null) {
            return false;
        }
        Object[] arrayOfObject1 = new Object[3];
        arrayOfObject1[0] = 24;
        arrayOfObject1[1] = Binder.getCallingUid();
        arrayOfObject1[2] = AppUtils.getAppPackageName();
        int m = (Integer) method.invoke(object, arrayOfObject1);
        return m == AppOpsManager.MODE_ALLOWED || !RomUtils.isDomesticSpecialRom();
    } catch (Exception ignore) {
    }
    return false;
}
 
Example 7
Source Project: Android-UtilCode   Source File: AppActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initView(Bundle savedInstanceState, View view) {
    findViewById(R.id.btn_install_app).setOnClickListener(this);
    findViewById(R.id.btn_install_app_silent).setOnClickListener(this);
    findViewById(R.id.btn_uninstall_app).setOnClickListener(this);
    findViewById(R.id.btn_uninstall_app_silent).setOnClickListener(this);
    findViewById(R.id.btn_launch_app).setOnClickListener(this);
    findViewById(R.id.btn_get_app_details_settings).setOnClickListener(this);
    TextView tvAboutApp = (TextView) findViewById(R.id.tv_about_app);
    tvAboutApp.setText(new SpannableStringUtils.Builder().append("app icon: ")
            .appendLine("").setDrawable(AppUtils.getAppIcon(), SpannableStringUtils.ALIGN_CENTER)
            .append(AppUtils.getAppInfo().toString())
            .appendLine("isAppRoot: " + AppUtils.isAppRoot())
            .appendLine("isAppDebug: " + AppUtils.isAppDebug())
            .appendLine("AppSignatureSHA1: " + AppUtils.getAppSignatureSHA1())
            .appendLine("isAppForeground: " + AppUtils.isAppForeground())
            .create());
}
 
Example 8
Source Project: AndroidUtilCode   Source File: AppInfoItem.java    License: Apache License 2.0 6 votes vote down vote up
public static List<AppInfoItem> getAppInfoItems() {
    final List<AppInfoItem> appInfoItems = new ArrayList<>();
    appInfoItems.add(new AppInfoItem(R.string.du_app_info_pkg_name, AppUtils.getAppPackageName()));
    appInfoItems.add(new AppInfoItem(R.string.du_app_info_version_name, AppUtils.getAppVersionName()));
    appInfoItems.add(new AppInfoItem(R.string.du_app_info_version_code, String.valueOf(AppUtils.getAppVersionCode())));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        appInfoItems.add(new AppInfoItem(R.string.du_app_info_min_sdk_version, String.valueOf(DebugUtils.getApp().getApplicationInfo().minSdkVersion)));
    }
    appInfoItems.add(new AppInfoItem(R.string.du_app_info_target_sdk_version, String.valueOf(DebugUtils.getApp().getApplicationInfo().targetSdkVersion)));
    appInfoItems.add(new AppInfoItem(R.string.du_app_info_open_app_info_page, "", new OnClickListener() {
        @Override
        public void onClick(View v) {
            AppUtils.launchAppDetailsSettings();
        }
    }));
    return appInfoItems;
}
 
Example 9
Source Project: FloatWindow   Source File: FloatWindowService.java    License: Apache License 2.0 5 votes vote down vote up
private Intent getStartAppIntent(Context context) {
    Intent intent = context.getPackageManager()
            .getLaunchIntentForPackage(AppUtils.getAppPackageName());
    if (intent != null) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    }

    return intent;
}
 
Example 10
Source Project: YCAudioPlayer   Source File: AppToolUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String getAidlCheckAppInfoSign(){
    String appPackageName = AppUtils.getAppPackageName();
    //String appPackageName = "cn.ycbjie.ycaudioplayer";
    @SuppressLint("SimpleDateFormat")
    // 设置日期格式
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm");
    // new Date()为获取当前系统时间,也可使用当前时间戳
    String date = df.format(new Date());
    return encrypt(date+"_"+appPackageName);
}
 
Example 11
Source Project: DoraemonKit   Source File: PerformanceDataManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    mLastFrameRate = totalFramesPerSecond;
    if (mLastFrameRate > MAX_FRAME_RATE) {
        mLastFrameRate = MAX_FRAME_RATE;
    }
    //保存fps数据
    if (AppUtils.isAppForeground()) {
        writeFpsDataIntoFile();
    }
    totalFramesPerSecond = 0;
    //1s中统计一次
    mMainHandler.postDelayed(this, FPS_SAMPLING_TIME);
}
 
Example 12
Source Project: DoraemonKit   Source File: AppHealthInfoUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置基本信息
 *
 * @param caseName   用例名称
 * @param testPerson 测试人员名字
 */
void setBaseInfo(String caseName, String testPerson) {
    AppHealthInfo.BaseInfoBean baseInfoBean = new AppHealthInfo.BaseInfoBean();
    baseInfoBean.setTestPerson(testPerson);
    baseInfoBean.setCaseName(caseName);
    baseInfoBean.setAppName(AppUtils.getAppName());
    baseInfoBean.setAppVersion(AppUtils.getAppVersionName());
    baseInfoBean.setDokitVersion(BuildConfig.DOKIT_VERSION);
    baseInfoBean.setPlatform("Android");
    baseInfoBean.setPhoneMode(DeviceUtils.getModel());
    baseInfoBean.setTime(TimeUtils.getNowString());
    baseInfoBean.setSystemVersion(DeviceUtils.getSDKVersionName());
    baseInfoBean.setpId("" + DokitConstant.PRODUCT_ID);
    mAppHealthInfo.setBaseInfo(baseInfoBean);
}
 
Example 13
Source Project: DoraemonKit   Source File: ImageCapture.java    License: Apache License 2.0 5 votes vote down vote up
public void init(Context context, Bundle bundle, ColorPickerDokitView colorPickerDokitView) throws Exception {
    this.mColorPickerDokitView = colorPickerDokitView;
    PackageManager packageManager = DoraemonKit.APPLICATION.getPackageManager();
    ApplicationInfo applicationInfo = packageManager.getApplicationInfo(AppUtils.getAppPackageName(), 0);
    //适配Android Q
    if (applicationInfo.targetSdkVersion >= 29) {
        if (ColorPickManager.getInstance().getMediaProjection() != null) {
            colorPickerDokitView.onScreenServiceReady();
        } else {
            try {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    Intent intent = new Intent(context, ScreenRecorderService.class);
                    intent.putExtra("data", bundle.getParcelable("data"));
                    context.startForegroundService(intent);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } else {
        mMediaProjectionManager = (MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
        if (mMediaProjectionManager != null) {
            mMediaProjection = mMediaProjectionManager.getMediaProjection(Activity.RESULT_OK, (Intent) bundle.getParcelable("data"));
            initImageRead(mMediaProjection);
        }
    }
}
 
Example 14
Source Project: DoraemonKit   Source File: DataPickBean.java    License: Apache License 2.0 5 votes vote down vote up
DataPickBean() {
    //初始化基础数据
    this.pId = DokitConstant.PRODUCT_ID;
    this.appName = AppUtils.getAppName();
    this.appId = AppUtils.getAppPackageName();
    this.dokitVersion = BuildConfig.DOKIT_VERSION;
    this.platform = "Android";
    this.phoneMode = DeviceUtils.getModel();
    this.time = "" + TimeUtils.getNowMills();
    this.systemVersion = DeviceUtils.getSDKVersionName();
    this.language = Locale.getDefault().getDisplayLanguage();
}
 
Example 15
Source Project: QPM   Source File: QPMGetAppInfoExecutor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void exec() throws QPMException {
    jmAppAnalysis.onCollectAppInfo(AppUtils.getAppPackageName(),
            AppUtils.getAppName(),
            AppUtils.getAppVersionName(),
            AppUtils.getAppVersionCode(),
            BuildConfig.VERSION_CODE,
            System.currentTimeMillis(),
            0);
}
 
Example 16
Source Project: DanDanPlayForAndroid   Source File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {

        if (System.currentTimeMillis() - touchTime > 1500) {
            ToastUtils.showShort("再按一次退出应用");
            touchTime = System.currentTimeMillis();
        } else {
            if (ServiceUtils.isServiceRunning(TorrentService.class))
                ServiceUtils.stopService(TorrentService.class);
            AppUtils.exitApp();
        }
    }
    return false;
}
 
Example 17
Source Project: FloatWindow   Source File: FloatWindowService.java    License: Apache License 2.0 5 votes vote down vote up
private Intent getStartAppIntent(Context context) {
    Intent intent = context.getPackageManager()
            .getLaunchIntentForPackage(AppUtils.getAppPackageName());
    if (intent != null) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    }

    return intent;
}
 
Example 18
Source Project: SuperNote   Source File: FeedbackPresenter.java    License: GNU General Public License v3.0 5 votes vote down vote up
private Feedback getFeedback(String content,String contact){
    Feedback feedback=new Feedback();
    feedback.setContent(content);
    feedback.setContact(contact);
    feedback.setSdk(DeviceUtils.getSDKVersion());
    feedback.setVersion(AppUtils.getAppVersionName());
    return feedback;
}
 
Example 19
Source Project: AndroidUtilCode   Source File: BaseApplication.java    License: Apache License 2.0 5 votes vote down vote up
private void initCrash() {
    CrashUtils.init(new CrashUtils.OnCrashListener() {
        @Override
        public void onCrash(String crashInfo, Throwable e) {
            LogUtils.e(crashInfo);
            AppUtils.relaunchApp();
        }
    });
}
 
Example 20
Source Project: AndroidUtilCode   Source File: BaseFragment.java    License: Apache License 2.0 5 votes vote down vote up
protected void log(String msg) {
    if (isDebug == null) {
        isDebug = AppUtils.isAppDebug();
    }
    if (isDebug) {
        Log.d("BaseFragment", getClass().getSimpleName() + ": " + msg);
    }
}
 
Example 21
Source Project: FloatWindow   Source File: FloatWindowParamManager.java    License: Apache License 2.0 4 votes vote down vote up
public static WindowManager.LayoutParams getFloatLayoutParam(boolean fullScreen, boolean touchAble) {

        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            layoutParams.type = TYPE_APPLICATION_OVERLAY;
            //刘海屏延伸到刘海里面
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
            }
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
                && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            layoutParams.type = TYPE_TOAST;
        } else {
            layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
        }

        layoutParams.packageName = AppUtils.getAppPackageName();

        layoutParams.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;

        //Focus会占用屏幕焦点,导致游戏无声
        if (touchAble) {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        } else {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
        }

        if (fullScreen) {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
            layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
            layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        } else {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
            layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
            layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        }

        layoutParams.format = PixelFormat.TRANSPARENT;

        return layoutParams;
    }
 
Example 22
Source Project: DoraemonKit   Source File: AppStartInfoFragment.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 将启动信息保存到文件并分享
 */
private void export2File(final String info) {
    if (TextUtils.isEmpty(info)) {
        ToastUtils.showShort("启动信息为空");
        return;
    }
    ToastUtils.showShort("启动信息保存中,请稍后...");
    final String logPath = PathUtils.getInternalAppFilesPath() + File.separator + AppUtils.getAppName() + "_" + "app_launch.log";
    final File logFile = new File(logPath);

    ThreadUtils.executeByCpu(new ThreadUtils.Task<Boolean>() {
        @Override
        public Boolean doInBackground() throws Throwable {
            try {

                FileIOUtils.writeFileFromString(logFile, info, false);

                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }

        @Override
        public void onSuccess(Boolean result) {
            if (result) {
                ToastUtils.showShort("启动信息文件保存在:" + logPath);
                //分享
                FileUtil.systemShare(DoraemonKit.APPLICATION, logFile);
            }
        }

        @Override
        public void onCancel() {
            if (logFile.exists()) {
                FileUtils.delete(logFile);
            }
            ToastUtils.showShort("启动信息保存失败");
        }

        @Override
        public void onFail(Throwable t) {
            if (logFile.exists()) {
                FileUtils.delete(logFile);
            }
            ToastUtils.showShort("启动信息保存失败");
        }
    });

}
 
Example 23
Source Project: DoraemonKit   Source File: LogInfoDokitView.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 将日志信息保存到文件
 *
 * @param operateType 100 保存到本地  101 保存到本地并分享
 */
private void export2File(final int operateType) {
    ToastUtils.showShort("日志保存中,请稍后...");
    final String logPath = PathUtils.getInternalAppFilesPath() + File.separator + AppUtils.getAppName() + "_" + TimeUtils.getNowString(new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss")) + ".log";
    final File logFile = new File(logPath);

    ThreadUtils.executeByCpu(new ThreadUtils.Task<Boolean>() {
        @Override
        public Boolean doInBackground() throws Throwable {
            try {
                List<LogLine> logLines = new ArrayList<>(mLogItemAdapter.getTrueValues());
                for (LogLine logLine : logLines) {
                    String strLog = logLine.getProcessId() + "   " + "   " + logLine.getTimestamp() + "   " + logLine.getTag() + "   " + logLine.getLogLevelText() + "   " + logLine.getLogOutput() + "\n";
                    FileIOUtils.writeFileFromString(logFile, strLog, true);
                }
                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }

        @Override
        public void onSuccess(Boolean result) {
            if (result) {
                ToastUtils.showShort("文件保存在:" + logPath);
                //分享
                if (operateType == 101) {
                    FileUtil.systemShare(DoraemonKit.APPLICATION, logFile);
                }
            }
        }

        @Override
        public void onCancel() {
            if (logFile.exists()) {
                FileUtils.delete(logFile);
            }
            ToastUtils.showShort("日志保存失败");
        }

        @Override
        public void onFail(Throwable t) {
            if (logFile.exists()) {
                FileUtils.delete(logFile);
            }
            ToastUtils.showShort("日志保存失败");
        }
    });

}
 
Example 24
Source Project: DanDanPlayForAndroid   Source File: SplashActivity.java    License: MIT License 4 votes vote down vote up
@Override
public void initView() {
    presenter.checkToken();

    //是否关闭启动页
    if (AppConfig.getInstance().isCloseSplashPage()) {
        launchActivity();
        return;
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
    alphaAnimation.setRepeatCount(Animation.ABSOLUTE);
    alphaAnimation.setInterpolator(new LinearInterpolator());
    alphaAnimation.setDuration(2000);

    String appName = "弹弹play 概念版 v" + AppUtils.getAppVersionName();
    appNameTv.setText(appName);

    textPathView.setAnimListener(new TextPathAnimView.AnimListener() {
        @Override
        public void onStart() {

        }

        @Override
        public void onEnd() {
            if (textPathView != null)
                textPathView.postDelayed(() -> launchActivity(), 350);
        }

        @Override
        public void onLoop() {

        }
    });

    textPathView.startAnim();
    iconSvgView.start();
    addressLl.startAnimation(alphaAnimation);
}
 
Example 25
Source Project: FloatWindow   Source File: FloatWindowParamManager.java    License: Apache License 2.0 4 votes vote down vote up
public static WindowManager.LayoutParams getFloatLayoutParam(boolean fullScreen, boolean touchAble) {

        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            layoutParams.type = TYPE_APPLICATION_OVERLAY;
            //刘海屏延伸到刘海里面
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
            }
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
                && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            layoutParams.type = TYPE_TOAST;
        } else {
            layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
        }

        layoutParams.packageName = AppUtils.getAppPackageName();

        layoutParams.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;

        //Focus会占用屏幕焦点,导致游戏无声
        if (touchAble) {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        } else {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
        }

        if (fullScreen) {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
            layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
            layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        } else {
            layoutParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
            layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
            layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        }

        layoutParams.format = PixelFormat.TRANSPARENT;

        return layoutParams;
    }
 
Example 26
Source Project: Android-UtilCode   Source File: AppActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onWidgetClick(View view) {
    switch (view.getId()) {
        case R.id.btn_install_app:
            if (AppUtils.isInstallApp(Config.TEST_PKG)) {
                ToastUtils.showShort(R.string.app_install_tips);
            } else {
                AppUtils.installApp(Config.getTestApkPath(), "com.blankj.androidutilcode.provider");
            }
            break;
        case R.id.btn_install_app_silent:
            new Thread(new Runnable() {
                @Override
                public void run() {
                    if (AppUtils.isInstallApp(Config.TEST_PKG)) {
                        ToastUtils.showShortSafe(R.string.app_install_tips);
                    } else {
                        if (AppUtils.installAppSilent(Config.getTestApkPath())) {
                            ToastUtils.showShortSafe(R.string.install_successfully);
                        } else {
                            ToastUtils.showShortSafe(R.string.install_unsuccessfully);
                        }
                    }
                }
            }).start();
            break;
        case R.id.btn_uninstall_app:
            if (AppUtils.isInstallApp(Config.TEST_PKG)) {
                AppUtils.uninstallApp(Config.TEST_PKG);
            } else {
                ToastUtils.showShort(R.string.app_uninstall_tips);
            }
            break;
        case R.id.btn_uninstall_app_silent:
            if (AppUtils.isInstallApp(Config.TEST_PKG)) {
                if (AppUtils.uninstallAppSilent(Config.TEST_PKG, false)) {
                    ToastUtils.showShort(R.string.uninstall_successfully);
                } else {
                    ToastUtils.showShort(R.string.uninstall_unsuccessfully);
                }
            } else {
                ToastUtils.showShort(R.string.app_uninstall_tips);
            }
            break;
        case R.id.btn_launch_app:
            AppUtils.launchApp(this.getPackageName());
            break;
        case R.id.btn_get_app_details_settings:
            AppUtils.getAppDetailsSettings();
            break;
    }
}
 
Example 27
Source Project: SuperNote   Source File: AppAboutActivity.java    License: GNU General Public License v3.0 4 votes vote down vote up
private void initVersions() {
    String versions = AppUtils.getAppVersionName();
    tvVersions.setText("V " + versions);
}
 
Example 28
Source Project: AndroidUtilCode   Source File: BaseApplication.java    License: Apache License 2.0 4 votes vote down vote up
private boolean isDebug() {
    if (isDebug == null) isDebug = AppUtils.isAppDebug();
    return isDebug;
}
 
Example 29
Source Project: AndroidUtilCode   Source File: BaseFloatView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    AppUtils.registerAppStatusChangedListener(this);
}
 
Example 30
Source Project: AndroidUtilCode   Source File: BaseFloatView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    AppUtils.unregisterAppStatusChangedListener(this);
    super.onDetachedFromWindow();
}