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

Commit e470a618 authored by Mohit Mali's avatar Mohit Mali Committed by Romain Hunault
Browse files

Setup /e/ colors

parent 7ce6d2c8
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -29,9 +29,16 @@ android {
    dataBinding {
    dataBinding {
        enabled = true
        enabled = true
    }
    }

    aaptOptions {
        additionalParameters '-I', 'e-ui-sdk.jar'
    }

}
}


dependencies {
dependencies {
    compileOnly files("../e-ui-sdk.jar")

    implementation project(':cert4android')
    implementation project(':cert4android')


    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxandroid:1.2.1'
+1 −21
Original line number Original line Diff line number Diff line
@@ -8,6 +8,7 @@ import android.view.WindowManager;


import androidx.annotation.ColorInt;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.ButterKnife;
import foundation.e.notes.R;
import foundation.e.notes.R;
import foundation.e.notes.android.fragment.about.AboutFragment;
import foundation.e.notes.android.fragment.about.AboutFragment;
@@ -20,27 +21,6 @@ public class AboutActivity extends AppCompatActivity {
        setContentView(R.layout.activity_about);
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
        ButterKnife.bind(this);
        getFragmentManager().beginTransaction().replace(R.id.container, new AboutFragment()).commit();
        getFragmentManager().beginTransaction().replace(R.id.container, new AboutFragment()).commit();
        updateAccentColor();
    }

    private void updateAccentColor(){
        //change toolbar color
        getSupportActionBar().setBackgroundDrawable(
                new ColorDrawable(NotesListViewActivity.ACCENT_COLOR));

        //change status bar color
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(darkenColor(NotesListViewActivity.ACCENT_COLOR));
        }
    }
    }


    @ColorInt
    int darkenColor(@ColorInt int color) {
        float[] hsv = new float[3];
        android.graphics.Color.colorToHSV(color, hsv);
        hsv[2] *= 0.8f;
        return android.graphics.Color.HSVToColor(hsv);
    }
}
}
 No newline at end of file
+8 −32
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@ import android.preference.PreferenceManager;


import androidx.annotation.ColorInt;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Bundle;
import android.view.View;
import android.view.View;
import android.view.Window;
import android.view.Window;
@@ -77,16 +78,14 @@ public class AccountActivity extends AppCompatActivity implements View.OnClickLi
        }
        }


        initview();
        initview();
        updateAccentColor();

    }
    }


    private void initview() {
    private void initview() {
        btn_eelo_Login = (Button) findViewById(R.id.eelo_account_login_button);
        btn_eelo_Login = (Button) findViewById(R.id.eelo_account_login_button);
        btn_eelo_Login.setBackgroundColor(NotesListViewActivity.ACCENT_COLOR);
        btn_eelo_Login.setOnClickListener(this);
        btn_eelo_Login.setOnClickListener(this);


        btn_manualLogin = (Button) findViewById(R.id.manual_account_login_button);
        btn_manualLogin = (Button) findViewById(R.id.manual_account_login_button);
        btn_manualLogin.setBackgroundColor(NotesListViewActivity.ACCENT_COLOR);
        btn_manualLogin.setOnClickListener(this);
        btn_manualLogin.setOnClickListener(this);


    }
    }
@@ -122,42 +121,19 @@ public class AccountActivity extends AppCompatActivity implements View.OnClickLi
        }
        }
    }
    }


    private void updateAccentColor(){
        //change toolbar color
        getSupportActionBar().setBackgroundDrawable(
                new ColorDrawable(NotesListViewActivity.ACCENT_COLOR));

        //change status bar color
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(darkenColor(NotesListViewActivity.ACCENT_COLOR));
        }
    }

    @ColorInt
    int darkenColor(@ColorInt int color) {
        float[] hsv = new float[3];
        android.graphics.Color.colorToHSV(color, hsv);
        hsv[2] *= 0.8f;
        return android.graphics.Color.HSVToColor(hsv);
    }

    @Override
    @Override
    public void onClick(View view) {
    public void onClick(View view) {


        if (view == btn_manualLogin) {
        if (view == btn_manualLogin) {
            if (getIntent().getBooleanExtra("preference", false)) {
            if (getIntent().getBooleanExtra("preference", false)) {
                startActivity(new Intent(AccountActivity.this, SettingsActivity.class));
                startActivity(new Intent(AccountActivity.this, SettingsActivity.class));
            }
            } else {
            else {
                Intent resultIntent = new Intent();
                Intent resultIntent = new Intent();
                resultIntent.putExtra(key_login_account, login_account_manual);
                resultIntent.putExtra(key_login_account, login_account_manual);
                setResult(RESULT_OK, resultIntent);
                setResult(RESULT_OK, resultIntent);
            }
            }
            finish();
            finish();
        }
        } else if (view == btn_eelo_Login) {
        else if(view==btn_eelo_Login){
            String[] accountTypes = new String[]{eelo_account_type};
            String[] accountTypes = new String[]{eelo_account_type};
            Intent intent = AccountManager.newChooseAccountIntent(
            Intent intent = AccountManager.newChooseAccountIntent(
                    null,
                    null,
+0 −21
Original line number Original line Diff line number Diff line
@@ -54,7 +54,6 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        }


        updateAccentColor();
    }
    }


    @Override
    @Override
@@ -222,24 +221,4 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
        }
        }
    }
    }


    private void updateAccentColor(){
        //change toolbar color
        getSupportActionBar().setBackgroundDrawable(
                new ColorDrawable(NotesListViewActivity.ACCENT_COLOR));

        //change status bar color
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(darkenColor(NotesListViewActivity.ACCENT_COLOR));
        }
    }

    @ColorInt
    int darkenColor(@ColorInt int color) {
        float[] hsv = new float[3];
        android.graphics.Color.colorToHSV(color, hsv);
        hsv[2] *= 0.8f;
        return android.graphics.Color.HSVToColor(hsv);
    }
}
}
+12 −66
Original line number Original line Diff line number Diff line
@@ -111,9 +111,6 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
    private final static String login_account_eelo = "login_account_eelo";
    private final static String login_account_eelo = "login_account_eelo";
    private final static String key_email_address = "email_address";
    private final static String key_email_address = "email_address";


    public static int ACCENT_COLOR;


    @BindView(R.id.notesListActivityActionBar)
    @BindView(R.id.notesListActivityActionBar)
    Toolbar toolbar;
    Toolbar toolbar;
    @BindView(R.id.drawerLayout)
    @BindView(R.id.drawerLayout)
