Some useful tools

Overview

JustWeTools - Some useful tools

logo

JustWe 现在有哪些模块?

##模块如何使用:

  • 将Demo作为library加入项目,或是直接将代码拷入

  • 使用Gradle构建:

    • Step 1. Add the JitPack repository to your build file
      Add it in your root build.gradle at the end of repositories:
      	allprojects {
    		repositories {
    			...
    			maven { url "https://jitpack.io" }
    		}
    	}
     	
    • Step 2. Add the dependency on
        dependencies {
            compile 'com.github.lfkdsk:JustWeTools:v1.0'
      }
    	
  • 使用Maven构建:

    • Step 1. Add the JitPack repository to your build file
      <repositories>
    	<repository>
    	    <id>jitpack.io</id>
    	    <url>https://jitpack.io</url>
    	</repository>
    </repositories>
    
    • Step 2. Add the dependency
    	
      <dependency>
        <groupId>com.github.lfkdsk</groupId>
        <artifactId>JustWeTools</artifactId>
        <version>v1.0</version>
    </dependency>
    

JustWe 模块介绍:

View自定义控件:

PaintView画图工具:

  • 可直接使用设定按钮来实现已拥有的方法,且拓展性强
  • 基础功能:更换颜色、更换橡皮、以及更换橡皮和笔的粗细、清屏、倒入图片
  • 特殊功能保存画笔轨迹帧动画、帧动画导入导出、ReDo和UnDo
  • 重构版本:提供笔刷类型基类DrawBase,可继承此类制作笔刷
效果图:

p1 p2

使用基础功能只需要:
1.1 添加xml:
   <com.lfk.justwetools.View.PaintIt.PaintView
       android:id="@+id/paintView"
       android:layout_width="match_parent"
       android:layout_height="match_parent" />
1.2 在activity里找到:
    paintView = (PaintView)findViewById(R.id.paint);
若想使用帧动画相关功能:

需要新建数据集,设定纪录paintview,并且设定onPathListener()

    pathNode = (PathNode)getApplication();
    paintView.setIsRecordPath(true,pathNode);
    paintView.setOnPathListener(new OnPathListener() {
        @Override
    public void AddNodeToPath(float x, float y, int event, boolean IsPaint) {
        PathNode.Node tempnode = pathNode.new Node();
        tempnode.x = x;
        tempnode.y = y;
        if (IsPaint) {
            tempnode.PenColor = UserInfo.PaintColor;
            tempnode.PenWidth = UserInfo.PaintWidth;
        } else {
            tempnode.EraserWidth = UserInfo.EraserWidth;
        }
        tempnode.IsPaint = IsPaint;
        Log.e(tempnode.PenColor + ":" + tempnode.PenWidth + ":" + 		tempnode.EraserWidth, tempnode.IsPaint + "");
        tempnode.TouchEvent = event;
        tempnode.time = System.currentTimeMillis();
        pathNode.AddNode(tempnode);
    	}
	});

相关的教程和解析请看:PaintView 绘图控件解析
图例中出现的Demo: 图例Demo
图例中使用了两个开源控件:
CircularFloatingActionMenuandroid-ColorPickerPreference


####CodeView代码查看/修改工具:

  • 基于WebView制作的代码编辑器
  • 实现代码高亮,暗色主题
  • 代码及时修改
效果图:

p3 p4

使用基础功能只需要:
2.1 添加xml:
    <com.lfk.justwetools.View.CodeView.CodeView
        android:id="@+id/mcodeview"
        android:layerType="hardware"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
2.2 在Activity中获取路径:
        codeView = (CodeView)findViewById(R.id.mcodeview);

        File dir = null;
        Uri fileUri = getIntent().getData();
        if (fileUri != null) {
            dir = new File(fileUri.getPath());
        }

        if (dir != null) {
            codeView.setDirSource(dir);
            getSupportActionBar().setSubtitle(dir.getName());
        }
        else
            finish();

如果是手动复制代码的话,需要复制assests文件夹下的js文件。

2.3 编辑修改:
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (item.getItemId() == R.id.action_code) {
            if (!codeView.isEditable()) {
                item.setTitle("完成");
                codeView.setContentEditable(true);
            } else {
                item.setTitle("编辑");
                codeView.setContentEditable(false);
            }
        }
        return super.onOptionsItemSelected(item);
    }

ExplorerView 文件浏览器:

  • 继承自ListView
  • 可拓展性强
  • 可进行文件类型分析
效果图:

p5 p6

  • 使用基础功能
3.1 添加xml:
    <com.lfk.justwetools.View.FileExplorer.FileExplorer
        android:id="@+id/ex"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
        
