Skip to content

Commit

Permalink
Bump version and remove permission check since we don't need
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Oct 17, 2020
1 parent e65d5ef commit 23ff8e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 39 deletions.
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
xmlns:tools="http://schemas.android.com/tools"
package="space.celestia.mobilecelestia"
android:versionCode="70"
android:versionName="1.0.4">
android:versionName="1.0.5">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="false"
Expand Down
50 changes: 13 additions & 37 deletions app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ package space.celestia.mobilecelestia

import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.PointF
import android.graphics.RectF
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.DocumentsContract
import android.util.Log
import android.view.*
import android.view.DisplayCutout
import android.view.MotionEvent
import android.view.View
import android.view.WindowManager
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.FrameLayout
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.app.ShareCompat
import androidx.core.content.ContextCompat
import androidx.core.graphics.contains
import androidx.fragment.app.Fragment
import com.google.gson.Gson
Expand All @@ -49,7 +49,10 @@ import space.celestia.mobilecelestia.celestia.CelestiaFragment
import space.celestia.mobilecelestia.celestia.CelestiaView
import space.celestia.mobilecelestia.common.Cleanable
import space.celestia.mobilecelestia.common.PoppableFragment
import space.celestia.mobilecelestia.control.*
import space.celestia.mobilecelestia.control.BottomControlFragment
import space.celestia.mobilecelestia.control.CameraControlAction
import space.celestia.mobilecelestia.control.CameraControlContainerFragment
import space.celestia.mobilecelestia.control.CameraControlFragment
import space.celestia.mobilecelestia.core.*
import space.celestia.mobilecelestia.eventfinder.EventFinderContainerFragment
import space.celestia.mobilecelestia.eventfinder.EventFinderInputFragment
Expand All @@ -73,7 +76,6 @@ import java.io.File
import java.io.IOException
import java.lang.ref.WeakReference
import java.util.*
import java.util.concurrent.CountDownLatch
import kotlin.collections.ArrayList
import kotlin.collections.HashMap

Expand Down Expand Up @@ -121,8 +123,6 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),
private var readyForInteraction = false
private var scriptOrURLPath: String? = null

private val permissionCountDownLatch = CountDownLatch(1)

private val celestiaConfigFilePath: String
get() {
val custom = customConfigFilePath
Expand Down Expand Up @@ -216,7 +216,7 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),

firstInstance = false
val disposable = createCopyAssetObservable()
.concatWith(createPermissionObservable())
.concatWith(createCreateExtraFolderObservable())
.concatWith(createLoadConfigObservable())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Expand Down Expand Up @@ -258,16 +258,6 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),
if (hasFocus) hideSystemUI()
}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
if (requestCode != WRITE_DATA_PERMISSION_REQUEST_CODE) return
// We do not care whether we got the permission here, just post notification
permissionCountDownLatch.countDown()
}

private fun hideSystemUI() {
// Enables sticky immersive mode.
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
Expand Down Expand Up @@ -399,18 +389,9 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),
}
}

private fun createPermissionObservable(): Observable<String> {
private fun createCreateExtraFolderObservable(): Observable<String> {
return Observable.create<String> {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
it.onComplete()
return@create
}
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
it.onComplete()
return@create
}
ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), WRITE_DATA_PERMISSION_REQUEST_CODE)
permissionCountDownLatch.await()
createAddonFolder()
it.onComplete()
}
}
Expand Down Expand Up @@ -1072,10 +1053,6 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),
}

override fun onDataLocationRequested(dataType: DataType) {
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// No permission to read
return
}
when (dataType) {
DataType.Config -> {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
Expand Down Expand Up @@ -1422,7 +1399,8 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),
}

companion object {
private const val CURRENT_DATA_VERSION = "14"
private const val CURRENT_DATA_VERSION = "15"
// 15: 1.0.5
// 14: 1.0.4
// 13: 1.0.3
// 12: 1.0.2
Expand All @@ -1443,8 +1421,6 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),

private var firstInstance = true

private const val WRITE_DATA_PERMISSION_REQUEST_CODE = 33

var customDataDirPath: String? = null
var customConfigFilePath: String? = null

Expand Down

0 comments on commit 23ff8e9

Please sign in to comment.