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

Commit 4da98b21 authored by Unknown's avatar Unknown
Browse files

Account Manager Screen

Launch Account Manager login screen
parent de4f7b14
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@
<!--
<!--
     Copyright (C) 2013 The CyanogenMod Project
     Copyright (C) 2013 The CyanogenMod Project
     Copyright (C) 2017 The LineageOS Project
     Copyright (C) 2017 The LineageOS Project
     Copyright (C) 2018 e.foundation


     Licensed under the Apache License, Version 2.0 (the "License");
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     you may not use this file except in compliance with the License.
@@ -45,6 +46,7 @@
    <uses-permission android:name="cyanogenmod.permission.LEGALESE" />
    <uses-permission android:name="cyanogenmod.permission.LEGALESE" />
    <uses-permission android:name="cyanogenmod.permission.WRITE_SETTINGS"/>
    <uses-permission android:name="cyanogenmod.permission.WRITE_SETTINGS"/>
    <uses-permission android:name="cyanogenmod.permission.WRITE_SECURE_SETTINGS"/>
    <uses-permission android:name="cyanogenmod.permission.WRITE_SECURE_SETTINGS"/>
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>


    <permission
    <permission
        android:name="cyanogenmod.permission.PROTECTED_APP"
        android:name="cyanogenmod.permission.PROTECTED_APP"
@@ -262,6 +264,19 @@
            </intent-filter>
            </intent-filter>
        </activity>
        </activity>


        <activity android:name=".EAccountManagerActivity"
                  android:label="@string/activity_label_empty"
                  android:excludeFromRecents="true"
                  android:configChanges="mcc|mnc"
                  android:immersive="true"
                  android:exported="false"
                  android:windowSoftInputMode="stateAlwaysHidden">
            <intent-filter>
                <action android:name="com.cyanogenmod.setupwizard.E_ACCOUNT_MANAGER_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        
        <activity android:name=".FinishActivity"
        <activity android:name=".FinishActivity"
                  android:label="@string/activity_label_empty"
                  android:label="@string/activity_label_empty"
                  android:excludeFromRecents="true"
                  android:excludeFromRecents="true"
+72 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2018 e.foundation

     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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/primary">

    <include layout="@layout/header_condensed" />

    <FrameLayout android:id="@+id/page"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <ScrollView android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingStart="@dimen/content_margin_left"
                android:paddingEnd="@dimen/content_margin_left"
                style="@style/PageContent">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/PageSummaryText"
                    android:textSize="16sp"
                    android:layout_marginBottom="@dimen/summary_margin_bottom"
                    android:paddingRight="@dimen/location_text_margin_right"
                    android:text="@string/e_account_manager_setup_summary" />

                <Button
                    android:id="@+id/setup_e_account_manager"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="@dimen/content_margin_left"
                    android:paddingRight="@dimen/location_text_margin_right"
                    android:gravity="center"
                    android:textSize="16sp"
                    android:textAllCaps="true"
                    android:textColor="@color/white"
                    android:background="@color/accent"
                    android:maxLines="1"
                    android:ellipsize="end"
                    android:text="@string/e_account_manager_setup_configure"/>

            </LinearLayout>
        </ScrollView>
    </FrameLayout>
    <fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
        android:id="@+id/navigation_bar"
        style="@style/setup_wizard_navbar_style" />
</LinearLayout>
+5 −1
Original line number Original line Diff line number Diff line
@@ -70,6 +70,10 @@
    </WizardAction>
    </WizardAction>


    <WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_LOCKSCREEN_SETTINGS;end" id="lockscreen_settings">
    <WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_LOCKSCREEN_SETTINGS;end" id="lockscreen_settings">
        <result wizard:action="e_account_manager_settings" />
    </WizardAction>

    <WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.E_ACCOUNT_MANAGER_SETTINGS;end" id="e_account_manager_settings">
        <result wizard:action="finish" />
        <result wizard:action="finish" />
    </WizardAction>
    </WizardAction>
    
    
+4 −0
Original line number Original line Diff line number Diff line
@@ -112,4 +112,8 @@
    <!-- e.foundation -->
    <!-- e.foundation -->
    <string name="eelo_start_synchronizer_err">Cannot start eelo synchronizer</string>
    <string name="eelo_start_synchronizer_err">Cannot start eelo synchronizer</string>
    
    
    <string name="e_account_manager_setup_title">Configure <b>/e/</b> account</string>
    <string name="e_account_manager_setup_summary">Configure /e/ SSO...</string>
    <string name="e_account_manager_setup_configure">Set up</string>
    
</resources>
</resources>
+103 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 e.foundation
 * 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.cyanogenmod.setupwizard;

import android.content.Intent;
import android.view.View;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
import android.os.Bundle;

public class EAccountManagerActivity extends SubBaseActivity {

    public static final String TAG = EAccountManagerActivity.class.getSimpleName();
    
    private static boolean isInit = false;
    private AccountManager accountManager = null;

    @Override
    protected void onStartSubactivity() {
        setNextAllowed(true);
        findViewById(R.id.setup_e_account_manager).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                launchAccountManagerSetup();
            }
        });
    }

    @Override
    protected int getTransition() {
        return TRANSITION_ID_SLIDE;
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.setup_e_account_manager;
    }

    @Override
    protected int getTitleResId() {
        return R.string.e_account_manager_setup_title;
    }

    @Override
    protected int getIconResId() {
        return R.drawable.ic_lock_screen; // TODO
    }

    private void launchAccountManagerSetup() {
    
        isInit = true;
        
        try {
            accountManager = AccountManager.get(this);
            accountManager.addAccount("bitfire.at.davdroid.eelo", null, null, null, this, null, null);
        } 
        catch (Exception e) {} 
        finally {}
    }

    @Override
    protected int getSubactivityNextTransition() {
        return TRANSITION_ID_SLIDE;
    }
    
    @Override
    protected void onResume() {
        super.onResume();

        if (isInit == false)
            return;
        
        try {
            Account[] accounts = accountManager.getAccounts();
            if (accounts != null) {
                // An eelo account has been created, goto the next screen
                onNavigateNext();
            }
        } 
        catch (Exception e) {
            onNavigateNext();
        } 
        finally {}

    }

}