├── app
├── .gitignore
├── src
│ └── main
│ │ ├── ic_launcher-playstore.png
│ │ ├── java
│ │ └── com
│ │ │ └── jintin
│ │ │ └── quickroute
│ │ │ ├── QuickRouteApp.kt
│ │ │ ├── base
│ │ │ ├── ItemComparable.kt
│ │ │ ├── BaseDao.kt
│ │ │ ├── ItemCallback.kt
│ │ │ └── RecyclerViewUtils.kt
│ │ │ ├── db
│ │ │ ├── ActionDao.kt
│ │ │ ├── QuickRouteDB.kt
│ │ │ └── ActionConverter.kt
│ │ │ ├── data
│ │ │ ├── AppInfo.kt
│ │ │ ├── IconUtils.kt
│ │ │ ├── Action.kt
│ │ │ ├── IntentUtils.kt
│ │ │ └── Extra.kt
│ │ │ ├── action
│ │ │ ├── ActionListViewModel.kt
│ │ │ ├── ActionListAdapter.kt
│ │ │ ├── SelectActionBottomSheet.kt
│ │ │ └── ActionListActivity.kt
│ │ │ ├── AppModule.kt
│ │ │ ├── DevRouteService.kt
│ │ │ ├── select
│ │ │ ├── ActListAdapter.kt
│ │ │ ├── AppListViewModel.kt
│ │ │ ├── AppListActivity.kt
│ │ │ ├── ActListViewModel.kt
│ │ │ ├── AppListAdapter.kt
│ │ │ └── ActListActivity.kt
│ │ │ └── extra
│ │ │ ├── ExtraListAdapter.kt
│ │ │ ├── EditDialogViewModel.kt
│ │ │ ├── ExtraListViewModel.kt
│ │ │ ├── ExtraListActivity.kt
│ │ │ └── EditDialogFragment.kt
│ │ ├── res
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── menu
│ │ │ ├── main.xml
│ │ │ └── extra.xml
│ │ ├── drawable
│ │ │ ├── ic_add.xml
│ │ │ ├── ic_done.xml
│ │ │ ├── ic_delete.xml
│ │ │ ├── ic_edit.xml
│ │ │ ├── ic_launcher_foreground.xml
│ │ │ └── ic_dev_options.xml
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── themes.xml
│ │ │ └── strings.xml
│ │ ├── values-night
│ │ │ └── themes.xml
│ │ └── layout
│ │ │ ├── adapter_act.xml
│ │ │ ├── activity_app.xml
│ │ │ ├── activity_act.xml
│ │ │ ├── activity_extra.xml
│ │ │ ├── adapter_app.xml
│ │ │ ├── fragment_action_sheet.xml
│ │ │ ├── adapter_extra.xml
│ │ │ ├── activity_action.xml
│ │ │ ├── adapter_action.xml
│ │ │ └── fragment_edit_extra.xml
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
├── schemas
│ └── com.jintin.quickroute.db.QuickRouteDB
│ │ └── 1.json
└── build.gradle
├── settings.gradle
├── .idea
├── .gitignore
├── compiler.xml
├── vcs.xml
├── google-java-format.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── runConfigurations.xml
├── misc.xml
├── gradle.xml
└── jarRepositories.xml
├── README
└── preview.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── .circleci
└── config.yml
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = "QuickRoute"
2 | include ':app'
3 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/README/preview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jintin/QuickRoute/HEAD/README/preview.gif
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jintin/QuickRoute/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jintin/QuickRoute/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/google-java-format.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/QuickRouteApp.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class QuickRouteApp : Application()
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/base/ItemComparable.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.base
2 |
3 | interface ItemComparable {
4 | fun areItemsTheSame(target: T): Boolean
5 |
6 | fun areContentsTheSame(target: T): Boolean
7 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 09 19:58:43 CST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/.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 | local.properties
16 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/base/BaseDao.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.base
2 |
3 | import androidx.room.Delete
4 | import androidx.room.Insert
5 | import androidx.room.Update
6 |
7 | interface BaseDao {
8 | @Insert
9 | suspend fun insert(data: T)
10 |
11 | @Delete
12 | suspend fun delete(data: T)
13 |
14 | @Update
15 | suspend fun update(data: T)
16 | }
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/db/ActionDao.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.db
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.room.Dao
5 | import androidx.room.Query
6 | import com.jintin.quickroute.base.BaseDao
7 | import com.jintin.quickroute.data.Action
8 |
9 | @Dao
10 | interface ActionDao : BaseDao {
11 |
12 | @Query("SELECT * FROM `action`")
13 | fun list(): LiveData>
14 |
15 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_done.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/data/AppInfo.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.data
2 |
3 | import com.jintin.quickroute.base.ItemComparable
4 |
5 | data class AppInfo(
6 | var name: String,
7 | val packageName: String
8 | ) : ItemComparable {
9 |
10 | override fun areItemsTheSame(target: AppInfo) = this.packageName == target.packageName
11 |
12 | override fun areContentsTheSame(target: AppInfo) = this == target
13 |
14 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FBC02D
4 | #FFBB86FC
5 | #FF6200EE
6 | #FF3700B3
7 | #FF03DAC5
8 | #FF018786
9 | #FF000000
10 | #FFFFFFFF
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/data/IconUtils.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.base
2 |
3 | import android.content.pm.PackageManager
4 | import android.widget.ImageView
5 | import kotlinx.coroutines.Dispatchers
6 | import kotlinx.coroutines.withContext
7 |
8 | suspend fun PackageManager.loadImage(imageView: ImageView, packageName: String) {
9 | imageView.setImageDrawable(null)
10 | imageView.setImageDrawable(
11 | withContext(Dispatchers.IO) {
12 | getApplicationIcon(packageName)
13 | })
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/base/ItemCallback.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.base
2 |
3 | import androidx.recyclerview.widget.DiffUtil
4 |
5 | class ItemCallback> : DiffUtil.ItemCallback() {
6 |
7 | override fun areItemsTheSame(oldItem: T, newItem: T): Boolean {
8 | return oldItem.areItemsTheSame(newItem)
9 | }
10 |
11 | override fun areContentsTheSame(
12 | oldItem: T,
13 | newItem: T
14 | ): Boolean {
15 | return oldItem.areContentsTheSame(newItem)
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_edit.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/db/QuickRouteDB.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.db
2 |
3 | import androidx.room.Database
4 | import androidx.room.RoomDatabase
5 | import androidx.room.TypeConverter
6 | import androidx.room.TypeConverters
7 | import com.jintin.quickroute.data.Action
8 |
9 | @Database(entities = [Action::class], version = 1, exportSchema = true)
10 | abstract class QuickRouteDB : RoomDatabase() {
11 |
12 | companion object {
13 | const val NAME = "QuickRouteDB"
14 | }
15 |
16 | abstract fun actionDao(): ActionDao
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/menu/extra.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/action/ActionListViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.action
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import com.jintin.quickroute.data.Action
6 | import com.jintin.quickroute.db.ActionDao
7 | import dagger.hilt.android.lifecycle.HiltViewModel
8 | import kotlinx.coroutines.launch
9 | import javax.inject.Inject
10 |
11 | @HiltViewModel
12 | class ActionListViewModel @Inject constructor(
13 | private val actionDao: ActionDao
14 | ) : ViewModel() {
15 | val liveData = actionDao.list()
16 |
17 | fun delete(data: Action) {
18 | viewModelScope.launch {
19 | actionDao.delete(data)
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QuickRoute
2 |
3 | [](https://circleci.com/gh/Jintin/QuickRoute)
4 |
5 | Using Quick Settings Tile to navigate to Developer options page without click a lot of buttons.
6 |
7 | ## Preview
8 |
9 | 
10 |
11 | ## Install
12 |
13 | 1. Can install from Google Play directly [here](https://play.google.com/store/apps/details?id=com.jintin.quickroute).
14 |
15 | 2. Pull the source and run on your own device.
16 |
17 | ## Contributing
18 |
19 | Bug reports and pull requests are welcome on GitHub at .
20 |
21 | ## License
22 |
23 | **QuickRoute** is released under Apache License 2.0.
24 | See [LICENSE](https://github.com/Jintin/QuickRoute/blob/master/LICENSE) for more details.
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/AppModule.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute
2 |
3 | import android.app.Application
4 | import androidx.room.Room
5 | import com.jintin.quickroute.db.QuickRouteDB
6 | import com.jintin.quickroute.db.ActionDao
7 | import dagger.Module
8 | import dagger.Provides
9 | import dagger.hilt.InstallIn
10 | import dagger.hilt.components.SingletonComponent
11 | import javax.inject.Singleton
12 |
13 | @InstallIn(SingletonComponent::class)
14 | @Module
15 | class AppModule {
16 |
17 | @Singleton
18 | @Provides
19 | fun provideDB(application: Application): QuickRouteDB {
20 | return Room.databaseBuilder(
21 | application,
22 | QuickRouteDB::class.java,
23 | QuickRouteDB.NAME
24 | ).build()
25 | }
26 |
27 | @Provides
28 | fun provideActionDao(db: QuickRouteDB): ActionDao {
29 | return db.actionDao()
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/db/ActionConverter.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.db
2 |
3 | import androidx.room.TypeConverter
4 | import com.jintin.quickroute.data.Extra
5 | import org.json.JSONArray
6 |
7 | class ActionConverter {
8 |
9 | @TypeConverter
10 | fun convert(list: List): String {
11 | val array = JSONArray()
12 | list.forEach {
13 | array.put("${it.name},${it.value},${it.type.ordinal}")
14 | }
15 | return array.toString()
16 | }
17 |
18 | @TypeConverter
19 | fun convert(string: String): List {
20 | val array = JSONArray(string)
21 | val list = mutableListOf()
22 | for (i in 0 until array.length()) {
23 | val values = array.optString(i, "")
24 | .split(",")
25 | list.add(Extra(values[0], values[1], Extra.Type.values()[values[2].toInt()]))
26 | }
27 | return list
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/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 |
23 | -keepclassmembers class * implements androidx.viewbinding.ViewBinding {
24 | public static ** inflate(...);
25 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/data/Action.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.data
2 |
3 | import android.os.Parcelable
4 | import androidx.room.Entity
5 | import androidx.room.PrimaryKey
6 | import androidx.room.TypeConverters
7 | import com.jintin.quickroute.base.ItemComparable
8 | import com.jintin.quickroute.db.ActionConverter
9 | import kotlinx.parcelize.Parcelize
10 |
11 | @TypeConverters(ActionConverter::class)
12 | @Parcelize
13 | @Entity(tableName = "action")
14 | data class Action(
15 | val name: String,
16 | val actName: String,
17 | val packageName: String,
18 | val extras: List = listOf(),
19 | @PrimaryKey(autoGenerate = true)
20 | var id: Int = 0,
21 | ) : ItemComparable, Parcelable {
22 |
23 | override fun areItemsTheSame(target: Action): Boolean {
24 | return id == target.id
25 | }
26 |
27 | override fun areContentsTheSame(target: Action): Boolean {
28 | return this == target
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_dev_options.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
13 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/data/IntentUtils.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.data
2 |
3 | import android.content.Intent
4 |
5 | fun Action.createIntent(): Intent {
6 | return Intent().setClassName(packageName, actName)
7 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
8 | .also { intent ->
9 | extras.map {
10 | it.fillExtra(intent)
11 | }
12 | }
13 | }
14 |
15 | fun Extra.fillExtra(intent: Intent) {
16 | when (this.type) {
17 | Extra.Type.STRING -> intent.putExtra(name, value)
18 | Extra.Type.INT -> intent.putExtra(name, value.toInt())
19 | Extra.Type.FLOAT -> intent.putExtra(name, value.toFloat())
20 | Extra.Type.BYTE -> intent.putExtra(name, value.toByte())
21 | Extra.Type.CHAR -> intent.putExtra(name, value.single())
22 | Extra.Type.LONG -> intent.putExtra(name, value.toLong())
23 | Extra.Type.SHORT -> intent.putExtra(name, value.toShort())
24 | Extra.Type.DOUBLE -> intent.putExtra(name, value.toDouble())
25 | Extra.Type.BOOLEAN -> intent.putExtra(name, value.toBoolean())
26 | }
27 | }
--------------------------------------------------------------------------------
/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=-Xmx2048m -Dfile.encoding=UTF-8
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 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
--------------------------------------------------------------------------------
/app/src/main/res/layout/adapter_act.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/DevRouteService.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute
2 |
3 | import android.content.Intent
4 | import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
5 | import android.provider.Settings
6 | import android.service.quicksettings.TileService
7 | import android.widget.Toast
8 |
9 | class DevRouteService : TileService() {
10 |
11 | override fun onClick() {
12 | super.onClick()
13 | val adb = Settings.Secure.getInt(
14 | this.contentResolver,
15 | Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
16 | 0
17 | )
18 | if (adb == 1) {
19 | startActivityAndCollapse(getIntent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS))
20 | } else {
21 | startActivityAndCollapse(getIntent(Settings.ACTION_SETTINGS))
22 | Toast.makeText(
23 | applicationContext,
24 | R.string.dev_not_enable_msg,
25 | Toast.LENGTH_SHORT
26 | ).show()
27 | }
28 | }
29 |
30 | private fun getIntent(action: String): Intent {
31 | return Intent(action).apply {
32 | flags = FLAG_ACTIVITY_NEW_TASK
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/select/ActListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.select
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.ListAdapter
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.jintin.bindingextension.toBinding
7 | import com.jintin.quickroute.base.ItemCallback
8 | import com.jintin.quickroute.data.Action
9 | import com.jintin.quickroute.databinding.AdapterActBinding
10 |
11 | class ActListAdapter(
12 | private val onSelectListener: (Action) -> Unit
13 | ) : ListAdapter(ItemCallback()) {
14 |
15 | inner class ViewHolder(private val binding: AdapterActBinding) :
16 | RecyclerView.ViewHolder(binding.root) {
17 |
18 | fun bind(data: Action) {
19 | binding.name.text = data.actName
20 | binding.root.setOnClickListener {
21 | onSelectListener.invoke(data)
22 | }
23 | }
24 | }
25 |
26 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
27 | ViewHolder(parent.toBinding())
28 |
29 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
30 | holder.bind(getItem(position))
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_app.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/base/RecyclerViewUtils.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.base
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.RecyclerView
5 |
6 |
7 | fun RecyclerView.Adapter<*>.bindEmptyView(view: View) {
8 |
9 | fun updateEmptyViewVisibility() {
10 | view.visibility = if (itemCount == 0) {
11 | View.VISIBLE
12 | } else {
13 | View.GONE
14 | }
15 | }
16 |
17 | updateEmptyViewVisibility()
18 |
19 | registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
20 | override fun onChanged() {
21 | updateEmptyViewVisibility()
22 | }
23 |
24 | override fun onItemRangeChanged(positionStart: Int, itemCount: Int) {
25 | updateEmptyViewVisibility()
26 | }
27 |
28 | override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
29 | updateEmptyViewVisibility()
30 | }
31 |
32 | override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
33 | updateEmptyViewVisibility()
34 | }
35 |
36 | override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) {
37 | updateEmptyViewVisibility()
38 | }
39 | })
40 |
41 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | QuickRoute
3 | Developer options
4 | "Need enable developer options first"
5 | Add
6 | Done
7 | Remove
8 | Apply
9 | Extra Name
10 | Type
11 | Value
12 | Action List
13 | Select App
14 | Select Activity
15 | Modify Extra
16 | Tutorial
17 | Delete
18 | Modify
19 | There\'s no action to launch yet, click add to create one!
20 | There\'s no Activity yet
21 | There\'s no Extra yet
22 | Not able to launch this Activity
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_act.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_extra.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/extra/ExtraListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.extra
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.ViewGroup
5 | import androidx.recyclerview.widget.ListAdapter
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.jintin.bindingextension.toBinding
8 | import com.jintin.quickroute.base.ItemCallback
9 | import com.jintin.quickroute.data.Extra
10 | import com.jintin.quickroute.databinding.AdapterExtraBinding
11 |
12 | class ExtraListAdapter(private val onSelectListener: (Extra) -> Unit) :
13 | ListAdapter(ItemCallback()) {
14 |
15 | inner class ViewHolder(private val binding: AdapterExtraBinding) :
16 | RecyclerView.ViewHolder(binding.root) {
17 |
18 | @SuppressLint("SetTextI18n")
19 | fun bind(data: Extra) {
20 | binding.name.text = data.name
21 | binding.value.text = data.value
22 | binding.type.text = "${data.type.label}:"
23 | binding.root.setOnClickListener {
24 | onSelectListener.invoke(data)
25 | }
26 | }
27 | }
28 |
29 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
30 | ViewHolder(parent.toBinding())
31 |
32 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
33 | holder.bind(getItem(position))
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/extra/EditDialogViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.extra
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import com.jintin.quickroute.data.Extra
7 | import javax.inject.Inject
8 |
9 | class EditDialogViewModel @Inject constructor() : ViewModel() {
10 |
11 | private val _validateLiveData = MutableLiveData()
12 | val validateLiveData: LiveData
13 | get() = _validateLiveData
14 |
15 | private var name: String? = null
16 | private var type: Extra.Type? = null
17 | private var value: String? = null
18 |
19 | fun setExtra(extra: Extra?) {
20 | name = extra?.name
21 | type = extra?.type
22 | value = extra?.value
23 | validate()
24 | }
25 |
26 | fun setName(value: String) {
27 | this.name = value
28 | validate()
29 | }
30 |
31 | fun setType(value: String) {
32 | this.type = Extra.Type.getType(value)
33 | validate()
34 | }
35 |
36 | fun setValue(value: String) {
37 | this.value = value
38 | validate()
39 | }
40 |
41 | fun validate() {
42 | if (name == null || name?.length == 0) {
43 | _validateLiveData.value = false
44 | return
45 | }
46 | _validateLiveData.value = type?.isValid(value) ?: false
47 | }
48 | }
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/select/AppListViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.select
2 |
3 | import android.app.Application
4 | import android.content.pm.PackageManager
5 | import androidx.lifecycle.AndroidViewModel
6 | import androidx.lifecycle.LiveData
7 | import androidx.lifecycle.MutableLiveData
8 | import androidx.lifecycle.viewModelScope
9 | import com.jintin.quickroute.data.AppInfo
10 | import dagger.hilt.android.lifecycle.HiltViewModel
11 | import kotlinx.coroutines.*
12 | import javax.inject.Inject
13 |
14 | @HiltViewModel
15 | class AppListViewModel @Inject constructor(app: Application) : AndroidViewModel(app) {
16 |
17 | private val _liveDate = MutableLiveData>()
18 | val liveData: LiveData>
19 | get() = _liveDate
20 |
21 | init {
22 | viewModelScope.launch {
23 | _liveDate.value = getList(app.packageManager)
24 | }
25 | }
26 |
27 | private suspend fun getList(packageManager: PackageManager) = withContext(Dispatchers.IO) {
28 | packageManager.getInstalledApplications(PackageManager.GET_META_DATA)
29 | .filter { packageManager.getLaunchIntentForPackage(it.packageName) != null }
30 | .parallelMap {
31 | AppInfo(
32 | packageManager.getApplicationLabel(it).toString(),
33 | it.packageName,
34 | )
35 | }
36 | }
37 |
38 |
39 | private suspend fun Iterable.parallelMap(f: suspend (A) -> B): List =
40 | coroutineScope {
41 | map { async { f(it) } }.awaitAll()
42 | }
43 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/select/AppListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.select
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import androidx.activity.viewModels
7 | import androidx.lifecycle.lifecycleScope
8 | import androidx.recyclerview.widget.LinearLayoutManager
9 | import com.jintin.bindingextension.BindingActivity
10 | import com.jintin.quickroute.base.bindEmptyView
11 | import com.jintin.quickroute.data.AppInfo
12 | import com.jintin.quickroute.databinding.ActivityAppBinding
13 | import dagger.hilt.android.AndroidEntryPoint
14 |
15 | @AndroidEntryPoint
16 | class AppListActivity : BindingActivity() {
17 |
18 | companion object {
19 | fun start(context: Context) {
20 | context.startActivity(Intent(context, AppListActivity::class.java))
21 | }
22 | }
23 |
24 | private val viewModel by viewModels()
25 |
26 | override fun onCreate(savedInstanceState: Bundle?) {
27 | super.onCreate(savedInstanceState)
28 |
29 | val adapter = AppListAdapter(packageManager, lifecycleScope, ::onSelect)
30 | adapter.bindEmptyView(binding.progressBar)
31 | binding.recyclerView.layoutManager =
32 | LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
33 | binding.recyclerView.adapter = adapter
34 | viewModel.liveData.observe(this) {
35 | adapter.submitList(it)
36 | }
37 | }
38 |
39 | private fun onSelect(info: AppInfo) {
40 | ActListActivity.start(this, info.name, info.packageName)
41 | }
42 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/adapter_app.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/select/ActListViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.select
2 |
3 | import android.app.Application
4 | import android.content.pm.PackageManager
5 | import androidx.lifecycle.AndroidViewModel
6 | import androidx.lifecycle.LiveData
7 | import androidx.lifecycle.MutableLiveData
8 | import androidx.lifecycle.viewModelScope
9 | import com.jintin.quickroute.data.Action
10 | import com.jintin.quickroute.db.ActionDao
11 | import dagger.hilt.android.lifecycle.HiltViewModel
12 | import kotlinx.coroutines.launch
13 | import javax.inject.Inject
14 |
15 | @HiltViewModel
16 | class ActListViewModel @Inject constructor(
17 | app: Application,
18 | private val actionDao: ActionDao
19 | ) : AndroidViewModel(app) {
20 |
21 | private val _liveData = MutableLiveData>()
22 | val liveData: LiveData>
23 | get() = _liveData
24 |
25 | fun getList(appName: String, packageName: String) {
26 | try {
27 | _liveData.value = getApplication()
28 | .packageManager
29 | .getPackageInfo(
30 | packageName,
31 | PackageManager.GET_ACTIVITIES
32 | ).activities
33 | .filter { it.exported }
34 | .map {
35 | Action(appName, it.name, it.packageName)
36 | }
37 | } catch (e: PackageManager.NameNotFoundException) {
38 | e.printStackTrace()
39 | }
40 | }
41 |
42 | fun add(action: Action) {
43 | viewModelScope.launch {
44 | actionDao.insert(action)
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/select/AppListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.select
2 |
3 | import android.content.pm.PackageManager
4 | import android.view.ViewGroup
5 | import androidx.recyclerview.widget.ListAdapter
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.jintin.bindingextension.toBinding
8 | import com.jintin.quickroute.base.ItemCallback
9 | import com.jintin.quickroute.base.loadImage
10 | import com.jintin.quickroute.data.AppInfo
11 | import com.jintin.quickroute.databinding.AdapterAppBinding
12 | import kotlinx.coroutines.CoroutineScope
13 | import kotlinx.coroutines.Job
14 | import kotlinx.coroutines.launch
15 |
16 | class AppListAdapter(
17 | private val packageManager: PackageManager,
18 | private val lifecycleScope: CoroutineScope,
19 | private val onSelectListener: (AppInfo) -> Unit
20 | ) : ListAdapter(ItemCallback()) {
21 |
22 | inner class ViewHolder(private val binding: AdapterAppBinding) :
23 | RecyclerView.ViewHolder(binding.root) {
24 | private var job: Job? = null
25 |
26 | fun bind(data: AppInfo) {
27 | job?.cancel()
28 | job = lifecycleScope.launch {
29 | packageManager.loadImage(binding.icon, data.packageName)
30 | }
31 | binding.name.text = data.name
32 | binding.root.setOnClickListener { onSelectListener.invoke(data) }
33 | }
34 | }
35 |
36 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
37 | ViewHolder(parent.toBinding())
38 |
39 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
40 | holder.bind(getItem(position))
41 | }
42 | }
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Use the latest 2.1 version of CircleCI pipeline process engine.
2 | # See: https://circleci.com/docs/2.0/configuration-reference
3 | version: 2.1
4 |
5 | # Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
6 | orbs:
7 | android: circleci/android@1.0.3
8 |
9 | jobs:
10 | # Below is the definition of your job to build and test your app, you can rename and customize it as you want.
11 | build-and-test:
12 | # These next lines define the Android machine image executor: https://circleci.com/docs/2.0/executor-types/
13 | executor:
14 | name: android/android-machine
15 |
16 | steps:
17 | # Checkout the code as the first step.
18 | - checkout
19 |
20 | # The next step will run the unit tests
21 | - android/run-tests:
22 | test-command: ./gradlew lint testDebug --continue
23 |
24 | # Then start the emulator and run the Instrumentation tests!
25 | - android/start-emulator-and-run-tests:
26 | test-command: ./gradlew connectedDebugAndroidTest
27 | system-image: system-images;android-25;google_apis;x86
28 |
29 | # And finally run the release build
30 | - run:
31 | name: Assemble release build
32 | command: |
33 | ./gradlew assembleRelease
34 |
35 | workflows:
36 | # Below is the definition of your workflow.
37 | # Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.
38 | # CircleCI will run this workflow on every commit.
39 | # For more details on extending your workflow, see the configuration docs: https://circleci.com/docs/2.0/configuration-reference/#workflows
40 | sample:
41 | jobs:
42 | - build-and-test
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_action_sheet.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
22 |
23 |
38 |
--------------------------------------------------------------------------------
/app/schemas/com.jintin.quickroute.db.QuickRouteDB/1.json:
--------------------------------------------------------------------------------
1 | {
2 | "formatVersion": 1,
3 | "database": {
4 | "version": 1,
5 | "identityHash": "4cf40248155d926465d4f51835706998",
6 | "entities": [
7 | {
8 | "tableName": "action",
9 | "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `actName` TEXT NOT NULL, `packageName` TEXT NOT NULL, `extras` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
10 | "fields": [
11 | {
12 | "fieldPath": "name",
13 | "columnName": "name",
14 | "affinity": "TEXT",
15 | "notNull": true
16 | },
17 | {
18 | "fieldPath": "actName",
19 | "columnName": "actName",
20 | "affinity": "TEXT",
21 | "notNull": true
22 | },
23 | {
24 | "fieldPath": "packageName",
25 | "columnName": "packageName",
26 | "affinity": "TEXT",
27 | "notNull": true
28 | },
29 | {
30 | "fieldPath": "extras",
31 | "columnName": "extras",
32 | "affinity": "TEXT",
33 | "notNull": true
34 | },
35 | {
36 | "fieldPath": "id",
37 | "columnName": "id",
38 | "affinity": "INTEGER",
39 | "notNull": true
40 | }
41 | ],
42 | "primaryKey": {
43 | "columnNames": [
44 | "id"
45 | ],
46 | "autoGenerate": true
47 | },
48 | "indices": [],
49 | "foreignKeys": []
50 | }
51 | ],
52 | "views": [],
53 | "setupQueries": [
54 | "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
55 | "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '4cf40248155d926465d4f51835706998')"
56 | ]
57 | }
58 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/adapter_extra.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
23 |
31 |
32 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_action.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
29 |
30 |
35 |
36 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/extra/ExtraListViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.extra
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import com.jintin.quickroute.data.Action
8 | import com.jintin.quickroute.data.Extra
9 | import com.jintin.quickroute.db.ActionDao
10 | import dagger.hilt.android.lifecycle.HiltViewModel
11 | import kotlinx.coroutines.launch
12 | import javax.inject.Inject
13 |
14 | @HiltViewModel
15 | class ExtraListViewModel @Inject constructor(private val actionDao: ActionDao) : ViewModel() {
16 |
17 | private val _liveData = MutableLiveData>()
18 | val liveData: LiveData>
19 | get() = _liveData
20 | private lateinit var data: Action
21 | private var newCreate: Boolean = false
22 | private var list = mutableListOf()
23 |
24 | fun setData(data: Action, newCreate: Boolean) {
25 | this.data = data
26 | this.newCreate = newCreate
27 | list = data.extras.toMutableList()
28 | setValue()
29 | }
30 |
31 | fun applyAction(afterAction: () -> Unit) {
32 | viewModelScope.launch {
33 | data.copy(extras = list).apply {
34 | if (newCreate) {
35 | actionDao.insert(this)
36 | } else {
37 | actionDao.update(this)
38 | }
39 | afterAction()
40 | }
41 | }
42 | }
43 |
44 | fun remove(extra: Extra) {
45 | list.remove(extra)
46 | setValue()
47 | }
48 |
49 | fun add(extra: Extra) {
50 | list.add(extra)
51 | setValue()
52 | }
53 |
54 | fun update(oldData: Extra, newData: Extra) {
55 | list[list.indexOf(oldData)] = newData
56 | setValue()
57 | }
58 |
59 | fun setValue() {
60 | _liveData.value = list.toList()
61 | }
62 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
34 |
37 |
38 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/action/ActionListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.action
2 |
3 | import android.content.pm.PackageManager
4 | import android.view.ViewGroup
5 | import androidx.recyclerview.widget.ListAdapter
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.jintin.bindingextension.toBinding
8 | import com.jintin.quickroute.base.ItemCallback
9 | import com.jintin.quickroute.base.loadImage
10 | import com.jintin.quickroute.data.Action
11 | import com.jintin.quickroute.databinding.AdapterActionBinding
12 | import kotlinx.coroutines.CoroutineScope
13 | import kotlinx.coroutines.Job
14 | import kotlinx.coroutines.launch
15 |
16 | class ActionListAdapter(
17 | private val packageManager: PackageManager,
18 | private val lifecycleScope: CoroutineScope,
19 | private val onSelectListener: (Action) -> Unit,
20 | private val onActionListener: (Action) -> Unit
21 | ) : ListAdapter(ItemCallback()) {
22 |
23 | inner class ViewHolder(
24 | private val binding: AdapterActionBinding
25 | ) : RecyclerView.ViewHolder(binding.root) {
26 |
27 | private var job: Job? = null
28 |
29 | fun bind(data: Action) {
30 | job?.cancel()
31 | job = lifecycleScope.launch {
32 | packageManager.loadImage(binding.icon, data.packageName)
33 | }
34 |
35 | binding.name.text = data.name
36 | binding.act.text = data.actName
37 | binding.root.setOnClickListener {
38 | onSelectListener.invoke(data)
39 | }
40 | binding.root.setOnLongClickListener {
41 | onActionListener.invoke(data)
42 | true
43 | }
44 | }
45 | }
46 |
47 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
48 | ViewHolder(parent.toBinding())
49 |
50 |
51 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
52 | holder.bind(getItem(position))
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/action/SelectActionBottomSheet.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.action
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.view.View
6 | import com.jintin.bindingextension.BindingBottomSheetDialogFragment
7 | import com.jintin.quickroute.data.Action
8 | import com.jintin.quickroute.databinding.FragmentActionSheetBinding
9 |
10 | class SelectActionBottomSheet : BindingBottomSheetDialogFragment() {
11 |
12 | interface OnActionListener {
13 | fun onDelete(data: Action)
14 |
15 | fun onModify(data: Action)
16 | }
17 |
18 | companion object {
19 | const val EXTRA_ACTION = "extra_action"
20 |
21 | fun newInstance(data: Action): SelectActionBottomSheet {
22 | val fragment = SelectActionBottomSheet()
23 | fragment.arguments = Bundle().apply {
24 | putParcelable(EXTRA_ACTION, data)
25 | }
26 | return fragment
27 | }
28 | }
29 |
30 | private var listener: OnActionListener? = null
31 | private lateinit var data: Action
32 |
33 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
34 | super.onViewCreated(view, savedInstanceState)
35 | data = arguments?.getParcelable(EXTRA_ACTION)
36 | ?: throw RuntimeException("Should pass ${Action::class} for ${this::class} select")
37 | binding.delete.setOnClickListener {
38 | listener?.onDelete(data)
39 | dismiss()
40 | }
41 | binding.modify.setOnClickListener {
42 | listener?.onModify(data)
43 | dismiss()
44 | }
45 | }
46 |
47 | override fun onAttach(context: Context) {
48 | super.onAttach(context)
49 | listener = context as? OnActionListener
50 | ?: throw RuntimeException("Should implement ${OnActionListener::class}")
51 | }
52 |
53 | override fun onDetach() {
54 | super.onDetach()
55 | listener = null
56 | }
57 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/adapter_action.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
35 |
36 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/select/ActListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.select
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import androidx.activity.viewModels
7 | import androidx.recyclerview.widget.LinearLayoutManager
8 | import com.jintin.bindingextension.BindingActivity
9 | import com.jintin.quickroute.base.bindEmptyView
10 | import com.jintin.quickroute.data.Action
11 | import com.jintin.quickroute.databinding.ActivityActBinding
12 | import com.jintin.quickroute.extra.ExtraListActivity
13 | import dagger.hilt.android.AndroidEntryPoint
14 |
15 | @AndroidEntryPoint
16 | class ActListActivity : BindingActivity() {
17 |
18 | companion object {
19 | const val EXTRA_NAME = "extra_name"
20 | const val EXTRA_PACKAGE = "extra_package"
21 |
22 | fun start(context: Context, appName: String, packageName: String) {
23 | context.startActivity(
24 | Intent(context, ActListActivity::class.java)
25 | .putExtra(EXTRA_NAME, appName)
26 | .putExtra(EXTRA_PACKAGE, packageName)
27 | )
28 | }
29 | }
30 |
31 | private val viewModel by viewModels()
32 |
33 | override fun onCreate(savedInstanceState: Bundle?) {
34 | super.onCreate(savedInstanceState)
35 |
36 | val appName =
37 | intent.getStringExtra(EXTRA_NAME) ?: throw RuntimeException("")
38 | val packageName =
39 | intent.getStringExtra(EXTRA_PACKAGE) ?: throw RuntimeException("")
40 |
41 | val adapter = ActListAdapter(::onSelect)
42 | adapter.bindEmptyView(binding.emptyView)
43 | binding.recyclerView.layoutManager =
44 | LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
45 | binding.recyclerView.adapter = adapter
46 |
47 | viewModel.getList(appName, packageName)
48 | viewModel.liveData.observe(this) {
49 | adapter.submitList(it)
50 | }
51 | }
52 |
53 | private fun onSelect(action: Action) {
54 | ExtraListActivity.start(this, action, true)
55 | }
56 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/data/Extra.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.data
2 |
3 | import android.os.Parcelable
4 | import com.jintin.quickroute.base.ItemComparable
5 | import kotlinx.parcelize.Parcelize
6 |
7 | @Parcelize
8 | data class Extra(
9 | val name: String,
10 | val value: String,
11 | val type: Type
12 | ) : Parcelable, ItemComparable {
13 |
14 | enum class Type {
15 | STRING, INT, BYTE, CHAR, LONG, FLOAT, SHORT, DOUBLE, BOOLEAN;
16 |
17 | val label: String
18 | get() = when (this) {
19 | STRING -> "String"
20 | INT -> "Int"
21 | FLOAT -> "Float"
22 | BYTE -> "Byte"
23 | CHAR -> "Char"
24 | LONG -> "Long"
25 | SHORT -> "Short"
26 | DOUBLE -> "Double"
27 | BOOLEAN -> "Boolean"
28 | }
29 |
30 | fun isValid(value: String?): Boolean {
31 | if (value == null) {
32 | return false
33 | }
34 | return when (this) {
35 | STRING -> value.isNotEmpty()
36 | INT -> value.toIntOrNull() != null
37 | FLOAT -> value.toFloatOrNull() != null
38 | BYTE -> value.toByteOrNull() != null
39 | CHAR -> value.singleOrNull() != null
40 | LONG -> value.toLongOrNull() != null
41 | SHORT -> value.toShortOrNull() != null
42 | DOUBLE -> value.toDoubleOrNull() != null
43 | BOOLEAN -> true
44 | }
45 | }
46 |
47 | companion object {
48 | fun getType(string: String): Type? {
49 | return when (string) {
50 | "String" -> STRING
51 | "Int" -> INT
52 | "Float" -> FLOAT
53 | "Byte" -> BYTE
54 | "Char" -> CHAR
55 | "Long" -> LONG
56 | "Short" -> SHORT
57 | "Double" -> DOUBLE
58 | "Boolean" -> BOOLEAN
59 | else -> null
60 | }
61 | }
62 | }
63 | }
64 |
65 | override fun areItemsTheSame(target: Extra): Boolean {
66 | return name == target.name
67 | }
68 |
69 | override fun areContentsTheSame(target: Extra): Boolean {
70 | return this == target
71 | }
72 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | id 'kotlin-kapt'
5 | id 'kotlin-parcelize'
6 | id 'dagger.hilt.android.plugin'
7 | }
8 |
9 | android {
10 | compileSdkVersion 30
11 | buildToolsVersion "30.0.3"
12 |
13 | buildFeatures {
14 | viewBinding = true
15 | }
16 |
17 | defaultConfig {
18 | applicationId "com.jintin.quickroute"
19 | minSdkVersion 24
20 | targetSdkVersion 30
21 | versionCode 4
22 | versionName "2.0"
23 |
24 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
25 | javaCompileOptions {
26 | annotationProcessorOptions {
27 | arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
28 | }
29 | }
30 |
31 | }
32 |
33 | buildTypes {
34 | release {
35 | minifyEnabled true
36 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
37 | }
38 | }
39 | compileOptions {
40 | sourceCompatibility JavaVersion.VERSION_1_8
41 | targetCompatibility JavaVersion.VERSION_1_8
42 | }
43 | kotlinOptions {
44 | jvmTarget = '1.8'
45 | }
46 | }
47 |
48 | dependencies {
49 | implementation 'androidx.core:core-ktx:1.5.0'
50 | implementation 'androidx.appcompat:appcompat:1.3.0'
51 | implementation 'androidx.recyclerview:recyclerview:1.2.1'
52 | implementation 'androidx.activity:activity-ktx:1.2.3'
53 | implementation 'androidx.fragment:fragment-ktx:1.3.5'
54 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
55 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
56 | implementation "androidx.room:room-ktx:2.3.0"
57 | kapt "androidx.room:room-compiler:2.3.0"
58 |
59 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
60 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
61 |
62 | implementation 'com.google.android.material:material:1.3.0'
63 | implementation "com.google.dagger:hilt-android:$hilt_version"
64 | kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
65 |
66 | implementation 'com.github.jintin:BindingExtension:3.1.0'
67 |
68 | testImplementation 'junit:junit:4.13.2'
69 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
70 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
71 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/action/ActionListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.action
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP
6 | import android.os.Bundle
7 | import android.view.Menu
8 | import android.view.MenuItem
9 | import android.widget.Toast
10 | import androidx.activity.viewModels
11 | import androidx.lifecycle.lifecycleScope
12 | import androidx.recyclerview.widget.LinearLayoutManager
13 | import com.jintin.bindingextension.BindingActivity
14 | import com.jintin.quickroute.R
15 | import com.jintin.quickroute.base.bindEmptyView
16 | import com.jintin.quickroute.data.Action
17 | import com.jintin.quickroute.data.createIntent
18 | import com.jintin.quickroute.databinding.ActivityActionBinding
19 | import com.jintin.quickroute.extra.ExtraListActivity
20 | import com.jintin.quickroute.select.AppListActivity
21 | import dagger.hilt.android.AndroidEntryPoint
22 |
23 | @AndroidEntryPoint
24 | class ActionListActivity : BindingActivity(),
25 | SelectActionBottomSheet.OnActionListener {
26 |
27 | companion object {
28 | fun bringToFront(context: Context) {
29 | context.startActivity(
30 | Intent(context, ActionListActivity::class.java)
31 | .addFlags(FLAG_ACTIVITY_CLEAR_TOP)
32 | )
33 | }
34 | }
35 |
36 | private val viewModel by viewModels()
37 |
38 | override fun onCreate(savedInstanceState: Bundle?) {
39 | super.onCreate(savedInstanceState)
40 |
41 | setTitle(R.string.txt_action_list)
42 | val adapter = ActionListAdapter(
43 | packageManager,
44 | lifecycleScope,
45 | ::onSelect,
46 | ::onAction
47 | )
48 | adapter.bindEmptyView(binding.emptyView)
49 |
50 | binding.addAction.setOnClickListener {
51 | AppListActivity.start(this)
52 | }
53 | binding.recyclerView.layoutManager =
54 | LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
55 | binding.recyclerView.adapter = adapter
56 |
57 | viewModel.liveData.observe(this) {
58 | adapter.submitList(it)
59 | }
60 | }
61 |
62 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
63 | menuInflater.inflate(R.menu.main, menu)
64 | return super.onCreateOptionsMenu(menu)
65 | }
66 |
67 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
68 | if (item.itemId == R.id.menu_add) {
69 | AppListActivity.start(this)
70 | return true
71 | }
72 | return super.onOptionsItemSelected(item)
73 | }
74 |
75 | override fun onDelete(data: Action) {
76 | viewModel.delete(data)
77 | }
78 |
79 | override fun onModify(data: Action) {
80 | ExtraListActivity.start(this, data, false)
81 | }
82 |
83 | private fun onSelect(data: Action) {
84 | try {
85 | startActivity(data.createIntent())
86 | } catch (e: Exception) {
87 | Toast.makeText(this, R.string.txt_not_able_launch, Toast.LENGTH_SHORT).show()
88 | }
89 | }
90 |
91 | private fun onAction(data: Action) {
92 | SelectActionBottomSheet.newInstance(data)
93 | .show(supportFragmentManager, null)
94 | }
95 |
96 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/extra/ExtraListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.extra
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import android.view.Menu
7 | import android.view.MenuItem
8 | import androidx.activity.viewModels
9 | import androidx.recyclerview.widget.LinearLayoutManager
10 | import com.jintin.bindingextension.BindingActivity
11 | import com.jintin.quickroute.R
12 | import com.jintin.quickroute.action.ActionListActivity
13 | import com.jintin.quickroute.base.bindEmptyView
14 | import com.jintin.quickroute.data.Action
15 | import com.jintin.quickroute.data.Extra
16 | import com.jintin.quickroute.databinding.ActivityExtraBinding
17 | import dagger.hilt.android.AndroidEntryPoint
18 |
19 | @AndroidEntryPoint
20 | class ExtraListActivity : BindingActivity(),
21 | EditDialogFragment.OnEditListener {
22 |
23 | companion object {
24 | const val EXTRA_DATA = "extra_data"
25 | const val EXTRA_NEW = "extra_new"
26 |
27 | fun start(context: Context, action: Action, newCreate: Boolean) {
28 | context.startActivity(
29 | Intent(context, ExtraListActivity::class.java)
30 | .putExtra(EXTRA_DATA, action)
31 | .putExtra(EXTRA_NEW, newCreate)
32 | )
33 | }
34 | }
35 |
36 | private val viewModel by viewModels()
37 |
38 | override fun onCreate(savedInstanceState: Bundle?) {
39 | super.onCreate(savedInstanceState)
40 | if (savedInstanceState == null) {
41 | viewModel.setData(
42 | intent.getParcelableExtra(EXTRA_DATA)
43 | ?: throw RuntimeException("Should pass ${Action::class} to edit"),
44 | intent.getBooleanExtra(EXTRA_NEW, false)
45 | )
46 | }
47 |
48 | val adapter = ExtraListAdapter(::onSelect)
49 | adapter.bindEmptyView(binding.emptyView)
50 |
51 | binding.recyclerView.layoutManager =
52 | LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
53 | binding.recyclerView.adapter = adapter
54 |
55 | viewModel.liveData.observe(this) {
56 | adapter.submitList(it)
57 | }
58 | }
59 |
60 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
61 | menuInflater.inflate(R.menu.extra, menu)
62 | return super.onCreateOptionsMenu(menu)
63 | }
64 |
65 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
66 | when (item.itemId) {
67 | R.id.menu_add -> {
68 | EditDialogFragment.newInstance().show(supportFragmentManager, null)
69 | return true
70 | }
71 | R.id.menu_done -> {
72 | onApply()
73 | return true
74 | }
75 | }
76 | return super.onOptionsItemSelected(item)
77 | }
78 |
79 | private fun onSelect(data: Extra) {
80 | EditDialogFragment.newInstance(data).show(supportFragmentManager, null)
81 | }
82 |
83 | private fun onApply() {
84 | viewModel.applyAction {
85 | ActionListActivity.bringToFront(this)
86 | }
87 | }
88 |
89 | override fun onRemoveExtra(data: Extra) {
90 | viewModel.remove(data)
91 | }
92 |
93 | override fun onUpdateExtra(oldData: Extra?, newData: Extra) {
94 | if (oldData == null) {
95 | viewModel.add(newData)
96 | } else {
97 | viewModel.update(oldData, newData)
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_edit_extra.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
25 |
26 |
27 |
36 |
37 |
43 |
44 |
45 |
46 |
56 |
57 |
62 |
63 |
64 |
65 |
75 |
76 |
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jintin/quickroute/extra/EditDialogFragment.kt:
--------------------------------------------------------------------------------
1 | package com.jintin.quickroute.extra
2 |
3 | import android.app.Dialog
4 | import android.content.Context
5 | import android.os.Bundle
6 | import android.view.View
7 | import android.widget.ArrayAdapter
8 | import android.widget.Toast
9 | import androidx.appcompat.app.AlertDialog
10 | import androidx.core.widget.addTextChangedListener
11 | import androidx.fragment.app.DialogFragment
12 | import androidx.fragment.app.viewModels
13 | import com.jintin.quickroute.R
14 | import com.jintin.quickroute.data.Extra
15 | import com.jintin.quickroute.databinding.FragmentEditExtraBinding
16 | import dagger.hilt.android.AndroidEntryPoint
17 |
18 | @AndroidEntryPoint
19 | class EditDialogFragment : DialogFragment() {
20 |
21 | companion object {
22 | const val EXTRA_EXTRA = "extra_extra"
23 |
24 | fun newInstance(
25 | extra: Extra? = null,
26 | ): EditDialogFragment {
27 | val fragment = EditDialogFragment()
28 | val args = Bundle()
29 | args.putParcelable(EXTRA_EXTRA, extra)
30 | fragment.arguments = args
31 | return fragment
32 | }
33 | }
34 |
35 | interface OnEditListener {
36 | fun onRemoveExtra(data: Extra)
37 |
38 | fun onUpdateExtra(oldData: Extra?, newData: Extra)
39 | }
40 |
41 | private val viewModel by viewModels()
42 | private var extra: Extra? = null
43 | private var newCreate = false
44 | private var listener: OnEditListener? = null
45 |
46 | override fun onAttach(context: Context) {
47 | super.onAttach(context)
48 | listener = context as? OnEditListener
49 | ?: throw RuntimeException("Should implement ${OnEditListener::class}")
50 | }
51 |
52 | override fun onDetach() {
53 | super.onDetach()
54 | listener = null
55 | }
56 |
57 | override fun onCreate(savedInstanceState: Bundle?) {
58 | super.onCreate(savedInstanceState)
59 | extra = arguments?.getParcelable(EXTRA_EXTRA)
60 | newCreate = extra == null
61 | }
62 |
63 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
64 | val dialog = AlertDialog.Builder(requireContext())
65 | .setView(createView())
66 | .create()
67 | dialog.setCanceledOnTouchOutside(false)
68 | return dialog
69 | }
70 |
71 | private fun createView(): View {
72 | val binding = FragmentEditExtraBinding.inflate(requireActivity().layoutInflater)
73 | val adapter: ArrayAdapter = ArrayAdapter(
74 | requireContext(),
75 | android.R.layout.simple_dropdown_item_1line,
76 | Extra.Type.values().map { it.label }
77 | )
78 | binding.type.setAdapter(adapter)
79 | extra?.let {
80 | binding.name.setText(it.name)
81 | binding.type.setText(it.type.label, false)
82 | binding.value.setText(it.value)
83 | }
84 | if (newCreate) {
85 | binding.apply.setText(R.string.txt_add)
86 | binding.remove.setText(android.R.string.cancel)
87 | } else {
88 | binding.apply.setText(R.string.txt_apply)
89 | binding.remove.setText(R.string.txt_remove)
90 | }
91 |
92 | binding.apply.setOnClickListener {
93 | val type = Extra.Type.getType(binding.type.text.toString())
94 | if (type == null) {
95 | Toast.makeText(requireContext(), "Type shouldn't be null", Toast.LENGTH_SHORT)
96 | .show()
97 | return@setOnClickListener
98 | }
99 | val newExtra = Extra(
100 | binding.name.text.toString(),
101 | binding.value.text.toString(),
102 | type
103 | )
104 | listener?.onUpdateExtra(extra, newExtra)
105 | dismiss()
106 | }
107 | binding.remove.setOnClickListener {
108 | extra?.let {
109 | listener?.onRemoveExtra(it)
110 | }
111 | dismiss()
112 | }
113 | binding.name.addTextChangedListener {
114 | viewModel.setName(it.toString())
115 | }
116 | binding.type.addTextChangedListener {
117 | viewModel.setType(it.toString())
118 | }
119 | binding.value.addTextChangedListener {
120 | viewModel.setValue(it.toString())
121 | }
122 | viewModel.setExtra(extra)
123 | viewModel.validateLiveData.observe(this) {
124 | binding.apply.isEnabled = it
125 | }
126 | return binding.root
127 | }
128 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 [yyyy] [name of copyright owner]
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 |
--------------------------------------------------------------------------------