Commit 0867f866 authored by Unknown's avatar Unknown

Merge branch 'AccountManager' into eelo-0.1

parents de4f7b14 d1816567
......@@ -2,6 +2,7 @@
<!--
Copyright (C) 2013 The CyanogenMod Project
Copyright (C) 2017 The LineageOS Project
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.
......@@ -45,6 +46,7 @@
<uses-permission android:name="cyanogenmod.permission.LEGALESE" />
<uses-permission android:name="cyanogenmod.permission.WRITE_SETTINGS"/>
<uses-permission android:name="cyanogenmod.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<permission
android:name="cyanogenmod.permission.PROTECTED_APP"
......@@ -262,6 +264,19 @@
</intent-filter>
</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"
android:label="@string/activity_label_empty"
android:excludeFromRecents="true"
......
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2017 The LineageOS 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="@color/black"
android:pathData="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1 .9 2 2
2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9
2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" />
</vector>
<?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>
......@@ -70,9 +70,13 @@
</WizardAction>
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_LOCKSCREEN_SETTINGS;end" id="lockscreen_settings">
<result wizard:action="finish" />
<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" />
</WizardAction>
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_SETUP_COMPLETE;end" id="finish">
<result wizard:action="exit" />
</WizardAction>
......
......@@ -84,4 +84,10 @@
<string name="lockscreen_setup_title">Protéger votre téléphone</string>
<string name="lockscreen_setup_summary"><b>"Protéger l\'appareil"</b>\" et exiger code, schéma ou mot de passe pour déverrouiller l\'écran\"</string>
<string name="lockscreen_setup_screen_lock_setup">Configurer</string>
<!-- e.foundation -->
<string name="e_account_manager_setup_title">Configurer votre compte <b>/e/</b></string>
<string name="e_account_manager_setup_summary">Permet d\'enregistrer vos identifiant /e/ dans le gestionnaire de compte afin de pouvoir les réutiliser simplement dans d\'autres applications.</string>
<string name="e_account_manager_setup_configure">Configurer</string>
</resources>
......@@ -110,6 +110,8 @@
<string name="lockscreen_setup_screen_lock_setup">Set up</string>
<!-- e.foundation -->
<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">Save your /e/ identifiers in the account manager, thus you can simply reuse them later in other applications.</string>
<string name="e_account_manager_setup_configure">Set up</string>
</resources>
/*
* 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_account_manager_screen;
}
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 {}
}
}
......@@ -64,29 +64,11 @@ public class FinishActivity extends BaseSetupWizardActivity {
private final Handler mHandler = new Handler();
private volatile boolean mIsFinishing = false;
private final static int EELO_SYNCHRONIZER_REQUEST_CODE = 0x01;
private boolean hasError = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hasError = false;
try {
Intent intent = new Intent("xxx.io.eelo.drive.LAUNCHER"); // TODO static
intent.putExtra("EELO_SETTINGS_LAUNCHER", "SETUP_WIZARD");
startActivityForResult(intent, EELO_SYNCHRONIZER_REQUEST_CODE);
} catch (android.content.ActivityNotFoundException err) {
hasError = true;
}
mSetupWizardApp = (SetupWizardApp) getApplication();
//mSetupWizardApp.getSettingsBundle().putBoolean(KEY_SEND_METRICS, false); // /e/ do *not* send metrics by default.
......@@ -96,31 +78,6 @@ public class FinishActivity extends BaseSetupWizardActivity {
EnableAccessibilityController.getInstance(getApplicationContext());
setNextText(R.string.start);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//super must be called
//super.onActivityResult(requestCode, resultCode, data);
if (requestCode==EELO_SYNCHRONIZER_REQUEST_CODE) {
//String message=data.getStringExtra("MESSAGE");
//alert(message);
if (resultCode == RESULT_CANCELED) {
//This is a BACK, or the Activity has not been found.
if (!hasError) {
// If the activity has not been found do *NOT* return back! (we will be in a (custom) loop)
onBackPressed();
}
}
}
}
@Override
protected int getTransition() {
......
......@@ -51,7 +51,6 @@ public class SetupWizardExitActivity extends BaseSetupWizardActivity {
SetupWizardUtils.enableCaptivePortalDetection(this);
PhoneMonitor.onSetupFinished();
launchHome();
launchEeloSynchronizer();
finish();
applyForwardTransition(TRANSITION_ID_FADE);
Intent i = new Intent();
......@@ -64,23 +63,5 @@ public class SetupWizardExitActivity extends BaseSetupWizardActivity {
.addCategory("android.intent.category.HOME")
.addFlags(FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_CLEAR_TASK));
}
/*
* Launch eelo synchronizer service
*/
private final void launchEeloSynchronizer() {
try {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
ComponentName receiver = new ComponentName("io.eelo.synchronizer",
"io.eelo.synchronizer.triggers.BootCompleteReceiver");
PackageManager pm = getPackageManager();
pm.setComponentEnabledSetting(receiver,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP);
} catch (java.lang.Throwable t) {
//Toast.makeText(getApplicationContext(), getString(R.string.eelo_start_synchronizer_err), Toast.LENGTH_LONG).show();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment