Commit 756e7e89 authored by Romain Hunault's avatar Romain Hunault
Browse files

Merge branch 'e-theme-implementation' into 'master'

/e/ theme implementation

See merge request e/apps/notes!15
parents 7ce6d2c8 e470a618
Pipeline #81243 passed with stage
in 2 minutes and 52 seconds
......@@ -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,8 +299,7 @@ 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() {
......@@ -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() {
......@@ -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;
......@@ -104,7 +105,7 @@ 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,
Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null,
getApplicationContext(), NoteListWidget.class);
updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
setResult(RESULT_OK, 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);
......
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:tint="@color/accent_color"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z" />
</vector>
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#cccccc" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFcccccc" android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:tint="#cccccc"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFcccccc"
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z" />
</vector>
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:tint="@color/accent_color"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z" />
</vector>
<vector android:height="24dp" android:tint="#FFCC00"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">