committed by
bunnei
23 changed files with 268 additions and 174 deletions
-
12src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.java
-
3src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
-
8src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
-
6src/android/app/src/main/java/org/yuzu/yuzu_emu/applets/SoftwareKeyboard.java
-
22src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt
-
3src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt
-
15src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.kt
-
2src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
-
18src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InsetsHelper.kt
-
67src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt
-
11src/android/app/src/main/res/drawable/gamelist_divider.xml
-
20src/android/app/src/main/res/layout/activity_main.xml
-
28src/android/app/src/main/res/layout/activity_settings.xml
-
23src/android/app/src/main/res/layout/card_game.xml
-
16src/android/app/src/main/res/layout/dialog_checkbox.xml
-
25src/android/app/src/main/res/layout/dialog_progress_bar.xml
-
39src/android/app/src/main/res/layout/fragment_emulation.xml
-
7src/android/app/src/main/res/layout/fragment_settings.xml
-
24src/android/app/src/main/res/layout/list_item_setting.xml
-
46src/android/app/src/main/res/layout/list_item_setting_switch.xml
-
11src/android/app/src/main/res/layout/list_item_settings_header.xml
-
25src/android/app/src/main/res/layout/premium_item_setting.xml
-
11src/android/app/src/main/res/menu/menu_game_grid.xml
@ -0,0 +1,18 @@ |
|||
package org.yuzu.yuzu_emu.utils |
|||
|
|||
import android.content.Context |
|||
|
|||
object InsetsHelper { |
|||
const val THREE_BUTTON_NAVIGATION = 0 |
|||
const val TWO_BUTTON_NAVIGATION = 1 |
|||
const val GESTURE_NAVIGATION = 2 |
|||
|
|||
fun getSystemGestureType(context: Context): Int { |
|||
val resources = context.resources |
|||
val resourceId = |
|||
resources.getIdentifier("config_navBarInteractionMode", "integer", "android") |
|||
return if (resourceId != 0) { |
|||
resources.getInteger(resourceId) |
|||
} else 0 |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
package org.yuzu.yuzu_emu.utils |
|||
|
|||
import android.app.Activity |
|||
import android.content.res.Configuration |
|||
import android.graphics.Color |
|||
import androidx.annotation.ColorInt |
|||
import androidx.appcompat.app.AppCompatActivity |
|||
import androidx.core.content.ContextCompat |
|||
import androidx.core.view.WindowCompat |
|||
import com.google.android.material.color.MaterialColors |
|||
import org.yuzu.yuzu_emu.R |
|||
import kotlin.math.roundToInt |
|||
|
|||
object ThemeHelper { |
|||
private const val NAV_BAR_ALPHA = 0.9f |
|||
|
|||
@JvmStatic |
|||
fun setTheme(activity: AppCompatActivity) { |
|||
val windowController = WindowCompat.getInsetsController( |
|||
activity.window, |
|||
activity.window.decorView |
|||
) |
|||
val isLightMode = |
|||
(activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO |
|||
windowController.isAppearanceLightStatusBars = isLightMode |
|||
windowController.isAppearanceLightNavigationBars = isLightMode |
|||
|
|||
activity.window.statusBarColor = ContextCompat.getColor(activity, android.R.color.transparent) |
|||
|
|||
val navigationBarColor = |
|||
MaterialColors.getColor(activity.window.decorView, R.attr.colorSurface) |
|||
setNavigationBarColor(activity, navigationBarColor) |
|||
} |
|||
|
|||
@JvmStatic |
|||
fun setNavigationBarColor(activity: Activity, @ColorInt color: Int) { |
|||
val gestureType = InsetsHelper.getSystemGestureType(activity.applicationContext) |
|||
val orientation = activity.resources.configuration.orientation |
|||
|
|||
if ((gestureType == InsetsHelper.THREE_BUTTON_NAVIGATION || |
|||
gestureType == InsetsHelper.TWO_BUTTON_NAVIGATION) && |
|||
orientation == Configuration.ORIENTATION_LANDSCAPE |
|||
) { |
|||
activity.window.navigationBarColor = color |
|||
} else if (gestureType == InsetsHelper.THREE_BUTTON_NAVIGATION || |
|||
gestureType == InsetsHelper.TWO_BUTTON_NAVIGATION |
|||
) { |
|||
activity.window.navigationBarColor = getColorWithOpacity(color, NAV_BAR_ALPHA) |
|||
} else { |
|||
activity.window.navigationBarColor = ContextCompat.getColor( |
|||
activity.applicationContext, |
|||
android.R.color.transparent |
|||
) |
|||
} |
|||
} |
|||
|
|||
@ColorInt |
|||
private fun getColorWithOpacity(@ColorInt color: Int, alphaFactor: Float): Int { |
|||
return Color.argb( |
|||
(alphaFactor * Color.alpha(color)).roundToInt(), Color.red(color), |
|||
Color.green(color), Color.blue(color) |
|||
) |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:shape="rectangle"> |
|||
|
|||
<size |
|||
android:width="1dp" |
|||
android:height="1dp" /> |
|||
|
|||
<solid android:color="@color/gamelist_divider" /> |
|||
|
|||
</shape> |
|||
@ -1,5 +1,27 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
<androidx.coordinatorlayout.widget.CoordinatorLayout |
|||
android:id="@+id/coordinator_main" |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:id="@+id/frame_content" /> |
|||
android:layout_height="match_parent"> |
|||
|
|||
<com.google.android.material.appbar.AppBarLayout |
|||
android:id="@+id/appbar_settings" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
|
|||
<androidx.appcompat.widget.Toolbar |
|||
android:id="@+id/toolbar_settings" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="?attr/actionBarSize" /> |
|||
|
|||
</com.google.android.material.appbar.AppBarLayout> |
|||
|
|||
<FrameLayout |
|||
android:id="@+id/frame_content" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> |
|||
|
|||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
|||
@ -1,16 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:orientation="vertical" |
|||
android:paddingTop="5dp" |
|||
android:paddingLeft="20dp" |
|||
android:paddingRight="20dp" |
|||
android:paddingBottom="0dp" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent"> |
|||
|
|||
<CheckBox |
|||
android:id="@+id/checkBox" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:text="@string/do_not_show_this_again" /> |
|||
</LinearLayout> |
|||
@ -1,26 +1,15 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout |
|||
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" |
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
android:orientation="vertical"> |
|||
|
|||
<ProgressBar |
|||
<com.google.android.material.progressindicator.LinearProgressIndicator |
|||
android:id="@+id/progress_bar" |
|||
style="?android:attr/progressBarStyleHorizontal" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginLeft="@dimen/spacing_large" |
|||
android:layout_marginRight="@dimen/spacing_large" |
|||
android:layout_alignParentEnd="true" |
|||
android:layout_below="@+id/progress_text" |
|||
android:layout_alignParentStart="true"/> |
|||
android:layout_margin="24dp" |
|||
app:trackCornerRadius="4dp" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/progress_text" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginLeft="@dimen/spacing_large" |
|||
android:layout_marginRight="@dimen/spacing_large" |
|||
android:gravity="right" |
|||
android:text="1/100" /> |
|||
</LinearLayout> |
|||
</LinearLayout> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue