forked from schwabe/ics-openvpn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement enough of edge-to-edge to work well on Android V
- Loading branch information
Showing
25 changed files
with
460 additions
and
285 deletions.
There are no files selected for viewing
45 changes: 0 additions & 45 deletions
45
main/src/ui/java/de/blinkt/openvpn/activities/BaseActivity.java
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
main/src/ui/java/de/blinkt/openvpn/activities/BaseActivity.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,81 @@ | ||
/* | ||
* Copyright (c) 2012-2015 Arne Schwabe | ||
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt | ||
*/ | ||
package de.blinkt.openvpn.activities | ||
|
||
import android.app.UiModeManager | ||
import android.content.Context | ||
import android.content.res.Configuration | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.view.Window | ||
import androidx.activity.SystemBarStyle | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import androidx.core.view.updateLayoutParams | ||
import androidx.core.view.updatePadding | ||
import de.blinkt.openvpn.R | ||
import de.blinkt.openvpn.core.LocaleHelper | ||
|
||
abstract class BaseActivity : AppCompatActivity() { | ||
val isAndroidTV: Boolean | ||
get() { | ||
val uiModeManager = getSystemService(UI_MODE_SERVICE) as UiModeManager | ||
return uiModeManager.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
if (isAndroidTV) { | ||
requestWindowFeature(Window.FEATURE_OPTIONS_PANEL) | ||
} | ||
this.enableEdgeToEdge(SystemBarStyle.dark(R.color.primary_dark)) | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
fun setUpEdgeEdgeInsetsListener( | ||
rootView: View, | ||
contentViewId: Int = R.id.root_linear_layout, | ||
setupBottom: Boolean = true | ||
) { | ||
val contentView = rootView.findViewById<View>(contentViewId) | ||
|
||
ViewCompat.setOnApplyWindowInsetsListener(contentView) { v, windowInsets -> | ||
val insets = | ||
windowInsets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()) | ||
val statusbarbg = findViewById<View>(R.id.statusbar_background); | ||
|
||
val statusBarInsets = windowInsets.getInsets(WindowInsetsCompat.Type.statusBars()) | ||
|
||
statusbarbg.layoutParams.height = statusBarInsets.top | ||
|
||
|
||
v.updateLayoutParams<ViewGroup.MarginLayoutParams> { | ||
topMargin = insets.top | ||
} | ||
|
||
v.updatePadding( | ||
left = insets.left, | ||
right = insets.right, | ||
) | ||
if (setupBottom) { | ||
v.updatePadding(bottom = insets.bottom) | ||
WindowInsetsCompat.CONSUMED | ||
} else { | ||
windowInsets | ||
} | ||
} | ||
} | ||
|
||
override fun attachBaseContext(base: Context) { | ||
super.attachBaseContext(LocaleHelper.updateResources(base)) | ||
} | ||
|
||
override fun onConfigurationChanged(newConfig: Configuration) { | ||
super.onConfigurationChanged(newConfig) | ||
LocaleHelper.onConfigurationChange(this) | ||
} | ||
} |
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
37 changes: 0 additions & 37 deletions
37
main/src/ui/java/de/blinkt/openvpn/activities/LogWindow.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
main/src/ui/java/de/blinkt/openvpn/activities/LogWindow.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,33 @@ | ||
/* | ||
* Copyright (c) 2012-2016 Arne Schwabe | ||
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt | ||
*/ | ||
package de.blinkt.openvpn.activities | ||
|
||
import android.os.Bundle | ||
import android.view.MenuItem | ||
import de.blinkt.openvpn.R | ||
import de.blinkt.openvpn.fragments.LogFragment | ||
|
||
/** | ||
* Created by arne on 13.10.13.setUpEdgeEdgeStuff | ||
*/ | ||
class LogWindow : BaseActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.log_window) | ||
supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||
|
||
if (savedInstanceState == null) { | ||
supportFragmentManager.beginTransaction() | ||
.add(R.id.container, LogFragment()) | ||
.commit() | ||
} | ||
|
||
setUpEdgeEdgeInsetsListener(getWindow().getDecorView().getRootView(), R.id.container) | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
return super.onOptionsItemSelected(item) | ||
} | ||
} |
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
Oops, something went wrong.