Allow exporting current device config
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
package com.aurora.store.view.ui.all
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.lifecycle.Lifecycle
|
||||
@@ -28,7 +29,6 @@ import com.aurora.gplayapi.data.models.AuthData
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.providers.AuthProvider
|
||||
import com.aurora.store.databinding.ActivityGenericPagerBinding
|
||||
import com.aurora.extensions.close
|
||||
import com.aurora.store.view.ui.commons.BaseActivity
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
@@ -59,10 +59,24 @@ class AppsGamesActivity : BaseActivity() {
|
||||
attachViewPager()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun attachToolbar() {
|
||||
B.layoutToolbarAction.txtTitle.text = getString(R.string.title_apps_games)
|
||||
B.layoutToolbarAction.imgActionPrimary.setOnClickListener {
|
||||
close()
|
||||
setSupportActionBar(B.layoutActionToolbar.toolbar)
|
||||
val actionBar = supportActionBar
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayShowCustomEnabled(true)
|
||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||
actionBar.elevation = 0f
|
||||
actionBar.title = getString(R.string.title_apps_games)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,16 +20,25 @@
|
||||
package com.aurora.store.view.ui.spoof
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.databinding.ActivityGenericPagerBinding
|
||||
import com.aurora.extensions.close
|
||||
import com.aurora.extensions.toast
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.providers.NativeDeviceInfoProvider
|
||||
import com.aurora.store.databinding.ActivityGenericPagerBinding
|
||||
import com.aurora.store.util.PathUtil
|
||||
import com.aurora.store.view.ui.commons.BaseActivity
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import nl.komponents.kovenant.task
|
||||
import nl.komponents.kovenant.ui.failUi
|
||||
import nl.komponents.kovenant.ui.successUi
|
||||
import java.io.FileOutputStream
|
||||
|
||||
class SpoofActivity : BaseActivity() {
|
||||
|
||||
@@ -55,10 +64,32 @@ class SpoofActivity : BaseActivity() {
|
||||
attachViewPager()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_spoof, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
R.id.action_export -> {
|
||||
exportDeviceConfig()
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun attachToolbar() {
|
||||
B.layoutToolbarAction.txtTitle.text = getString(R.string.title_spoof_manager)
|
||||
B.layoutToolbarAction.imgActionPrimary.setOnClickListener {
|
||||
close()
|
||||
setSupportActionBar(B.layoutActionToolbar.toolbar)
|
||||
val actionBar = supportActionBar
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayShowCustomEnabled(true)
|
||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||
actionBar.elevation = 0f
|
||||
actionBar.title = getString(R.string.title_spoof_manager)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +106,24 @@ class SpoofActivity : BaseActivity() {
|
||||
}.attach()
|
||||
}
|
||||
|
||||
private fun exportDeviceConfig() {
|
||||
task {
|
||||
NativeDeviceInfoProvider(this)
|
||||
.getNativeDeviceProperties()
|
||||
.store(
|
||||
FileOutputStream(
|
||||
PathUtil.getExternalPath() + "/native-device.properties.export"
|
||||
),
|
||||
"DEVICE_CONFIG"
|
||||
)
|
||||
} successUi {
|
||||
toast(R.string.toast_export_success)
|
||||
} failUi {
|
||||
it.printStackTrace()
|
||||
toast(R.string.toast_export_failed)
|
||||
}
|
||||
}
|
||||
|
||||
internal class ViewPagerAdapter(fragment: FragmentManager, lifecycle: Lifecycle) :
|
||||
FragmentStateAdapter(fragment, lifecycle) {
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
android:id="@+id/layout_toolbar_action"
|
||||
layout="@layout/view_toolbar_action" />
|
||||
android:id="@+id/layout_action_toolbar"
|
||||
layout="@layout/view_toolbar_native" />
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/layout_toolbar_action"
|
||||
android:layout_below="@id/layout_action_toolbar"
|
||||
android:background="@android:color/transparent"
|
||||
android:paddingStart="@dimen/margin_large"
|
||||
android:paddingEnd="@dimen/margin_large"
|
||||
|
||||
24
app/src/main/res/menu/menu_spoof.xml
Normal file
24
app/src/main/res/menu/menu_spoof.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Aurora Store
|
||||
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
~
|
||||
~ Aurora Store 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 2 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ Aurora Store 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 Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_export"
|
||||
android:title="@string/action_export" />
|
||||
</menu>
|
||||
@@ -364,4 +364,6 @@
|
||||
<string name="toast_rated_success">Rated successfully</string>
|
||||
<string name="toast_rated_failed">Failed to submit rating</string>
|
||||
<string name="toast_aas_token_failed">Failed to generate AAS Token</string>
|
||||
<string name="toast_export_success">Device config exported successfully</string>
|
||||
<string name="toast_export_failed">Failed to export device config</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user