1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2025-09-14 20:59:42 +02:00
This commit is contained in:
vanitasvitae 2016-10-24 18:17:39 +00:00 committed by GitHub
commit 18de19901b
54 changed files with 2434 additions and 388 deletions

View file

@ -50,7 +50,8 @@ dependencies {
compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.1.0' //Don't update. Broken up to 24.2.1 compile 'com.android.support:design:24.1.0' //Don't update. Broken up to 24.2.1
compile 'com.android.support:support-v4:24.2.1' compile 'com.android.support:support-v4:24.2.1'
compile "com.android.support:customtabs:24.2.1" compile 'com.android.support:customtabs:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
// More libraries // More libraries
compile 'com.jakewharton:butterknife:8.0.1' compile 'com.jakewharton:butterknife:8.0.1'

View file

@ -15,7 +15,8 @@
<provider <provider
android:name="com.github.dfa.diaspora_android.data.HashtagProvider" android:name="com.github.dfa.diaspora_android.data.HashtagProvider"
android:authorities="com.github.dfa.diaspora_android.mainactivity" /> android:authorities="com.github.dfa.diaspora_android.mainactivity"
android:exported="false"/>
<service <service
android:name="com.github.dfa.diaspora_android.task.GetPodsService" android:name="com.github.dfa.diaspora_android.task.GetPodsService"

View file

@ -69,7 +69,7 @@ public class AboutActivity extends ThemedActivity
private ViewPager mViewPager; private ViewPager mViewPager;
@BindView(R.id.about__appbar) @BindView(R.id.about__appbar)
AppBarLayout appBarLayout; protected AppBarLayout appBarLayout;
@BindView(R.id.main__topbar) @BindView(R.id.main__topbar)
protected Toolbar toolbar; protected Toolbar toolbar;
@ -87,7 +87,11 @@ public class AboutActivity extends ThemedActivity
ButterKnife.bind(this); ButterKnife.bind(this);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px)); if(Build.VERSION.SDK_INT >= 21) {
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px, getTheme()));
} else {
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px));
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -116,7 +120,7 @@ public class AboutActivity extends ThemedActivity
} }
@Override @Override
protected void applyColorToViews() { public void applyColorToViews() {
ThemeHelper.updateToolbarColor(toolbar); ThemeHelper.updateToolbarColor(toolbar);
ThemeHelper.updateTabLayoutColor(tabLayout); ThemeHelper.updateTabLayoutColor(tabLayout);
ThemeHelper.setPrimaryColorAsBackground(linearLayout); ThemeHelper.setPrimaryColorAsBackground(linearLayout);
@ -231,9 +235,8 @@ public class AboutActivity extends ThemedActivity
} }
public String getContributorsHtml(Context context) { public String getContributorsHtml(Context context) {
String text = Helpers.readTextfileFromRawRessource(context, R.raw.contributors, return Helpers.readTextfileFromRawRessource(context, R.raw.contributors,
"<font color='" + accentColor + "'><b>*</b></font> ", "<br>"); "<font color='" + accentColor + "'><b>*</b></font> ", "<br>");
return text;
} }
public String getMaintainersHtml(Context context) { public String getMaintainersHtml(Context context) {
@ -245,9 +248,8 @@ public class AboutActivity extends ThemedActivity
} }
public String getLicenseHtml(Context context) { public String getLicenseHtml(Context context) {
String text = Helpers.readTextfileFromRawRessource(context, R.raw.license, return Helpers.readTextfileFromRawRessource(context, R.raw.license,
"", "").replace("\n\n", "<br><br>"); "", "").replace("\n\n", "<br><br>");
return text;
} }
public String getLicense3dPartyHtml(Context context) { public String getLicense3dPartyHtml(Context context) {

View file

@ -25,6 +25,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -71,6 +72,7 @@ import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver; import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver;
import com.github.dfa.diaspora_android.receiver.UpdateTitleReceiver; import com.github.dfa.diaspora_android.receiver.UpdateTitleReceiver;
import com.github.dfa.diaspora_android.ui.BadgeDrawable; import com.github.dfa.diaspora_android.ui.BadgeDrawable;
import com.github.dfa.diaspora_android.ui.ContextMenuWebView;
import com.github.dfa.diaspora_android.ui.IntellihideToolbarActivityListener; import com.github.dfa.diaspora_android.ui.IntellihideToolbarActivityListener;
import com.github.dfa.diaspora_android.ui.PodSelectionDialog; import com.github.dfa.diaspora_android.ui.PodSelectionDialog;
import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.AppLog;
@ -440,11 +442,28 @@ public class MainActivity extends ThemedActivity
} else if (ACTION_CHANGE_ACCOUNT.equals(action)) { } else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
AppLog.v(this, "Reset pod data and show PodSelectionFragment"); AppLog.v(this, "Reset pod data and show PodSelectionFragment");
appSettings.setPod(null); appSettings.setPod(null);
app.resetPodData(((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView()); runOnUiThread(new Runnable() {
@Override
public void run() {
app.resetPodData(((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView());
}
});
showFragment(getFragment(PodSelectionFragment.TAG)); showFragment(getFragment(PodSelectionFragment.TAG));
} else if (ACTION_CLEAR_CACHE.equals(action)) { } else if (ACTION_CLEAR_CACHE.equals(action)) {
AppLog.v(this, "Clear WebView cache"); AppLog.v(this, "Clear WebView cache");
((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView().clearCache(true); showFragment(getFragment(DiasporaStreamFragment.TAG));
runOnUiThread(new Runnable() {
@Override
public void run() {
ContextMenuWebView wv = ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView();
if(wv != null) {
AppLog.d(this, "clearing...");
wv.clearCache(true);
} else {
AppLog.e(this, "WebView is null!");
}
}
});
} else if (Intent.ACTION_SEND.equals(action) && type != null) { } else if (Intent.ACTION_SEND.equals(action) && type != null) {
switch (type) { switch (type) {
case "text/plain": case "text/plain":
@ -528,6 +547,11 @@ public class MainActivity extends ThemedActivity
} }
} }
@Override
public AssetManager getAssets() {
return getResources().getAssets();
}
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
@ -588,7 +612,7 @@ public class MainActivity extends ThemedActivity
///Hide bottom toolbar ///Hide bottom toolbar
toolbarBottom.setVisibility(View.GONE); toolbarBottom.setVisibility(View.GONE);
} else { } else {
getMenuInflater().inflate(appSettings.isExtendedNotificationsActivated() ? getMenuInflater().inflate(appSettings.isExtendedNotifications() ?
R.menu.main__menu_top__notifications_dropdown : R.menu.main__menu_top, menu); R.menu.main__menu_top__notifications_dropdown : R.menu.main__menu_top, menu);
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu()); getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater()); top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
@ -631,7 +655,7 @@ public class MainActivity extends ThemedActivity
AppLog.i(this, "onOptionsItemSelected()"); AppLog.i(this, "onOptionsItemSelected()");
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_notifications: { case R.id.action_notifications: {
if(appSettings.isExtendedNotificationsActivated()) { if(appSettings.isExtendedNotifications()) {
return true; return true;
} }
//Otherwise we execute the action of action_notifications_all //Otherwise we execute the action of action_notifications_all
@ -736,7 +760,7 @@ public class MainActivity extends ThemedActivity
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
View layout = getLayoutInflater().inflate(R.layout.ui__dialog_search__people_tags, null, false); View layout = getLayoutInflater().inflate(R.layout.ui__dialog_search__people_tags, this.appBarLayout, false);
final EditText input = (EditText) layout.findViewById(R.id.dialog_search__input); final EditText input = (EditText) layout.findViewById(R.id.dialog_search__input);
final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
@Override @Override
@ -877,7 +901,7 @@ public class MainActivity extends ThemedActivity
AppLog.v(this, "Set shared text; Subject: \"" + escapedSubject + "\" Body: \"" + escapedBody + "\""); AppLog.v(this, "Set shared text; Subject: \"" + escapedSubject + "\" Body: \"" + escapedBody + "\"");
textToBeShared = "**" + escapedSubject + "** " + escapedBody; textToBeShared = "**" + escapedSubject + "** " + escapedBody;
} else { } else {
AppLog.v(this, "Set shared text; Subject: \"" + sharedSubject + "\" Body: \"" + sharedBody + "\""); AppLog.v(this, "Set shared text; Subject: \"null\" Body: \"" + sharedBody + "\"");
textToBeShared = escapedBody; textToBeShared = escapedBody;
} }
} }
@ -1090,14 +1114,14 @@ public class MainActivity extends ThemedActivity
/** /**
* Set the string that will be shared into the new-post-editor * Set the string that will be shared into the new-post-editor
* *
* @param textToBeShared * @param textToBeShared text that the user wants to share in the post editor
*/ */
public void setTextToBeShared(String textToBeShared) { public void setTextToBeShared(String textToBeShared) {
this.textToBeShared = textToBeShared; this.textToBeShared = textToBeShared;
} }
@Override @Override
protected void applyColorToViews() { public void applyColorToViews() {
ThemeHelper.updateToolbarColor(toolbarTop); ThemeHelper.updateToolbarColor(toolbarTop);
ThemeHelper.updateActionMenuViewColor(toolbarBottom); ThemeHelper.updateActionMenuViewColor(toolbarBottom);
navDrawerLayout.setBackgroundColor(appSettings.getPrimaryColor()); navDrawerLayout.setBackgroundColor(appSettings.getPrimaryColor());

View file

@ -1,61 +1,50 @@
/* /*
This file is part of the Diaspora for Android. This file is part of the Diaspora for Android.
Diaspora for Android is free software: you can redistribute it and/or modify Diaspora for Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful, Diaspora for Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with the Diaspora for Android. along with the Diaspora for Android.
If not, see <http://www.gnu.org/licenses/>. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.github.dfa.diaspora_android.activity; package com.github.dfa.diaspora_android.activity;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.support.design.widget.AppBarLayout; import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings; import com.github.dfa.diaspora_android.fragment.SettingsFragment__Overview;
import com.github.dfa.diaspora_android.ui.IntellihideToolbarActivityListener;
import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.ProxyHandler; import com.github.dfa.diaspora_android.util.ProxyHandler;
import com.github.dfa.diaspora_android.util.theming.ColorPalette;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper; import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import uz.shift.colorpicker.LineColorPicker;
import uz.shift.colorpicker.OnColorChangedListener;
/** /**
* @author vanitas * SettingsActivity
* Created by vanitas on 15.10.16.
*/ */
public class SettingsActivity extends ThemedActivity implements IntellihideToolbarActivityListener {
public class SettingsActivity extends ThemedActivity {
//Toolbar
@BindView(R.id.settings__appbar) @BindView(R.id.settings__appbar)
protected AppBarLayout appBarLayout; protected AppBarLayout appBarLayout;
@ -64,12 +53,11 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb
private ProxyHandler.ProxySettings oldProxySettings; private ProxyHandler.ProxySettings oldProxySettings;
public void onCreate(Bundle b) {
@Override super.onCreate(b);
public void onCreate(Bundle savedInstanceState) { this.setContentView(R.layout.settings_activity);
super.onCreate(savedInstanceState);
setContentView(R.layout.settings__activity);
ButterKnife.bind(this); ButterKnife.bind(this);
toolbar.setTitle(R.string.settings);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px)); toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px));
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@ -79,255 +67,16 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb
} }
}); });
oldProxySettings = getAppSettings().getProxySettings(); oldProxySettings = getAppSettings().getProxySettings();
getFragmentManager().beginTransaction().replace(R.id.settings__fragment_container, new SettingsFragment()).commit(); getSupportFragmentManager().beginTransaction().replace(
R.id.settings__fragment_container, new SettingsFragment__Overview(), SettingsFragment__Overview.TAG).commit();
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem menuItem) { public void applyColorToViews() {
switch (menuItem.getItemId()) { //Toolbar
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(menuItem);
}
}
@Override
protected void applyColorToViews() {
ThemeHelper.updateToolbarColor(toolbar); ThemeHelper.updateToolbarColor(toolbar);
} }
@Override
public void enableToolbarHiding() {
AppLog.d(this, "Enable Intellihide");
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
//scroll|enterAlways|snap
params.setScrollFlags(toolbarDefaultScrollFlags);
appBarLayout.setExpanded(true, true);
}
@Override
public void disableToolbarHiding() {
AppLog.d(this, "Disable Intellihide");
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
params.setScrollFlags(0); // clear all scroll flags
appBarLayout.setExpanded(true, true);
}
public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
private SharedPreferences sharedPreferences;
public void onCreate(Bundle savedInstances) {
super.onCreate(savedInstances);
getPreferenceManager().setSharedPreferencesName("app");
addPreferencesFromResource(R.xml.preferences);
sharedPreferences = getPreferenceScreen().getSharedPreferences();
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
setPreferenceSummaries();
sharedPreferences.edit().putBoolean(getString(R.string.pref_key__proxy_was_enabled),
sharedPreferences.getBoolean(getString(R.string.pref_key__http_proxy_enabled), false)).apply();
}
private void setPreferenceSummaries() {
String[] editTextKeys = new String[]{
getString(R.string.pref_key__http_proxy_host), getString(R.string.pref_key__http_proxy_port)
};
for (String key : editTextKeys) {
EditTextPreference p = (EditTextPreference) findPreference(key);
p.setSummary(p.getText());
}
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
updatePreference(findPreference(key));
if(isAdded()) {
if (key.equals(getString(R.string.pref_key__intellihide_toolbars))) {
if (sharedPreferences.getBoolean(getString(R.string.pref_key__intellihide_toolbars), false)) {
((SettingsActivity) getActivity()).enableToolbarHiding();
} else {
((SettingsActivity) getActivity()).disableToolbarHiding();
}
}
}
}
private void updatePreference(Preference preference) {
if (preference == null) {
return;
}
if (preference instanceof EditTextPreference) {
EditTextPreference textPref = (EditTextPreference) preference;
textPref.setSummary(textPref.getText());
return;
}
if (preference instanceof ListPreference) {
ListPreference listPref = (ListPreference) preference;
listPref.setSummary(listPref.getEntry());
}
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
App app = ((App) getActivity().getApplication());
AppSettings appSettings = app.getSettings();
if (Build.VERSION.SDK_INT >= 21) {
if (preference instanceof PreferenceScreen && ((PreferenceScreen) preference).getDialog() != null) {
Window window = ((PreferenceScreen) preference).getDialog().getWindow();
if (window != null) {
window.setStatusBarColor(ThemeHelper.getPrimaryDarkColor());
}
}
}
Intent intent = new Intent(getActivity(), MainActivity.class);
DiasporaUrlHelper diasporaUrlHelper = new DiasporaUrlHelper(app.getSettings());
switch (preference.getTitleRes()) {
case R.string.pref_title__primary_color: {
showColorPickerDialog(1);
intent = null;
break;
}
case R.string.pref_title__accent_color: {
showColorPickerDialog(2);
intent = null;
break;
}
case R.string.pref_title__personal_settings: {
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getPersonalSettingsUrl());
break;
}
case R.string.pref_title__manage_tags: {
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getManageTagsUrl());
break;
}
case R.string.pref_title__manage_contacts: {
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getManageContactsUrl());
break;
}
case R.string.pref_title__change_account: {
new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.confirmation))
.setMessage(getString(R.string.pref_warning__change_account))
.setNegativeButton(android.R.string.no, null)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_CHANGE_ACCOUNT);
startActivity(intent);
getActivity().finish();
}
})
.show();
return true;
}
case R.string.pref_title__http_proxy_load_tor_preset: {
((EditTextPreference) findPreference(getString(R.string.pref_key__http_proxy_host))).setText("127.0.0.1");
((EditTextPreference) findPreference(getString(R.string.pref_key__http_proxy_port))).setText("8118");
return true;
}
case R.string.pref_title__clear_cache: {
intent.setAction(MainActivity.ACTION_CLEAR_CACHE);
break;
}
default: {
intent = null;
break;
}
}
if (intent != null) {
startActivity(intent);
getActivity().finish();
return true;
}
return super.onPreferenceTreeClick(screen, preference);
}
/**
* Show a colorPicker Dialog
*
* @param type 1 -> Primary Color, 2 -> Accent Color
*/
public void showColorPickerDialog(final int type) {
final AppSettings appSettings = ((App) getActivity().getApplication()).getSettings();
final Context context = getActivity();
//Inflate dialog layout
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogLayout = inflater.inflate(R.layout.color_picker__dialog, null);
final android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(context);
builder.setView(dialogLayout);
final FrameLayout titleBackground = (FrameLayout) dialogLayout.findViewById(R.id.color_picker_dialog__title_background);
final TextView title = (TextView) dialogLayout.findViewById(R.id.color_picker_dialog__title);
final LineColorPicker base = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_dialog__base_picker);
final LineColorPicker shade = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_dialog__shade_picker);
title.setText(type == 1 ? R.string.pref_title__primary_color : R.string.pref_title__accent_color);
title.setTextColor(getResources().getColor(R.color.white));
final int[] current = (type == 1 ? appSettings.getPrimaryColorSettings() : appSettings.getAccentColorSettings());
base.setColors((type == 1 ? ColorPalette.getBaseColors(context) : ColorPalette.getAccentColors(context)));
base.setSelectedColor(current[0]);
shade.setColors(ColorPalette.getColors(context, current[0]));
shade.setSelectedColor(current[1]);
titleBackground.setBackgroundColor(shade.getColor());
base.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
AppLog.d(this, "Selected Base color changed: " + i);
shade.setColors(ColorPalette.getColors(context, i));
titleBackground.setBackgroundColor(i);
if (i == current[0]) {
shade.setSelectedColor(current[1]);
titleBackground.setBackgroundColor(shade.getColor());
}
}
});
shade.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
titleBackground.setBackgroundColor(i);
}
});
//Build dialog
builder
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (type == 1) {
appSettings.setPrimaryColorSettings(base.getColor(), shade.getColor());
if (Build.VERSION.SDK_INT >= 21) {
getActivity().getWindow().setStatusBarColor(ThemeHelper.getPrimaryDarkColor());
}
((ThemedActivity) getActivity()).applyColorToViews();
} else {
appSettings.setAccentColorSettings(base.getColor(), shade.getColor());
}
}
}).show();
}
}
@Override
protected void onPause() {
super.onPause();
// Reset logging
AppSettings settings = new AppSettings(getApplicationContext());
AppLog.setLoggingEnabled(settings.isLoggingEnabled());
AppLog.setLoggingSpamEnabled(settings.isLoggingSpamEnabled());
}
@Override @Override
protected void onStop() { protected void onStop() {
ProxyHandler.ProxySettings newProxySettings = getAppSettings().getProxySettings(); ProxyHandler.ProxySettings newProxySettings = getAppSettings().getProxySettings();

View file

@ -49,7 +49,7 @@ public abstract class ThemedActivity extends AppCompatActivity {
applyColorToViews(); applyColorToViews();
} }
protected abstract void applyColorToViews(); public abstract void applyColorToViews();
/** /**
* Update color of the status bar * Update color of the status bar

View file

@ -17,10 +17,14 @@ package com.github.dfa.diaspora_android.data;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod; import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl; import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl;
import com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference;
import com.github.dfa.diaspora_android.ui.ThemedIntEditTextPreference;
import com.github.dfa.diaspora_android.ui.ThemedStringEditTextPreference;
import com.github.dfa.diaspora_android.util.ProxyHandler; import com.github.dfa.diaspora_android.util.ProxyHandler;
import org.json.JSONException; import org.json.JSONException;
@ -75,24 +79,24 @@ public class AppSettings {
setString(pref, keyRessourceId, sb.toString().replaceFirst("%%%", "")); setString(pref, keyRessourceId, sb.toString().replaceFirst("%%%", ""));
} }
private String[] getStringArray(SharedPreferences pref, int keyRessourceId) { private String[] getStringArray(SharedPreferences pref, int keyResourceId) {
String value = pref.getString(context.getString(keyRessourceId), "%%%"); String value = pref.getString(context.getString(keyResourceId), "%%%");
if (value.equals("%%%")) { if (value.equals("%%%")) {
return new String[0]; return new String[0];
} }
return value.split("%%%"); return value.split("%%%");
} }
private String getString(SharedPreferences pref, int ressourceId, String defaultValue) { private String getString(SharedPreferences pref, int resourceId, String defaultValue) {
return pref.getString(context.getString(ressourceId), defaultValue); return pref.getString(context.getString(resourceId), defaultValue);
} }
private boolean getBoolean(SharedPreferences pref, int ressourceId, boolean defaultValue) { private boolean getBoolean(SharedPreferences pref, int resourceId, boolean defaultValue) {
return pref.getBoolean(context.getString(ressourceId), defaultValue); return pref.getBoolean(context.getString(resourceId), defaultValue);
} }
private int getInt(SharedPreferences pref, int ressourceId, int defaultValue) { private int getInt(SharedPreferences pref, int resourceId, int defaultValue) {
return pref.getInt(context.getString(ressourceId), defaultValue); return pref.getInt(context.getString(resourceId), defaultValue);
} }
@ -103,7 +107,7 @@ public class AppSettings {
return getString(prefPod, R.string.pref_key__podprofile_id, ""); return getString(prefPod, R.string.pref_key__podprofile_id, "");
} }
public void setProfileId(String profileId) { void setProfileId(String profileId) {
setString(prefPod, R.string.pref_key__podprofile_id, profileId); setString(prefPod, R.string.pref_key__podprofile_id, profileId);
} }
@ -125,6 +129,37 @@ public class AppSettings {
} }
} }
public String getMinimumFontSizeString() {
String[] values = context.getResources().getStringArray(R.array.pref_entries_values__font_size);
String[] titles = context.getResources().getStringArray(R.array.pref_entries__font_size);
String current = getString(prefApp, R.string.pref_key__font_size, "normal");
for(int i=0; i<values.length; i++) {
if(values[i].equals(current)) {
return titles[i];
}
}
return titles[0];
}
public void setMinimumFontSize(int size) {
switch (size) {
case 20:
setString(prefApp, R.string.pref_key__font_size, "huge");
break;
case 16:
setString(prefApp, R.string.pref_key__font_size, "large");
break;
default:
setString(prefApp, R.string.pref_key__font_size, "normal");
}
}
public void setMinimumFontSizeIndex(int index) {
if(index == 0) setMinimumFontSize(8);
else if(index == 1) setMinimumFontSize(16);
else setMinimumFontSize(20);
}
public String getAvatarUrl() { public String getAvatarUrl() {
return getString(prefPod, R.string.pref_key__podprofile_avatar_url, ""); return getString(prefPod, R.string.pref_key__podprofile_avatar_url, "");
} }
@ -237,21 +272,6 @@ public class AppSettings {
return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false); return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false);
} }
public boolean wasProxyEnabled() {
return getBoolean(prefApp, R.string.pref_key__proxy_was_enabled, false);
}
/**
* Needed in order to determine, whether the proxy has just been disabled (trigger app restart)
* or if proxy was disabled before (do not restart app)
*
* @param b new value
*/
@SuppressLint("CommitPrefEdits")
public void setProxyWasEnabled(boolean b) {
prefApp.edit().putBoolean(context.getString(R.string.pref_key__proxy_was_enabled), b).commit();
}
/** /**
* Default value: "" * Default value: ""
* *
@ -344,39 +364,71 @@ public class AppSettings {
return getBoolean(prefApp, R.string.pref_key__visibility_nav__profile, true); return getBoolean(prefApp, R.string.pref_key__visibility_nav__profile, true);
} }
public void setPrimaryColorSettings(int base, int shade) { public void setPrimaryColorPickerSettings(int base, int shade) {
setInt(prefApp, R.string.pref_key__primary_color_base, base); setInt(prefApp, R.string.pref_key__primary_color_base, base);
setInt(prefApp, R.string.pref_key__primary_color_shade, shade); setInt(prefApp, R.string.pref_key__primary_color_shade, shade);
} }
public int[] getPrimaryColorSettings() { public int[] getPrimaryColorPickerSettings() {
return new int[]{ return new int[]{
getInt(prefApp, R.string.pref_key__primary_color_base, context.getResources().getColor(R.color.md_blue_500)), getInt(prefApp, R.string.pref_key__primary_color_base, getColor(R.color.md_blue_500)),
getInt(prefApp, R.string.pref_key__primary_color_shade, context.getResources().getColor(R.color.primary)) getInt(prefApp, R.string.pref_key__primary_color_shade, getColor(R.color.primary))
}; };
} }
public int getPrimaryColor() { public int getPrimaryColor() {
return getInt(prefApp, R.string.pref_key__primary_color_shade, context.getResources().getColor(R.color.primary)); return getInt(prefApp, R.string.pref_key__primary_color_shade, getColor(R.color.primary));
} }
public void setAccentColorSettings(int base, int shade) { private int getColor(int id) {
if(Build.VERSION.SDK_INT >= 23) {
return context.getResources().getColor(id, context.getTheme());
} else {
return context.getResources().getColor(id);
}
}
public void setAccentColorPickerSettings(int base, int shade) {
setInt(prefApp, R.string.pref_key__accent_color_base, base); setInt(prefApp, R.string.pref_key__accent_color_base, base);
setInt(prefApp, R.string.pref_key__accent_color_shade, shade); setInt(prefApp, R.string.pref_key__accent_color_shade, shade);
} }
public int[] getAccentColorSettings() { public int[] getAccentColorPickerSettings() {
return new int[]{ return new int[]{
getInt(prefApp, R.string.pref_key__accent_color_base, context.getResources().getColor(R.color.md_deep_orange_500)), getInt(prefApp, R.string.pref_key__accent_color_base, getColor(R.color.md_deep_orange_500)),
getInt(prefApp, R.string.pref_key__accent_color_shade, context.getResources().getColor(R.color.accent)) getInt(prefApp, R.string.pref_key__accent_color_shade, getColor(R.color.accent))
}; };
} }
public int getAccentColor() { public int getAccentColor() {
return getInt(prefApp, R.string.pref_key__accent_color_shade, context.getResources().getColor(R.color.accent)); return getInt(prefApp, R.string.pref_key__accent_color_shade, getColor(R.color.accent));
} }
public boolean isExtendedNotificationsActivated() { public boolean isExtendedNotifications() {
return getBoolean(prefApp, R.string.pref_key__extended_notifications, false); return getBoolean(prefApp, R.string.pref_key__extended_notifications, false);
} }
}
public boolean getThemedCheckboxPreferenceValue(ThemedCheckBoxPreference t) {
return prefApp.getBoolean(t.getPrefKey(), t.getDefaultValue());
}
public void setThemedCheckboxPreferenceValue(ThemedCheckBoxPreference t, boolean b) {
prefApp.edit().putBoolean(t.getPrefKey(), b).apply();
}
public String getThemedStringEditTextPreferenceValue(ThemedStringEditTextPreference t) {
return prefApp.getString(t.getPrefKey(), t.getDefaultValue());
}
public void setThemedStringEditTextPreferenceValue(ThemedStringEditTextPreference t, String value) {
prefApp.edit().putString(t.getPrefKey(), value).apply();
}
public int getThemedIntEditTextPreferenceValue(ThemedIntEditTextPreference t) {
return prefApp.getInt(t.getPrefKey(), t.getDefaultValue());
}
public void setThemedIntEditTextPreferenceValue(ThemedIntEditTextPreference t, int value) {
prefApp.edit().putInt(t.getPrefKey(), value).apply();
}
}

View file

@ -1,5 +1,7 @@
package com.github.dfa.diaspora_android.data; package com.github.dfa.diaspora_android.data;
import android.support.annotation.NonNull;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -280,13 +282,11 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
} }
@Override @Override
public int compareTo(DiasporaPod otherPod) { public int compareTo(@NonNull DiasporaPod otherPod) {
if (otherPod != null) { List<DiasporaPodUrl> myPodUrls = getPodUrls();
List<DiasporaPodUrl> myPodUrls = getPodUrls(); List<DiasporaPodUrl> otherPodUrls = otherPod.getPodUrls();
List<DiasporaPodUrl> otherPodUrls = otherPod.getPodUrls(); if (!myPodUrls.isEmpty() && !otherPodUrls.isEmpty()) {
if (!myPodUrls.isEmpty() && !otherPodUrls.isEmpty()) { return myPodUrls.get(0).getHost().compareTo(otherPodUrls.get(0).getHost());
return myPodUrls.get(0).getHost().compareTo(otherPodUrls.get(0).getHost());
}
} }
return name.compareTo(otherPod.getName()); return name.compareTo(otherPod.getName());
} }
@ -406,7 +406,7 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
/** /**
* Get the base url * Get the base url
* *
* @return * @return baseUrl
*/ */
public String getBaseUrl() { public String getBaseUrl() {
return protocol + "://" + host + (isPortNeeded() ? port : ""); return protocol + "://" + host + (isPortNeeded() ? port : "");

View file

@ -24,21 +24,22 @@ import android.content.ContentProvider;
import android.content.ContentValues; import android.content.ContentValues;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull;
public class HashtagProvider extends ContentProvider { public class HashtagProvider extends ContentProvider {
@Override @Override
public int delete(Uri arg0, String arg1, String[] arg2) { public int delete(@NonNull Uri arg0, String arg1, String[] arg2) {
return 0; return 0;
} }
@Override @Override
public String getType(Uri arg0) { public String getType(@NonNull Uri arg0) {
return "vnd.android.cursor.item/vnd.cc.tag"; return "vnd.android.cursor.item/vnd.cc.tag";
} }
@Override @Override
public Uri insert(Uri arg0, ContentValues arg1) { public Uri insert(@NonNull Uri arg0, ContentValues arg1) {
return null; return null;
} }
@ -48,13 +49,13 @@ public class HashtagProvider extends ContentProvider {
} }
@Override @Override
public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3, public Cursor query(@NonNull Uri arg0, String[] arg1, String arg2, String[] arg3,
String arg4) { String arg4) {
return null; return null;
} }
@Override @Override
public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) { public int update(@NonNull Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
return 0; return 0;
} }
} }