@@ -168,7 +165,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap


                            newShortcuts.add(new ShortcutInfo.Builder(getApplicationContext(), note.getId() + "")
                            newShortcuts.add(new ShortcutInfo.Builder(getApplicationContext(), note.getId() + "")
                                    .setShortLabel(note.getTitle())
                                    .setShortLabel(note.getTitle())
                                    .setIcon(Icon.createWithResource(getApplicationContext(), note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp))
                                    .setIcon(Icon.createWithResource(getApplicationContext(), note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_border_white_24dp))
                                    .setIntent(intent)
                                    .setIntent(intent)
                                    .build());
                                    .build());
                        }
                        }
@@ -248,10 +245,6 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
        //    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(getResources().getColor(R.color.fg_default));
        //    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(getResources().getColor(R.color.fg_default));
        //}
        //}



        ACCENT_COLOR= fetchAccentColor(this);
        fabCreate.setBackgroundTintList(ColorStateList.valueOf(darkenColor20(ACCENT_COLOR)));
        headerView.setBackgroundColor(ACCENT_COLOR);
    }
    }


    private void migrateUrl() {
    private void migrateUrl() {
@@ -306,8 +299,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
            if (db.getNoteServerSyncHelper().isSyncPossible()) {
            if (db.getNoteServerSyncHelper().isSyncPossible()) {
                synchronize();
                synchronize();
            }
            }
        }
        } else {
        else {
            Snackbar.make(coordinatorLayout, getString(R.string.error_sync_disabled),
            Snackbar.make(coordinatorLayout, getString(R.string.error_sync_disabled),
                    Snackbar.LENGTH_LONG).setAction(R.string.action_enable_sync, new
                    Snackbar.LENGTH_LONG).setAction(R.string.action_enable_sync, new
                    View.OnClickListener() {
                    View.OnClickListener() {
@@ -350,6 +342,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
    private void setupNotesList() {
    private void setupNotesList() {
        initList();
        initList();
        // Pull to Refresh
        // Pull to Refresh
        swipeRefreshLayout.setColorSchemeColors(getColor(R.color.accent_color));
        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            @Override
            public void onRefresh() {
            public void onRefresh() {
@@ -360,8 +353,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
                        swipeRefreshLayout.setRefreshing(false);
                        swipeRefreshLayout.setRefreshing(false);
                        Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
                        Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
                    }
                    }
                }
                } else {
                else {
                    swipeRefreshLayout.setRefreshing(false);
                    swipeRefreshLayout.setRefreshing(false);
                    Snackbar.make(coordinatorLayout, getString(R.string.error_sync_disabled),
                    Snackbar.make(coordinatorLayout, getString(R.string.error_sync_disabled),
                            Snackbar.LENGTH_LONG).setAction(R.string.action_enable_sync, new
                            Snackbar.LENGTH_LONG).setAction(R.string.action_enable_sync, new
@@ -778,13 +770,11 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
                    } else {
                    } else {
                        Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
                        Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
                    }
                    }
                }
                } else {
                else {
                    Intent settingsIntent = new Intent(this, SettingsActivity.class);
                    Intent settingsIntent = new Intent(this, SettingsActivity.class);
                    startActivityForResult(settingsIntent, server_settings);
                    startActivityForResult(settingsIntent, server_settings);
                }
                }
            }
            } else {
            else {
                finish();
                finish();
            }
            }
        } else if (requestCode == server_settings) {
        } else if (requestCode == server_settings) {
@@ -798,8 +788,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
                } else {
                } else {
                    Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
                    Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
                }
                }
            }
            } else {
            else {
                finish();
                finish();
            }
            }
        }
        }
@@ -948,47 +937,4 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
        }
        }
    }
    }


    /*
     * get Accent color from OS
     * */
    private int fetchAccentColor(Context context) {

        TypedValue typedValue = new TypedValue();
        ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(this,
                android.R.style.Theme_DeviceDefault);
        contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent,
                typedValue, true);
        int color_accent = typedValue.data;
        Log.e("TAG", "accent Colour  #"+Integer.toHexString(color_accent));

        //change toolbar color
        getSupportActionBar().setBackgroundDrawable(
                new ColorDrawable(color_accent));

        //change status bar color
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(darkenColor(color_accent));
        }

        return color_accent;
    }


    @ColorInt
    int darkenColor(@ColorInt int color) {
        float[] hsv = new float[3];
        android.graphics.Color.colorToHSV(color, hsv);
        hsv[2] *= 0.8f;
        return android.graphics.Color.HSVToColor(hsv);
    }

    @ColorInt int darkenColor20(@ColorInt int color) {
        float[] hsv = new float[3];
        android.graphics.Color.colorToHSV(color, hsv);
        hsv[2] *= 0.6f;
        return android.graphics.Color.HSVToColor(hsv);
    }

}
}
Loading