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 { ...@@ -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'
......
...@@ -8,6 +8,7 @@ import android.view.WindowManager; ...@@ -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 { ...@@ -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
...@@ -10,6 +10,7 @@ import android.preference.PreferenceManager; ...@@ -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 ...@@ -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,49 +121,26 @@ public class AccountActivity extends AppCompatActivity implements View.OnClickLi ...@@ -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 @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,
null, null,
accountTypes, accountTypes,
null, null,
null, null,null); null, null, null);
startActivityForResult(intent, pick_account_request_code); startActivityForResult(intent, pick_account_request_code);
} }
......
...@@ -54,7 +54,6 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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,16 +299,15 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap ...@@ -306,16 +299,15 @@ 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() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS)); startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS));
} }
}).show(); }).show();
} }
super.onResume(); super.onResume();
} }
...@@ -350,6 +342,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 { ...@@ -27,27 +27,6 @@ public class PreferencesActivity extends AppCompatActivity {
.replace(android.R.id.content, new PreferencesFragment()) .replace(android.R.id.content, new PreferencesFragment())
.commit(); .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 { ...@@ -49,7 +49,6 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
swipeRefreshLayout.setEnabled(false); swipeRefreshLayout.setEnabled(false);
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
updateAccentColor();
} }
@Override @Override
...@@ -84,24 +83,4 @@ public class SelectSingleNoteActivity extends NotesListViewActivity { ...@@ -84,24 +83,4 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
finish(); 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; ...@@ -61,7 +61,7 @@ import static android.os.Process.myPid;
/** /**
* @author Nihar Thakkar * @author Nihar Thakkar
* * <p>
* Allows to set Settings like URL, Username and Password for Server-Synchronization * Allows to set Settings like URL, Username and Password for Server-Synchronization
* Created by stefan on 22.09.15. * Created by stefan on 22.09.15.
*/ */
...@@ -143,8 +143,6 @@ public class SettingsActivity extends AppCompatActivity { ...@@ -143,8 +143,6 @@ public class SettingsActivity extends AppCompatActivity {
handleSubmitButtonEnabled(); handleSubmitButtonEnabled();
updateAccentColor();
} }
private void setupListener() { private void setupListener() {
...@@ -347,7 +345,7 @@ public class SettingsActivity extends AppCompatActivity { ...@@ -347,7 +345,7 @@ public class SettingsActivity extends AppCompatActivity {
// show snackbar after 60s to switch back to old login method // show snackbar after 60s to switch back to old login method
new Handler().postDelayed(() -> { new Handler().postDelayed(() -> {
Snackbar.make(webView, R.string.fallback_weblogin_text, Snackbar.LENGTH_INDEFINITE) 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); }, 45 * 1000);
} }
...@@ -553,26 +551,4 @@ public class SettingsActivity extends AppCompatActivity { ...@@ -553,26 +551,4 @@ public class SettingsActivity extends AppCompatActivity {
String password; 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; ...@@ -15,6 +15,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.util.Log; import android.util.Log;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
...@@ -64,7 +65,7 @@ public class NoteListWidgetConfiguration extends AppCompatActivity { ...@@ -64,7 +65,7 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
if (extras != null) { if (extras != null) {
appWidgetId = extras.get