View file

@ -107,9 +107,12 @@ public class BrowserFragment extends ThemedFragment {
loadUrl(pendingUrl); loadUrl(pendingUrl);
pendingUrl = null; pendingUrl = null;
} }
getActivity().runOnUiThread(new Runnable() {
webView.setParentActivity(getActivity()); @Override
public void run() {
webView.setParentActivity(getActivity());
}
});
this.setRetainInstance(true); this.setRetainInstance(true);
} }
@ -149,10 +152,15 @@ public class BrowserFragment extends ThemedFragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (webView != null) { getActivity().runOnUiThread(new Runnable() {
webSettings.setMinimumFontSize(appSettings.getMinimumFontSize()); @Override
webSettings.setLoadsImagesAutomatically(appSettings.isLoadImages()); public void run() {
} if (webView != null) {
webSettings.setMinimumFontSize(appSettings.getMinimumFontSize());
webSettings.setLoadsImagesAutomatically(appSettings.isLoadImages());
}
}
});
} }
@SuppressWarnings("ResultOfMethodCallIgnored") @SuppressWarnings("ResultOfMethodCallIgnored")
@ -249,16 +257,27 @@ public class BrowserFragment extends ThemedFragment {
public boolean onBackPressed() { public boolean onBackPressed() {
if (webView.canGoBack()) { if (webView.canGoBack()) {
webView.goBack(); getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
webView.goBack();
}
});
return true; return true;
} }
return false; return false;
} }
public void loadUrl(String url) { public void loadUrl(final String url) {
if (getWebView() != null) { if (getWebView() != null) {
AppLog.v(this, "loadUrl(): load " + url); AppLog.v(this, "loadUrl(): load " + url);
getWebView().loadUrlNew(url); getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
getWebView().loadUrlNew(url);
}
});
} else { } else {
AppLog.v(this, "loadUrl(): WebView null: Set pending url to " + url); AppLog.v(this, "loadUrl(): WebView null: Set pending url to " + url);
pendingUrl = url; pendingUrl = url;
@ -275,9 +294,15 @@ public class BrowserFragment extends ThemedFragment {
public void reloadUrl() { public void reloadUrl() {
AppLog.v(this, "reloadUrl()"); AppLog.v(this, "reloadUrl()");
if (getWebView() != null) { getActivity().runOnUiThread(new Runnable() {
getWebView().reload(); @Override
} public void run() {
if (getWebView() != null) {
getWebView().reload();
}
}
});
} }
public ContextMenuWebView getWebView() { public ContextMenuWebView getWebView() {

View file

@ -105,18 +105,18 @@ public class HashtagListFragment extends CustomFragment {
private String[] followedTagsList; private String[] followedTagsList;
private View.OnClickListener itemClickListener; private View.OnClickListener itemClickListener;
public static class ViewHolder extends RecyclerView.ViewHolder { static class ViewHolder extends RecyclerView.ViewHolder {
// each data item is just a string in this case // each data item is just a string in this case
public TextView title; public TextView title;
public ViewHolder(View v) { ViewHolder(View v) {
super(v); super(v);
title = (TextView) v.findViewById(R.id.recycler_view__list_item__text); title = (TextView) v.findViewById(R.id.recycler_view__list_item__text);
} }
} }
// Provide a suitable constructor (depends on the kind of dataset) // Provide a suitable constructor (depends on the kind of dataset)
public FollowedTagsAdapter(String[] tags, View.OnClickListener itemClickListener) { FollowedTagsAdapter(String[] tags, View.OnClickListener itemClickListener) {
this.followedTagsList = tags; this.followedTagsList = tags;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }

View file

@ -22,7 +22,6 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
@ -52,7 +51,6 @@ import com.github.dfa.diaspora_android.ui.PodSelectionDialog;
import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper; import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.Helpers; import com.github.dfa.diaspora_android.util.Helpers;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;

View file

@ -0,0 +1,87 @@
/*
This file is part of the Diaspora for Android.
Diaspora for Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.dfa.diaspora_android.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* SettingsFragment that contains debugging options
* Created by vanitas on 16.10.16.
*/
public class SettingsFragment__Debugging extends ThemedSettingsFragment {
public static final String TAG = "com.github.dfa.diaspora_android.SettingsFragment__Debugging";
@BindView(R.id.settings_activity__header_more__debugging)
protected TextView titleDebugging;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppLog.d(this, "onCreateView()");
View layout = inflater.inflate(R.layout.settings_activity__subsection_debugging, container, false);
ButterKnife.bind(this, layout);
return layout;
}
@Override
protected void applyColorToViews() {
ThemeHelper.updateTitleColor(titleDebugging);
}
@Override
protected void applySettingsToViews() {
}
@Override
protected void setOnClickListenersOnViews() {
}
@Override
public String getFragmentTag() {
return TAG;
}
@Override
public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
/* Nothing to do */
}
@Override
public boolean onBackPressed() {
return false;
}
@Override
public void onClick(View view) {
}
}

View file

@ -0,0 +1,86 @@
/*
This file is part of the Diaspora for Android.
Diaspora for Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.dfa.diaspora_android.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* SettingsFragment that controls the visibility of different NavigationSlider items
* Created by vanitas on 16.10.16.
*/
public class SettingsFragment__NavigationSlider extends ThemedSettingsFragment {
public static final String TAG = "com.github.dfa.diaspora_android.SettingsFragment__NavigationSlider";
@BindView(R.id.settings_activity__header_appearance__nav_slider)
protected TextView titleNavSlider;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppLog.d(this, "onCreateView()");
View layout = inflater.inflate(R.layout.settings_activity__subsection_nav_slider, container, false);
ButterKnife.bind(this, layout);
return layout;
}
@Override
protected void applyColorToViews() {
ThemeHelper.updateTitleColor(titleNavSlider);
}
@Override
public String getFragmentTag() {
return TAG;
}
@Override
public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
/* Nothing to do */
}
@Override
public boolean onBackPressed() {
return false;
}
@Override
protected void applySettingsToViews() {
}
@Override
protected void setOnClickListenersOnViews() {
}
@Override
public void onClick(View view) {
}
}

View file

@ -0,0 +1,258 @@
/*
This file is part of the Diaspora for Android.
Diaspora for Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.dfa.diaspora_android.fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.activity.MainActivity;
import com.github.dfa.diaspora_android.ui.ThemedPreference;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Fragment that holds the main settings screen
* Created by vanitas on 15.10.16.
*/
public class SettingsFragment__Overview extends ThemedSettingsFragment {
public static final String TAG = "com.github.dfa.diaspora_android.SettingsFragment__Overview";
//Appearance
@BindView(R.id.settings_activity__header_appearance)
protected TextView titleAppearance;
@BindView(R.id.settings_activity__themes)
protected ThemedPreference optionThemes;
@BindView(R.id.settings_activity__navigation_slider)
protected ThemedPreference optionNavigationSlider;
@BindView(R.id.settings_activity__font_size)
protected ThemedPreference optionFontSize;
//Pod Settings
@BindView(R.id.settings_activity__header_pod_settings)
protected TextView titlePodSettings;
@BindView(R.id.settings_activity__personal_settings)
protected ThemedPreference optionPersonalSettings;
@BindView(R.id.settings_activity__manage_tags)
protected ThemedPreference optionManageTags;
@BindView(R.id.settings_activity__manage_contacts)
protected ThemedPreference optionManageContacts;
@BindView(R.id.settings_activity__change_account)
protected ThemedPreference optionChangeAccount;
//Network
@BindView(R.id.settings_activity__header_network)
protected TextView titleNetwork;
@BindView(R.id.settings_activity__clear_cache)
protected ThemedPreference optionClearCache;
@BindView(R.id.settings_activity__proxy_settings)
protected ThemedPreference optionProxySettings;
//More
@BindView(R.id.settings_activity__header_more)
protected TextView titleMore;
@BindView(R.id.settings_activity__debugging)
protected ThemedPreference optionDebugging;
protected DiasporaUrlHelper urls;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppLog.d(this, "onCreateView()");
View layout = inflater.inflate(R.layout.settings_activity__overview, container, false);
ButterKnife.bind(this, layout);
return layout;
}
@Override
public void onViewCreated(View layout, Bundle savedInstanceState) {
super.onViewCreated(layout, savedInstanceState);
urls = new DiasporaUrlHelper(getAppSettings());
}
protected void applySettingsToViews() {
optionFontSize.setSummaryText(getAppSettings().getMinimumFontSizeString());
}
protected void setOnClickListenersOnViews() {
/** Appearance */
optionThemes.setOnClickListener(this);
optionNavigationSlider.setOnClickListener(this);
optionFontSize.setOnClickListener(this);
/** Pod Settings */
optionPersonalSettings.setOnClickListener(this);
optionManageTags.setOnClickListener(this);
optionManageContacts.setOnClickListener(this);
optionChangeAccount.setOnClickListener(this);
/** Network */
optionClearCache.setOnClickListener(this);
optionProxySettings.setOnClickListener(this);
/** More */
optionDebugging.setOnClickListener(this);
}
@Override
protected void applyColorToViews() {
AppLog.d(this, "applyColorToViews()");
ThemeHelper.getInstance(getAppSettings());
//Card Titles
ThemeHelper.updateTitleColor(titleAppearance);
ThemeHelper.updateTitleColor(titlePodSettings);
ThemeHelper.updateTitleColor(titleNetwork);
ThemeHelper.updateTitleColor(titleMore);
}
protected void showFontSizeDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
ListView listView = (ListView) getLayoutInflater(null).inflate(R.layout.settings_activity__dialog_font_size, null, false);
builder.setView(listView)
.setTitle(R.string.pref_title__font_size);
final AlertDialog dialog = builder.create();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
getAppSettings().setMinimumFontSizeIndex(i);
optionFontSize.setSummaryText(getAppSettings().getMinimumFontSizeString());
dialog.dismiss();
}
});
dialog.show();
}
@Override
public String getFragmentTag() {
return TAG;
}
@Override
public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
/* Nothing to do */
}
@Override
public boolean onBackPressed() {
return false;
}
@Override
public void onClick(View view) {
AppLog.d(this, "Click!");
switch (view.getId()) {
/** Appearance */
case R.id.settings_activity__themes:
AppLog.d(this, "Themes!");
getFragmentManager().beginTransaction()
.addToBackStack(null)
.replace(R.id.settings__fragment_container, new SettingsFragment__ThemeColors(), SettingsFragment__ThemeColors.TAG).commit();
break;
case R.id.settings_activity__navigation_slider:
getFragmentManager().beginTransaction().addToBackStack(null)
.replace(R.id.settings__fragment_container, new SettingsFragment__NavigationSlider(), SettingsFragment__NavigationSlider.TAG).commit();
break;
case R.id.settings_activity__font_size:
showFontSizeDialog();
break;
/** Pod Settings */
case R.id.settings_activity__personal_settings: {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, urls.getPersonalSettingsUrl());
startActivity(intent);
getActivity().finish();
break;
}
case R.id.settings_activity__manage_tags: {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, urls.getManageTagsUrl());
startActivity(intent);
getActivity().finish();
break;
}
case R.id.settings_activity__manage_contacts: {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_OPEN_URL);
intent.putExtra(MainActivity.URL_MESSAGE, urls.getManageContactsUrl());
startActivity(intent);
getActivity().finish();
break;
}
case R.id.settings_activity__change_account: {
new android.app.AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.confirmation))
.setMessage(getString(R.string.pref_warning__change_account))
.setNegativeButton(android.R.string.no, null)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_CHANGE_ACCOUNT);
startActivity(intent);
getActivity().finish();
}
})
.show();
break;
}
/** Network */
case R.id.settings_activity__clear_cache: {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setAction(MainActivity.ACTION_CLEAR_CACHE);
getActivity().sendBroadcast(intent);
getActivity().finish();
break;
}
case R.id.settings_activity__proxy_settings:
getFragmentManager().beginTransaction().addToBackStack(null)
.replace(R.id.settings__fragment_container, new SettingsFragment__Proxy(), SettingsFragment__Proxy.TAG).commit();
break;
/** More */
case R.id.settings_activity__debugging:
getFragmentManager().beginTransaction().addToBackStack(null)
.replace(R.id.settings__fragment_container, new SettingsFragment__Debugging(), SettingsFragment__Debugging.TAG).commit();
break;
}
}
}

View file

@ -0,0 +1,130 @@
/*
This file is part of the Diaspora for Android.
Diaspora for Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.dfa.diaspora_android.fragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference;
import com.github.dfa.diaspora_android.ui.ThemedIntEditTextPreference;
import com.github.dfa.diaspora_android.ui.ThemedPreference;
import com.github.dfa.diaspora_android.ui.ThemedStringEditTextPreference;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* SettingsFragment that contains some proxy related settings
* Created by vanitas on 16.10.16.
*/
public class SettingsFragment__Proxy extends ThemedSettingsFragment {
public static final String TAG = "com.github.dfa.diaspora_android.SettingsFragment__Proxy";
@BindView(R.id.settings_activity__header_network__proxy)
protected TextView titleProxy;
@BindView(R.id.settings_activity__proxy_enabled)
protected ThemedCheckBoxPreference checkboxProxyEnabled;
@BindView(R.id.settings_activity__proxy_host)
protected ThemedStringEditTextPreference editTextProxyHost;
@BindView(R.id.settings_activity__proxy_port)
protected ThemedIntEditTextPreference editTextProxyPort;
@BindView(R.id.settings_activity__proxy_orbot_preset)
protected ThemedPreference optionProxyOrbotPreset;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppLog.d(this, "onCreateView()");
View layout = inflater.inflate(R.layout.settings_activity__subsection_proxy, container, false);
ButterKnife.bind(this, layout);
return layout;
}
@Override
protected void applyColorToViews() {
ThemeHelper.updateTitleColor(titleProxy);
}
@SuppressLint("SetTextI18n")
@Override
protected void applySettingsToViews() {
boolean enabled = getAppSettings().isProxyHttpEnabled();
editTextProxyHost.setVisibility(enabled ? View.VISIBLE : View.GONE);
editTextProxyHost.setEnabled(enabled);
editTextProxyPort.setVisibility(enabled ? View.VISIBLE : View.GONE);
editTextProxyPort.setEnabled(enabled);
optionProxyOrbotPreset.setVisibility(enabled ? View.VISIBLE : View.GONE);
optionProxyOrbotPreset.setEnabled(enabled);
}
@Override
protected void setOnClickListenersOnViews() {
optionProxyOrbotPreset.setOnClickListener(this);
checkboxProxyEnabled.setOnCheckedChangedListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
AppLog.d(this, "Clicked: Proxy Enabled");
applySettingsToViews();
}
});
}
@SuppressLint("SetTextI18n")
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.settings_activity__proxy_orbot_preset:
AppLog.d(this, "Clicked: Proxy Preset");
editTextProxyHost.setValue("localhost");
editTextProxyPort.setValue(8118);
Toast.makeText(getContext(), R.string.toast__proxy_orbot_preset_set, Toast.LENGTH_SHORT).show();
break;
}
}
@Override
public String getFragmentTag() {
return TAG;
}
@Override
public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
/* Nothing to do */
}
@Override
public boolean onBackPressed() {
return false;
}
}

