-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display API logs in separate activity
- Loading branch information
Showing
15 changed files
with
209 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package nl.eduvpn.app | ||
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import nl.eduvpn.app.base.BaseActivity | ||
import nl.eduvpn.app.databinding.ActivityApiLogsBinding | ||
import nl.eduvpn.app.viewmodel.ApiLogsViewModel | ||
import nl.eduvpn.app.viewmodel.ViewModelFactory | ||
import javax.inject.Inject | ||
|
||
class ApiLogsActivity : BaseActivity<ActivityApiLogsBinding>() { | ||
|
||
override val layout = R.layout.activity_api_logs | ||
|
||
@Inject | ||
protected lateinit var viewModelFactory: ViewModelFactory | ||
|
||
private val viewModel by viewModels<ApiLogsViewModel> { viewModelFactory } | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
EduVPNApplication.get(this).component().inject(this) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
binding.logContents.text = viewModel.getLogFileContents() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/nl/eduvpn/app/viewmodel/ApiLogsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package nl.eduvpn.app.viewmodel | ||
|
||
import androidx.lifecycle.AndroidViewModel | ||
import androidx.lifecycle.ViewModel | ||
import nl.eduvpn.app.entity.Settings | ||
import nl.eduvpn.app.service.BackendService | ||
import nl.eduvpn.app.service.HistoryService | ||
import nl.eduvpn.app.service.PreferencesService | ||
import javax.inject.Inject | ||
|
||
class ApiLogsViewModel @Inject constructor( | ||
private val backendService: BackendService | ||
) : ViewModel() { | ||
fun getLogFileContents() : String { | ||
return backendService.getLogFile()!!.readLines().joinToString("\n") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/src/main/java/nl/eduvpn/app/viewmodel/SettingsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package nl.eduvpn.app.viewmodel | ||
|
||
import androidx.lifecycle.AndroidViewModel | ||
import androidx.lifecycle.ViewModel | ||
import nl.eduvpn.app.entity.Settings | ||
import nl.eduvpn.app.service.BackendService | ||
import nl.eduvpn.app.service.HistoryService | ||
import nl.eduvpn.app.service.PreferencesService | ||
import javax.inject.Inject | ||
|
||
class SettingsViewModel @Inject constructor( | ||
private val historyService: HistoryService, | ||
private val preferencesService: PreferencesService, | ||
private val backendService: BackendService | ||
) : ViewModel() { | ||
|
||
val appSettings get() = preferencesService.getAppSettings() | ||
|
||
val apiLogFile get() = backendService.getLogFile() | ||
|
||
val hasAddedServers get() = historyService.addedServers?.hasServers() == true | ||
|
||
fun removeOrganizationData() { | ||
historyService.removeOrganizationData() | ||
} | ||
|
||
fun storeAppSettings(appSettings: Settings) { | ||
preferencesService.storeAppSettings(appSettings) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ This file is part of eduVPN. | ||
~ | ||
~ eduVPN is free software: you can redistribute it and/or modify | ||
~ it under the terms of the GNU General Public License as published by | ||
~ the Free Software Foundation, either version 3 of the License, or | ||
~ (at your option) any later version. | ||
~ | ||
~ eduVPN is distributed in the hope that it will be useful, | ||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
~ GNU General Public License for more details. | ||
~ | ||
~ You should have received a copy of the GNU General Public License | ||
~ along with eduVPN. If not, see <http://www.gnu.org/licenses/>. | ||
~ | ||
--> | ||
<layout> | ||
|
||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" | ||
tools:context=".LicenseActivity"> | ||
|
||
<ScrollView | ||
android:id="@+id/scrollview" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginTop="@dimen/actionbar_size" | ||
android:background="@color/backgroundColor"> | ||
|
||
<TextView | ||
android:id="@+id/log_contents" | ||
android:layout_width="match_parent" | ||
android:fontFamily="monospace" | ||
android:textStyle="bold" | ||
tools:text="@tools:sample/lorem/random" | ||
android:layout_height="wrap_content"/> | ||
|
||
</ScrollView> | ||
|
||
<include | ||
android:id="@+id/toolbar" | ||
layout="@layout/include_toolbar" /> | ||
</RelativeLayout> | ||
</layout> |
Oops, something went wrong.