mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-26 09:44:43 +01:00
Make icon toggleable
This commit adds an option to choose between the original and the new icon
This commit is contained in:
parent
0ae8826732
commit
fd6bc82214
@ -441,11 +441,36 @@
|
||||
android:theme="@style/AppTheme.Launcher"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity-alias
|
||||
android:name=".DefaultIcon"
|
||||
android:targetActivity=".activities.MainActivity"
|
||||
android:label="@string/application_name"
|
||||
android:enabled="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity-alias
|
||||
android:name=".OriginalIcon"
|
||||
android:targetActivity=".activities.MainActivity"
|
||||
android:label="@string/application_name"
|
||||
android:enabled="false"
|
||||
android:icon="@mipmap/original_ic_launcher"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity
|
||||
android:name=".activities.LoginActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize|layoutDirection"
|
||||
|
@ -1,6 +1,8 @@
|
||||
package eu.toldi.infinityforlemmy.settings;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -42,6 +44,7 @@ public class MiscellaneousPreferenceFragment extends CustomFontPreferenceFragmen
|
||||
ListPreference languageListPreference = findPreference(SharedPreferencesUtils.LANGUAGE);
|
||||
EditTextPreference anonymousAccountInstance = findPreference(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE);
|
||||
EditTextPreference postFeedMaxResolution = findPreference(SharedPreferencesUtils.POST_FEED_MAX_RESOLUTION);
|
||||
ListPreference iconPreference = findPreference(SharedPreferencesUtils.ICON_PREFERENCE);
|
||||
|
||||
if (mainPageBackButtonActionListPreference != null) {
|
||||
mainPageBackButtonActionListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
@ -102,5 +105,41 @@ public class MiscellaneousPreferenceFragment extends CustomFontPreferenceFragmen
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (iconPreference != null) {
|
||||
iconPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
updateIcon((String) newValue);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIcon(String iconValue) {
|
||||
PackageManager pm = getActivity().getPackageManager();
|
||||
|
||||
// Disable all the alternative icons
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName(getActivity(), "eu.toldi.infinityforlemmy.OriginalIcon"),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName(getActivity(), "eu.toldi.infinityforlemmy.DefaultIcon"),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
|
||||
// Enable the chosen icon
|
||||
if ("original_icon".equals(iconValue)) {
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName(getActivity(), "eu.toldi.infinityforlemmy.OriginalIcon"),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
} else {
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName(getActivity(), "eu.toldi.infinityforlemmy.DefaultIcon"),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -420,4 +420,6 @@ public class SharedPreferencesUtils {
|
||||
public static final String SHOW_POST_AND_COMMENT_SCORE = "show_score";
|
||||
|
||||
public static final String SHARE_LINK_ON_LOCAL_INSTANCE = "share_link_on_local_instance";
|
||||
|
||||
public static final String ICON_PREFERENCE = "icon_preference";
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground_monochrome" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground_monochrome" />
|
||||
</adaptive-icon>
|
@ -691,4 +691,13 @@
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="icon_labels">
|
||||
<item>Cosmic Lemmy</item>
|
||||
<item>Galactic Cruiser Lemmy</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="icon_values">
|
||||
<item>default_icon</item>
|
||||
<item>original_icon</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -1386,4 +1386,6 @@
|
||||
<string name="settings_hide_user_instance">Hide user instance</string>
|
||||
<string name="share_links_on_your_local_instance_rather_than_the_original_creation_instance">Share links on your local instance rather than the original creation instance.</string>
|
||||
<string name="share_links_on_your_local_instance">Share links on your local instance</string>
|
||||
|
||||
<string name="icon_original_label">Original Icon</string>
|
||||
</resources>
|
@ -52,6 +52,13 @@
|
||||
app:title="@string/share_links_on_your_local_instance"
|
||||
app:summary="@string/share_links_on_your_local_instance_rather_than_the_original_creation_instance" />
|
||||
|
||||
<ListPreference
|
||||
app:key="icon_preference"
|
||||
app:title="Change App Icon"
|
||||
app:entries="@array/icon_labels"
|
||||
app:entryValues="@array/icon_values"
|
||||
app:defaultValue="default_icon" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceCategory app:title="@string/settings_miscellaneous_dangerous_group_title" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreference
|
||||
|
Loading…
x
Reference in New Issue
Block a user