View file

@ -0,0 +1,194 @@
/*
This file is part of the Diaspora for Android.
Diaspora for Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.dfa.diaspora_android.fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.activity.ThemedActivity;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.theming.ColorPalette;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
import uz.shift.colorpicker.LineColorPicker;
import uz.shift.colorpicker.OnColorChangedListener;
/**
* SettingsFragment that contains Theme and Color related settings
* Created by vanitas on 15.10.16.
*/
public class SettingsFragment__ThemeColors extends ThemedSettingsFragment {
public static final String TAG = "com.github.dfa.diaspora_android.SettingsFragment__ThemeColors";
@BindView(R.id.settings_activity__header_appearance__theme_and_colors)
protected TextView titleThemeColors;
@BindView(R.id.settings_activity__theme_colors__primary_color)
protected RelativeLayout optionPrimaryColor;
@BindView(R.id.settings_activity__theme_colors__primary_color__preview)
protected ImageView previewPrimaryColor;
@BindView(R.id.settings_activity__theme_colors__accent_color)
protected RelativeLayout optionAccentColor;
@BindView(R.id.settings_activity__theme_colors__accent_color__preview)
protected ImageView previewAccentColor;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppLog.d(this, "onCreateView()");
View layout = inflater.inflate(R.layout.settings_activity__subsection_theming, container, false);
ButterKnife.bind(this, layout);
return layout;
}
protected void applySettingsToViews() {
ThemeHelper.updatePrimaryColorPreview(previewPrimaryColor);
ThemeHelper.updateAccentColorPreview(previewAccentColor);
}
protected void setOnClickListenersOnViews() {
optionPrimaryColor.setOnClickListener(this);
previewPrimaryColor.setOnClickListener(this);
optionAccentColor.setOnClickListener(this);
previewAccentColor.setOnClickListener(this);
}
@Override
protected void applyColorToViews() {
ThemeHelper.updateTitleColor(titleThemeColors);
}
@Override
public String getFragmentTag() {
return TAG;
}
@Override
public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
/* Nothing to do */
}
@Override
public boolean onBackPressed() {
return false;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.settings_activity__theme_colors__primary_color:
case R.id.settings_activity__theme_colors__primary_color__preview:
showColorPickerDialog(1);
break;
case R.id.settings_activity__theme_colors__accent_color:
case R.id.settings_activity__theme_colors__accent_color__preview:
showColorPickerDialog(2);
break;
}
}
/**
* Show a colorPicker Dialog
*
* @param type 1 -> Primary Color, 2 -> Accent Color
*/
public void showColorPickerDialog(final int type) {
final AppSettings appSettings = ((App) getActivity().getApplication()).getSettings();
final Context context = getActivity();
//Inflate dialog layout
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogLayout = inflater.inflate(R.layout.color_picker__dialog, null);
final android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(context);
builder.setView(dialogLayout);
final FrameLayout titleBackground = (FrameLayout) dialogLayout.findViewById(R.id.color_picker_dialog__title_background);
final TextView title = (TextView) dialogLayout.findViewById(R.id.color_picker_dialog__title);
final LineColorPicker base = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_dialog__base_picker);
final LineColorPicker shade = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_dialog__shade_picker);
title.setText(type == 1 ? R.string.pref_title__primary_color : R.string.pref_title__accent_color);
title.setTextColor(getResources().getColor(R.color.white));
final int[] current = (type == 1 ? appSettings.getPrimaryColorPickerSettings() : appSettings.getAccentColorPickerSettings());
base.setColors((type == 1 ? ColorPalette.getBaseColors(context) : ColorPalette.getAccentColors(context)));
base.setSelectedColor(current[0]);
shade.setColors(ColorPalette.getColors(context, current[0]));
shade.setSelectedColor(current[1]);
titleBackground.setBackgroundColor(shade.getColor());
base.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
AppLog.d(this, "Selected Base color changed: " + i);
shade.setColors(ColorPalette.getColors(context, i));
titleBackground.setBackgroundColor(i);
if (i == current[0]) {
shade.setSelectedColor(current[1]);
titleBackground.setBackgroundColor(shade.getColor());
} else {
shade.setSelectedColor(i);
}
}
});
shade.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
titleBackground.setBackgroundColor(i);
}
});
//Build dialog
builder
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (type == 1) { //Primary Color
appSettings.setPrimaryColorPickerSettings(base.getColor(), shade.getColor());
if (Build.VERSION.SDK_INT >= 21) {
getActivity().getWindow().setStatusBarColor(ThemeHelper.getPrimaryDarkColor());
}
((ThemedActivity) getActivity()).applyColorToViews();
} else { //Accent Color
appSettings.setAccentColorPickerSettings(base.getColor(), shade.getColor());
}
applyColorToViews();
applySettingsToViews();
}
}).show();
}
}

