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

Setup /e/ colors

parent 7ce6d2c8
......@@ -29,9 +29,16 @@ android {
dataBinding {
enabled = true
}
aaptOptions {
additionalParameters '-I', 'e-ui-sdk.jar'
}
}
dependencies {
compileOnly files("../e-ui-sdk.jar")
implementation project(':cert4android')
implementation 'io.reactivex:rxandroid:1.2.1'
......
......@@ -8,6 +8,7 @@ import android.view.WindowManager;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import butterknife.ButterKnife;
import foundation.e.notes.R;
import foundation.e.notes.android.fragment.about.AboutFragment;
......@@ -20,27 +21,6 @@ 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
......@@ -10,6 +10,7 @@ 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;
......@@ -77,16 +78,14 @@ public class AccountActivity extends AppCompatActivity implements View.OnClickLi
}
initview();
updateAccentColor();
}
private void initview() {
btn_eelo_Login=(Button)findViewById(R.id.eelo_account_login_button);
btn_eelo_Login.setBackgroundColor(NotesListViewActivity.ACCENT_COLOR);
btn_eelo_Login = (Button) findViewById(R.id.eelo_account_login_button);
btn_eelo_Login.setOnClickListener(this);
btn_manualLogin=(Button)findViewById(R.id.manual_account_login_button);
btn_manualLogin.setBackgroundColor(NotesListViewActivity.ACCENT_COLOR);
btn_manualLogin = (Button) findViewById(R.id.manual_account_login_button);
btn_manualLogin.setOnClickListener(this);
}
......@@ -122,49 +121,26 @@ 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
public void onClick(View view) {
if(view==btn_manualLogin){
if (view == btn_manualLogin) {
if (getIntent().getBooleanExtra("preference", false)) {
startActivity(new Intent(AccountActivity.this, SettingsActivity.class));
}
else {
} else {
Intent resultIntent = new Intent();
resultIntent.putExtra(key_login_account, login_account_manual);
setResult(RESULT_OK, resultIntent);
}
finish();
}
else if(view==btn_eelo_Login){
} else if (view == btn_eelo_Login) {
String[] accountTypes = new String[]{eelo_account_type};
Intent intent = AccountManager.newChooseAccountIntent(
null,
null,
accountTypes,
null,
null, null,null);
null, null, null);
startActivityForResult(intent, pick_account_request_code);
}
......
......@@ -54,7 +54,6 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
actionBar.setDisplayHomeAsUpEnabled(true);
}
updateAccentColor();
}
@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);
}
}
......@@ -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 key_email_address = "email_address";
public static int ACCENT_COLOR;
@BindView(R.id.notesListActivityActionBar)
Toolbar toolbar;
@BindView(R.id.drawerLayout)
......@@ -168,7 +165,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
newShortcuts.add(new ShortcutInfo.Builder(getApplicationContext(), note.getId() + "")
.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)
.build());
}
......@@ -248,10 +245,6 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
// 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() {
......@@ -306,16 +299,15 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
if (db.getNoteServerSyncHelper().isSyncPossible()) {
synchronize();
}
}
else {
} else {
Snackbar.make(coordinatorLayout, getString(R.string.error_sync_disabled),
Snackbar.LENGTH_LONG).setAction(R.string.action_enable_sync, new
View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS));
}
}).show();
@Override
public void onClick(View view) {
startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS));
}
}).show();
}
super.onResume();
}
......@@ -350,6 +342,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
private void setupNotesList() {
initList();
// Pull to Refresh
swipeRefreshLayout.setColorSchemeColors(getColor(R.color.accent_color));
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
......@@ -360,8 +353,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
swipeRefreshLayout.setRefreshing(false);
Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
}
}
else {
} else {
swipeRefreshLayout.setRefreshing(false);
Snackbar.make(coordinatorLayout, getString(R.string.error_sync_disabled),
Snackbar.LENGTH_LONG).setAction(R.string.action_enable_sync, new
......@@ -778,13 +770,11 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
} else {
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);
startActivityForResult(settingsIntent, server_settings);
}
}
else {
} else {
finish();
}
} else if (requestCode == server_settings) {
......@@ -798,8 +788,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
} else {
Toast.makeText(getApplicationContext(), getString(R.string.error_sync, getString(NotesClientUtil.LoginStatus.NO_NETWORK.str)), Toast.LENGTH_LONG).show();
}
}
else {
} else {
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);
}
}
......@@ -27,27 +27,6 @@ public class PreferencesActivity extends AppCompatActivity {
.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);
}
}
......@@ -49,7 +49,6 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
swipeRefreshLayout.setEnabled(false);
swipeRefreshLayout.setRefreshing(false);
updateAccentColor();
}
@Override
......@@ -84,24 +83,4 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
finish();
}
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);
}
}
......@@ -61,7 +61,7 @@ import static android.os.Process.myPid;
/**
* @author Nihar Thakkar
*
* <p>
* Allows to set Settings like URL, Username and Password for Server-Synchronization
* Created by stefan on 22.09.15.
*/
......@@ -143,8 +143,6 @@ public class SettingsActivity extends AppCompatActivity {
handleSubmitButtonEnabled();
updateAccentColor();
}
private void setupListener() {
......@@ -347,7 +345,7 @@ public class SettingsActivity extends AppCompatActivity {
// show snackbar after 60s to switch back to old login method
new Handler().postDelayed(() -> {
Snackbar.make(webView, R.string.fallback_weblogin_text, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.fallback_weblogin_back, (View.OnClickListener) v -> initLegacyLogin(field_url.getText().toString())).show();
.setAction(R.string.fallback_weblogin_back, (View.OnClickListener) v -> initLegacyLogin(field_url.getText().toString())).show();
}, 45 * 1000);
}
......@@ -553,26 +551,4 @@ public class SettingsActivity extends AppCompatActivity {
String password;
}
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));
}
btn_submit.setBackgroundColor(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);
}
}
......@@ -15,6 +15,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
......@@ -64,7 +65,7 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
if (extras != null) {
appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
AppWidgetManager.INVALID_APPWIDGET_ID);
}
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
......@@ -73,13 +74,13 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
}
itemRecent = new NavigationAdapter.NavigationItem(NotesListViewActivity.ADAPTER_KEY_RECENT,
getString(foundation.e.notes.R.string.label_all_notes),
null,
foundation.e.notes.R.drawable.ic_access_time_grey600_24dp);
getString(foundation.e.notes.R.string.label_all_notes),
null,
foundation.e.notes.R.drawable.ic_access_time_grey600_24dp);
itemFavorites = new NavigationAdapter.NavigationItem(NotesListViewActivity.ADAPTER_KEY_STARRED,
getString(foundation.e.notes.R.string.label_favorites),
null,
foundation.e.notes.R.drawable.ic_star_yellow_24dp);
getString(foundation.e.notes.R.string.label_favorites),
null,
foundation.e.notes.R.drawable.ic_star_yellow_24dp);
RecyclerView recyclerView;
RecyclerView.LayoutManager layoutManager;
......@@ -104,8 +105,8 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
sp.putBoolean(NoteListWidget.DARK_THEME_KEY + appWidgetId, Notes.getAppTheme(getApplicationContext()));
sp.apply();
Intent updateIntent = new Intent( AppWidgetManager.ACTION_APPWIDGET_UPDATE, null,
getApplicationContext(), NoteListWidget.class);
Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null,
getApplicationContext(), NoteListWidget.class);
updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
setResult(RESULT_OK, updateIntent);
getApplicationContext().sendBroadcast(updateIntent);
......@@ -122,8 +123,6 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapterCategories);
updateAccentColor();
}
@Override
......@@ -170,26 +169,4 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
adapterCategories.setItems(items);
}
}
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);
}
}
......@@ -96,7 +96,7 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact
if (note.isFavorite()) {
note_content.setImageViewResource(R.id.widget_entry_fav_icon_dark, R.drawable.ic_star_yellow_24dp);
} else {
note_content.setImageViewResource(R.id.widget_entry_fav_icon_dark, R.drawable.ic_star_grey_ccc_24dp);
note_content.setImageViewResource(R.id.widget_entry_fav_icon_dark, R.drawable.ic_star_border_white_24dp);
}
} else {
note_content = new RemoteViews(context.getPackageName(), R.layout.widget_entry);
......@@ -106,7 +106,7 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact
if (note.isFavorite()) {
note_content.setImageViewResource(R.id.widget_entry_fav_icon, R.drawable.ic_star_yellow_24dp);
} else {
note_content.setImageViewResource(R.id.widget_entry_fav_icon, R.drawable.ic_star_grey_ccc_24dp);
note_content.setImageViewResource(R.id.widget_entry_fav_icon, R.drawable.ic_star_border_white_24dp);
}
}
......
......@@ -277,7 +277,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
ShortcutInfo pinShortcutInfo = new ShortcutInfo.Builder(getActivity(), note.getId() + "")
.setShortLabel(note.getTitle())
.setIcon(Icon.createWithResource(getActivity().getApplicationContext(), note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp))
.setIcon(Icon.createWithResource(getActivity().getApplicationContext(), note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_border_white_24dp))
.setIntent(intent)
.build();
......
......@@ -105,7 +105,7 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
nvHolder.noteCategory.setText(Html.fromHtml(note.getCategory()));
nvHolder.noteExcerpt.setText(Html.fromHtml(note.getExcerpt()));
nvHolder.noteStatus.setVisibility(DBStatus.VOID.equals(note.getStatus()) ? View.INVISIBLE : View.VISIBLE);
nvHolder.noteFavorite.setImageResource(note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp);
nvHolder.noteFavorite.setImageResource(note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_border_white_24dp);
nvHolder.noteFavorite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......
package foundation.e.notes.model;
import android.graphics.Color;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -97,8 +100,8 @@ public class NavigationAdapter extends RecyclerView.Adapter<NavigationAdapter.Vi
} else {
icon.setVisibility(View.GONE);
}
view.setBackgroundColor(isSelected ? view.getResources().getColor(R.color.bg_highlighted) : Color.TRANSPARENT);
int textColor = view.getResources().getColor(isSelected ? R.color.primary_dark : R.color.fg_default);
view.setBackgroundColor(isSelected ? view.getResources().getColor(R.color.bg_selected_item) : Color.TRANSPARENT);
int textColor = view.getResources().getColor(isSelected ? R.color.accent_color : R.color.fg_default);
name.setTextColor(textColor);
count.setTextColor(textColor);
......