├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-ldpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable │ │ │ │ ├── ripple_bg.xml │ │ │ │ ├── ripple_bg_drawable.xml │ │ │ │ └── baseline_save_24.xml │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── xml │ │ │ │ └── network_security_config.xml │ │ │ ├── menu │ │ │ │ ├── main_menu.xml │ │ │ │ └── view_setting_menu.xml │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── activity_view_setting.xml │ │ │ │ └── item_view_setting.xml │ │ ├── java │ │ │ └── top │ │ │ │ └── itning │ │ │ │ └── getupearly │ │ │ │ ├── strategy │ │ │ │ ├── Strategy.java │ │ │ │ ├── OpenStrategy.java │ │ │ │ ├── impl │ │ │ │ │ ├── UrlSchemeStrategy.java │ │ │ │ │ ├── QqLinkStrategy.java │ │ │ │ │ └── WeiBoBrowserStrategy.java │ │ │ │ └── StrategyContext.java │ │ │ │ ├── App.java │ │ │ │ ├── net │ │ │ │ ├── NetInfo.java │ │ │ │ └── HttpHelper.java │ │ │ │ ├── constant │ │ │ │ ├── ViewItem.java │ │ │ │ ├── ApiBundle.java │ │ │ │ └── Api.java │ │ │ │ ├── config │ │ │ │ ├── Config.java │ │ │ │ └── SharedPreferencesConfig.java │ │ │ │ ├── ui │ │ │ │ ├── entity │ │ │ │ │ └── ItemData.java │ │ │ │ ├── adapter │ │ │ │ │ └── ViewSettingAdapter.java │ │ │ │ ├── callback │ │ │ │ │ └── ViewItemTouchHelperCallBack.java │ │ │ │ └── ViewSettingActivity.java │ │ │ │ ├── factory │ │ │ │ ├── AbstractViewFactory.java │ │ │ │ └── ViewFactory.java │ │ │ │ ├── entity │ │ │ │ └── UpdateInfo.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ └── test │ │ └── java │ │ └── top │ │ └── itning │ │ └── getupearly │ │ └── ExampleUnitTest.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── key.jks ├── pic ├── index.jpg └── setting.jpg ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── .gitignore ├── .github └── dependabot.yml ├── gradle.properties ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name='GetUpEarly' 3 | -------------------------------------------------------------------------------- /key.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/key.jks -------------------------------------------------------------------------------- /pic/index.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/pic/index.jpg -------------------------------------------------------------------------------- /pic/setting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/pic/setting.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/app/src/main/res/mipmap-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/GetUpEarly/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ripple_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ff212121 4 | #ff000000 5 | #ff80cbc4 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ripple_bg_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | release/ 16 | bugly/ 17 | .idea/ -------------------------------------------------------------------------------- /app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/menu/view_setting_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/strategy/Strategy.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.strategy; 2 | 3 | /** 4 | * @author itning 5 | * @since 2020/8/11 13:23 6 | */ 7 | public enum Strategy { 8 | /** 9 | * QQ内置浏览器 10 | */ 11 | QQ_LINK, 12 | /** 13 | * urlScheme 14 | */ 15 | URL_SCHEME, 16 | /** 17 | * 微博内置浏览器 18 | */ 19 | WEIBO 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/App.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly; 2 | 3 | import android.app.Application; 4 | 5 | import top.itning.getupearly.net.HttpHelper; 6 | 7 | /** 8 | * @author itning 9 | * @since 2020/12/8 12:54 10 | */ 11 | public class App extends Application { 12 | 13 | @Override 14 | public void onCreate() { 15 | HttpHelper.initRetrofit(); 16 | super.onCreate(); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/net/NetInfo.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.net; 2 | 3 | import io.reactivex.rxjava3.core.Observable; 4 | import retrofit2.http.GET; 5 | import top.itning.getupearly.entity.UpdateInfo; 6 | 7 | /** 8 | * @author itning 9 | * @since 2020/12/8 10:09 10 | */ 11 | public interface NetInfo { 12 | 13 | /** 14 | * 获取更新信息 15 | * 16 | * @return UpdateInfo 17 | */ 18 | @GET("update.json") 19 | Observable get(); 20 | } 21 | -------------------------------------------------------------------------------- /app/src/test/java/top/itning/getupearly/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/constant/ViewItem.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.constant; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | /** 6 | * 每一项 7 | * 8 | * @author itning 9 | * @since 2020/8/11 8:52 10 | */ 11 | public interface ViewItem { 12 | /** 13 | * 获取顺序 14 | * 15 | * @return 顺序 16 | */ 17 | int getOrder(); 18 | 19 | /** 20 | * 获取某一项 21 | * 22 | * @return 某一项 23 | */ 24 | @NonNull 25 | T getItem(); 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_view_setting.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gradle" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_save_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/strategy/OpenStrategy.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.strategy; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | /** 8 | * 打开策略 9 | * 10 | * @author itning 11 | * @since 2020/8/11 12:46 12 | */ 13 | public interface OpenStrategy { 14 | /** 15 | * 支持这种打开么 16 | * 17 | * @param strategy Strategy 18 | * @return 支持与否 19 | */ 20 | boolean support(@NonNull Strategy strategy); 21 | 22 | /** 23 | * 打开 24 | * 25 | * @param uri URI 26 | * @param context 上下文 27 | */ 28 | void open(@NonNull String uri,@NonNull Context context); 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/config/Config.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.config; 2 | 3 | import androidx.annotation.CheckResult; 4 | import androidx.annotation.NonNull; 5 | 6 | import java.util.Map; 7 | 8 | import top.itning.getupearly.constant.Api; 9 | import top.itning.getupearly.constant.ViewItem; 10 | 11 | /** 12 | * 用户配置 13 | * 14 | * @author itning 15 | * @since 2020/8/10 20:04 16 | */ 17 | public interface Config { 18 | /** 19 | * 获取配置信息 20 | * 21 | * @return 映射 22 | */ 23 | @NonNull 24 | @CheckResult 25 | Map, Boolean> getConfig(); 26 | 27 | /** 28 | * 保存配置信息 29 | * 30 | * @param api API 31 | * @param isShow 是否显示 32 | * @param order 顺序 33 | */ 34 | void saveConfig(@NonNull Api api, boolean isShow, int order); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/ui/entity/ItemData.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.ui.entity; 2 | 3 | import top.itning.getupearly.constant.Api; 4 | 5 | /** 6 | * @author itning 7 | * @since 2020/8/11 15:33 8 | */ 9 | public class ItemData { 10 | private Api api; 11 | private boolean show; 12 | private int order; 13 | 14 | public ItemData() { 15 | } 16 | 17 | public ItemData(Api api, boolean show, int order) { 18 | this.api = api; 19 | this.show = show; 20 | this.order = order; 21 | } 22 | 23 | public Api getApi() { 24 | return api; 25 | } 26 | 27 | public void setApi(Api api) { 28 | this.api = api; 29 | } 30 | 31 | public boolean isShow() { 32 | return show; 33 | } 34 | 35 | public void setShow(boolean show) { 36 | this.show = show; 37 | } 38 | 39 | public int getOrder() { 40 | return order; 41 | } 42 | 43 | public void setOrder(int order) { 44 | this.order = order; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/strategy/impl/UrlSchemeStrategy.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.strategy.impl; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | 7 | import androidx.annotation.NonNull; 8 | 9 | import top.itning.getupearly.strategy.OpenStrategy; 10 | import top.itning.getupearly.strategy.Strategy; 11 | 12 | /** 13 | * @author itning 14 | * @since 2020/8/11 13:13 15 | */ 16 | public class UrlSchemeStrategy implements OpenStrategy { 17 | private UrlSchemeStrategy() { 18 | } 19 | 20 | private static final OpenStrategy URL_SCHEME_STRATEGY = new UrlSchemeStrategy(); 21 | 22 | public static OpenStrategy getInstance() { 23 | return URL_SCHEME_STRATEGY; 24 | } 25 | 26 | @Override 27 | public boolean support(@NonNull Strategy strategy) { 28 | return strategy.equals(Strategy.URL_SCHEME); 29 | } 30 | 31 | @Override 32 | public void open(@NonNull String uri, @NonNull Context context) { 33 | context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri))); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_view_setting.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | android.injected.testOnly=false 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 早起打卡 3 | QQ打卡 4 | QQ早起打卡奖金赛 5 | 微博早起打卡赢现金 6 | 蚂蚁森林 7 | 支付宝运动 8 | 蚂蚁庄园 9 | 支付宝早起打卡挑战赛 10 | 支付宝天天红包赛 11 | 在GitHub上点个Star 12 | 版本:%1$s 13 | 个性化设置 14 | 保存成功,重新打开APP生效 15 | 淘宝早起打卡挑战赛 16 | 京东金融早起打卡 17 | 长按某一项可以拖动排序哦 18 | 支付宝健康早起打卡 19 | 支付宝运动打卡领健康金 20 | 检查更新失败 21 | 取消 22 | 确定 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/strategy/impl/QqLinkStrategy.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.strategy.impl; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | 7 | import androidx.annotation.NonNull; 8 | 9 | import top.itning.getupearly.strategy.OpenStrategy; 10 | import top.itning.getupearly.strategy.Strategy; 11 | 12 | /** 13 | * @author itning 14 | * @since 2020/8/11 13:17 15 | */ 16 | public class QqLinkStrategy implements OpenStrategy { 17 | private static final OpenStrategy QQ_LINK_STRATEGY = new QqLinkStrategy(); 18 | private static final String QQ_BROWSER_URL_TEMPLATE = "mqqapi://forward/url?url_prefix=%s&souce=oicqzone.com&version=1&src_type=web"; 19 | 20 | public static OpenStrategy getInstance() { 21 | return QQ_LINK_STRATEGY; 22 | } 23 | 24 | private QqLinkStrategy() { 25 | } 26 | 27 | 28 | @Override 29 | public boolean support(@NonNull Strategy strategy) { 30 | return strategy.equals(Strategy.QQ_LINK); 31 | } 32 | 33 | @Override 34 | public void open(@NonNull String uri, @NonNull Context context) { 35 | String formatUri = String.format(QQ_BROWSER_URL_TEMPLATE, uri); 36 | Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(formatUri)); 37 | context.startActivity(intent); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/constant/ApiBundle.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.constant; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.annotation.Nullable; 5 | 6 | /** 7 | * API包裹 8 | * 9 | * @author itning 10 | * @since 2020/8/11 9:01 11 | */ 12 | public class ApiBundle implements ViewItem { 13 | private final Api api; 14 | private final int order; 15 | 16 | public ApiBundle(@NonNull Api api) { 17 | this(api, Integer.MAX_VALUE); 18 | } 19 | 20 | public ApiBundle(@NonNull Api api, int order) { 21 | this.api = api; 22 | this.order = order; 23 | } 24 | 25 | @Override 26 | public int getOrder() { 27 | return order; 28 | } 29 | 30 | @NonNull 31 | @Override 32 | public Api getItem() { 33 | return api; 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | return this.api.hashCode(); 39 | } 40 | 41 | @Override 42 | public boolean equals(@Nullable Object obj) { 43 | if (obj instanceof ApiBundle) { 44 | ApiBundle apiBundle = (ApiBundle) obj; 45 | return api.equals(apiBundle.api); 46 | } 47 | return super.equals(obj); 48 | } 49 | 50 | @NonNull 51 | @Override 52 | public String toString() { 53 | return "ApiBundle{" + 54 | "api=" + api + 55 | ", order=" + order + 56 | '}'; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/strategy/impl/WeiBoBrowserStrategy.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.strategy.impl; 2 | 3 | import android.content.ActivityNotFoundException; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | 8 | import androidx.annotation.NonNull; 9 | 10 | import top.itning.getupearly.strategy.OpenStrategy; 11 | import top.itning.getupearly.strategy.Strategy; 12 | 13 | /** 14 | * @author itning 15 | * @since 2020/8/11 12:58 16 | */ 17 | public class WeiBoBrowserStrategy implements OpenStrategy { 18 | private WeiBoBrowserStrategy() { 19 | } 20 | 21 | private static final OpenStrategy WEIBO_BROWSER_STRATEGY = new WeiBoBrowserStrategy(); 22 | 23 | public static OpenStrategy getInstance() { 24 | return WEIBO_BROWSER_STRATEGY; 25 | } 26 | 27 | @Override 28 | public boolean support(@NonNull Strategy strategy) { 29 | return strategy.equals(Strategy.WEIBO); 30 | } 31 | 32 | @Override 33 | public void open(@NonNull String uri, @NonNull Context context) { 34 | Intent intent = new Intent(); 35 | intent.setAction(android.content.Intent.ACTION_VIEW); 36 | intent.addCategory("android.intent.category.DEFAULT"); 37 | intent.setData(Uri.parse("sinaweibo://browser?url=" + uri)); 38 | try { 39 | context.startActivity(intent); 40 | } catch (ActivityNotFoundException e) { 41 | UrlSchemeStrategy.getInstance().open(uri, context); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/net/HttpHelper.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.net; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import java.util.concurrent.TimeUnit; 6 | 7 | import okhttp3.OkHttpClient; 8 | import retrofit2.Retrofit; 9 | import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory; 10 | import retrofit2.converter.gson.GsonConverterFactory; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | public final class HttpHelper { 16 | 17 | private static Retrofit RETROFIT; 18 | 19 | /** 20 | * 初始化Retrofit 21 | */ 22 | public static void initRetrofit() { 23 | String baseUrl = "https://gitee.com/itning/get-up-early/raw/master/"; 24 | 25 | OkHttpClient okHttpClient = new OkHttpClient.Builder() 26 | // 设置超时时间 27 | .connectTimeout(15L, TimeUnit.SECONDS) 28 | // 设置读写时间 29 | .readTimeout(15L, TimeUnit.SECONDS) 30 | .build(); 31 | RETROFIT = new Retrofit.Builder() 32 | .baseUrl(baseUrl) 33 | .addCallAdapterFactory(RxJava3CallAdapterFactory.create()) 34 | .addConverterFactory(GsonConverterFactory.create()) 35 | .client(okHttpClient) 36 | .build(); 37 | } 38 | 39 | /** 40 | * 获取RETROFIT实例 41 | * 42 | * @param service 服务名 43 | * @param 返回类型 44 | * @return 代理的实例 45 | */ 46 | public static T get(@NonNull final Class service) { 47 | return RETROFIT.create(service); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 20 | 21 | 24 | 25 | 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 早起打卡 2 | Android APP 3 | 4 | [![GitHub stars](https://img.shields.io/github/stars/itning/GetUpEarly.svg?style=social&label=Stars)](https://github.com/itning/GetUpEarly/stargazers) 5 | [![GitHub forks](https://img.shields.io/github/forks/itning/GetUpEarly.svg?style=social&label=Fork)](https://github.com/itning/GetUpEarly/network/members) 6 | [![GitHub watchers](https://img.shields.io/github/watchers/itning/GetUpEarly.svg?style=social&label=Watch)](https://github.com/itning/GetUpEarly/watchers) 7 | [![GitHub followers](https://img.shields.io/github/followers/itning.svg?style=social&label=Follow)](https://github.com/itning?tab=followers) 8 | 9 | [![GitHub issues](https://img.shields.io/github/issues/itning/GetUpEarly.svg)](https://github.com/itning/GetUpEarly/issues) 10 | [![GitHub license](https://img.shields.io/github/license/itning/GetUpEarly.svg)](https://github.com/itning/GetUpEarly/blob/master/LICENSE) 11 | [![GitHub last commit](https://img.shields.io/github/last-commit/itning/GetUpEarly.svg)](https://github.com/itning/GetUpEarly/commits) 12 | [![GitHub release](https://img.shields.io/github/release/itning/GetUpEarly.svg)](https://github.com/itning/GetUpEarly/releases) 13 | [![GitHub repo size in bytes](https://img.shields.io/github/repo-size/itning/GetUpEarly.svg)](https://github.com/itning/GetUpEarly) 14 | [![HitCount](https://hitcount.itning.com/?u=itning&r=GetUpEarly)](https://github.com/itning/hit-count) 15 | [![language](https://img.shields.io/badge/language-JAVA-green.svg)](https://github.com/itning/GetUpEarly) 16 | 17 | ![index](https://raw.githubusercontent.com/itning/GetUpEarly/master/pic/index.jpg) 18 | 19 | ![index](https://raw.githubusercontent.com/itning/GetUpEarly/master/pic/setting.jpg) 20 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/strategy/StrategyContext.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.strategy; 2 | 3 | import android.content.ActivityNotFoundException; 4 | import android.content.Context; 5 | 6 | import androidx.annotation.CheckResult; 7 | import androidx.annotation.NonNull; 8 | 9 | import top.itning.getupearly.strategy.impl.QqLinkStrategy; 10 | import top.itning.getupearly.strategy.impl.UrlSchemeStrategy; 11 | import top.itning.getupearly.strategy.impl.WeiBoBrowserStrategy; 12 | 13 | /** 14 | * 策略上下文 15 | * 16 | * @author itning 17 | * @since 2020/8/11 12:47 18 | */ 19 | public class StrategyContext { 20 | private final Context context; 21 | private final OpenStrategy openStrategy; 22 | 23 | public StrategyContext(@NonNull Context context, @NonNull OpenStrategy openStrategy) { 24 | this.context = context; 25 | this.openStrategy = openStrategy; 26 | } 27 | 28 | public StrategyContext(@NonNull Context context, @NonNull Strategy strategy) { 29 | this.context = context; 30 | this.openStrategy = getOpenStrategy(strategy); 31 | } 32 | 33 | @CheckResult 34 | @NonNull 35 | private OpenStrategy getOpenStrategy(@NonNull Strategy strategy) { 36 | switch (strategy) { 37 | case WEIBO: { 38 | return WeiBoBrowserStrategy.getInstance(); 39 | } 40 | case QQ_LINK: { 41 | return QqLinkStrategy.getInstance(); 42 | } 43 | default: { 44 | return UrlSchemeStrategy.getInstance(); 45 | } 46 | } 47 | } 48 | 49 | public void open(@NonNull String uri) throws ActivityNotFoundException { 50 | openStrategy.open(uri, context); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdk 35 5 | defaultConfig { 6 | applicationId "top.itning.getupearly" 7 | minSdkVersion 21 8 | targetSdkVersion 35 9 | versionCode 12 10 | versionName "1.3.7" 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | resConfigs 'zh', 'en' 13 | } 14 | buildTypes { 15 | release { 16 | // 混淆 17 | minifyEnabled true 18 | // 移除无用的resource文件 19 | shrinkResources true 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | compileOptions { 25 | sourceCompatibility = 1.8 26 | targetCompatibility = 1.8 27 | } 28 | 29 | buildFeatures { 30 | buildConfig = true 31 | } 32 | 33 | namespace 'top.itning.getupearly' 34 | } 35 | 36 | dependencies { 37 | implementation fileTree(dir: 'libs', include: ['*.jar']) 38 | implementation 'androidx.appcompat:appcompat:1.7.0' 39 | implementation 'cat.ereza:customactivityoncrash:2.4.0' 40 | implementation "androidx.recyclerview:recyclerview:1.3.2" 41 | implementation "com.squareup.retrofit2:retrofit:2.11.0" 42 | implementation "com.squareup.retrofit2:converter-gson:2.11.0" 43 | implementation 'com.squareup.retrofit2:adapter-rxjava3:2.11.0' 44 | implementation 'io.reactivex.rxjava3:rxandroid:3.0.2' 45 | implementation 'io.reactivex.rxjava3:rxjava:3.1.10' 46 | testImplementation 'junit:junit:4.13.2' 47 | androidTestImplementation 'androidx.test:runner:1.6.2' 48 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' 49 | implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/config/SharedPreferencesConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.config; 2 | 3 | import android.content.SharedPreferences; 4 | 5 | import androidx.annotation.CheckResult; 6 | import androidx.annotation.NonNull; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | import top.itning.getupearly.constant.Api; 12 | import top.itning.getupearly.constant.ApiBundle; 13 | import top.itning.getupearly.constant.ViewItem; 14 | 15 | /** 16 | * SharedPreferences实现配置 17 | * 18 | * @author itning 19 | * @since 2020/8/10 20:07 20 | */ 21 | public class SharedPreferencesConfig implements Config { 22 | 23 | private static final String ORDER_PREFIX = "ORDER_"; 24 | 25 | private static final String IS_SHOW_PREFIX = "SHOW_"; 26 | 27 | @NonNull 28 | private final SharedPreferences sharedPref; 29 | 30 | public SharedPreferencesConfig(@NonNull SharedPreferences sharedPref) { 31 | this.sharedPref = sharedPref; 32 | } 33 | 34 | @Override 35 | @NonNull 36 | @CheckResult 37 | public Map, Boolean> getConfig() { 38 | Map, Boolean> map = new HashMap<>(); 39 | for (Api api : Api.values()) { 40 | map.put(new ApiBundle(api, sharedPref.getInt(getOrderKey(api.name()), Integer.MAX_VALUE)), sharedPref.getBoolean(getIsShowKey(api.name()), true)); 41 | } 42 | return map; 43 | } 44 | 45 | @Override 46 | public void saveConfig(@NonNull Api api, boolean isShow, int order) { 47 | sharedPref 48 | .edit() 49 | .putBoolean(getIsShowKey(api.name()), isShow) 50 | .putInt(getOrderKey(api.name()), order) 51 | .apply(); 52 | } 53 | 54 | public static String getOrderKey(String value) { 55 | return ORDER_PREFIX + value; 56 | } 57 | 58 | public static String getIsShowKey(String value) { 59 | return IS_SHOW_PREFIX + value; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | # 代码混淆压缩比,在0~7之间,默认为5,一般不做修改 23 | -optimizationpasses 5 24 | 25 | # 混合时不使用大小写混合,混合后的类名为小写 26 | -dontusemixedcaseclassnames 27 | 28 | # 指定不去忽略非公共库的类 29 | -dontskipnonpubliclibraryclasses 30 | 31 | # 这句话能够使我们的项目混淆后产生映射文件 32 | # 包含有类名->混淆后类名的映射关系 33 | -verbose 34 | 35 | # 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。 36 | -dontpreverify 37 | 38 | # 忽略警告,继续执行 39 | -ignorewarnings 40 | 41 | # 指定混淆是采用的算法,后面的参数是一个过滤器 42 | # 这个过滤器是谷歌推荐的算法,一般不做更改 43 | -optimizations !code/simplification/cast,!field/*,!class/merging/* 44 | 45 | -dontwarn javax.annotation.** 46 | -dontwarn javax.inject.** 47 | 48 | -keep class top.itning.getupearly.entity.** { *; } 49 | 50 | #Bugly 51 | -dontwarn com.tencent.bugly.** 52 | -keep public class com.tencent.bugly.**{*;} 53 | -keep class android.support.**{*;} 54 | 55 | # Retain service method parameters when optimizing. 56 | -keepclassmembers,allowshrinking,allowobfuscation interface * { 57 | @retrofit2.http.* ; 58 | } 59 | 60 | # Ignore annotation used for build tooling. 61 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 62 | 63 | # Ignore JSR 305 annotations for embedding nullability information. 64 | -dontwarn javax.annotation.** 65 | 66 | # Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. 67 | -dontwarn kotlin.Unit -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/factory/AbstractViewFactory.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.factory; 2 | 3 | 4 | import android.view.View; 5 | import android.widget.LinearLayout; 6 | 7 | import androidx.annotation.NonNull; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import top.itning.getupearly.constant.ViewItem; 13 | 14 | /** 15 | * 抽象视图工厂 16 | * 17 | * @author itning 18 | * @since 2020/8/10 19:54 19 | */ 20 | public abstract class AbstractViewFactory implements View.OnClickListener { 21 | 22 | /** 23 | * 模板方法 24 | * 25 | * @param linearLayout LinearLayout 26 | */ 27 | public final void start(@NonNull LinearLayout linearLayout) { 28 | List> viewItems = generateList(); 29 | sort(viewItems); 30 | List generateView = generateView(viewItems); 31 | inflaterLayout(generateView, linearLayout); 32 | } 33 | 34 | /** 35 | * 生成每一项 36 | * 37 | * @return 集合 38 | */ 39 | @NonNull 40 | public abstract List> generateList(); 41 | 42 | /** 43 | * 对集合进行排序 44 | * 45 | * @param list 集合 46 | */ 47 | public abstract void sort(@NonNull List> list); 48 | 49 | @NonNull 50 | public List generateView(@NonNull List> list) { 51 | List viewList = new ArrayList<>(); 52 | for (ViewItem viewItem : list) { 53 | View view = getView(viewItem); 54 | view.setOnClickListener(this); 55 | view.setTag(viewItem.getItem()); 56 | viewList.add(view); 57 | } 58 | return viewList; 59 | } 60 | 61 | /** 62 | * 获取一个View 63 | * 64 | * @param viewItem 某一项View 65 | * @return View 66 | */ 67 | @NonNull 68 | public abstract View getView(@NonNull ViewItem viewItem); 69 | 70 | public void inflaterLayout(List list, LinearLayout linearLayout) { 71 | for (View view : list) { 72 | linearLayout.addView(view); 73 | } 74 | } 75 | 76 | @SuppressWarnings("unchecked") 77 | @Override 78 | public final void onClick(View v) { 79 | onItemClick((T) v.getTag()); 80 | } 81 | 82 | /** 83 | * 当某一项被点击时 84 | * 85 | * @param t 被点击的内容 86 | */ 87 | public abstract void onItemClick(@NonNull T t); 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/ui/adapter/ViewSettingAdapter.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.ui.adapter; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.appcompat.app.AppCompatActivity; 9 | import androidx.appcompat.widget.AppCompatCheckBox; 10 | import androidx.appcompat.widget.AppCompatTextView; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import java.util.List; 14 | 15 | import top.itning.getupearly.R; 16 | import top.itning.getupearly.ui.entity.ItemData; 17 | 18 | /** 19 | * @author itning 20 | * @since 2020/8/11 15:04 21 | */ 22 | public class ViewSettingAdapter extends RecyclerView.Adapter { 23 | private final AppCompatActivity activity; 24 | private final List list; 25 | 26 | public ViewSettingAdapter(@NonNull AppCompatActivity activity, @NonNull List list) { 27 | this.activity = activity; 28 | this.list = list; 29 | } 30 | 31 | @NonNull 32 | @Override 33 | public SettingViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 34 | View view = LayoutInflater.from(activity).inflate(R.layout.item_view_setting, parent, false); 35 | return new SettingViewHolder(view); 36 | } 37 | 38 | @Override 39 | public void onBindViewHolder(@NonNull SettingViewHolder holder, int position) { 40 | ItemData itemData = list.get(position); 41 | holder.textView.setText(itemData.getApi().getStrRes()); 42 | holder.textView.setTag(holder.checkBox); 43 | holder.textView.setOnClickListener(v -> { 44 | AppCompatCheckBox checkBox = (AppCompatCheckBox) v.getTag(); 45 | checkBox.setChecked(!checkBox.isChecked()); 46 | }); 47 | holder.checkBox.setChecked(itemData.isShow()); 48 | holder.checkBox.setTag(itemData); 49 | holder.checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> ((ItemData) buttonView.getTag()).setShow(isChecked)); 50 | } 51 | 52 | @Override 53 | public int getItemCount() { 54 | return list.size(); 55 | } 56 | 57 | static class SettingViewHolder extends RecyclerView.ViewHolder { 58 | AppCompatCheckBox checkBox; 59 | AppCompatTextView textView; 60 | 61 | public SettingViewHolder(@NonNull View itemView) { 62 | super(itemView); 63 | checkBox = itemView.findViewById(R.id.cb_item_view); 64 | textView = itemView.findViewById(R.id.tv_item_view); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/ui/callback/ViewItemTouchHelperCallBack.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.ui.callback; 2 | 3 | import android.graphics.Color; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | import androidx.recyclerview.widget.ItemTouchHelper; 8 | import androidx.recyclerview.widget.RecyclerView; 9 | 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | import top.itning.getupearly.ui.adapter.ViewSettingAdapter; 14 | import top.itning.getupearly.ui.entity.ItemData; 15 | 16 | /** 17 | * @author itning 18 | * @since 2020/8/11 15:56 19 | */ 20 | public class ViewItemTouchHelperCallBack extends ItemTouchHelper.Callback { 21 | private final List list; 22 | private final ViewSettingAdapter adapter; 23 | 24 | public ViewItemTouchHelperCallBack(@NonNull List list, @NonNull ViewSettingAdapter adapter) { 25 | this.list = list; 26 | this.adapter = adapter; 27 | } 28 | 29 | @Override 30 | public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { 31 | // 也就是说返回值是组合式的 32 | // makeMovementFlags (int dragFlags, int swipeFlags),看下面的解释说明 33 | int swipFlag = 0; 34 | // 如果也监控左右方向的话,swipFlag=ItemTouchHelper.LEFT|ItemTouchHelper.RIGHT; 35 | int dragflag = ItemTouchHelper.UP | ItemTouchHelper.DOWN; 36 | // 等价于:0001&0010;多点触控标记触屏手指的顺序和个数也是这样标记哦 37 | return makeMovementFlags(dragflag, swipFlag); 38 | } 39 | 40 | @Override 41 | public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) { 42 | // 直接按照文档来操作啊,这文档写得太给力了,简直完美! 43 | adapter.notifyItemMoved(viewHolder.getBindingAdapterPosition(), target.getBindingAdapterPosition()); 44 | // 注意这里有个坑的,itemView 都移动了,对应的数据也要移动 45 | Collections.swap(list, viewHolder.getBindingAdapterPosition(), target.getBindingAdapterPosition()); 46 | return true; 47 | } 48 | 49 | @Override 50 | public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { 51 | 52 | } 53 | 54 | @Override 55 | public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState) { 56 | if (actionState != ItemTouchHelper.ACTION_STATE_IDLE && null != viewHolder) { 57 | viewHolder.itemView.setBackgroundColor(Color.BLACK); 58 | } 59 | super.onSelectedChanged(viewHolder, actionState); 60 | } 61 | 62 | @Override 63 | public void clearView(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { 64 | super.clearView(recyclerView, viewHolder); 65 | viewHolder.itemView.setBackgroundColor(Color.parseColor("#ff212121")); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/entity/UpdateInfo.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.entity; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | * @since 2020/12/8 10:10 10 | */ 11 | public class UpdateInfo implements Serializable { 12 | private int versionCode; 13 | private String versionName; 14 | private String link; 15 | private String desc; 16 | private String title; 17 | private boolean needCheckVersionCode; 18 | private String negativeButtonText; 19 | private String positiveButtonText; 20 | 21 | public int getVersionCode() { 22 | return versionCode; 23 | } 24 | 25 | public void setVersionCode(int versionCode) { 26 | this.versionCode = versionCode; 27 | } 28 | 29 | public String getVersionName() { 30 | return versionName; 31 | } 32 | 33 | public void setVersionName(String versionName) { 34 | this.versionName = versionName; 35 | } 36 | 37 | public String getLink() { 38 | return link; 39 | } 40 | 41 | public void setLink(String link) { 42 | this.link = link; 43 | } 44 | 45 | public String getDesc() { 46 | return desc; 47 | } 48 | 49 | public void setDesc(String desc) { 50 | this.desc = desc; 51 | } 52 | 53 | public String getTitle() { 54 | return title; 55 | } 56 | 57 | public void setTitle(String title) { 58 | this.title = title; 59 | } 60 | 61 | public boolean isNeedCheckVersionCode() { 62 | return needCheckVersionCode; 63 | } 64 | 65 | public void setNeedCheckVersionCode(boolean needCheckVersionCode) { 66 | this.needCheckVersionCode = needCheckVersionCode; 67 | } 68 | 69 | public String getNegativeButtonText() { 70 | return negativeButtonText; 71 | } 72 | 73 | public void setNegativeButtonText(String negativeButtonText) { 74 | this.negativeButtonText = negativeButtonText; 75 | } 76 | 77 | public String getPositiveButtonText() { 78 | return positiveButtonText; 79 | } 80 | 81 | public void setPositiveButtonText(String positiveButtonText) { 82 | this.positiveButtonText = positiveButtonText; 83 | } 84 | 85 | @NonNull 86 | @Override 87 | public String toString() { 88 | return "UpdateInfo{" + 89 | "versionCode=" + versionCode + 90 | ", versionName='" + versionName + '\'' + 91 | ", link='" + link + '\'' + 92 | ", desc='" + desc + '\'' + 93 | ", title='" + title + '\'' + 94 | ", needCheckVersionCode=" + needCheckVersionCode + 95 | ", negativeButtonText='" + negativeButtonText + '\'' + 96 | ", positiveButtonText='" + positiveButtonText + '\'' + 97 | '}'; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/constant/Api.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.constant; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.annotation.StringRes; 5 | 6 | import top.itning.getupearly.R; 7 | import top.itning.getupearly.strategy.Strategy; 8 | 9 | /** 10 | * API枚举 11 | * 12 | * @author itning 13 | * @since 2020/8/10 19:33 14 | */ 15 | public enum Api { 16 | /** 17 | * 蚂蚁森林 18 | */ 19 | ALI_TREE_URL_SCHEME(R.string.ali_tree_str, Strategy.URL_SCHEME, "alipays://platformapi/startapp?saId=60000002"), 20 | /** 21 | * 蚂蚁庄园 22 | */ 23 | ALI_MANOR_URL_SCHEME(R.string.ali_manor_str, Strategy.URL_SCHEME, "alipays://platformapi/startapp?appId=66666674"), 24 | /** 25 | * 阿里运动 26 | */ 27 | ALI_SPORT_URL_SCHEME(R.string.ali_sport_str, Strategy.URL_SCHEME, "alipays://platformapi/startapp?saId=20000869"), 28 | /** 29 | * QQ打卡 30 | */ 31 | QQ_CHECK_IN_URL_PREFIX(R.string.qq_check_in_str, Strategy.QQ_LINK, "aHR0cHM6Ly90aS5xcS5jb20vc2lnbmluL3B1YmxpYy9pbmRleC5odG1sP193dj0xMDkwNTMyMjU3Jl93d3Y9MTM="), 32 | /** 33 | * QQ早起奖金 34 | */ 35 | QQ_GET_UP_EARLY_URL_PREFIX(R.string.qq_get_up_early_str, Strategy.QQ_LINK, "aHR0cHM6Ly95dW5kb25nLnFxLmNvbS9wYWdlL3NpZ24vaW5kZXg/X3d2PTE4OTUwMTE1Jl93d3Y9MSZBRFRBRz1yZWRwa2cuYm9udXMucHVuY2hjYXJkJnN0ZXA9ODk1Mg=="), 36 | /** 37 | * 微博早起奖金 38 | */ 39 | WEIBO_GET_UP_EARLY_URL(R.string.weibo_get_up_early_str, Strategy.WEIBO, "https://getup.sc.weibo.com/home"), 40 | /** 41 | * 支付宝早起打卡挑战赛 42 | */ 43 | ALI_SPORTS_GETUP_SERVER_URL_SCHEME(R.string.ali_sport_server_str, Strategy.URL_SCHEME, "alipays://platformapi/startapp?appId=20000067&url=https%3a%2f%2factivity-alisports.taobao.com%2fgetup"), 44 | /** 45 | * 支付宝天天红包赛 46 | */ 47 | ALI_DD_SPORTS_SERVER_URL_SCHEME(R.string.ali_dd_server_str, Strategy.URL_SCHEME, "alipays://platformapi/startapp?appId=20000067&url=https%3a%2f%2fhuodong.taobao.com%2fwow%2ftyact%2fact%2fddsports-home-alipay%3fgame_type%3d1"), 48 | /** 49 | * 淘宝早起打卡挑战赛 50 | */ 51 | TAOBAO_GETUP_SERVER_URL_SCHEME(R.string.taobao_get_up_early_str, Strategy.URL_SCHEME, "taobao://activity-alisports.taobao.com/p/taobao/activity/getup_early/m_home.html?game_type=9"), 52 | /** 53 | * 京东金融早起打卡 54 | */ 55 | JD_GET_UP_EARLY_URL_SCHEME(R.string.jd_get_up_early_str, Strategy.URL_SCHEME, "jdmobile://share?jumpType=7&jumpUrl=215"), 56 | /** 57 | * 支付宝健康早起打卡 58 | */ 59 | ALI_HEALTH_GET_UP_EARLY_URL_SCHEME(R.string.ali_health_get_up_early_str, Strategy.URL_SCHEME, "alipays://platformapi/startapp?appId=2018091361395351&page=pages/signin/index"), 60 | /** 61 | * 支付宝运动打卡领健康金 62 | */ 63 | ALI_HEALTH_SPORTS_URL_SCHEME(R.string.ali_health_sports_early_str, Strategy.URL_SCHEME, "alipays://platformapi/startapp?appId=2018091361395351&page=pages/sport/index"), 64 | ; 65 | /** 66 | * 打开策略 67 | */ 68 | private final Strategy strategy; 69 | /** 70 | * URI 71 | */ 72 | private final String url; 73 | /** 74 | * 标题 75 | */ 76 | private final int strRes; 77 | 78 | Api(@StringRes int strRes, Strategy strategy, String url) { 79 | this.strRes = strRes; 80 | this.strategy = strategy; 81 | this.url = url; 82 | } 83 | 84 | @NonNull 85 | public String getUrl() { 86 | return url; 87 | } 88 | 89 | @StringRes 90 | public int getStrRes() { 91 | return strRes; 92 | } 93 | 94 | @NonNull 95 | public Strategy getStrategy() { 96 | return strategy; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/factory/ViewFactory.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.factory; 2 | 3 | import android.content.ActivityNotFoundException; 4 | import android.content.Context; 5 | import android.content.res.ColorStateList; 6 | import android.graphics.Color; 7 | import android.graphics.drawable.Drawable; 8 | import android.util.Log; 9 | import android.view.Gravity; 10 | import android.view.View; 11 | import android.widget.LinearLayout; 12 | import android.widget.Toast; 13 | 14 | import androidx.annotation.NonNull; 15 | import androidx.appcompat.view.ContextThemeWrapper; 16 | import androidx.appcompat.widget.AppCompatButton; 17 | import androidx.core.content.res.ResourcesCompat; 18 | 19 | import java.util.ArrayList; 20 | import java.util.Collections; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | import top.itning.getupearly.R; 25 | import top.itning.getupearly.config.Config; 26 | import top.itning.getupearly.constant.Api; 27 | import top.itning.getupearly.constant.ViewItem; 28 | import top.itning.getupearly.strategy.StrategyContext; 29 | 30 | /** 31 | * 视图工厂 32 | * 33 | * @author itning 34 | * @since 2020/8/11 8:17 35 | */ 36 | public class ViewFactory extends AbstractViewFactory { 37 | private static final String TAG = "ViewFactory"; 38 | 39 | private final Config config; 40 | private final Context context; 41 | 42 | public ViewFactory(Config config, Context context) { 43 | this.config = config; 44 | this.context = context; 45 | } 46 | 47 | @NonNull 48 | @Override 49 | public List> generateList() { 50 | List> list = new ArrayList<>(); 51 | for (Map.Entry, Boolean> entry : config.getConfig().entrySet()) { 52 | if (entry.getValue().equals(true)) { 53 | list.add(entry.getKey()); 54 | } 55 | } 56 | return list; 57 | } 58 | 59 | @Override 60 | public void sort(@NonNull List> list) { 61 | Collections.sort(list, (a, b) -> Integer.compare(a.getOrder(), b.getOrder())); 62 | } 63 | 64 | @NonNull 65 | @Override 66 | public View getView(@NonNull ViewItem viewItem) { 67 | ContextThemeWrapper newContext = new ContextThemeWrapper(context, R.style.AppTheme); 68 | AppCompatButton appCompatButton = new AppCompatButton(newContext); 69 | 70 | LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f); 71 | appCompatButton.setLayoutParams(layoutParams); 72 | 73 | appCompatButton.setGravity(Gravity.CENTER); 74 | 75 | ColorStateList colorStateList = ResourcesCompat.getColorStateList(context.getResources(), R.color.colorPrimary, null); 76 | Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), R.drawable.ripple_bg, null); 77 | appCompatButton.setBackgroundTintList(colorStateList); 78 | appCompatButton.setBackground(drawable); 79 | 80 | appCompatButton.setTextColor(Color.WHITE); 81 | appCompatButton.setText(viewItem.getItem().getStrRes()); 82 | 83 | return appCompatButton; 84 | } 85 | 86 | @Override 87 | public void onItemClick(@NonNull Api api) { 88 | StrategyContext strategyContext = new StrategyContext(context, api.getStrategy()); 89 | try { 90 | strategyContext.open(api.getUrl()); 91 | } catch (ActivityNotFoundException e) { 92 | Log.w(TAG, "app not found " + e.getMessage()); 93 | Toast.makeText(context, "APP没有找到", Toast.LENGTH_LONG).show(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/ui/ViewSettingActivity.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly.ui; 2 | 3 | import static top.itning.getupearly.config.SharedPreferencesConfig.getIsShowKey; 4 | import static top.itning.getupearly.config.SharedPreferencesConfig.getOrderKey; 5 | 6 | import android.content.SharedPreferences; 7 | import android.os.Bundle; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | import android.widget.Toast; 11 | 12 | import androidx.appcompat.app.ActionBar; 13 | import androidx.appcompat.app.AppCompatActivity; 14 | import androidx.core.content.ContextCompat; 15 | import androidx.recyclerview.widget.ItemTouchHelper; 16 | import androidx.recyclerview.widget.LinearLayoutManager; 17 | import androidx.recyclerview.widget.RecyclerView; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import top.itning.getupearly.R; 23 | import top.itning.getupearly.config.Config; 24 | import top.itning.getupearly.config.SharedPreferencesConfig; 25 | import top.itning.getupearly.constant.Api; 26 | import top.itning.getupearly.ui.adapter.ViewSettingAdapter; 27 | import top.itning.getupearly.ui.callback.ViewItemTouchHelperCallBack; 28 | import top.itning.getupearly.ui.entity.ItemData; 29 | 30 | /** 31 | * 视图设置 32 | * 33 | * @author itning 34 | */ 35 | public class ViewSettingActivity extends AppCompatActivity { 36 | 37 | private SharedPreferences sharedPreferences; 38 | private List itemDataList; 39 | 40 | @Override 41 | protected void onCreate(Bundle savedInstanceState) { 42 | super.onCreate(savedInstanceState); 43 | setContentView(R.layout.activity_view_setting); 44 | ActionBar supportActionBar = getSupportActionBar(); 45 | if (supportActionBar != null) { 46 | supportActionBar.setTitle(R.string.view_setting_str); 47 | supportActionBar.setDisplayHomeAsUpEnabled(true); 48 | supportActionBar.setElevation(0); 49 | } 50 | getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimary)); 51 | 52 | init(); 53 | } 54 | 55 | private void init() { 56 | sharedPreferences = getSharedPreferences("app_config", MODE_PRIVATE); 57 | 58 | RecyclerView view = findViewById(R.id.rv_root); 59 | view.setLayoutManager(new LinearLayoutManager(this)); 60 | 61 | itemDataList = getItemDataList(); 62 | 63 | ViewSettingAdapter adapter = new ViewSettingAdapter(this, itemDataList); 64 | 65 | view.setAdapter(adapter); 66 | 67 | ViewItemTouchHelperCallBack callBack = new ViewItemTouchHelperCallBack(itemDataList, adapter); 68 | ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callBack); 69 | itemTouchHelper.attachToRecyclerView(view); 70 | 71 | Toast.makeText(this, R.string.sort_tip_toast_str, Toast.LENGTH_SHORT).show(); 72 | } 73 | 74 | @Override 75 | public boolean onOptionsItemSelected(MenuItem item) { 76 | if (item.getItemId() == android.R.id.home) { 77 | this.finish(); 78 | return true; 79 | } else if (item.getItemId() == R.id.save_config) { 80 | saveConfig(); 81 | return true; 82 | } else { 83 | return super.onOptionsItemSelected(item); 84 | } 85 | } 86 | 87 | private void saveConfig() { 88 | Config config = new SharedPreferencesConfig(sharedPreferences); 89 | int i = 0; 90 | for (ItemData itemData : itemDataList) { 91 | config.saveConfig(itemData.getApi(), itemData.isShow(), i++); 92 | } 93 | Toast.makeText(this, R.string.save_success_str, Toast.LENGTH_LONG).show(); 94 | } 95 | 96 | @Override 97 | public boolean onCreateOptionsMenu(Menu menu) { 98 | getMenuInflater().inflate(R.menu.view_setting_menu, menu); 99 | return true; 100 | } 101 | 102 | private List getItemDataList() { 103 | List list = new ArrayList<>(); 104 | for (Api api : Api.values()) { 105 | ItemData itemData = new ItemData(); 106 | int order = sharedPreferences.getInt(getOrderKey(api.name()), Integer.MAX_VALUE); 107 | boolean isShow = sharedPreferences.getBoolean(getIsShowKey(api.name()), true); 108 | itemData.setApi(api); 109 | itemData.setOrder(order); 110 | itemData.setShow(isShow); 111 | list.add(itemData); 112 | } 113 | return list; 114 | } 115 | } -------------------------------------------------------------------------------- /app/src/main/java/top/itning/getupearly/MainActivity.java: -------------------------------------------------------------------------------- 1 | package top.itning.getupearly; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.widget.LinearLayout; 9 | import android.widget.Toast; 10 | 11 | import androidx.appcompat.app.ActionBar; 12 | import androidx.appcompat.app.AlertDialog; 13 | import androidx.appcompat.app.AppCompatActivity; 14 | import androidx.core.content.ContextCompat; 15 | 16 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; 17 | import io.reactivex.rxjava3.disposables.Disposable; 18 | import io.reactivex.rxjava3.schedulers.Schedulers; 19 | import top.itning.getupearly.config.SharedPreferencesConfig; 20 | import top.itning.getupearly.factory.ViewFactory; 21 | import top.itning.getupearly.net.HttpHelper; 22 | import top.itning.getupearly.net.NetInfo; 23 | import top.itning.getupearly.strategy.Strategy; 24 | import top.itning.getupearly.strategy.StrategyContext; 25 | import top.itning.getupearly.strategy.impl.UrlSchemeStrategy; 26 | import top.itning.getupearly.ui.ViewSettingActivity; 27 | 28 | 29 | /** 30 | * @author itning 31 | */ 32 | public class MainActivity extends AppCompatActivity { 33 | 34 | private static final String TAG = "MainActivity"; 35 | /** 36 | * Project GitHub Url 37 | */ 38 | private static final String GITHUB_FOR_STAR = "https://github.com/itning/GetUpEarly"; 39 | 40 | private Disposable disposable; 41 | 42 | @Override 43 | protected void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | setContentView(R.layout.activity_main); 46 | ActionBar supportActionBar = getSupportActionBar(); 47 | if (supportActionBar != null) { 48 | supportActionBar.setElevation(0); 49 | } 50 | getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimary)); 51 | 52 | LinearLayout linearLayout = findViewById(R.id.ll_root); 53 | SharedPreferencesConfig config = new SharedPreferencesConfig(getSharedPreferences("app_config", MODE_PRIVATE)); 54 | ViewFactory viewFactory = new ViewFactory(config, this); 55 | viewFactory.start(linearLayout); 56 | //getInfoFromNet(); 57 | } 58 | 59 | private void getInfoFromNet() { 60 | disposable = HttpHelper.get(NetInfo.class) 61 | .get() 62 | .subscribeOn(Schedulers.io()) 63 | .observeOn(AndroidSchedulers.mainThread()) 64 | .subscribe(info -> { 65 | Log.i(TAG, "Get Net Info:" + info.toString()); 66 | if (info.isNeedCheckVersionCode() && info.getVersionCode() <= BuildConfig.VERSION_CODE) { 67 | return; 68 | } 69 | new AlertDialog.Builder(this, R.style.MyAlertDialogStyle) 70 | .setTitle(info.getTitle()) 71 | .setMessage(info.getDesc()) 72 | .setNegativeButton(null == info.getNegativeButtonText() ? getResources().getString(R.string.check_update_negative_button_str) : info.getNegativeButtonText(), null) 73 | .setPositiveButton(null == info.getPositiveButtonText() ? getResources().getString(R.string.check_update_positive_button_str) : info.getPositiveButtonText(), (dialog, which) -> { 74 | if (null != info.getLink()) { 75 | new StrategyContext(this, Strategy.URL_SCHEME).open(info.getLink()); 76 | } 77 | }) 78 | .show(); 79 | 80 | }, e -> { 81 | Log.e(TAG, "Get Net Info Exception", e); 82 | Toast.makeText(this, R.string.check_update_failed_str, Toast.LENGTH_SHORT).show(); 83 | }); 84 | } 85 | 86 | @Override 87 | public boolean onCreateOptionsMenu(Menu menu) { 88 | menu.add(Menu.NONE, Menu.NONE, Menu.NONE, getString(R.string.app_version_str, BuildConfig.VERSION_NAME)); 89 | getMenuInflater().inflate(R.menu.main_menu, menu); 90 | return true; 91 | } 92 | 93 | @Override 94 | public boolean onOptionsItemSelected(MenuItem item) { 95 | if (item.getItemId() == R.id.github_for_star) { 96 | new StrategyContext(this, UrlSchemeStrategy.getInstance()).open(GITHUB_FOR_STAR); 97 | return true; 98 | } else if (item.getItemId() == R.id.view_setting) { 99 | startActivity(new Intent(this, ViewSettingActivity.class)); 100 | return true; 101 | } else { 102 | return super.onOptionsItemSelected(item); 103 | } 104 | } 105 | 106 | @Override 107 | protected void onDestroy() { 108 | if (disposable != null && !disposable.isDisposed()) { 109 | disposable.dispose(); 110 | } 111 | super.onDestroy(); 112 | } 113 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2018 itning 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------