Refine styling

This commit is contained in:
Mygod
2018-07-29 00:39:45 +08:00
parent 430d97d514
commit 6939efed0d
15 changed files with 140 additions and 42 deletions

View File

@@ -1,4 +1,5 @@
# https://github.com/arturbosch/detekt/blob/RC6-4/detekt-cli/src/main/resources/default-detekt-config.yml # https://github.com/arturbosch/detekt/blob/RC8/detekt-cli/src/main/resources/default-detekt-config.yml
autoCorrect: true
comments: comments:
active: false active: false
@@ -46,12 +47,14 @@ complexity:
thresholdInInterfaces: 11 thresholdInInterfaces: 11
thresholdInObjects: 11 thresholdInObjects: 11
thresholdInEnums: 11 thresholdInEnums: 11
ignoreDeprecated: true
ignorePrivate: false
empty-blocks: empty-blocks:
active: true active: true
EmptyCatchBlock: EmptyCatchBlock:
active: true active: true
allowedExceptionNameRegex: "^(_|ignore|expected).*" allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
EmptyClassBlock: EmptyClassBlock:
active: true active: true
EmptyDefaultConstructor: EmptyDefaultConstructor:
@@ -125,6 +128,90 @@ exceptions:
- Throwable - Throwable
- RuntimeException - RuntimeException
formatting:
active: true
android: true
autoCorrect: true
ChainWrapping:
active: true
autoCorrect: true
CommentSpacing:
active: false
Filename:
active: true
FinalNewline:
active: true
autoCorrect: true
ImportOrdering:
active: true
autoCorrect: false
Indentation:
active: true
autoCorrect: true
indentSize: 4
continuationIndentSize: 4
MaximumLineLength:
active: false
ModifierOrdering:
active: true
autoCorrect: true
NoBlankLineBeforeRbrace:
active: true
autoCorrect: true
NoConsecutiveBlankLines:
active: true
autoCorrect: true
NoEmptyClassBody:
active: true
autoCorrect: true
NoItParamInMultilineLambda:
active: true
NoLineBreakAfterElse:
active: true
autoCorrect: true
NoLineBreakBeforeAssignment:
active: true
autoCorrect: true
NoMultipleSpaces:
active: false
NoSemicolons:
active: true
autoCorrect: true
NoTrailingSpaces:
active: true
autoCorrect: true
NoUnitReturn:
active: true
autoCorrect: true
NoUnusedImports:
active: true
autoCorrect: true
NoWildcardImports:
active: false
ParameterListWrapping:
active: false
SpacingAroundColon:
active: true
autoCorrect: true
SpacingAroundComma:
active: true
autoCorrect: true
SpacingAroundCurly:
active: true
autoCorrect: true
SpacingAroundKeyword:
active: true
autoCorrect: true
SpacingAroundOperators:
active: true
autoCorrect: true
SpacingAroundRangeOperator:
active: true
autoCorrect: true
StringTemplate:
active: true
autoCorrect: true
naming: naming:
active: true active: true
ClassNaming: ClassNaming:
@@ -153,14 +240,15 @@ naming:
ObjectPropertyNaming: ObjectPropertyNaming:
active: true active: true
propertyPattern: '[A-Za-z][_A-Za-z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
constantPattern: '[A-Za-z][_A-Za-z0-9]*'
PackageNaming: PackageNaming:
active: true active: true
packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$' packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$'
TopLevelPropertyNaming: TopLevelPropertyNaming:
active: true active: true
constantPattern: '[A-Z][_A-Z0-9]*' constantPattern: '[A-Z][_A-Z0-9]*'
propertyPattern: '[a-z][A-Za-z\d]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '(_)?[a-z][A-Za-z0-9]*' privatePropertyPattern: '(_)?[A-Za-z][A-Za-z0-9]*'
VariableMaxLength: VariableMaxLength:
active: true active: true
maximumVariableNameLength: 64 maximumVariableNameLength: 64
@@ -223,6 +311,7 @@ style:
active: true active: true
ExpressionBodySyntax: ExpressionBodySyntax:
active: true active: true
includeLineWrapping: false
ForbiddenComment: ForbiddenComment:
active: true active: true
values: 'TODO:,FIXME:,STOPSHIP:' values: 'TODO:,FIXME:,STOPSHIP:'
@@ -238,11 +327,14 @@ style:
maxJumpCount: 1 maxJumpCount: 1
MagicNumber: MagicNumber:
active: false active: false
MandatoryBracesIfStatements:
active: false
MaxLineLength: MaxLineLength:
active: true active: true
maxLineLength: 120 maxLineLength: 120
excludePackageStatements: false excludePackageStatements: true
excludeImportStatements: false excludeImportStatements: true
excludeCommentStatements: true
MayBeConst: MayBeConst:
active: true active: true
ModifierOrder: ModifierOrder:
@@ -259,6 +351,8 @@ style:
active: true active: true
OptionalWhenBraces: OptionalWhenBraces:
active: true active: true
PreferToOverPairSyntax:
active: false
ProtectedMemberInFinalClass: ProtectedMemberInFinalClass:
active: true active: true
RedundantVisibilityModifierRule: RedundantVisibilityModifierRule:
@@ -288,9 +382,12 @@ style:
active: true active: true
UnusedPrivateMember: UnusedPrivateMember:
active: true active: true
allowedNames: "(_|ignored|expected|serialVersionUID)"
UseDataClass: UseDataClass:
active: false active: false
UtilityClassWithPublicConstructor: UtilityClassWithPublicConstructor:
active: true active: true
VarCouldBeVal:
active: false
WildcardImport: WildcardImport:
active: false active: false

