Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 34450491 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #3402 from k9mail/material_account_settings

Switch 'account settings' to use PreferenceFragmentCompat 
parents 8521e39e 5e3efd3a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -27,9 +27,10 @@ dependencies {
    implementation 'commons-io:commons-io:2.4'
    implementation "com.android.support:support-v4:${androidSupportLibraryVersion}"
    implementation "com.android.support:appcompat-v7:${androidSupportLibraryVersion}"
    implementation "com.android.support:preference-v14:${androidSupportLibraryVersion}"
    implementation 'com.takisoft.fix:preference-v7:27.1.1.1'
    implementation 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.1'
    implementation 'com.takisoft.fix:preference-v7-colorpicker:27.1.1.1'
    implementation 'com.takisoft.fix:preference-v7-ringtone:27.1.1.1'
    implementation "com.android.support:recyclerview-v7:${androidSupportLibraryVersion}"
    implementation "android.arch.lifecycle:extensions:1.1.0"
    implementation 'androidx.core:core-ktx:0.3'
+5 −13
Original line number Diff line number Diff line
@@ -78,20 +78,13 @@
            </intent-filter>
        </activity>

        <activity
            android:name=".activity.setup.Prefs"
            android:configChanges="locale"
            android:excludeFromRecents="true"
            android:label="@string/prefs_title"
            android:taskAffinity="${applicationId}.activity.setup.Prefs"/>

        <activity
            android:name=".activity.setup.WelcomeMessage"
            android:configChanges="locale"
            android:label="@string/welcome_message_title"/>

        <activity
            android:name=".activity.setup.OpenPgpAppSelectDialog"
            android:name=".ui.settings.account.OpenPgpAppSelectDialog"
            android:configChanges="locale"
            android:theme="@style/Theme.K9.Transparent"
            />
@@ -180,11 +173,6 @@
            android:configChanges="keyboardHidden|orientation|locale"
            android:label="@string/account_setup_check_settings_title"/>

        <activity
            android:name=".activity.setup.AccountSettings"
            android:configChanges="locale"
            android:label="@string/account_settings_title_fmt"/>

        <activity
            android:name=".activity.setup.FolderSettings"
            android:configChanges="locale"
@@ -313,6 +301,10 @@
            android:name=".ui.settings.general.GeneralSettingsActivity"
            android:label="@string/general_settings_title" />

        <activity
            android:name=".ui.settings.account.AccountSettingsActivity"
            android:label="@string/account_settings_title_fmt" />

        <receiver
            android:name=".service.BootReceiver"
            android:enabled="true">
+13 −2
Original line number Diff line number Diff line
@@ -6,7 +6,10 @@ import com.fsck.k9.autocrypt.autocryptModule
import com.fsck.k9.controller.MessagingController
import com.fsck.k9.crypto.openPgpModule
import com.fsck.k9.mail.TransportProvider
import com.fsck.k9.mailstore.StorageManager
import com.fsck.k9.mailstore.mailStoreModule
import com.fsck.k9.ui.endtoend.endToEndUiModule
import com.fsck.k9.ui.folders.FolderNameFormatter
import com.fsck.k9.ui.settings.settingsUiModule
import com.fsck.k9.widget.unread.unreadWidgetModule
import org.koin.Koin
@@ -23,7 +26,9 @@ object DI {
        bean { Preferences.getPreferences(get()) }
        bean { MessagingController.getInstance(get()) }
        bean { TransportProvider() }
        bean { (get() as Context).resources }
        bean { get<Context>().resources }
        bean { StorageManager.getInstance(get()) }
        bean { FolderNameFormatter(get()) }
    }

    val appModules = listOf(
@@ -32,7 +37,8 @@ object DI {
            unreadWidgetModule,
            endToEndUiModule,
            openPgpModule,
            autocryptModule
            autocryptModule,
            mailStoreModule
    )

    @JvmStatic fun start(application: Application) {
@@ -54,4 +60,9 @@ object DI {
            koinContext.resolveInstance(kClass, parameters) { koinContext.beanRegistry.searchByName(name) }
        }
    }

    inline fun <reified T : Any> get(name: String = "", noinline parameters: Parameters = { emptyMap() }): T {
        val koinContext = StandAloneContext.koinContext as KoinContext
        return koinContext.get(name, parameters)
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ import com.fsck.k9.R;
import com.fsck.k9.activity.compose.MessageActions;
import com.fsck.k9.activity.misc.ExtendedAsyncTask;
import com.fsck.k9.activity.misc.NonConfigurationInstance;
import com.fsck.k9.activity.setup.AccountSettings;
import com.fsck.k9.activity.setup.AccountSetupBasics;
import com.fsck.k9.activity.setup.WelcomeMessage;
import com.fsck.k9.controller.MessagingController;
@@ -90,6 +89,7 @@ import com.fsck.k9.search.SearchAccount;
import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.ui.settings.SettingsActivity;
import com.fsck.k9.ui.settings.account.AccountSettingsActivity;
import com.fsck.k9.view.ColorChip;
import de.cketti.library.changelog.ChangeLog;
import timber.log.Timber;
@@ -1016,7 +1016,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
    }

    private void onEditAccount(Account account) {
        AccountSettings.actionSettings(this, account);
        AccountSettingsActivity.start(this, account.getUuid());
    }

    @Override
+0 −82
Original line number Diff line number Diff line
package com.fsck.k9.activity;

import com.fsck.k9.R;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.*;
import android.view.LayoutInflater;
import android.view.View;

import com.larswerkman.colorpicker.ColorPicker;


/**
 * Dialog displaying a color picker.
 */
public class ColorPickerDialog extends AlertDialog {

    /**
     * The interface users of {@link ColorPickerDialog} have to implement to learn the selected
     * color.
     */
    public interface OnColorChangedListener {
        /**
         * This is called after the user pressed the "OK" button of the dialog.
         *
         * @param color
         *         The ARGB value of the selected color.
         */
        void colorChanged(int color);
    }

    OnColorChangedListener mColorChangedListener;
    ColorPicker mColorPicker;

    public ColorPickerDialog(Context context, OnColorChangedListener listener, int color) {
        super(context);
        mColorChangedListener = listener;

        @SuppressLint("InflateParams")
        View view = LayoutInflater.from(context).inflate(R.layout.holo_color_picker_dialog, null);

        mColorPicker = view.findViewById(R.id.color_picker);
        mColorPicker.setColor(color);

        setView(view);
        setTitle(R.string.color_picker_default_title);

        setButton(BUTTON_POSITIVE, context.getString(R.string.okay_action),
                new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mColorChangedListener != null) {
                    mColorChangedListener.colorChanged(mColorPicker.getColor());
                }
            }
        });

        setButton(BUTTON_NEUTRAL, context.getString(R.string.account_settings_color_none),
                new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mColorChangedListener != null) {
                    mColorChangedListener.colorChanged(0x0); // Transparent
                }
            }
        });

        setButton(BUTTON_NEGATIVE, context.getString(R.string.cancel_action),
                (OnClickListener) null);
    }

    /**
     * Set the color the color picker should highlight as selected color.
     *
     * @param color
     *         The (A)RGB value of a color (the alpha channel will be ignored).
     */
    public void setColor(int color) {
        mColorPicker.setColor(color);
    }
}
Loading