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

Commit baab5e03 authored by Narinder Rana's avatar Narinder Rana
Browse files

Manage Accent color all Activity, Feb button, navigation drawer, some Button

parent ccaf4205
Loading
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
package foundation.e.notes.android.activity;

import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import butterknife.ButterKnife;
import foundation.e.notes.R;
@@ -15,6 +20,27 @@ public class AboutActivity extends AppCompatActivity {
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
        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
+71 −29
Original line number Diff line number Diff line
@@ -4,10 +4,17 @@ import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.preference.PreferenceManager;

import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import foundation.e.notes.R;

@@ -23,7 +30,7 @@ import static foundation.e.notes.android.activity.SettingsActivity.CREDENTIALS_C
 * @author Nihar Thakkar
 */

public class AccountActivity extends AppCompatActivity {
public class AccountActivity extends AppCompatActivity implements View.OnClickListener {

    private final static String key_login_account = "login_account";
    private final static String login_account_eelo = "login_account_eelo";
@@ -34,6 +41,8 @@ public class AccountActivity extends AppCompatActivity {

    private AccountManager accountManager;
    private SharedPreferences sharedPreferences;
    private Button btn_eelo_Login;
    private Button btn_manualLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -67,35 +76,19 @@ public class AccountActivity extends AppCompatActivity {
            }
        }

        findViewById(R.id.eelo_account_login_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String[] accountTypes = new String[]{eelo_account_type};
                Intent intent = AccountManager.newChooseAccountIntent(
                        null,
                        null,
                        accountTypes,
                        null,
                        null, null,null);

                startActivityForResult(intent, pick_account_request_code);
        initview();
        updateAccentColor();
    }
        });

        findViewById(R.id.manual_account_login_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (getIntent().getBooleanExtra("preference", false)) {
                    startActivity(new Intent(AccountActivity.this, SettingsActivity.class));
                }
                else {
                    Intent resultIntent = new Intent();
                    resultIntent.putExtra(key_login_account, login_account_manual);
                    setResult(RESULT_OK, resultIntent);
                }
                finish();
            }
        });
    private void initview() {
        btn_eelo_Login=(Button)findViewById(R.id.eelo_account_login_button);
        btn_eelo_Login.setBackgroundColor(NotesListViewActivity.ACCENT_COLOR);
        btn_eelo_Login.setOnClickListener(this);

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

    }

    @Override
@@ -128,4 +121,53 @@ public class AccountActivity extends AppCompatActivity {
            }
        }
    }

    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
    public void onClick(View view) {

        if(view==btn_manualLogin){
            if (getIntent().getBooleanExtra("preference", false)) {
                startActivity(new Intent(AccountActivity.this, SettingsActivity.class));
            }
            else {
                Intent resultIntent = new Intent();
                resultIntent.putExtra(key_login_account, login_account_manual);
                setResult(RESULT_OK, resultIntent);
            }
            finish();
        }
        else if(view==btn_eelo_Login){
            String[] accountTypes = new String[]{eelo_account_type};
            Intent intent = AccountManager.newChooseAccountIntent(
                    null,
                    null,
                    accountTypes,
                    null,
                    null, null,null);

            startActivityForResult(intent, pick_account_request_code);
        }

    }
}
+28 −0
Original line number Diff line number Diff line
@@ -3,12 +3,17 @@ package foundation.e.notes.android.activity;
import android.app.Fragment;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;

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

@@ -48,6 +53,8 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        updateAccentColor();
    }

    @Override
@@ -214,4 +221,25 @@ 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);
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.drawable.ColorDrawable;
@@ -249,6 +250,8 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap


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

    private void migrateUrl() {
@@ -980,4 +983,12 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
        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);
    }

}
+28 −0
Original line number Diff line number Diff line
package foundation.e.notes.android.activity;

import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

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

@@ -21,5 +26,28 @@ public class PreferencesActivity extends AppCompatActivity {
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, new PreferencesFragment())
                .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);
    }
}
Loading