Skip to content

Commit

Permalink
Merge pull request #1444 from CypherpunkArmory/master
Browse files Browse the repository at this point in the history
Version 2.8.3
  • Loading branch information
corbinlc authored Oct 8, 2021
2 parents be25a39 + 1ad26ab commit 76346d1
Show file tree
Hide file tree
Showing 19 changed files with 263 additions and 75 deletions.
21 changes: 14 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'jacoco'
apply plugin: 'de.undercouch.download'

android {
compileSdkVersion 29
compileSdkVersion 30

defaultConfig {
// Version code is generated as time since June 1, 2019. These allows for constantly
Expand All @@ -22,16 +22,21 @@ android {

applicationId "tech.ula"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode vcode
versionName "2.8.1"
versionName "2.8.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'

vectorDrawables.useSupportLibrary = true
buildConfigField 'boolean', 'ENABLE_PLAY_SERVICES', 'true'

//these are used to help determine the resolution
buildConfigField 'boolean', 'FORCE_PORTRAIT_GEOMETRY', 'true'
buildConfigField 'int', "MAX_DIMENSION", "1280"
buildConfigField 'int', "MIN_DIMENSION", "360"

// Ignore Sentry packages that cause lint failure
lintOptions {
lintConfig file("$projectDir/src/main/resources/lint.xml")
Expand Down Expand Up @@ -200,7 +205,7 @@ ext.architectures = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
ext.libDir = "$project.projectDir/src/main/jniLibs"

task downloadAssets(type: Download) {
def assetVersion = "v1.2.6"
def assetVersion = "v1.2.7"
def baseUrl = "https://github.com/CypherpunkArmory/UserLAnd-Assets-Support/releases/download/$assetVersion"
for (arch in architectures) {
src "$baseUrl/$arch-assets.zip"
Expand Down Expand Up @@ -240,20 +245,20 @@ preBuild.dependsOn checkIfAssetsMissing

dependencies {
def moshi_version = '1.8.0'
def okhttp_version = '3.13.1'
def okhttp_version = '3.14.7'
def sentry_version = '1.7.22'
def slf4j_version = '1.7.26'

def kotlinx_coroutines_version = '1.0.0'
def kotlin_jdk_version = '1.3.31'
def kotlin_jdk_version = '1.3.61'

// Androidx versions
def room_version = '2.1.0-beta01'
def lifecycle_version = '2.2.0-alpha01'
def support_library_version = '1.1.0-alpha06'
def preference_version = '1.1.0-alpha05'
def ktx_version = '1.0.2'
def billing_version = '2.2.1'
def billing_version = '3.0.3'

implementation project(':terminal-term')

Expand Down Expand Up @@ -307,4 +312,6 @@ dependencies {
}
androidTestUtil "androidx.test:orchestrator:$androidx_test_version"

implementation 'com.google.code.gson:gson:2.8.6'

}
15 changes: 15 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="vnc" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="x11" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="ssh" />
</intent>
</queries>

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
Expand Down
41 changes: 35 additions & 6 deletions app/src/main/java/tech/ula/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.net.Uri
import android.net.wifi.WifiManager
import android.os.Build
import android.os.Bundle
import android.os.StatFs
import android.os.* // ktlint-disable no-wildcard-imports
import com.google.android.material.textfield.TextInputEditText
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -33,6 +31,7 @@ import androidx.navigation.Navigation
import androidx.navigation.findNavController
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.NavigationUI.setupWithNavController
import com.google.gson.Gson
import kotlinx.android.synthetic.main.activity_main.* // ktlint-disable no-wildcard-imports
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -58,6 +57,7 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,

private var progressBarIsVisible = false
private var currentFragmentDisplaysProgressDialog = false
private var autoStarted = false

private val logger = SentryLogger()
private val ulaFiles by lazy { UlaFiles(this, this.applicationInfo.nativeLibraryDir) }
Expand Down Expand Up @@ -142,6 +142,14 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
.get(MainActivityViewModel::class.java)
}

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
if (intent?.type.equals("settings"))
navController.navigate(R.id.settings_fragment)
else
autoStart()
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Expand Down Expand Up @@ -173,6 +181,10 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
}

viewModel.getState().observe(this, stateObserver)
if (intent?.type.equals("settings"))
navController.navigate(R.id.settings_fragment)
else
autoStart()
}

private fun setNavStartDestination() {
Expand Down Expand Up @@ -222,6 +234,18 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
return true
}

private fun autoStart() {
val prefs = getSharedPreferences("apps", Context.MODE_PRIVATE)
val json = prefs.getString("AutoApp", " ")
if (json != null)
if (json.compareTo(" ") != 0) {
val gson = Gson()
val autoApp = gson.fromJson(json, App::class.java)
autoStarted = true
appHasBeenSelected(autoApp, true)
}
}

override fun onStart() {
super.onStart()
LocalBroadcastManager.getInstance(this)
Expand Down Expand Up @@ -270,13 +294,13 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
unregisterReceiver(downloadBroadcastReceiver)
}

override fun appHasBeenSelected(app: App) {
override fun appHasBeenSelected(app: App, autoStart: Boolean) {
if (!PermissionHandler.permissionsAreGranted(this)) {
PermissionHandler.showPermissionsNecessaryDialog(this)
viewModel.waitForPermissions(appToContinue = app)
return
}
viewModel.submitAppSelection(app)
viewModel.submitAppSelection(app, autoStart)
}

override fun sessionHasBeenSelected(session: Session) {
Expand Down Expand Up @@ -332,7 +356,7 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
val windowManager = applicationContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager

val orientation = applicationContext.resources.configuration.orientation
deviceDimensions.saveDeviceDimensions(windowManager, DisplayMetrics(), orientation)
deviceDimensions.saveDeviceDimensions(windowManager, DisplayMetrics(), orientation, defaultSharedPreferences)
session.geometry = deviceDimensions.getScreenResolution()
}

Expand All @@ -341,6 +365,11 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
.putExtra("type", "start")
.putExtra("session", session)
startService(serviceIntent)
if (autoStarted) {
Handler(Looper.getMainLooper()).postDelayed({
finish()
}, 2000)
}
}

/*
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/tech/ula/ui/AppDetailsFragment.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tech.ula.ui

import android.app.Activity
import android.content.Context
import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
Expand Down Expand Up @@ -31,7 +32,7 @@ class AppDetailsFragment : Fragment() {
val sessionDao = UlaDatabase.getInstance(activityContext).sessionDao()
val appDetails = AppDetails(activityContext.filesDir.path, activityContext.resources)
val buildVersion = Build.VERSION.SDK_INT
val factory = AppDetailsViewmodelFactory(sessionDao, appDetails, buildVersion)
val factory = AppDetailsViewmodelFactory(sessionDao, appDetails, buildVersion, activityContext.getSharedPreferences("apps", Context.MODE_PRIVATE))
ViewModelProviders.of(this, factory)
.get(AppDetailsViewModel::class.java)
}
Expand All @@ -51,6 +52,7 @@ class AppDetailsFragment : Fragment() {
})
viewModel.submitEvent(AppDetailsEvent.SubmitApp(app))
setupPreferredServiceTypeRadioGroup()
setupAutoStartCheckbox()
}

private fun handleViewStateChange(viewState: AppDetailsViewState) {
Expand All @@ -63,6 +65,8 @@ class AppDetailsFragment : Fragment() {
if (viewState.selectedServiceTypeButton != null) {
apps_service_type_preferences.check(viewState.selectedServiceTypeButton)
}

checkbox_auto_start.setChecked(viewState.autoStartEnabled)
}

private fun handleEnableRadioButtons(viewState: AppDetailsViewState) {
Expand Down Expand Up @@ -95,4 +99,10 @@ class AppDetailsFragment : Fragment() {
viewModel.submitEvent(AppDetailsEvent.ServiceTypeChanged(checkedId, app))
}
}

private fun setupAutoStartCheckbox() {
checkbox_auto_start.setOnCheckedChangeListener { _, checked ->
viewModel.submitEvent(AppDetailsEvent.AutoStartChanged(checked, app))
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/tech/ula/ui/AppsListFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import tech.ula.viewmodel.AppsListViewModelFactory
class AppsListFragment : Fragment(), AppsListAdapter.AppsClickHandler {

interface AppSelection {
fun appHasBeenSelected(app: App)
fun appHasBeenSelected(app: App, autoStart: Boolean)
}

private val doOnAppSelection: AppSelection by lazy {
Expand Down Expand Up @@ -108,7 +108,7 @@ class AppsListFragment : Fragment(), AppsListAdapter.AppsClickHandler {
}

override fun onClick(app: App) {
doOnAppSelection.appHasBeenSelected(app)
doOnAppSelection.appHasBeenSelected(app, false)
}

override fun createContextMenu(menu: Menu) {
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/tech/ula/ui/SettingsFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.ula.ui

import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
Expand All @@ -26,6 +27,16 @@ class SettingsFragment : PreferenceFragmentCompat() {
prootDebugLogger.deleteLogs()
true
}

val clearAutoStartPreference: Preference = findPreference("pref_clear_auto_start")!!
clearAutoStartPreference.setOnPreferenceClickListener {
val prefs = activity!!.getSharedPreferences("apps", Context.MODE_PRIVATE)
with(prefs.edit()) {
remove("AutoApp")
apply()
true
}
}
}

override fun setDivider(divider: Drawable?) {
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/tech/ula/utils/BillingManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.android.billingclient.api.Purchase
import com.android.billingclient.api.PurchasesUpdatedListener
import com.android.billingclient.api.SkuDetails
import com.android.billingclient.api.SkuDetailsParams
import java.util.* // ktlint-disable no-wildcard-imports
import kotlin.collections.HashMap

/**
* When using this class:
Expand Down Expand Up @@ -93,7 +95,7 @@ class BillingManager(
if (isSubscriptionPurchaseSupported()) {
val purchasesResult = billingClient.queryPurchases(BillingClient.SkuType.SUBS)
if (purchasesResult.responseCode == BillingResponseCode.OK) {
onEntitledSubPurchases(purchasesResult.purchasesList)
onEntitledSubPurchases(Collections.unmodifiableList(purchasesResult.purchasesList))
} else {
log("Error trying to query purchases: $purchasesResult")
}
Expand All @@ -103,7 +105,7 @@ class BillingManager(
fun queryInAppPurchases() {
val purchasesResult = billingClient.queryPurchases(BillingClient.SkuType.INAPP)
if (purchasesResult.responseCode == BillingResponseCode.OK) {
onEntitledInAppPurchases(purchasesResult.purchasesList)
onEntitledInAppPurchases(Collections.unmodifiableList(purchasesResult.purchasesList))
} else {
log("Error trying to query purchases: $purchasesResult")
}
Expand Down
Loading

0 comments on commit 76346d1

Please sign in to comment.