View file

@ -0,0 +1,48 @@
/*
This file is part of the Diaspora for Android.
Diaspora for Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.dfa.diaspora_android.fragment;
import android.os.Bundle;
import android.view.View;
/**
* Abstract class of a SettingsFragment that is themed and listens for clicks on views
* Created by vanitas on 16.10.16.
*/
public abstract class ThemedSettingsFragment extends ThemedFragment implements View.OnClickListener {
@Override
public void onViewCreated(View layout, Bundle savedInstanceState) {
super.onViewCreated(layout, savedInstanceState);
applyColorToViews();
applySettingsToViews();
setOnClickListenersOnViews();
}
/**
* Apply current settings to views (like checked checkboxes...)
*/
protected abstract void applySettingsToViews();
/**
* Set the onClickListener (normally this) on views.
*/
protected abstract void setOnClickListenersOnViews();
}

View file

@ -53,7 +53,7 @@ public class OpenExternalLinkReceiver extends BroadcastReceiver {
AppLog.v(this, "OpenExternalLinkReceiver.onReceive(): url"); AppLog.v(this, "OpenExternalLinkReceiver.onReceive(): url");
Uri url = null; Uri url;
try { try {
String sUrl = receiveIntent.getStringExtra(MainActivity.EXTRA_URL); String sUrl = receiveIntent.getStringExtra(MainActivity.EXTRA_URL);
url = Uri.parse(sUrl); url = Uri.parse(sUrl);

View file

@ -56,7 +56,6 @@ public class StatisticsFetchTask extends AsyncTask<Void, Void, Void> {
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
String extractedProfileData = null;
final CookieManager cookieManager = app.getCookieManager(); final CookieManager cookieManager = app.getCookieManager();
String cookies = cookieManager.getCookie(urls.getPodUrl()); String cookies = cookieManager.getCookie(urls.getPodUrl());

View file

@ -28,6 +28,7 @@ import android.graphics.Rect;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
@ -67,7 +68,7 @@ public class BadgeDrawable extends Drawable {
} }
@Override @Override
public void draw(Canvas canvas) { public void draw(@NonNull Canvas canvas) {
if (!shouldDraw) { if (!shouldDraw) {
return; return;
} }

View file

@ -5,7 +5,6 @@ import android.app.Dialog;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatDialogFragment;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -35,12 +34,13 @@ import butterknife.OnClick;
import butterknife.OnItemSelected; import butterknife.OnItemSelected;
/** /**
* Dialog that lets the user chose a pod
* Created by gsantner (https://gsantner.github.io) on 06.10.16. * Created by gsantner (https://gsantner.github.io) on 06.10.16.
*/ */
public class PodSelectionDialog extends ThemedAppCompatDialogFragment { public class PodSelectionDialog extends ThemedAppCompatDialogFragment {
public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionDialog"; public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionDialog";
public static interface PodSelectionDialogResultListener { public interface PodSelectionDialogResultListener {
void onPodSelectionDialogResult(DiasporaPod pod, boolean accepted); void onPodSelectionDialogResult(DiasporaPod pod, boolean accepted);
} }
@ -118,8 +118,8 @@ public class PodSelectionDialog extends ThemedAppCompatDialogFragment {
textProfile.setVisibility(View.VISIBLE); textProfile.setVisibility(View.VISIBLE);
spinnerProfile.setVisibility(View.VISIBLE); spinnerProfile.setVisibility(View.VISIBLE);
String[] podUrlss = new String[podUrls.size()]; String[] podUrlss = new String[podUrls.size()];
for (int i = 0; i < podUrls.size(); podUrlss[i] = podUrls.get(i++).getBaseUrl()) ; //for (int i = 0; i < podUrls.size(); podUrlss[i] = podUrls.get(i++).getBaseUrl()) ;
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, podUrlss); ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, podUrlss);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerProfile.setAdapter(spinnerAdapter); spinnerProfile.setAdapter(spinnerAdapter);
} }
@ -131,11 +131,11 @@ public class PodSelectionDialog extends ThemedAppCompatDialogFragment {
protected void applyColorsToViews() { protected void applyColorsToViews() {
ThemeHelper.getInstance(app.getSettings()); ThemeHelper.getInstance(app.getSettings());
textPodAddress.setTextColor(ThemeHelper.getAccentColor()); ThemeHelper.updateTitleColor(textPodAddress);
textPodName.setTextColor(ThemeHelper.getAccentColor()); ThemeHelper.updateTitleColor(textPodName);
textProfile.setTextColor(ThemeHelper.getAccentColor()); ThemeHelper.updateTitleColor(textProfile);
textProtocol.setTextColor(ThemeHelper.getAccentColor()); ThemeHelper.updateTitleColor(textProtocol);
textTorPreset.setTextColor(ThemeHelper.getAccentColor()); ThemeHelper.updateTitleColor(textTorPreset);
ThemeHelper.updateEditTextColor(editPodAddress); ThemeHelper.updateEditTextColor(editPodAddress);
ThemeHelper.updateEditTextColor(editPodName); ThemeHelper.updateEditTextColor(editPodName);
@ -205,7 +205,6 @@ public class PodSelectionDialog extends ThemedAppCompatDialogFragment {
if(pod.getPodUrl().getHost().endsWith(".onion") && checkboxTorPreset.isChecked()){ if(pod.getPodUrl().getHost().endsWith(".onion") && checkboxTorPreset.isChecked()){
AppSettings settings = app.getSettings(); AppSettings settings = app.getSettings();
settings.setProxyHttpEnabled(true); settings.setProxyHttpEnabled(true);
settings.setProxyWasEnabled(false);
settings.setProxyHttpPort(8118); settings.setProxyHttpPort(8118);
settings.setProxyHttpHost("127.0.0.1"); settings.setProxyHttpHost("127.0.0.1");
ProxyHandler.getInstance().updateProxySettings(getContext()); ProxyHandler.getInstance().updateProxySettings(getContext());

View file

@ -0,0 +1,143 @@
package com.github.dfa.diaspora_android.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Customizable CheckboxPreference-like widget
* Created by vanitas on 23.10.16.
*/
public class ThemedCheckBoxPreference extends RelativeLayout implements ThemedPreferenceObject<Boolean> {
@BindView(R.id.preference__themed_checkbox__title)
protected TextView title;
@BindView(R.id.preference__themed_checkbox__summary)
protected TextView summary;
@BindView(R.id.preference__themed_checkbox__checkbox)
protected CheckBox checkBox;
protected String prefKey;
protected boolean defaultValue;
protected AppSettings appSettings;
protected CompoundButton.OnCheckedChangeListener externalOnCheckedChangedListener;
public ThemedCheckBoxPreference(Context context) {
super(context);
init(context, null, 0);
}
public ThemedCheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
public ThemedCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs, defStyle);
}
protected void init(Context context, AttributeSet attrs, int defStyle) {
appSettings = new AppSettings(context.getApplicationContext());
View.inflate(context, R.layout.preference__themed_checkbox, this);
ButterKnife.bind(this);
setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
checkBox.performClick();
}
});
// Assign custom attributes
if (attrs != null) {
String titleText = "";
String summaryText = "";
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThemedCheckBoxPreference, defStyle, 0);
try {
titleText = a.getString(R.styleable.ThemedCheckBoxPreference_titleText);
summaryText = a.getString(R.styleable.ThemedCheckBoxPreference_summaryText);
prefKey = a.getString(R.styleable.ThemedCheckBoxPreference_prefKey);
defaultValue = a.getBoolean(R.styleable.ThemedCheckBoxPreference_defaultBoolean, false);
} catch (Exception e) {
AppLog.e(this, "There was an error loading attributes.");
} finally {
a.recycle();
}
setTitleText(titleText);
if(titleText == null || titleText.equals("")) {
title.setVisibility(GONE);
}
setSummaryText(summaryText);
if(summaryText == null || summaryText.equals("")) {
summary.setVisibility(GONE);
}
setChecked(appSettings.getThemedCheckboxPreferenceValue(this));
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
appSettings.setThemedCheckboxPreferenceValue(ThemedCheckBoxPreference.this, b);
if(externalOnCheckedChangedListener != null) {
externalOnCheckedChangedListener.onCheckedChanged(compoundButton, b);
}
}
});
applyColor();
}
}
public void applyColor() {
ThemeHelper.getInstance(appSettings);
ThemeHelper.updateCheckBoxColor(checkBox);
}
public void setTitleText(String text) {
title.setText(text);
}
public void setSummaryText(String text) {
summary.setText(text);
}
public void setChecked(boolean checked) {
checkBox.setChecked(checked);
}
public void setOnCheckedChangedListener(CompoundButton.OnCheckedChangeListener listener) {
externalOnCheckedChangedListener = listener;
}
public String getPrefKey() {
return this.prefKey;
}
public Boolean getDefaultValue() {
return this.defaultValue;
}
@Override
public Boolean getValue() {
return appSettings.getThemedCheckboxPreferenceValue(this);
}
@Override
public void setValue(Boolean value) {
appSettings.setThemedCheckboxPreferenceValue(this, value);
}
}

View file

@ -0,0 +1,169 @@
package com.github.dfa.diaspora_android.ui;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.support.v7.app.AlertDialog;
import android.text.InputType;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.Helpers;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Customizable EditTextPreference-like class
* Created by vanitas on 23.10.16.
*/
public class ThemedIntEditTextPreference extends LinearLayout implements ThemedPreferenceObject<Integer> {
@BindView(R.id.preference__themed_edittext_title)
protected TextView title;
@BindView(R.id.preference__themed_edittext_summary)
protected TextView summary;
protected String prefKey;
protected int defaultValue;
protected AppSettings appSettings;
protected boolean showValueInSummary;
protected OnPositiveButtonClickedListener onPositiveButtonClickedListener;
public ThemedIntEditTextPreference(Context context) {
super(context);
init(context, null, 0);
}
public ThemedIntEditTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
public ThemedIntEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs, defStyle);
}
protected void init(final Context context, AttributeSet attrs, int defStyle) {
appSettings = new AppSettings(context.getApplicationContext());
View.inflate(context, R.layout.preference__themed_edittext, this);
ButterKnife.bind(this);
setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
// Assign custom attributes
if (attrs != null) {
String titleText = "";
String summaryText = "";
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemedIntEditTextPreference, defStyle, 0);
try {
titleText = a.getString(R.styleable.ThemedIntEditTextPreference_titleText);
summaryText = a.getString(R.styleable.ThemedIntEditTextPreference_summaryText);
prefKey = a.getString(R.styleable.ThemedIntEditTextPreference_prefKey);
defaultValue = a.getInt(R.styleable.ThemedIntEditTextPreference_defaultInt, 0);
showValueInSummary = a.getBoolean(R.styleable.ThemedIntEditTextPreference_showValueInSummary, false);
} catch (Exception e) {
AppLog.e(this, "There was an error loading attributes.");
} finally {
a.recycle();
}
final String finalTitle = titleText;
AppLog.d(this, "ShowValueInSummary: "+showValueInSummary + " port: "+appSettings.getProxyHttpPort());
setTitleText(titleText);
setSummaryText(showValueInSummary ? Integer.toString(appSettings.getThemedIntEditTextPreferenceValue(this)) : summaryText);
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
AppLog.d(this, "Click!");
showDialog(context, finalTitle);
}
});
}
}
public void showDialog(Context context, String title) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
final EditText dialogLayout = (EditText) LayoutInflater.from(context).inflate(R.layout.settings_activity__dialog_proxy, null, false);
dialogLayout.setInputType(InputType.TYPE_CLASS_NUMBER);
dialogLayout.setSingleLine();
FrameLayout container = new FrameLayout(context);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int marginHoriz = Helpers.dpToPx(context, (int) context.getResources().getDimension(R.dimen.activity_horizontal_margin_half));
params.leftMargin = marginHoriz;
params.rightMargin = marginHoriz;
dialogLayout.setLayoutParams(params);
container.addView(dialogLayout);
dialogLayout.setText(Integer.toString(appSettings.getThemedIntEditTextPreferenceValue(this)));
builder.setTitle(title)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
setValue(Integer.valueOf(dialogLayout.getText().toString()));
if(onPositiveButtonClickedListener != null) {
onPositiveButtonClickedListener.onPositiveButtonClicked(Integer.valueOf(dialogLayout.getText().toString()));
}
}
}).setNegativeButton(android.R.string.cancel, null)
.setView(container)
.show();
}
public void setTitleText(String titleText) {
this.title.setText(titleText);
if(titleText == null || titleText.equals("")) {
title.setVisibility(GONE);
} else {
title.setVisibility(VISIBLE);
}
}
public void setSummaryText(String summaryText) {
this.summary.setText(summaryText);
if(summaryText == null || summaryText.equals("")) {
summary.setVisibility(GONE);
} else {
title.setVisibility(VISIBLE);
}
}
@Override
public Integer getDefaultValue() {
return defaultValue;
}
@Override
public Integer getValue() {
return appSettings.getThemedIntEditTextPreferenceValue(this);
}
@Override
public void setValue(Integer value) {
appSettings.setThemedIntEditTextPreferenceValue(this, value);
if(showValueInSummary) {
setSummaryText(Integer.toString(value));
}
}
public String getPrefKey() {
return this.prefKey;
}
public void setOnPositiveButtonClickedListener(OnPositiveButtonClickedListener listener) {
this.onPositiveButtonClickedListener = listener;
}
public interface OnPositiveButtonClickedListener {
void onPositiveButtonClicked(int input);
}
}