View File

@@ -3,8 +3,8 @@ package be.mygod.vpnhotspot
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.net.wifi.WifiManager import android.net.wifi.WifiManager
import androidx.annotation.RequiresApi
import android.widget.Toast import android.widget.Toast
import androidx.annotation.RequiresApi
import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.manage.LocalOnlyHotspotManager import be.mygod.vpnhotspot.manage.LocalOnlyHotspotManager
import be.mygod.vpnhotspot.net.IpNeighbourMonitor import be.mygod.vpnhotspot.net.IpNeighbourMonitor

View File

@@ -3,24 +3,24 @@ package be.mygod.vpnhotspot
import android.content.ComponentName import android.content.ComponentName
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import androidx.databinding.DataBindingUtil
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import androidx.browser.customtabs.CustomTabsIntent
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.snackbar.Snackbar
import androidx.fragment.app.Fragment
import androidx.core.content.ContextCompat
import androidx.appcompat.app.AppCompatActivity
import android.view.Gravity import android.view.Gravity
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import be.mygod.vpnhotspot.client.ClientMonitorService import be.mygod.vpnhotspot.client.ClientMonitorService
import be.mygod.vpnhotspot.client.ClientsFragment import be.mygod.vpnhotspot.client.ClientsFragment
import be.mygod.vpnhotspot.databinding.ActivityMainBinding import be.mygod.vpnhotspot.databinding.ActivityMainBinding
import be.mygod.vpnhotspot.manage.TetheringFragment import be.mygod.vpnhotspot.manage.TetheringFragment
import be.mygod.vpnhotspot.util.ServiceForegroundConnector import be.mygod.vpnhotspot.util.ServiceForegroundConnector
import com.google.android.material.bottomnavigation.BottomNavigationMenuView import com.google.android.material.bottomnavigation.BottomNavigationMenuView
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.snackbar.Snackbar
import q.rorbin.badgeview.QBadgeView import q.rorbin.badgeview.QBadgeView
class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener, ServiceConnection { class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener, ServiceConnection {

View File

@@ -10,9 +10,9 @@ import android.net.wifi.p2p.WifiP2pGroup
import android.net.wifi.p2p.WifiP2pInfo import android.net.wifi.p2p.WifiP2pInfo
import android.net.wifi.p2p.WifiP2pManager import android.net.wifi.p2p.WifiP2pManager
import android.os.Looper import android.os.Looper
import androidx.annotation.StringRes
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.annotation.StringRes
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper

View File

@@ -2,17 +2,17 @@ package be.mygod.vpnhotspot.client
import android.content.ComponentName import android.content.ComponentName
import android.content.ServiceConnection import android.content.ServiceConnection
import androidx.databinding.DataBindingUtil
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.databinding.FragmentRepeaterBinding import be.mygod.vpnhotspot.databinding.FragmentRepeaterBinding
import be.mygod.vpnhotspot.databinding.ListitemClientBinding import be.mygod.vpnhotspot.databinding.ListitemClientBinding

View File

@@ -1,9 +1,9 @@
package be.mygod.vpnhotspot.manage package be.mygod.vpnhotspot.manage
import android.content.Intent import android.content.Intent
import android.view.View
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import android.view.View
import be.mygod.vpnhotspot.TetheringService import be.mygod.vpnhotspot.TetheringService
import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding
import be.mygod.vpnhotspot.net.TetherType import be.mygod.vpnhotspot.net.TetherType

View File

@@ -11,10 +11,10 @@ import android.location.LocationManager
import android.os.Build import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.provider.Settings import android.provider.Settings
import androidx.recyclerview.widget.RecyclerView
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import androidx.recyclerview.widget.RecyclerView
import be.mygod.vpnhotspot.LocalOnlyHotspotService import be.mygod.vpnhotspot.LocalOnlyHotspotService
import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding

View File

@@ -3,8 +3,8 @@ package be.mygod.vpnhotspot.manage
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.recyclerview.widget.RecyclerView
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
object ManageBar : Manager() { object ManageBar : Manager() {

View File

@@ -1,10 +1,10 @@
package be.mygod.vpnhotspot.manage package be.mygod.vpnhotspot.manage
import android.annotation.TargetApi import android.annotation.TargetApi
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding
import be.mygod.vpnhotspot.databinding.ListitemRepeaterBinding import be.mygod.vpnhotspot.databinding.ListitemRepeaterBinding
@@ -23,7 +23,7 @@ abstract class Manager {
override fun areItemsTheSame(oldItem: Manager, newItem: Manager) = oldItem.isSameItemAs(newItem) override fun areItemsTheSame(oldItem: Manager, newItem: Manager) = oldItem.isSameItemAs(newItem)
override fun areContentsTheSame(oldItem: Manager, newItem: Manager) = oldItem == newItem override fun areContentsTheSame(oldItem: Manager, newItem: Manager) = oldItem == newItem
fun createViewHolder(inflater: LayoutInflater, parent: ViewGroup, type: Int): RecyclerView.ViewHolder = when (type) { fun createViewHolder(inflater: LayoutInflater, parent: ViewGroup, type: Int) = when (type) {
VIEW_TYPE_INTERFACE -> VIEW_TYPE_INTERFACE ->
InterfaceManager.ViewHolder(ListitemInterfaceBinding.inflate(inflater, parent, false)) InterfaceManager.ViewHolder(ListitemInterfaceBinding.inflate(inflater, parent, false))
VIEW_TYPE_MANAGE -> ManageBar.ViewHolder(inflater.inflate(R.layout.listitem_manage, parent, false)) VIEW_TYPE_MANAGE -> ManageBar.ViewHolder(inflater.inflate(R.layout.listitem_manage, parent, false))

View File

@@ -6,18 +6,18 @@ import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.content.ServiceConnection import android.content.ServiceConnection
import android.content.pm.PackageManager import android.content.pm.PackageManager
import androidx.databinding.DataBindingUtil
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import be.mygod.vpnhotspot.LocalOnlyHotspotService import be.mygod.vpnhotspot.LocalOnlyHotspotService
import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.TetheringService import be.mygod.vpnhotspot.TetheringService

View File

@@ -5,8 +5,8 @@ import android.net.ConnectivityManager
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import androidx.annotation.RequiresApi
import android.util.Log import android.util.Log
import androidx.annotation.RequiresApi
import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.App.Companion.app
import com.android.dx.stock.ProxyBuilder import com.android.dx.stock.ProxyBuilder
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics

View File

@@ -44,7 +44,8 @@ class P2pSupplicantConfiguration(private val initContent: String? = null) : Parc
return try { return try {
val match = pskParser.findAll(content ?: return null).single() val match = pskParser.findAll(content ?: return null).single()
if (match.groups[2] == null && match.groups[3] == null) "" else { if (match.groups[2] == null && match.groups[3] == null) "" else {
val result = match.groupValues[2] + match.groupValues[3] // only one will match and hold non-empty value // only one will match and hold non-empty value
val result = match.groupValues[2] + match.groupValues[3]
check(result.length in 8..63) check(result.length in 8..63)
result result
} }

View File

@@ -1,11 +1,11 @@
package be.mygod.vpnhotspot.preference package be.mygod.vpnhotspot.preference
import androidx.preference.PreferenceDialogFragmentCompat
import androidx.appcompat.widget.AppCompatAutoCompleteTextView
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.widget.AppCompatAutoCompleteTextView
import androidx.preference.PreferenceDialogFragmentCompat
open class AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat : PreferenceDialogFragmentCompat() { open class AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat : PreferenceDialogFragmentCompat() {
companion object { companion object {

View File

@@ -1,14 +1,14 @@
package be.mygod.vpnhotspot.util package be.mygod.vpnhotspot.util
import android.app.Service import android.app.Service
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import kotlin.reflect.KClass import kotlin.reflect.KClass
/** /**

View File

@@ -2,9 +2,9 @@ package be.mygod.vpnhotspot.widget
import android.content.Context import android.content.Context
import android.graphics.Rect import android.graphics.Rect
import androidx.appcompat.widget.AppCompatAutoCompleteTextView
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import androidx.appcompat.widget.AppCompatAutoCompleteTextView
import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.R
/** /**