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

Commit ce1707bd authored by Sumit Pundir's avatar Sumit Pundir
Browse files

ui: eelo: distinguish b/w custom servers based on /e/ and others



Custom/Self-hosted based servers like pure NextCloud based and others do not have
mail server hosting sevices and syncing for their mail servers crashes the mail
application so distinguish and turn off syncs for them unlike /e/ based
custom servers which also implements a corresponding mail server with it.

Also, fix indentation for files.

Signed-off-by: default avatarSumit Pundir <pundirsumit11@gmail.com>
parent 1f14eef2
Loading
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@ class Credentials(
        val password: String? = null,
        val authState: AuthState? = null,
        val certificateAlias: String? = null,
	val serverUri: URI? = null
        val serverUri: URI? = null,
        val isTypeEelo: Boolean = true
) {

    enum class Type {
+73 −65
Original line number Diff line number Diff line
@@ -229,7 +229,15 @@ class AccountDetailsFragment: Fragment() {
                }

                ContentResolver.setSyncAutomatically(account, context.getString(R.string.notes_authority), true)

                /**
                 * Set Mail sync for custom servers not based on /e/ to be not syncable.
                 */
                if (!credentials.isTypeEelo)
                    ContentResolver.setIsSyncable(account, context.getString(R.string.email_authority), 0)
                else
                    ContentResolver.setSyncAutomatically(account, context.getString(R.string.email_authority), true)

                ContentResolver.setSyncAutomatically(account, context.getString(R.string.media_authority), true)
                ContentResolver.setSyncAutomatically(account, context.getString(R.string.app_data_authority), true)

+52 −32
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ import android.view.ViewGroup
import android.widget.Toast
import android.net.Uri
import android.net.ConnectivityManager
import android.text.method.LinkMovementMethod
import android.widget.RadioGroup

import foundation.e.accountmanager.R
import androidx.lifecycle.ViewModelProviders
@@ -32,6 +34,8 @@ class EeloAuthenticatorFragment : Fragment() {
    val TOGGLE_BUTTON_CHECKED_KEY = "toggle_button_checked"
    var toggleButtonState = false

    var isTypeEelo = true

    private fun isNetworkAvailable(): Boolean {
        val connectivityManager = activity!!.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
        val activeNetworkInfo = connectivityManager.activeNetworkInfo
@@ -67,8 +71,16 @@ class EeloAuthenticatorFragment : Fragment() {
            }
        }

        v.root.account_type_radio_group.setOnCheckedChangeListener(
                RadioGroup.OnCheckedChangeListener{ group, checkedId ->
                    if(checkedId == R.id.custom_type)
                        isTypeEelo = false
                })

        v.login.setOnClickListener { login() }

        v.root.learn_more_textview.setMovementMethod(LinkMovementMethod.getInstance())

        // code below is to draw toggle button in its correct state and show or hide server url input field
        //add by Vincent, 18/02/2019
        if(savedInstanceState != null){
@@ -78,10 +90,14 @@ class EeloAuthenticatorFragment : Fragment() {
        //This allow the button to be redraw in the correct state if user turn screen
        if(toggleButtonState == true) {
            v.root.expand_collapse_button.setChecked(toggleButtonState)
            v.root.account_type_layout.setVisibility(View.VISIBLE)
            v.root.learn_more_textview.setVisibility(View.VISIBLE)
            v.root.urlpwd_server_uri_layout.setVisibility(View.VISIBLE)
            v.root.urlpwd_server_uri.setEnabled(true)
        }else{
            v.root.urlpwd_server_uri_layout.setVisibility(View.GONE)
            v.root.learn_more_textview.setVisibility(View.GONE)
            v.root.account_type_layout.setVisibility(View.GONE)
            v.root.urlpwd_server_uri.setEnabled(false)
        }

@@ -147,7 +163,7 @@ class EeloAuthenticatorFragment : Fragment() {

                if (loginModel.baseURI != null) {
                    valid = true
		    loginModel.credentials = Credentials(userName.toLowerCase(), password, null, null, loginModel.baseURI)
                    loginModel.credentials = Credentials(userName.toLowerCase(), password, null, null, loginModel.baseURI, isTypeEelo)
                }
            }

@@ -165,11 +181,15 @@ class EeloAuthenticatorFragment : Fragment() {

        if(expand_collapse_button.isChecked) {
            urlpwd_server_uri_layout.setVisibility(View.VISIBLE)
            account_type_layout.setVisibility(View.VISIBLE)
            learn_more_textview.setVisibility(View.VISIBLE)
            urlpwd_server_uri.setEnabled(true)
            toggleButtonState = true;
        }
        else {
            urlpwd_server_uri_layout.setVisibility(View.GONE)
            account_type_layout.setVisibility(View.GONE)
            learn_more_textview.setVisibility(View.GONE)
            urlpwd_server_uri.setEnabled(false)
            toggleButtonState = false;
        }
+175 −119
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright © Ricki Hirner (bitfire web engineering).
  ~ All rights reserved. This program and the accompanying materials
  ~ are made available under the terms of the GNU Public License v3.0
@@ -8,11 +7,13 @@
  -->

<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto">
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <import type="android.view.View" />

        <variable
            name="model"
            type="foundation.e.accountmanager.ui.setup.EeloAuthenticatorModel" />
@@ -20,20 +21,24 @@

    <LinearLayout
        android:layout_width="match_parent"
	android:orientation="vertical"
	android:layout_height="match_parent">
        android:layout_height="match_parent"
        android:orientation="vertical">

        <!-- We don't want the keyboard up when the user arrives in this initial screen -->
    <View android:layout_height="0dp"
        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:contentDescription="@null"
            android:focusable="true"
            android:focusableInTouchMode="true"
        android:contentDescription="@null"
        android:importantForAccessibility="no" tools:ignore="UnusedAttribute">
            android:importantForAccessibility="no"
            tools:ignore="UnusedAttribute">

            <requestFocus />
        </View>

    	<ScrollView android:layout_width="match_parent"
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

@@ -42,26 +47,26 @@
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
            	android:paddingBottom="16dp"
            	android:paddingTop="8dp">
                android:paddingTop="8dp"
                android:paddingBottom="16dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="32dp"
                    android:layout_marginTop="32dp"
                    android:layout_marginBottom="32dp"
                    android:gravity="center"
                    android:text="@string/login_eelo_title"
                    android:textColor="#000000"
                    android:textSize="22sp" />

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
		    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
		    app:boxBackgroundColor="@android:color/white"
                    android:paddingStart="16dp"
                    android:paddingEnd="16dp"
                    android:paddingStart="16dp">
                    app:boxBackgroundColor="@android:color/white">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/urlpwd_user_name"
@@ -72,12 +77,12 @@
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
		    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
		    app:boxBackgroundColor="@android:color/white"
                    android:paddingEnd="16dp"
                    android:paddingStart="16dp"
                    android:paddingEnd="16dp"
                    app:boxBackgroundColor="@android:color/white"
                    app:passwordToggleEnabled="true">

                    <com.google.android.material.textfield.TextInputEditText
@@ -117,21 +122,21 @@
                        android:layout_marginBottom="24dp"
                        android:background="#00000000"
                        android:button="@drawable/custom_url_button_value"
                        android:clickable="false"
                        android:text=""
                        android:textOff=""
		    android:textOn="" 
		    android:clickable="false"/>	
                        android:textOn="" />

                </LinearLayout>
                <!--android:checked="false"-->
                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/urlpwd_server_uri_layout"
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
		    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    app:boxBackgroundColor="@android:color/white"
                    android:paddingStart="16dp"
                    android:paddingEnd="16dp">
                    android:paddingEnd="16dp"
                    app:boxBackgroundColor="@android:color/white">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/urlpwd_server_uri"
@@ -143,25 +148,76 @@
                        android:textAlignment="textStart" />
                </com.google.android.material.textfield.TextInputLayout>

                <LinearLayout
                    android:id="@+id/account_type_layout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/custom_account_type_title"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="24dp"
                        android:gravity="center_horizontal"
                        android:text="@string/custom_account_type_title"
                        android:textColor="#000000"
                        android:textSize="18sp" />

                    <RadioGroup
                        android:id="@+id/account_type_radio_group"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginEnd="10dp"
                        android:checkedButton="@+id/e_type"
                        android:orientation="horizontal">

                        <com.google.android.material.radiobutton.MaterialRadioButton
                            android:id="@+id/e_type"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="@string/e_type" />

                        <com.google.android.material.radiobutton.MaterialRadioButton
                            android:id="@+id/custom_type"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="@string/custom_type" />
                    </RadioGroup>

					<TextView
						android:id="@+id/learn_more_textview"
						android:layout_width="match_parent"
						android:layout_height="wrap_content"
						android:layout_marginTop="24dp"
						android:gravity="center_horizontal"
						android:text="@string/learn_more_text"
						android:textColor="#000000"
						android:textSize="16sp" />

                </LinearLayout>
            </LinearLayout>
        </ScrollView>

        <LinearLayout
            style="@style/stepper_nav_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
	    style="@style/stepper_nav_bar">
            android:layout_height="wrap_content">

            <Space
                style="@style/stepper_nav_button"
                android:layout_width="0dp"
            	android:layout_weight="1"
            	style="@style/stepper_nav_button"/>
                android:layout_weight="1" />

            <Button
                android:id="@+id/login"
                style="@style/stepper_nav_button"
                android:layout_width="0dp"
                android:layout_weight="1"
            	android:text="@string/login_login"
            	style="@style/stepper_nav_button"/>
                android:text="@string/login_login" />

        </LinearLayout>
    </LinearLayout>
+5 −0
Original line number Diff line number Diff line
@@ -352,4 +352,9 @@
    <string name="google_alert_title">WARNING</string>
    <string name="google_alert_message">/e/ will report a fake device model to Google to protect your privacy.\nYou can check which one on Google\'s Device Activity after you log in.</string>

    <!-- custom account -->
    <string name="custom_account_type_title">Your custom server implementation is based on:</string>
    <string name="e_type">/e/ Type</string>
    <string name="custom_type">Others</string>
    <string name="learn_more_text">Learn more about /e/ type servers <a href="https://gitlab.e.foundation/e/infra/ecloud-selfhosting/-/blob/develop/README.md">here.</a></string>
</resources>