View file

@ -0,0 +1,122 @@
package com.github.dfa.diaspora_android.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.util.AppLog;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Customizable clickable Preference class
* Created by vanitas on 23.10.16.
*/
public class ThemedPreference extends RelativeLayout implements ThemedPreferenceObject<Void> {
@BindView(R.id.preference__themed_preference_title)
protected TextView title;
@BindView(R.id.preference__themed_preference_summary)
protected TextView summary;
@BindView(R.id.preference__themed_preference_image)
protected ImageView image;
protected String prefKey;
public ThemedPreference(Context context) {
super(context);
init(context, null, 0);
}
public ThemedPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
public ThemedPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs, defStyle);
}
protected void init(Context context, final AttributeSet attrs, int defStyle) {
View.inflate(context, R.layout.preference__themed_preference, this);
ButterKnife.bind(this);
if (attrs != null) {
String titleText = "";
String summaryText = "";
Drawable imageDrawable = null;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemedPreference, defStyle, 0);
try {
titleText = a.getString(R.styleable.ThemedPreference_titleText);
summaryText = a.getString(R.styleable.ThemedPreference_summaryText);
prefKey = a.getString(R.styleable.ThemedPreference_prefKey);
imageDrawable = a.getDrawable(R.styleable.ThemedPreference_image);
} catch (Exception e) {
AppLog.e(this, "There was an error loading attributes.");
} finally {
a.recycle();
}
setTitleText(titleText);
setSummaryText(summaryText);
setImageDrawable(imageDrawable);
}
}
@Override
public String getPrefKey() {
return prefKey;
}
@Override
public void setTitleText(String titleText) {
title.setText(titleText);
if(titleText == null || titleText.equals("")) {
title.setVisibility(GONE);
} else {
title.setVisibility(VISIBLE);
}
}
@Override
public void setSummaryText(String summaryText) {
summary.setText(summaryText);
if(summaryText == null || summaryText.equals("")) {
summary.setVisibility(GONE);
} else {
summary.setVisibility(VISIBLE);
}
}
public void setImageDrawable(Drawable drawable) {
if(drawable != null) {
image.setImageDrawable(drawable);
image.setVisibility(VISIBLE);
} else {
image.setImageDrawable(null);
image.setVisibility(GONE);
}
}
@Override
public Void getDefaultValue() {
return null;
}
@Override
public Void getValue() {
return null;
}
@Override
public void setValue(Void value) {
/* Nope */
}
}

View file

@ -0,0 +1,15 @@
package com.github.dfa.diaspora_android.ui;
/**
* Basic methods a ThemedPreference class should implement
* Created by vanitas on 23.10.16.
*/
public interface ThemedPreferenceObject<T> {
String getPrefKey();
void setTitleText(String titleText);
void setSummaryText(String summaryText);
T getDefaultValue();
T getValue();
void setValue(T value);
}

View file

@ -0,0 +1,167 @@
package com.github.dfa.diaspora_android.ui;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.support.v7.app.AlertDialog;
import android.text.InputType;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.Helpers;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Customizable EditTextPreference-like class
* Created by vanitas on 23.10.16.
*/
public class ThemedStringEditTextPreference extends LinearLayout implements ThemedPreferenceObject<String> {
@BindView(R.id.preference__themed_edittext_title)
protected TextView title;
@BindView(R.id.preference__themed_edittext_summary)
protected TextView summary;
protected String prefKey;
protected String defaultValue;
protected AppSettings appSettings;
protected boolean showValueInSummary;
protected OnPositiveButtonClickedListener onPositiveButtonClickedListener;
public ThemedStringEditTextPreference(Context context) {
super(context);
init(context, null, 0);
}
public ThemedStringEditTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
public ThemedStringEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs, defStyle);
}
protected void init(final Context context, AttributeSet attrs, int defStyle) {
appSettings = new AppSettings(context.getApplicationContext());
View.inflate(context, R.layout.preference__themed_edittext, this);
ButterKnife.bind(this);
setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
// Assign custom attributes
if (attrs != null) {
String titleText = "";
String summaryText = "";
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemedStringEditTextPreference, defStyle, 0);
try {
titleText = a.getString(R.styleable.ThemedStringEditTextPreference_titleText);
summaryText = a.getString(R.styleable.ThemedStringEditTextPreference_summaryText);
prefKey = a.getString(R.styleable.ThemedStringEditTextPreference_prefKey);
defaultValue = a.getString(R.styleable.ThemedStringEditTextPreference_defaultString);
showValueInSummary = a.getBoolean(R.styleable.ThemedStringEditTextPreference_showValueInSummary, false);
} catch (Exception e) {
AppLog.e(this, "There was an error loading attributes.");
} finally {
a.recycle();
}
final String finalTitle = titleText;
setTitleText(titleText);
setSummaryText(showValueInSummary ? appSettings.getThemedStringEditTextPreferenceValue(this) : summaryText);
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
showDialog(context, finalTitle);
}
});
}
}
public void showDialog(Context context, String title) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
final EditText dialogLayout = (EditText) LayoutInflater.from(context).inflate(R.layout.settings_activity__dialog_proxy, null, false);
dialogLayout.setInputType(InputType.TYPE_CLASS_TEXT);
dialogLayout.setText(appSettings.getThemedStringEditTextPreferenceValue(this));
dialogLayout.setSingleLine();
FrameLayout container = new FrameLayout(context);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int marginHoriz = Helpers.dpToPx(context, (int) context.getResources().getDimension(R.dimen.activity_horizontal_margin_half));
params.leftMargin = marginHoriz;
params.rightMargin = marginHoriz;
dialogLayout.setLayoutParams(params);
container.addView(dialogLayout);
builder.setTitle(title)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
setValue(dialogLayout.getText().toString());
if(onPositiveButtonClickedListener != null) {
onPositiveButtonClickedListener.onPositiveButtonClicked(dialogLayout.getText().toString());
}
}
}).setNegativeButton(android.R.string.cancel, null)
.setView(container)
.show();
}
public void setTitleText(String titleText) {
this.title.setText(titleText);
if(titleText == null || titleText.equals("")) {
title.setVisibility(GONE);
} else {
title.setVisibility(VISIBLE);
}
}
public void setSummaryText(String summaryText) {
this.summary.setText(summaryText);
if(summaryText == null || summaryText.equals("")) {
summary.setVisibility(GONE);
} else {
title.setVisibility(VISIBLE);
}
}
@Override
public String getDefaultValue() {
return defaultValue;
}
@Override
public String getValue() {
return appSettings.getThemedStringEditTextPreferenceValue(this);
}
@Override
public void setValue(String value) {
appSettings.setThemedStringEditTextPreferenceValue(this, value);
if(showValueInSummary) {
setSummaryText(value);
}
}
public String getPrefKey() {
return this.prefKey;
}
public void setOnPositiveButtonClickedListener(OnPositiveButtonClickedListener listener) {
this.onPositiveButtonClickedListener = listener;
}
public interface OnPositiveButtonClickedListener {
void onPositiveButtonClicked(String input);
}
}

View file

@ -94,7 +94,7 @@ public class CustomTabActivityHelper {
/** /**
* Register a Callback to be called when connected or disconnected from the Custom Tabs Service * Register a Callback to be called when connected or disconnected from the Custom Tabs Service
* *
* @param connectionCallback * @param connectionCallback connectionCallback
*/ */
public void setConnectionCallback(ConnectionCallback connectionCallback) { public void setConnectionCallback(ConnectionCallback connectionCallback) {
this.mConnectionCallback = connectionCallback; this.mConnectionCallback = connectionCallback;
@ -130,10 +130,14 @@ public class CustomTabActivityHelper {
} }
public boolean mayLaunchUrl(Uri uri, Bundle extras, List<Bundle> otherLikelyBundles) { public boolean mayLaunchUrl(Uri uri, Bundle extras, List<Bundle> otherLikelyBundles) {
if (mClient == null) return false; if (mClient == null) {
return false;
}
CustomTabsSession session = getSession(); CustomTabsSession session = getSession();
if (session == null) return false; if (session == null) {
return false;
}
return session.mayLaunchUrl(uri, extras, otherLikelyBundles); return session.mayLaunchUrl(uri, extras, otherLikelyBundles);
} }

View file

@ -27,6 +27,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
@ -85,7 +86,7 @@ public class Helpers {
public static String readTextfileFromRawRessource(Context context, int rawRessourceId, String linePrefix, String linePostfix) { public static String readTextfileFromRawRessource(Context context, int rawRessourceId, String linePrefix, String linePostfix) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String line = ""; String line;
BufferedReader br = null; BufferedReader br = null;
linePrefix = linePrefix == null ? "" : linePrefix; linePrefix = linePrefix == null ? "" : linePrefix;
linePostfix = linePostfix == null ? "" : linePostfix; linePostfix = linePostfix == null ? "" : linePostfix;
@ -149,4 +150,9 @@ public class Helpers {
} }
return !isOnline; return !isOnline;
} }
public static int dpToPx(Context context, int dp) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
}
} }

View file

@ -8,6 +8,7 @@ import android.support.v4.graphics.ColorUtils;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
/** /**
* ColorPalette
* Created by dnld on 24/02/16. * Created by dnld on 24/02/16.
*/ */
public class ColorPalette { public class ColorPalette {

View file

@ -22,17 +22,18 @@ package com.github.dfa.diaspora_android.util.theming;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.widget.CompoundButtonCompat; import android.support.v4.widget.CompoundButtonCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
@ -95,6 +96,14 @@ public class ThemeHelper {
if (textView != null) { if (textView != null) {
textView.setHighlightColor(getInstance().appSettings.getAccentColor()); textView.setHighlightColor(getInstance().appSettings.getAccentColor());
textView.setLinkTextColor(getInstance().appSettings.getAccentColor()); textView.setLinkTextColor(getInstance().appSettings.getAccentColor());
} else {
Log.d("ThemeHelper", "TextView is null!");
}
}
public static void updateTitleColor(TextView textView) {
if(textView != null) {
textView.setTextColor(getInstance().appSettings.getAccentColor());
} }
} }
@ -104,6 +113,12 @@ public class ThemeHelper {
} }
} }
public static void setToolbarColor(Toolbar toolbar, int color) {
if(toolbar != null) {
toolbar.setBackgroundColor(color);
}
}
public static void updateActionMenuViewColor(ActionMenuView actionMenuView) { public static void updateActionMenuViewColor(ActionMenuView actionMenuView) {
if (actionMenuView != null) { if (actionMenuView != null) {
actionMenuView.setBackgroundColor(getInstance().appSettings.getPrimaryColor()); actionMenuView.setBackgroundColor(getInstance().appSettings.getPrimaryColor());
@ -128,10 +143,8 @@ public class ThemeHelper {
return ColorPalette.getObscuredColor(getPrimaryColor()); return ColorPalette.getObscuredColor(getPrimaryColor());
} }
public static void updateActionBarColor(ActionBar actionBar) { public static int getNeutralGreyColor() {
if (actionBar != null) { return ContextCompat.getColor(getInstance().appSettings.getApplicationContext(), R.color.md_grey_800);
actionBar.setBackgroundDrawable(new ColorDrawable(getInstance().appSettings.getPrimaryColor()));
}
} }
public static void updateProgressBarColor(ProgressBar progressBar) { public static void updateProgressBarColor(ProgressBar progressBar) {
@ -140,6 +153,16 @@ public class ThemeHelper {
} }
} }
public static void updateAccentColorPreview(ImageView imageView) {
if (imageView != null) {
Drawable circle = imageView.getDrawable();
if (circle != null) {
circle.setColorFilter(getAccentColor(), PorterDuff.Mode.SRC_ATOP);
imageView.setImageDrawable(circle);
}
}
}
public static void updateRadioGroupColor(RadioGroup radioGroup) { public static void updateRadioGroupColor(RadioGroup radioGroup) {
if(radioGroup != null && Build.VERSION.SDK_INT >= 21) { if(radioGroup != null && Build.VERSION.SDK_INT >= 21) {
for (int i = 0; i < radioGroup.getChildCount(); ++i) { for (int i = 0; i < radioGroup.getChildCount(); ++i) {
@ -152,7 +175,16 @@ public class ThemeHelper {
} }
} }
public static int getNeutralGreyColor() { public static void updatePrimaryColorPreview(ImageView imageView) {
return ContextCompat.getColor(getInstance().appSettings.getApplicationContext(), R.color.md_grey_800); if(imageView != null) {
Drawable circle = imageView.getDrawable();
if(circle != null) {
circle.setColorFilter(getPrimaryColor(), PorterDuff.Mode.SRC_ATOP);
}
}
}
public static void setViewEnabled(View v, boolean enabled) {
v.setBackgroundColor(getInstance().appSettings.getApplicationContext().getResources().getColor(enabled ? R.color.white : R.color.layout_disabled));
} }
} }

View file

@ -25,6 +25,7 @@ import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.WebHelper; import com.github.dfa.diaspora_android.util.WebHelper;
/** /**
* WebChromeClient for DiasporaStreams
* Created by vanitas on 26.09.16. * Created by vanitas on 26.09.16.
*/ */

View file

@ -24,6 +24,7 @@ import android.webkit.WebView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
/** /**
* WebChromeClient that supports uploading images
* Created by vanitas on 26.09.16. * Created by vanitas on 26.09.16.
*/ */
@ -35,11 +36,6 @@ public class FileUploadWebChromeClient extends ProgressBarWebChromeClient {
this.fileUploadCallback = fileUploadCallback; this.fileUploadCallback = fileUploadCallback;
} }
@Override
public void onProgressChanged(WebView wv, int progress) {
super.onProgressChanged(wv, progress);
}
//For Android 4.1/4.2 only. DO NOT REMOVE! //For Android 4.1/4.2 only. DO NOT REMOVE!
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {

View file

@ -0,0 +1,4 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/md_red_500"/>
</shape>

View file

@ -3,7 +3,6 @@
android:id="@+id/nav_drawer" android:id="@+id/nav_drawer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="110dp" android:layout_height="110dp"
android:background="@color/colorPrimary"
android:gravity="bottom" android:gravity="bottom"
android:orientation="vertical" android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark"> android:theme="@style/ThemeOverlay.AppCompat.Dark">

View file

@ -0,0 +1,32 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/preference__themed_checkbox__root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin">
<LinearLayout
android:id="@+id/preference__themed_checkbox__text_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/preference__themed_checkbox__checkbox">
<TextView
android:id="@+id/preference__themed_checkbox__title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
<TextView
android:id="@+id/preference__themed_checkbox__summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<CheckBox
android:id="@+id/preference__themed_checkbox__checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"/>
</RelativeLayout>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/preference__themed_edittext_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/preference__themed_edittext_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
<TextView
android:id="@+id/preference__themed_edittext_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/preference__themed_preference_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/preference__themed_preference_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_centerVertical="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toEndOf="@+id/preference__themed_preference_image">
<TextView
android:id="@+id/preference__themed_preference_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
<TextView
android:id="@+id/preference__themed_preference_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>

View file

@ -22,7 +22,7 @@
<FrameLayout <FrameLayout
android:id="@+id/settings__fragment_container" android:id="@+id/settings__fragment_container"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior" />

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/pref_entries__font_size" />

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Appearance -->
<android.support.v7.widget.CardView
android:id="@+id/settings_activity__card_appearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/card_spacing"
android:layout_marginBottom="@dimen/card_spacing"
android:layout_marginStart="@dimen/card_spacing"
android:layout_marginEnd="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<include
layout="@layout/settings_activity__section_appearance" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/settings_activity__card_pod_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_spacing"
android:layout_marginStart="@dimen/card_spacing"
android:layout_marginEnd="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<include
layout="@layout/settings_activity__section_pod_settings" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/settings_activity__card_network"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_spacing"
android:layout_marginStart="@dimen/card_spacing"
android:layout_marginEnd="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<include
layout="@layout/settings_activity__section_network" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/settings_activity__card_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_spacing"
android:layout_marginStart="@dimen/card_spacing"
android:layout_marginEnd="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<include
layout="@layout/settings_activity__section_more" />
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_appearance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_cat__visuals"/>
<!-- Themes 'n Colors -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__themes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__themes"
app:summaryText="@string/pref_desc__themes" />
<!-- Navigation Slider Items -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__navigation_slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__sub_nav_slider"
app:summaryText="@string/pref_desc__sub_nav_slider"/>
<!-- Font size -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__font_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__font_size"/>
<!-- Intellihide toolbars -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:id="@+id/settings_activity__intellihide_toolbars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__intellihide_toolbars"
app:summaryText="@string/pref_desc__intellihide_toolbars"
app:prefKey="@string/pref_key__intellihide_toolbars"
app:defaultBoolean="true" />
<!-- Dropdown Notifications -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:id="@+id/settings_activity__dropdown_notifications"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__extended_notifications"
app:summaryText="@string/pref_desc__extended_notifications"
app:prefKey="@string/pref_key__extended_notifications"
app:defaultBoolean="false" />
<!-- Share reference to app -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:id="@+id/settings_activity__append_reference"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__append_shared_via_app"
app:summaryText="@string/pref_desc__append_shared_via_app"
app:prefKey="@string/pref_key__append_shared_via_app"
app:defaultBoolean="true" />
<!-- Chrome custom tabs -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:id="@+id/settings_activity__custom_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__chrome_custom_tabs_enabled"
app:summaryText="@string/pref_desc__chrome_custom_tabs_enabled"
app:prefKey="@string/pref_key__chrome_custom_tabs_enabled"
app:defaultBoolean="true" />
</LinearLayout>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_cat__more"/>
<!-- Debugging -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__debugging"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__sub_logging"
app:summaryText="@string/pref_desc__sub_logging" />
</LinearLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_network"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_cat__network"/>
<!-- Load images -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:id="@+id/settings_activity__load_images"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__load_images"
app:summaryText="@string/pref_desc__load_images"
app:prefKey="@string/pref_key__load_images"
app:defaultBoolean="true" />
<!-- Clear cache -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__clear_cache"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__clear_cache"
app:summaryText="@string/pref_desc__clear_cache" />
<!-- Proxy Settings -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__proxy_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__sub_proxy"
app:summaryText="@string/pref_desc__sub_proxy"/>
</LinearLayout>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_pod_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_cat__pod_settings"/>
<!-- Personal Settings -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__personal_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__personal_settings"
app:summaryText="@string/pref_desc__personal_settings"/>
<!-- Manage tags -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__manage_tags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__manage_tags"
app:summaryText="@string/pref_desc__manage_tags"/>
<!-- Manage Contacts -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__manage_contacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__manage_contacts"
app:summaryText="@string/pref_desc__manage_contacts"/>
<!-- Change Account -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__change_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__change_account"
app:summaryText="@string/pref_desc__change_account"/>
</LinearLayout>

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_more__debugging"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_title__sub_logging"/>
<!-- Debug Protocol -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__logging_enabled"
app:prefKey="@string/pref_key__logging_enabled"
app:defaultBoolean="true"/>
<!-- Verbose debugging -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__logging_spam_enabled"
app:prefKey="@string/pref_key__logging_spam_enabled"
app:defaultBoolean="true"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Proxy -->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_appearance__nav_slider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_title__sub_nav_slider"/>
<!-- Entries -->
<!-- Profile -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_profile"
app:prefKey="@string/pref_key__visibility_nav__profile"
app:defaultBoolean="true"/>
<!-- Followed Tags -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_followed_tags"
app:prefKey="@string/pref_key__visibility_nav__followed_tags"
app:defaultBoolean="true"/>
<!-- Aspects -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_aspects"
app:prefKey="@string/pref_key__visibility_nav__aspects"
app:defaultBoolean="true"/>
<!-- Activities -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_activities"
app:prefKey="@string/pref_key__visibility_nav__activities"
app:defaultBoolean="false"/>
<!-- Liked -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_liked"
app:prefKey="@string/pref_key__visibility_nav__liked"
app:defaultBoolean="true"/>
<!-- Commented -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_commented"
app:prefKey="@string/pref_key__visibility_nav__commented"
app:defaultBoolean="true"/>
<!-- Mentions -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_mentions"
app:prefKey="@string/pref_key__visibility_nav__mentions"
app:defaultBoolean="false"/>
<!-- Public Activities -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_public_activities"
app:prefKey="@string/pref_key__visibility_nav__public_activities"
app:defaultBoolean="false"/>
<!-- Exit -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/action_exit_app"
app:prefKey="@string/pref_key__visibility_nav__exit"
app:defaultBoolean="false"/>
<!-- About -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/nav_help_license"
app:prefKey="@string/pref_key__visibility_nav__help_license"
app:defaultBoolean="true"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Proxy -->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_network__proxy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_title__sub_proxy"/>
<!-- Proxy Enabled -->
<com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference
android:id="@+id/settings_activity__proxy_enabled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__proxy_enabled"
app:summaryText="@string/pref_desc__http_proxy_enabled"
app:prefKey="@string/pref_key__http_proxy_enabled"
app:defaultBoolean="false" />
<!-- Host -->
<com.github.dfa.diaspora_android.ui.ThemedStringEditTextPreference
android:id="@+id/settings_activity__proxy_host"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__http_proxy_host"
app:showValueInSummary="true"
app:defaultString=""
app:prefKey="@string/pref_key__http_proxy_host"/>
<!-- Port -->
<com.github.dfa.diaspora_android.ui.ThemedIntEditTextPreference
android:id="@+id/settings_activity__proxy_port"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__http_proxy_port"
app:showValueInSummary="true"
app:defaultInt="0"
app:prefKey="@string/pref_key__http_proxy_port"/>
<!-- Orbot Preset -->
<com.github.dfa.diaspora_android.ui.ThemedPreference
android:id="@+id/settings_activity__proxy_orbot_preset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleText="@string/pref_title__http_proxy_load_tor_preset"
app:summaryText="@string/pref_desc__http_proxy_load_tor_preset"
app:image="@drawable/tor_onion"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Theme and Colors -->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_spacing"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin_half">
<TextView
android:id="@+id/settings_activity__header_appearance__theme_and_colors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/pref_title__themes"/>
<!-- Primary Color -->
<RelativeLayout
android:id="@+id/settings_activity__theme_colors__primary_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:clickable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toStartOf="@+id/settings_activity__theme_colors__primary_color__preview">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:text="@string/pref_title__primary_color"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pref_desc__primary_color"/>
</LinearLayout>
<ImageView
android:id="@+id/settings_activity__theme_colors__primary_color__preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:minWidth="30dp"
android:minHeight="30dp"
android:src="@drawable/circle"/>
</RelativeLayout>
<!-- Accent Color -->
<RelativeLayout
android:id="@+id/settings_activity__theme_colors__accent_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:clickable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toStartOf="@+id/settings_activity__theme_colors__accent_color__preview">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:text="@string/pref_title__accent_color"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pref_desc__accent_color"/>
</LinearLayout>
<ImageView
android:id="@+id/settings_activity__theme_colors__accent_color__preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:minHeight="30dp"
android:minWidth="30dp"
android:src="@drawable/circle"/>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="titleText" format="string" />
<attr name="summaryText" format="string" />
<attr name="prefKey" format="string" />
<attr name="showValueInSummary" format="boolean" />
<declare-styleable name="ThemedCheckBoxPreference">
<attr name="titleText" />
<attr name="summaryText" />
<attr name="prefKey" />
<attr name="defaultBoolean" format="boolean" />
</declare-styleable>
<declare-styleable name="ThemedStringEditTextPreference">
<attr name="titleText" />
<attr name="summaryText" />
<attr name="prefKey" />
<attr name="defaultString" format="string" />
<attr name="showValueInSummary" />
</declare-styleable>
<declare-styleable name="ThemedIntEditTextPreference">
<attr name="titleText" />
<attr name="summaryText" />
<attr name="prefKey" />
<attr name="defaultInt" format="string" />
<attr name="showValueInSummary" />
</declare-styleable>
<declare-styleable name="ThemedPreference">
<attr name="titleText" />
<attr name="summaryText" />
<attr name="prefKey" />
<attr name="image" format="reference" />
</declare-styleable>
</resources>

View file

@ -15,6 +15,8 @@
<color name="divider">#B6B6B6</color> <color name="divider">#B6B6B6</color>
<!-- End colors from Palette --> <!-- End colors from Palette -->
<color name="layout_disabled">#b6b6b6</color>
<color name="white">#ffffff</color> <color name="white">#ffffff</color>
<color name="black">#000000</color> <color name="black">#000000</color>

View file

@ -15,4 +15,9 @@
<dimen name="textsize_badge_count">11sp</dimen> <dimen name="textsize_badge_count">11sp</dimen>
<dimen name="card_corner_radius">5dp</dimen>
<dimen name="card_elevation">5dp</dimen>
<dimen name="card_spacing">10dp</dimen>
<dimen name="card_margin_horizontal">5dp</dimen>
</resources> </resources>

View file

@ -112,6 +112,7 @@
<string name="pref_title__http_proxy_port">Port</string> <string name="pref_title__http_proxy_port">Port</string>
<string name="HTTP" translatable="false">HTTP</string> <string name="HTTP" translatable="false">HTTP</string>
<string name="SOCKS5" translatable="false">SOCKS5</string> <string name="SOCKS5" translatable="false">SOCKS5</string>
<string name="toast__proxy_orbot_preset_set">Orbot proxy settings applied</string>
<!-- Chrome custom tabs --> <!-- Chrome custom tabs -->