Commit 7020644b authored by Thomas's avatar Thomas
Browse files

Fix issue #373 - Allow to change icon

parent aaa44d89
Loading
Loading
Loading
Loading
+99 −2
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@
        android:name=".MainApplication"
        android:allowBackup="false"
        android:configChanges="orientation|screenSize"
        android:icon="@mipmap/ic_launcher"
        android:icon="@mipmap/ic_launcher_bubbles"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:roundIcon="@mipmap/ic_launcher_bubbles_round"
        android:supportsRtl="true"
        android:theme="@style/AppThemeDark"
        android:usesCleartextTraffic="true"
@@ -56,6 +56,103 @@
            </intent-filter>
        </activity>

        <activity-alias
            android:name=".activities.MainActivity.Bubbles"
            android:enabled="true"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_bubbles"
            android:roundIcon="@mipmap/ic_launcher_bubbles_round"
            android:targetActivity=".activities.MainActivity">
            <meta-data
                android:name="icon"
                android:value="bubbles" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".activities.MainActivity.Fediverse"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_fediverse"
            android:roundIcon="@mipmap/ic_launcher_fediverse_round"
            android:targetActivity=".activities.MainActivity">
            <meta-data
                android:name="icon"
                android:value="Fediverse" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".activities.MainActivity.Hero"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_hero"
            android:roundIcon="@mipmap/ic_launcher_hero_round"
            android:targetActivity=".activities.MainActivity">
            <meta-data
                android:name="icon"
                android:value="hero" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".activities.MainActivity.Atom"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_atom"
            android:roundIcon="@mipmap/ic_launcher_atom_round"
            android:targetActivity=".activities.MainActivity">
            <meta-data
                android:name="icon"
                android:value="atom" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".activities.MainActivity.BrainCrash"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_crash"
            android:roundIcon="@mipmap/ic_launcher_crash_round"
            android:targetActivity=".activities.MainActivity">
            <meta-data
                android:name="icon"
                android:value="braincrash" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".activities.MainActivity.Mastalab"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_mastalab"
            android:roundIcon="@mipmap/ic_launcher_mastalab_round"
            android:targetActivity=".activities.MainActivity">
            <meta-data
                android:name="icon"
                android:value="mastalab" />
            <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|screenSize"
+692 −640

File changed.

Preview size limit exceeded, changes collapsed.

+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package app.fedilab.android.helper;

import static android.content.Context.DOWNLOAD_SERVICE;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.helper.LogoHelper.getNotificationIcon;
import static app.fedilab.android.webview.ProxyHelper.setProxy;

import android.annotation.SuppressLint;
@@ -1475,7 +1476,7 @@ public class Helper {
                channelTitle = context.getString(R.string.channel_notif_boost);
        }
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId)
                .setSmallIcon(R.drawable.ic_notification).setTicker(message);
                .setSmallIcon(getNotificationIcon(context)).setTicker(message);
      /*  if (notifType == NotifType.MENTION) {
            if (message.length() > 500) {
                message = message.substring(0, 499) + "…";
@@ -1547,7 +1548,7 @@ public class Helper {
                .setContentText(channelTitle)
                .setContentIntent(pIntent)
                .setLargeIcon(icon)
                .setSmallIcon(R.drawable.ic_notification)
                .setSmallIcon(getNotificationIcon(context))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
                .setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "" + "@" + account.instance)
                .setGroupSummary(true)
+107 −0
Original line number Diff line number Diff line
package app.fedilab.android.helper;
/* Copyright 2022 Thomas Schneider
 *
 * This file is a part of Fedilab
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with Fedilab; if not,
 * see <http://www.gnu.org/licenses>. */

import static app.fedilab.android.BaseMainActivity.mLauncher;

import android.content.Context;
import android.content.SharedPreferences;

import androidx.preference.PreferenceManager;

import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;

public class LogoHelper {


    public static int getNotificationIcon(Context context) {
        final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
        String logo = sharedpreferences.getString(context.getString(R.string.SET_LOGO_LAUNCHER), "Bubbles");
        switch (logo) {
            case "Fediverse":
                return R.drawable.ic_plain_fediverse;
            case "Hero":
                return R.drawable.ic_plain_hero;
            case "Atom":
                return R.drawable.ic_plain_atom;
            case "BrainCrash":
                return R.drawable.ic_plain_crash;
            case "Mastalab":
                return R.drawable.ic_plain_mastalab;
            default:
                return R.drawable.ic_plain_bubbles;
        }
    }

    public static int getMainLogo(Context context) {
        final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
        String logo = sharedpreferences.getString(context.getString(R.string.SET_LOGO_LAUNCHER), "Bubbles");
        switch (logo) {
            case "Fediverse":
                return R.drawable.fedilab_logo_fediverse;
            case "Hero":
                return R.drawable.fedilab_logo_hero;
            case "Atom":
                return R.drawable.fedilab_logo_atom;
            case "BrainCrash":
                return R.drawable.fedilab_logo_crash;
            case "Mastalab":
                return R.drawable.fedilab_logo_mastalab;
            default:
                return R.drawable.fedilab_logo_bubbles;
        }
    }


    public static int getDrawable(String value) {
        switch (value) {
            case "Fediverse":
                return R.drawable.fedilab_logo_fediverse;
            case "Hero":
                return R.drawable.fedilab_logo_hero;
            case "Atom":
                return R.drawable.fedilab_logo_atom;
            case "BrainCrash":
                return R.drawable.fedilab_logo_crash;
            case "Mastalab":
                return R.drawable.fedilab_logo_mastalab;
            default:
                return R.drawable.fedilab_logo_bubbles;
        }
    }

    public static void setDrawable(String value) {
        switch (value) {
            case "Fediverse":
                mLauncher = BaseMainActivity.iconLauncher.FEDIVERSE;
                return;
            case "Hero":
                mLauncher = BaseMainActivity.iconLauncher.HERO;
                break;
            case "Atom":
                mLauncher = BaseMainActivity.iconLauncher.ATOM;
                break;
            case "BrainCrash":
                mLauncher = BaseMainActivity.iconLauncher.BRAINCRASH;
                break;
            case "Mastalab":
                mLauncher = BaseMainActivity.iconLauncher.MASTALAB;
                break;
            default:
                mLauncher = BaseMainActivity.iconLauncher.BUBBLES;
        }
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package app.fedilab.android.helper;
import static android.content.Context.DOWNLOAD_SERVICE;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.helper.Helper.notify_user;
import static app.fedilab.android.helper.LogoHelper.getMainLogo;

import android.app.Activity;
import android.app.DownloadManager;
@@ -167,7 +168,7 @@ public class MediaHelper {
                            intent.setDataAndType(uri, mime);
                            if (!share) {
                                notify_user(context, currentAccount, intent, BitmapFactory.decodeResource(context.getResources(),
                                        R.mipmap.ic_launcher), Helper.NotifType.STORE, context.getString(R.string.save_over), context.getString(R.string.download_from, fileName));
                                        getMainLogo(context)), Helper.NotifType.STORE, context.getString(R.string.save_over), context.getString(R.string.download_from, fileName));
                                Toasty.success(context, context.getString(R.string.save_over), Toasty.LENGTH_LONG).show();
                            } else {
                                Intent shareIntent = new Intent(Intent.ACTION_SEND);
Loading