Skip to content

Commit

Permalink
Build133
Browse files Browse the repository at this point in the history
  - Improved license verification screen
  - MVVM architecture for license verification
  - Auto focus for keyboards
  - Fixed fuzzy rate dialog issue
  • Loading branch information
Hamza417 committed Aug 9, 2021
1 parent 1ce66cf commit b900a52
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 107 deletions.
4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ android {

compileSdkVersion 30

def appVersionCode = 132
def appVersionCode = 133
def appVersionName = "positional_build_${appVersionCode}_final"

defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.animation.DecelerateInterpolator
import android.widget.Toast
import androidx.core.app.ActivityCompat
Expand Down Expand Up @@ -32,13 +34,14 @@ import app.simple.positional.util.LocationExtension.getLocationStatus
import app.simple.positional.util.LocationPrompt.displayLocationSettingsRequest

class MainActivity : BaseActivity(),
PermissionCallbacks,
BottomSheetSlide,
android.content.SharedPreferences.OnSharedPreferenceChangeListener {
PermissionCallbacks,
BottomSheetSlide,
android.content.SharedPreferences.OnSharedPreferenceChangeListener {

private val defaultPermissionRequestCode = 123
private lateinit var bottomBar: DynamicCornerRecyclerView
private lateinit var bottomBarAdapter: BottomBarAdapter
private val handler = Handler(Looper.getMainLooper())

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -66,7 +69,7 @@ class MainActivity : BaseActivity(),

if (savedInstanceState.isNull()) {
openFragment(FragmentPreferences.getCurrentTag(),
FragmentPreferences.getCurrentPage())
FragmentPreferences.getCurrentPage())
}
}

Expand All @@ -76,7 +79,10 @@ class MainActivity : BaseActivity(),
return
} else {
if (MainPreferences.getShowRatingDialog()) {
Rate().show(supportFragmentManager, "rate")
handler.postDelayed({
Rate.newInstance()
.show(supportFragmentManager, "rate")
}, 1500L)
}
}
}
Expand All @@ -93,9 +99,14 @@ class MainActivity : BaseActivity(),
stopService()
}

override fun onDestroy() {
super.onDestroy()
handler.removeCallbacksAndMessages(null)
}

private fun checkRunTimePermission() {
if (ActivityCompat.checkSelfPermission(applicationContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(applicationContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.checkSelfPermission(applicationContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (MainPreferences.getShowPermissionDialog()) {
val permissionDialog = Permission.newInstance()
permissionDialog.show(supportFragmentManager, "permission_info")
Expand All @@ -115,7 +126,7 @@ class MainActivity : BaseActivity(),
runService()
} else {
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION) &&
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
Toast.makeText(this, R.string.no_location_permission_alert, Toast.LENGTH_LONG).show()
}
}
Expand Down Expand Up @@ -159,41 +170,41 @@ class MainActivity : BaseActivity(),
bottomBar.smoothScrollToPosition(position)
getFragment(tag).let {
supportFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.dialog_in, R.anim.dialog_out)
.replace(R.id.containers, it, tag)
.commit()
.setCustomAnimations(R.anim.dialog_in, R.anim.dialog_out)
.replace(R.id.containers, it, tag)
.commit()
}
}

private fun getFragment(name: String): Fragment {
when (name) {
"clock" -> {
return supportFragmentManager.findFragmentByTag("clock") as Clock?
?: Clock.newInstance()
?: Clock.newInstance()
}
"compass" -> {
return supportFragmentManager.findFragmentByTag("compass") as Compass?
?: Compass.newInstance()
?: Compass.newInstance()
}
"location" -> {
return supportFragmentManager.findFragmentByTag("location") as GPS?
?: GPS.newInstance()
?: GPS.newInstance()
}
"trail" -> {
return supportFragmentManager.findFragmentByTag("trail") as Trail?
?: Trail.newInstance()
?: Trail.newInstance()
}
"level" -> {
return supportFragmentManager.findFragmentByTag("level") as Level?
?: Level.newInstance()
?: Level.newInstance()
}
"settings" -> {
return supportFragmentManager.findFragmentByTag("settings") as AppSettings?
?: AppSettings.newInstance()
?: AppSettings.newInstance()
}
else -> {
return supportFragmentManager.findFragmentByTag("location") as GPS?
?: GPS.newInstance()
?: GPS.newInstance()
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/app/simple/positional/dialogs/app/Rate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,13 @@ class Rate : CustomBottomSheetDialogFragment() {
requireContext().startActivity(webIntent)
}
}

companion object {
fun newInstance(): Rate {
val args = Bundle()
val fragment = Rate()
fragment.arguments = args
return fragment
}
}
}
15 changes: 15 additions & 0 deletions app/src/main/java/app/simple/positional/dialogs/trail/AddMarker.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package app.simple.positional.dialogs.trail

import android.app.ActionBar
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.core.widget.doOnTextChanged
import app.simple.positional.R
Expand Down Expand Up @@ -47,12 +51,23 @@ class AddMarker : CustomDialogFragment() {
nameInputEditText.setText(TrailPreferences.getLastMarkerName())
noteInputEditText.setText(TrailPreferences.getLastMarkerNote())

kotlin.runCatching {
nameInputEditText.requestFocus()
dialog!!.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
}.getOrElse {
nameInputEditText.clearFocus()
}

return view
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

with(requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager) {
showSoftInput(nameInputEditText, InputMethodManager.SHOW_FORCED)
}

nameInputEditText.doOnTextChanged { text, _, _, _ ->
TrailPreferences.setLastMarkerName(text.toString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.EditText
import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.viewModels
Expand Down Expand Up @@ -40,6 +41,13 @@ class AddTrail : CustomDialogFragment() {
nameInputEditText.setText(TrailPreferences.getLastTrailName())
noteInputEditText.setText(TrailPreferences.getLastTrailNote())

kotlin.runCatching {
nameInputEditText.requestFocus()
dialog!!.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
}.getOrElse {
nameInputEditText.clearFocus()
}

return view
}

Expand Down
Loading

0 comments on commit b900a52

Please sign in to comment.