3.2 在Activity里面:
    fileExplorer = (FileExplorer)findViewById(R.id.ex);
        

此时默认的打开路径为sd卡根目录: 可通过如下修改:

    // 打开路径
    fileExplorer.setCurrentDir(Environment.getExternalStorageDirectory().getPath());
    // 根路径(能到达最深的路径,以此避免用户进入root路径)
    fileExplorer.setRootDir(Environment.getExternalStorageDirectory().getPath());
    

Item的点击事件:

        //覆盖屏蔽原有长按事件
        fileExplorer.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                return false;
            }
        });
        //选择文件 默认打开CodeView
        fileExplorer.setOnFileChosenListener(new OnFileChosenListener() {
            @Override
            public void onFileChosen(Uri fileUri) {
                Intent intent = new Intent(ExplorerActivity.this, CodeActivity.class);
                intent.setData(fileUri);
                startActivity(intent);
            }
        });
        

返回键返回上一级:

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK
                && event.getAction() == KeyEvent.ACTION_DOWN) {
            if(!fileExplorer.toParentDir()){
                if(System.currentTimeMillis() - exitTime < 1000)
                    finish();
                exitTime = System.currentTimeMillis();
                Toast.makeText(this, "再次点击退出", Toast.LENGTH_SHORT).show();
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
    

高级功能:

根据文件夹内的各种文件类型的大小比例,分析比例图,不建议在sd卡根目录使用内容过多反应较慢.

3.3 添加xml:
    <com.lfk.justwetools.View.Proportionview.ProportionView
        android:id="@+id/pv"
        android:layout_margin="10dp"
        android:layout_width="match_parent"
        android:layout_height="30dp" />
        
3.4 在Activity中添加:
    final ProportionView view = (ProportionView) findViewById(R.id.pv);
    

注册分析文件比例的接口:

    //新路径下分析文件比例
    fileExplorer.setOnPathChangedListener(new OnPathChangedListener() {
        @Override
        public void onPathChanged(String path) {
            try {
                view.setData(fileExplorer.getPropotionText(path));
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), "此路径下不可访问或文件夹下无文件", Toast.LENGTH_LONG).show();
            }
        }
    });
    

ReadView小说阅读:

  • 基于Canvas制作的小说阅读
  • 可更换字体、字号、字颜色
  • 拓展性强
效果图:

p7

使用基础功能只需要:
   ReadView readView = new ReadView(this,dir.getPath());
   setContentView(readView);
   
如果需要打开文件时调用请修改manifest和:
        File dir = null;
        Uri fileUri = getIntent().getData();
        if (fileUri != null) {
            dir = new File(fileUri.getPath());
        }
        readView = null;
        if (dir != null) {
            readView = new ReadView(this,dir.getPath());
        }
        else
            finish();
        setContentView(readView);
        

MarkDownView支持MarkDown语法的渲染器:

  • 基于WebView的MarkDown渲染器
  • 支持标准化的MarkDown语法
  • 调用接口和CodeView保持一致使用简便
效果图:

markdown

使用基础功能:
    <com.lfk.justwetools.View.MarkDown.MarkDownView
        android:id="@+id/markdownview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </com.lfk.justwetools.View.MarkDown.MarkDownView>
    

并添加:

        MarkDownView markDownView = (MarkDownView)findViewById(R.id.markdownview);
        if(getIntent().getStringExtra("str") != null){
            markDownView.setStringSource(getIntent().getStringExtra("str"));
        }
        
如果需要打开文件时调用请修改manifest和:
        File dir = null;
        Uri fileUri = getIntent().getData();
        if (fileUri != null) {
            dir = new File(fileUri.getPath());
        }

        if (dir != null) {
            markDownView.setDirSource(dir);
        }
        

VerTextView竖行排版的TextView:

  • 支持竖行排版
  • 添加了下划线功能,开启简便,下划线粗细、颜色、间距均可自定义
  • 接口调用方式与TextView相似,使用简便
效果图:

vertextview

使用基础功能:
    <com.lfk.justwetools.View.VerText.VerTextView
    android:id="@+id/vertextview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
        

并添加:

    VerTextView verTextView = (VerTextView)findViewById(R.id.vertextview);
    verTextView.setText(getResources().getString(R.string.poem));
        
一些设定:
    verTextView.setFontSize(100);             // 设定字体尺寸
    verTextView.setIsOpenUnderLine(true);     // 设定开启下划线
    verTextView.setUnderLineColor(Color.RED); // 设定下划线颜色
    verTextView.setUnderLineWidth(3);         // 设定下划线宽度
    verTextView.setUnderLineSpacing(10);      // 设定下划线到字的间距
    verTextView.setTextStartAlign(VerTextView.RIGHT); // 从右侧或左侧开始排版
    verTextView.setTextColor(color);           // 设定字体颜色
    ...
        

Clock 绘制时钟:自定义View绘制的时钟

clock

    <com.lfk.justwetools.View.Clock.Clock
        android:id="@+id/clock"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/flashTextView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp" />
一些设定:
    void setColor(int color);
    void setNeedleColor(int needleColor);
    void setTextColor(int textColor);
    void setCircleColor(int circleColor);
    void setUnthehourLineColor(int unthehourLineColor);
    void setThehourLineColor(int thehourLineColor);
    void setHourSize(int hourSize);
    ...
    

有问题反馈

在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流

License

Copyright 2015 [刘丰恺](http://www.cnblogs.com/lfk-dsk/)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
Some useful Android Kotlin utilities

Android-Kotlin-utilities Some useful Android Kotlin utilities Any PR are welcomed :) Please put your code in several files like this. it helps others

Combine some useful exts in One place

Helper Extensions Extensions Combine some useful exts in One place Examples : this.errorMsg(msg = "Test error" , duration = 6000)

A library provides some useful kotlin extension functions

ktext 🔥 A library provides some useful kotlin extension functions. Including in your project Gradle Add below codes to your root build.gradle file (n

WolfxPaper - A Paper fork designed for Wolfx Survial, may useful for some Semi-Vanilla Server

WolfxPaper A Paper fork designed for Wolfx Survial, may useful for some "Semi-Va

Some beautiful android loading drawable, can be combined with any view as the LoadingView or the ProgressBar. Besides, some Drawable can customize the loading progress too.
Some beautiful android loading drawable, can be combined with any view as the LoadingView or the ProgressBar. Besides, some Drawable can customize the loading progress too.

LoadingDrawable: Android cool animation collection 前言 CircleRotate源码解析 Fish源码解析 LoadingDrawable is some android animations implement of drawable: a li

Don't know what to do next? Don't worry, NEG or NotEnoughGoals will give you some help by giving you some goals to achieve to make skyblock less boring.

NotEnoughGoals Don't know what to do next? Don't worry, NEG or NotEnoughGoals will give you some help by giving you some goals to achieve to make skyb

Application that allows to search some products and display them in a list, also allows to add some product to the shopping cart and remove it
Application that allows to search some products and display them in a list, also allows to add some product to the shopping cart and remove it

Application that allows to search some products and display them in a list, also allows to add some product to the shopping cart and remove it

Useful library to use custom fonts in your android app
Useful library to use custom fonts in your android app

EasyFonts A simple and useful android library to use custom fonts in android apps without adding fonts into asset/resource folder.Also by using this l

Adapter Kit is a set of useful adapters for Android.
Adapter Kit is a set of useful adapters for Android.

Adapter Kit Adapter Kit is a set of useful adapters for Android. The kit currently includes, Instant Adapter Instant Cursor Adapter Simple Section Ada

This library provides Easy Android ListView Adapters(EasyListAdapter & EasyCursorAdapter) which makes designing Multi-Row-Type ListView very simple & cleaner, It also provides many useful features for ListView.
This library provides Easy Android ListView Adapters(EasyListAdapter & EasyCursorAdapter) which makes designing Multi-Row-Type ListView very simple & cleaner, It also provides many useful features for ListView.

EasyListViewAdapters Whenever you want to display custom items in listview, then only way to achieve this is to implement your own subclass of BaseAda

A list of most useful resources for designing android apps such as all material colors and dimens, 180 Gradient background + html, social, flat, fluent, metro colors.

Timer UI Login UI Fitness UI Material-Resources-Library A list of most useful resources for designing android apps such as all material colors and dim

Under the Hood is a flexible and powerful Android debug view library. It uses a modular template system that can be easily extended to your needs, although coming with many useful elements built-in.
Under the Hood is a flexible and powerful Android debug view library. It uses a modular template system that can be easily extended to your needs, although coming with many useful elements built-in.

Under the Hood - Android App Debug View Library Under the Hood is a flexible and powerful Android debug view library. It uses a modular template syste

A small customizable library useful to handle an gallery image pick action built-in your app. :sunrise_over_mountains::stars:
A small customizable library useful to handle an gallery image pick action built-in your app. :sunrise_over_mountains::stars:

Louvre A small customizable image picker. Useful to handle an gallery image pick action built-in your app. *Images from Google Image Search Installati

Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps. :dvd::notes:
Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps. :dvd::notes:

Music Cover View A Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps. It's used

A Common RecyclerView.Adapter  implementation which supports all kind of items and has useful data operating APIs such as remove,add,etc.
A Common RecyclerView.Adapter implementation which supports all kind of items and has useful data operating APIs such as remove,add,etc.

##PowerfulRecyclerViewAdapter A Common RecyclerView.Adapter implementation which supports any kind of items and has useful data operating APIs such as

Andorid app which provides a bunch of useful Linux commands.
Andorid app which provides a bunch of useful Linux commands.

Linux Command Library for Android The app currently has 3203 manual pages, 1351 one-line scripts and a bunch of general terminal tips. It works 100% o

A tool that enables advanced features through adb installing and uninstalling apps like wildcards and multi device support. Useful if you want to clean your test device from all company apks or install a lot of apks in one go.  Written in Java so it should run on your platform.
Various useful utilities for Android apps development

Android Commons Various useful utilities for Android apps development. API documentation provided as Javadoc. Usage Add dependency to your build.gradl

A collection of useful Kotlin extension for Android

karamba A collection of useful Kotlin extension for Android Install Add to gradle in allprojects maven { url 'https://jitpack.io' } then add this com

Comments
  • Migrate to GradleMavenPush https://github.com/Vorlonsoft/GradleMavenPush

    Migrate to GradleMavenPush https://github.com/Vorlonsoft/GradleMavenPush

    Reasons:

    • Old plugin don't have updates for 4 years
    • Better javadocs generation
    • Better pom file generation
    • Smaller gradle.properties
    • You can easy migrate from Maven Central to JCenter by adding to your code IS_JCENTER = true only and register at https://bintray.com/bintray/jcenter
    opened by AlexanderLS 0
  • Useful tools

    Useful tools

    With a quick overview of PaintView, I found that it's a powerful canvas. However, It's a little wired that why a View needs javax encryption API?

    I'm sure that there's no need to call Bitmap.recycle() anymore since Android 4.0, because Android 4.0 moved the Bitmap from native heap to dalvik heap. Once there is no strong reference to a Bitmap, it will be garbage collected.

    opened by Alonexx 0
Releases(v1.0)
Owner
JustWe
I'm Batman. 表演工程师
JustWe
Useful helpers that make it easier to implement maven-plugin mojos with kotlin

A library that makes writing powerful maven plugins even easier by providing kotlin extensions and convenience functions for common use cases.

TOOListicon 1 Nov 4, 2022
CreditCardHelper 🖊️ A Jetpack-Compose library providing useful credit card utilities such as card type recognition and TextField ViewTransformations

CreditCardHelper ??️ A Jetpack-Compose library providing useful credit card utilities such as card type recognition and TextField ViewTransformations

Stelios Papamichail 18 Dec 19, 2022
Monitor keyboard height tools

Monitor keyboard height tools

Season 29 Nov 19, 2022
A collection of small utility functions to make it easier to deal with some otherwise nullable APIs on Android.

requireKTX is a collection of small utility functions to make it easier to deal with some otherwise nullable APIs on Android, using the same idea as requireContext, requireArguments, and other similar Android SDK methods.

Márton Braun 82 Oct 1, 2022
Same as the Outlined text fields presented on the Material Design page but with some dynamic changes. 📝 🎉

README SSCustomEditTextOutlineBorder Getting Started SSCustomEditTextOutLineBorder is a small kotlin library for android to support outlined (stroked)

Simform Solutions 194 Dec 30, 2022
Math World is an Android Application specialized in mathematics, where the application includes some sections related to arithmetic, unit conversion, scientific math laws and constants, as well as some mathematical questions that need some intelligence to reach the solution.

Math World is an Android Application specialized in mathematics, where the application includes some sections related to arithmetic, unit conversion, scientific math laws and constants, as well as some mathematical questions that need some intelligence to reach the solution.

null 7 Mar 12, 2022
A simple NoSQL client for Android. Meant as a document store using key/value pairs and some rudimentary querying. Useful for avoiding the hassle of SQL code.

SimpleNoSQL A simple NoSQL client for Android. If you ever wanted to just save some data but didn't really want to worry about where it was going to b

Colin Miller 389 Sep 25, 2022
A simple NoSQL client for Android. Meant as a document store using key/value pairs and some rudimentary querying. Useful for avoiding the hassle of SQL code.

SimpleNoSQL A simple NoSQL client for Android. If you ever wanted to just save some data but didn't really want to worry about where it was going to b

Colin Miller 389 Sep 25, 2022
IntelliJ plugin that provides some useful utilities to support the daily work with Gradle.

IntelliJ Gradle Utilities Plugin This IntelliJ plugin provides some useful utilities to support the daily work with Gradle. It's available on the offi

Marcel Kliemannel 6 Jul 29, 2022