Settings: Add Game Space support
Co-authored-by: alanndz <alanndz7@gmail.com>
This commit is contained in:
@@ -181,4 +181,8 @@
|
||||
<string name="clipboard_auto_clear_summary">Automatically clear clipboard at the scheduled time</string>
|
||||
<string name="clipboard_auto_clear_enabled_title">Use clipboard auto clear</string>
|
||||
<string name="clipboard_auto_clear_timeout_disable_clipboard">Disable clipboard</string>
|
||||
|
||||
<!-- Game space -->
|
||||
<string name="game_space_title">Game space</string>
|
||||
<string name="game_space_summary">Enhance your gaming experience</string>
|
||||
</resources>
|
||||
|
||||
@@ -75,6 +75,14 @@
|
||||
android:targetPackage="${applicationId}"/>
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="game_settings"
|
||||
android:title="@string/game_space_title"
|
||||
android:summary="@string/game_space_summary"
|
||||
android:order="-994"
|
||||
settings:controller="com.android.settings.applications.GameSpaceController">
|
||||
</Preference>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="10"/>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2022 Bianca Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.Intent;
|
||||
import android.content.ComponentName;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class GameSpaceController extends BasePreferenceController {
|
||||
|
||||
private static final String GAME_PACKAGE = "io.chaldeaprjkt.gamespace";
|
||||
private static final String GAME_SETTINGS = "io.chaldeaprjkt.gamespace.settings.SettingsActivity";
|
||||
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
public GameSpaceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mPackageManager = mContext.getPackageManager();
|
||||
}
|
||||
|
||||
private Intent settingsIntent() {
|
||||
Intent intent = new Intent();
|
||||
ComponentName component = new ComponentName(GAME_PACKAGE, GAME_SETTINGS);
|
||||
intent.setComponent(component);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().resolveActivity(settingsIntent(), 0) != null
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Intent intent = settingsIntent();
|
||||
intent.putExtra("referer", this.getClass().getCanonicalName());
|
||||
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user