added incognito header
This commit is contained in:
parent
f9913eadf5
commit
bf4884c70a
4 changed files with 104 additions and 3 deletions
|
|
@ -70,6 +70,73 @@
|
||||||
</LayoutPositions>
|
</LayoutPositions>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="nav_graph.xml">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions>
|
||||||
|
<option name="myPositions">
|
||||||
|
<map>
|
||||||
|
<entry key="historyFragment">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions>
|
||||||
|
<option name="myPosition">
|
||||||
|
<Point>
|
||||||
|
<option name="x" value="230" />
|
||||||
|
<option name="y" value="12" />
|
||||||
|
</Point>
|
||||||
|
</option>
|
||||||
|
</LayoutPositions>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="homeFragment">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions>
|
||||||
|
<option name="myPosition">
|
||||||
|
<Point>
|
||||||
|
<option name="x" value="12" />
|
||||||
|
<option name="y" value="12" />
|
||||||
|
</Point>
|
||||||
|
</option>
|
||||||
|
</LayoutPositions>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="moreFragment">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions>
|
||||||
|
<option name="myPosition">
|
||||||
|
<Point>
|
||||||
|
<option name="x" value="12" />
|
||||||
|
<option name="y" value="368" />
|
||||||
|
</Point>
|
||||||
|
</option>
|
||||||
|
<option name="myPositions">
|
||||||
|
<map>
|
||||||
|
<entry key="action_moreFragment_to_settingsFragment">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</LayoutPositions>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="settingsFragment">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions>
|
||||||
|
<option name="myPosition">
|
||||||
|
<Point>
|
||||||
|
<option name="x" value="230" />
|
||||||
|
<option name="y" value="368" />
|
||||||
|
</Point>
|
||||||
|
</option>
|
||||||
|
</LayoutPositions>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</LayoutPositions>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import android.Manifest
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
|
@ -14,6 +16,7 @@ import android.util.Log
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
|
@ -42,6 +45,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
lateinit var context: Context
|
lateinit var context: Context
|
||||||
private lateinit var homeFragment: HomeFragment
|
private lateinit var homeFragment: HomeFragment
|
||||||
private lateinit var historyFragment: HistoryFragment
|
private lateinit var historyFragment: HistoryFragment
|
||||||
|
private lateinit var preferences: SharedPreferences
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
@ -51,6 +55,9 @@ class MainActivity : AppCompatActivity() {
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
context = baseContext
|
context = baseContext
|
||||||
|
|
||||||
|
preferences = context.getSharedPreferences("root_preferences", MODE_PRIVATE)
|
||||||
|
|
||||||
askPermissions()
|
askPermissions()
|
||||||
checkUpdate()
|
checkUpdate()
|
||||||
fm = supportFragmentManager
|
fm = supportFragmentManager
|
||||||
|
|
@ -103,6 +110,18 @@ class MainActivity : AppCompatActivity() {
|
||||||
handleIntents(intent)
|
handleIntents(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
val incognitoHeader = findViewById<TextView>(R.id.incognito_header)
|
||||||
|
if (preferences.getBoolean("incognito", false)){
|
||||||
|
incognitoHeader.visibility = View.VISIBLE
|
||||||
|
window.statusBarColor = (incognitoHeader.background as ColorDrawable).color
|
||||||
|
}else{
|
||||||
|
window.statusBarColor = getColor(android.R.color.transparent)
|
||||||
|
incognitoHeader.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
handleIntents(intent)
|
handleIntents(intent)
|
||||||
|
|
@ -167,7 +186,6 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
|
||||||
private fun checkUpdate() {
|
private fun checkUpdate() {
|
||||||
val preferences = context.getSharedPreferences("root_preferences", MODE_PRIVATE)
|
|
||||||
if (preferences.getBoolean("update_app", false)) {
|
if (preferences.getBoolean("update_app", false)) {
|
||||||
val updateUtil = UpdateUtil(this)
|
val updateUtil = UpdateUtil(this)
|
||||||
updateUtil.updateApp()
|
updateUtil.updateApp()
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,9 @@ class DownloadWorker(
|
||||||
val incognito = sharedPreferences.getBoolean("incognito", false)
|
val incognito = sharedPreferences.getBoolean("incognito", false)
|
||||||
if (!incognito) {
|
if (!incognito) {
|
||||||
val unixtime = System.currentTimeMillis() / 1000
|
val unixtime = System.currentTimeMillis() / 1000
|
||||||
val historyItem = HistoryItem(0, downloadItem.url, downloadItem.title, downloadItem.author, downloadItem.duration, downloadItem.thumb, downloadItem.type, unixtime, finalPath!!, downloadItem.website, downloadItem.format)
|
val file = File(finalPath!!)
|
||||||
|
downloadItem.format.filesize = if (file.exists()) file.length() else 0L
|
||||||
|
val historyItem = HistoryItem(0, downloadItem.url, downloadItem.title, downloadItem.author, downloadItem.duration, downloadItem.thumb, downloadItem.type, unixtime, finalPath, downloadItem.website, downloadItem.format)
|
||||||
runBlocking {
|
runBlocking {
|
||||||
historyDao.insert(historyItem)
|
historyDao.insert(historyItem)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,20 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/incognito_header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Incognito"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:background="?colorPrimaryContainer"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/frame_layout"
|
android:id="@+id/frame_layout"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
@ -13,7 +27,7 @@
|
||||||
app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
|
app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toBottomOf="@+id/incognito_header" />
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/bottomNavigationView"
|
android:id="@+id/bottomNavigationView"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue