diff --git a/app/build.gradle b/app/build.gradle index e580b2dc..4d4074c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,7 +50,8 @@ dependencies { 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: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 compile 'com.jakewharton:butterknife:8.0.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b4d7d10c..6e88f143 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,8 @@ + android:authorities="com.github.dfa.diaspora_android.mainactivity" + android:exported="false"/> = 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() { @Override public void onClick(View v) { @@ -116,7 +120,7 @@ public class AboutActivity extends ThemedActivity } @Override - protected void applyColorToViews() { + public void applyColorToViews() { ThemeHelper.updateToolbarColor(toolbar); ThemeHelper.updateTabLayoutColor(tabLayout); ThemeHelper.setPrimaryColorAsBackground(linearLayout); @@ -231,9 +235,8 @@ public class AboutActivity extends ThemedActivity } public String getContributorsHtml(Context context) { - String text = Helpers.readTextfileFromRawRessource(context, R.raw.contributors, + return Helpers.readTextfileFromRawRessource(context, R.raw.contributors, "* ", "
"); - return text; } public String getMaintainersHtml(Context context) { @@ -245,9 +248,8 @@ public class AboutActivity extends ThemedActivity } public String getLicenseHtml(Context context) { - String text = Helpers.readTextfileFromRawRessource(context, R.raw.license, + return Helpers.readTextfileFromRawRessource(context, R.raw.license, "", "").replace("\n\n", "

"); - return text; } public String getLicense3dPartyHtml(Context context) { diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 4b3c36f6..24b672c9 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -25,6 +25,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.content.res.AssetManager; import android.graphics.drawable.LayerDrawable; import android.net.Uri; 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.UpdateTitleReceiver; 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.PodSelectionDialog; import com.github.dfa.diaspora_android.util.AppLog; @@ -440,11 +442,28 @@ public class MainActivity extends ThemedActivity } else if (ACTION_CHANGE_ACCOUNT.equals(action)) { AppLog.v(this, "Reset pod data and show PodSelectionFragment"); 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)); } else if (ACTION_CLEAR_CACHE.equals(action)) { 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) { switch (type) { case "text/plain": @@ -528,6 +547,11 @@ public class MainActivity extends ThemedActivity } } + @Override + public AssetManager getAssets() { + return getResources().getAssets(); + } + @Override protected void onStart() { super.onStart(); @@ -588,7 +612,7 @@ public class MainActivity extends ThemedActivity ///Hide bottom toolbar toolbarBottom.setVisibility(View.GONE); } else { - getMenuInflater().inflate(appSettings.isExtendedNotificationsActivated() ? + getMenuInflater().inflate(appSettings.isExtendedNotifications() ? R.menu.main__menu_top__notifications_dropdown : R.menu.main__menu_top, menu); getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu()); top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater()); @@ -631,7 +655,7 @@ public class MainActivity extends ThemedActivity AppLog.i(this, "onOptionsItemSelected()"); switch (item.getItemId()) { case R.id.action_notifications: { - if(appSettings.isExtendedNotificationsActivated()) { + if(appSettings.isExtendedNotifications()) { return true; } //Otherwise we execute the action of action_notifications_all @@ -736,7 +760,7 @@ public class MainActivity extends ThemedActivity if (WebHelper.isOnline(MainActivity.this)) { 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 DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override @@ -877,7 +901,7 @@ public class MainActivity extends ThemedActivity AppLog.v(this, "Set shared text; Subject: \"" + escapedSubject + "\" Body: \"" + escapedBody + "\""); textToBeShared = "**" + escapedSubject + "** " + escapedBody; } else { - AppLog.v(this, "Set shared text; Subject: \"" + sharedSubject + "\" Body: \"" + sharedBody + "\""); + AppLog.v(this, "Set shared text; Subject: \"null\" Body: \"" + sharedBody + "\""); textToBeShared = escapedBody; } } @@ -1090,14 +1114,14 @@ public class MainActivity extends ThemedActivity /** * 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) { this.textToBeShared = textToBeShared; } @Override - protected void applyColorToViews() { + public void applyColorToViews() { ThemeHelper.updateToolbarColor(toolbarTop); ThemeHelper.updateActionMenuViewColor(toolbarBottom); navDrawerLayout.setBackgroundColor(appSettings.getPrimaryColor()); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java index dd0032d7..251e11a7 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java @@ -1,61 +1,50 @@ /* 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 . */ package com.github.dfa.diaspora_android.activity; import android.app.AlarmManager; -import android.app.AlertDialog; import android.app.PendingIntent; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Build; 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.v7.widget.Toolbar; -import android.view.LayoutInflater; -import android.view.MenuItem; 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.data.AppSettings; -import com.github.dfa.diaspora_android.ui.IntellihideToolbarActivityListener; +import com.github.dfa.diaspora_android.fragment.SettingsFragment__Overview; 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.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; + /** - * @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) protected AppBarLayout appBarLayout; @@ -64,12 +53,11 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb private ProxyHandler.ProxySettings oldProxySettings; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.settings__activity); + public void onCreate(Bundle b) { + super.onCreate(b); + this.setContentView(R.layout.settings_activity); ButterKnife.bind(this); + toolbar.setTitle(R.string.settings); setSupportActionBar(toolbar); toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px)); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @@ -79,255 +67,16 @@ public class SettingsActivity extends ThemedActivity implements IntellihideToolb } }); 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 - public boolean onOptionsItemSelected(MenuItem menuItem) { - switch (menuItem.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(menuItem); - } - } - - @Override - protected void applyColorToViews() { + public void applyColorToViews() { + //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 protected void onStop() { ProxyHandler.ProxySettings newProxySettings = getAppSettings().getProxySettings(); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/ThemedActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/ThemedActivity.java index aba3c1c0..301469f6 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/ThemedActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/ThemedActivity.java @@ -49,7 +49,7 @@ public abstract class ThemedActivity extends AppCompatActivity { applyColorToViews(); } - protected abstract void applyColorToViews(); + public abstract void applyColorToViews(); /** * Update color of the status bar diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java index bc724cd8..24fff68a 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java @@ -17,10 +17,14 @@ package com.github.dfa.diaspora_android.data; import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; +import android.os.Build; 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.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 org.json.JSONException; @@ -75,24 +79,24 @@ public class AppSettings { setString(pref, keyRessourceId, sb.toString().replaceFirst("%%%", "")); } - private String[] getStringArray(SharedPreferences pref, int keyRessourceId) { - String value = pref.getString(context.getString(keyRessourceId), "%%%"); + private String[] getStringArray(SharedPreferences pref, int keyResourceId) { + String value = pref.getString(context.getString(keyResourceId), "%%%"); if (value.equals("%%%")) { return new String[0]; } return value.split("%%%"); } - private String getString(SharedPreferences pref, int ressourceId, String defaultValue) { - return pref.getString(context.getString(ressourceId), defaultValue); + private String getString(SharedPreferences pref, int resourceId, String defaultValue) { + return pref.getString(context.getString(resourceId), defaultValue); } - private boolean getBoolean(SharedPreferences pref, int ressourceId, boolean defaultValue) { - return pref.getBoolean(context.getString(ressourceId), defaultValue); + private boolean getBoolean(SharedPreferences pref, int resourceId, boolean defaultValue) { + return pref.getBoolean(context.getString(resourceId), defaultValue); } - private int getInt(SharedPreferences pref, int ressourceId, int defaultValue) { - return pref.getInt(context.getString(ressourceId), defaultValue); + private int getInt(SharedPreferences pref, int resourceId, int defaultValue) { + return pref.getInt(context.getString(resourceId), defaultValue); } @@ -103,7 +107,7 @@ public class AppSettings { 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); } @@ -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= 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_shade, shade); } - public int[] getAccentColorSettings() { + public int[] getAccentColorPickerSettings() { 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_shade, context.getResources().getColor(R.color.accent)) + 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, getColor(R.color.accent)) }; } 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); } -} \ No newline at end of file + + 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(); + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java b/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java index 150f7303..6f59b030 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java @@ -1,5 +1,7 @@ package com.github.dfa.diaspora_android.data; +import android.support.annotation.NonNull; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -280,13 +282,11 @@ public class DiasporaPodList implements Iterable, S } @Override - public int compareTo(DiasporaPod otherPod) { - if (otherPod != null) { - List myPodUrls = getPodUrls(); - List otherPodUrls = otherPod.getPodUrls(); - if (!myPodUrls.isEmpty() && !otherPodUrls.isEmpty()) { - return myPodUrls.get(0).getHost().compareTo(otherPodUrls.get(0).getHost()); - } + public int compareTo(@NonNull DiasporaPod otherPod) { + List myPodUrls = getPodUrls(); + List otherPodUrls = otherPod.getPodUrls(); + if (!myPodUrls.isEmpty() && !otherPodUrls.isEmpty()) { + return myPodUrls.get(0).getHost().compareTo(otherPodUrls.get(0).getHost()); } return name.compareTo(otherPod.getName()); } @@ -406,7 +406,7 @@ public class DiasporaPodList implements Iterable, S /** * Get the base url * - * @return + * @return baseUrl */ public String getBaseUrl() { return protocol + "://" + host + (isPortNeeded() ? port : ""); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/HashtagProvider.java b/app/src/main/java/com/github/dfa/diaspora_android/data/HashtagProvider.java index bcd18511..77476525 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/HashtagProvider.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/HashtagProvider.java @@ -24,21 +24,22 @@ import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; +import android.support.annotation.NonNull; public class HashtagProvider extends ContentProvider { @Override - public int delete(Uri arg0, String arg1, String[] arg2) { + public int delete(@NonNull Uri arg0, String arg1, String[] arg2) { return 0; } @Override - public String getType(Uri arg0) { + public String getType(@NonNull Uri arg0) { return "vnd.android.cursor.item/vnd.cc.tag"; } @Override - public Uri insert(Uri arg0, ContentValues arg1) { + public Uri insert(@NonNull Uri arg0, ContentValues arg1) { return null; } @@ -48,13 +49,13 @@ public class HashtagProvider extends ContentProvider { } @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) { return null; } @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; } } \ No newline at end of file diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/BrowserFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/BrowserFragment.java index 38cabc79..99504588 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/BrowserFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/BrowserFragment.java @@ -107,9 +107,12 @@ public class BrowserFragment extends ThemedFragment { loadUrl(pendingUrl); pendingUrl = null; } - - webView.setParentActivity(getActivity()); - + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + webView.setParentActivity(getActivity()); + } + }); this.setRetainInstance(true); } @@ -149,10 +152,15 @@ public class BrowserFragment extends ThemedFragment { @Override public void onResume() { super.onResume(); - if (webView != null) { - webSettings.setMinimumFontSize(appSettings.getMinimumFontSize()); - webSettings.setLoadsImagesAutomatically(appSettings.isLoadImages()); - } + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (webView != null) { + webSettings.setMinimumFontSize(appSettings.getMinimumFontSize()); + webSettings.setLoadsImagesAutomatically(appSettings.isLoadImages()); + } + } + }); } @SuppressWarnings("ResultOfMethodCallIgnored") @@ -249,16 +257,27 @@ public class BrowserFragment extends ThemedFragment { public boolean onBackPressed() { if (webView.canGoBack()) { - webView.goBack(); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + webView.goBack(); + } + }); return true; } return false; } - public void loadUrl(String url) { + public void loadUrl(final String url) { if (getWebView() != null) { AppLog.v(this, "loadUrl(): load " + url); - getWebView().loadUrlNew(url); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + getWebView().loadUrlNew(url); + } + }); + } else { AppLog.v(this, "loadUrl(): WebView null: Set pending url to " + url); pendingUrl = url; @@ -275,9 +294,15 @@ public class BrowserFragment extends ThemedFragment { public void reloadUrl() { AppLog.v(this, "reloadUrl()"); - if (getWebView() != null) { - getWebView().reload(); - } + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (getWebView() != null) { + getWebView().reload(); + } + } + }); + } public ContextMenuWebView getWebView() { diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java index 6c32d6b9..d63253b4 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java @@ -105,18 +105,18 @@ public class HashtagListFragment extends CustomFragment { private String[] followedTagsList; 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 public TextView title; - public ViewHolder(View v) { + ViewHolder(View v) { super(v); title = (TextView) v.findViewById(R.id.recycler_view__list_item__text); } } // 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.itemClickListener = itemClickListener; } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java index f4d600b4..81301555 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java @@ -22,7 +22,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.res.Resources; import android.os.Build; import android.os.Bundle; 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.DiasporaUrlHelper; import com.github.dfa.diaspora_android.util.Helpers; -import com.github.dfa.diaspora_android.util.theming.ThemeHelper; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Debugging.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Debugging.java new file mode 100644 index 00000000..70bf8c77 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Debugging.java @@ -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 . + */ +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) { + + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__NavigationSlider.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__NavigationSlider.java new file mode 100644 index 00000000..cc855dfb --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__NavigationSlider.java @@ -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 . + */ +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) { + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java new file mode 100644 index 00000000..30026fb9 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java @@ -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 . + */ +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; + } + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Proxy.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Proxy.java new file mode 100644 index 00000000..80ca76a4 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Proxy.java @@ -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 . + */ +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; + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__ThemeColors.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__ThemeColors.java new file mode 100644 index 00000000..804d129e --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__ThemeColors.java @@ -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 . + */ +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(); + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/ThemedSettingsFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/ThemedSettingsFragment.java new file mode 100644 index 00000000..9647d657 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/ThemedSettingsFragment.java @@ -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 . + */ +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(); +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/receiver/OpenExternalLinkReceiver.java b/app/src/main/java/com/github/dfa/diaspora_android/receiver/OpenExternalLinkReceiver.java index add3f685..17af9e98 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/receiver/OpenExternalLinkReceiver.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/receiver/OpenExternalLinkReceiver.java @@ -53,7 +53,7 @@ public class OpenExternalLinkReceiver extends BroadcastReceiver { AppLog.v(this, "OpenExternalLinkReceiver.onReceive(): url"); - Uri url = null; + Uri url; try { String sUrl = receiveIntent.getStringExtra(MainActivity.EXTRA_URL); url = Uri.parse(sUrl); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/task/StatisticsFetchTask.java b/app/src/main/java/com/github/dfa/diaspora_android/task/StatisticsFetchTask.java index b8b0b0e9..7a0034b6 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/task/StatisticsFetchTask.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/task/StatisticsFetchTask.java @@ -56,7 +56,6 @@ public class StatisticsFetchTask extends AsyncTask { @Override protected Void doInBackground(Void... params) { - String extractedProfileData = null; final CookieManager cookieManager = app.getCookieManager(); String cookies = cookieManager.getCookie(urls.getPodUrl()); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java index cc585aea..188fd189 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java @@ -28,6 +28,7 @@ import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; +import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import com.github.dfa.diaspora_android.R; @@ -67,7 +68,7 @@ public class BadgeDrawable extends Drawable { } @Override - public void draw(Canvas canvas) { + public void draw(@NonNull Canvas canvas) { if (!shouldDraw) { return; } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java index 62a78550..75389b23 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java @@ -5,7 +5,6 @@ import android.app.Dialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatDialogFragment; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -35,12 +34,13 @@ import butterknife.OnClick; import butterknife.OnItemSelected; /** + * Dialog that lets the user chose a pod * Created by gsantner (https://gsantner.github.io) on 06.10.16. */ public class PodSelectionDialog extends ThemedAppCompatDialogFragment { public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionDialog"; - public static interface PodSelectionDialogResultListener { + public interface PodSelectionDialogResultListener { void onPodSelectionDialogResult(DiasporaPod pod, boolean accepted); } @@ -118,8 +118,8 @@ public class PodSelectionDialog extends ThemedAppCompatDialogFragment { textProfile.setVisibility(View.VISIBLE); spinnerProfile.setVisibility(View.VISIBLE); String[] podUrlss = new String[podUrls.size()]; - for (int i = 0; i < podUrls.size(); podUrlss[i] = podUrls.get(i++).getBaseUrl()) ; - ArrayAdapter spinnerAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, podUrlss); + //for (int i = 0; i < podUrls.size(); podUrlss[i] = podUrls.get(i++).getBaseUrl()) ; + ArrayAdapter spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, podUrlss); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerProfile.setAdapter(spinnerAdapter); } @@ -131,11 +131,11 @@ public class PodSelectionDialog extends ThemedAppCompatDialogFragment { protected void applyColorsToViews() { ThemeHelper.getInstance(app.getSettings()); - textPodAddress.setTextColor(ThemeHelper.getAccentColor()); - textPodName.setTextColor(ThemeHelper.getAccentColor()); - textProfile.setTextColor(ThemeHelper.getAccentColor()); - textProtocol.setTextColor(ThemeHelper.getAccentColor()); - textTorPreset.setTextColor(ThemeHelper.getAccentColor()); + ThemeHelper.updateTitleColor(textPodAddress); + ThemeHelper.updateTitleColor(textPodName); + ThemeHelper.updateTitleColor(textProfile); + ThemeHelper.updateTitleColor(textProtocol); + ThemeHelper.updateTitleColor(textTorPreset); ThemeHelper.updateEditTextColor(editPodAddress); ThemeHelper.updateEditTextColor(editPodName); @@ -205,7 +205,6 @@ public class PodSelectionDialog extends ThemedAppCompatDialogFragment { if(pod.getPodUrl().getHost().endsWith(".onion") && checkboxTorPreset.isChecked()){ AppSettings settings = app.getSettings(); settings.setProxyHttpEnabled(true); - settings.setProxyWasEnabled(false); settings.setProxyHttpPort(8118); settings.setProxyHttpHost("127.0.0.1"); ProxyHandler.getInstance().updateProxySettings(getContext()); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java new file mode 100644 index 00000000..2af9be37 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java @@ -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 { + + @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); + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedIntEditTextPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedIntEditTextPreference.java new file mode 100644 index 00000000..c91d311a --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedIntEditTextPreference.java @@ -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 { + @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); + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreference.java new file mode 100644 index 00000000..710ef7fb --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreference.java @@ -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 { + + @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 */ + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceObject.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceObject.java new file mode 100644 index 00000000..a0218fcb --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceObject.java @@ -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 { + String getPrefKey(); + void setTitleText(String titleText); + void setSummaryText(String summaryText); + T getDefaultValue(); + T getValue(); + void setValue(T value); +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedStringEditTextPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedStringEditTextPreference.java new file mode 100644 index 00000000..fb80be55 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedStringEditTextPreference.java @@ -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 { + @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); + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/CustomTabHelpers/CustomTabActivityHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/util/CustomTabHelpers/CustomTabActivityHelper.java index 0429b44b..e6c573aa 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/CustomTabHelpers/CustomTabActivityHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/CustomTabHelpers/CustomTabActivityHelper.java @@ -94,7 +94,7 @@ public class CustomTabActivityHelper { /** * 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) { this.mConnectionCallback = connectionCallback; @@ -130,10 +130,14 @@ public class CustomTabActivityHelper { } public boolean mayLaunchUrl(Uri uri, Bundle extras, List otherLikelyBundles) { - if (mClient == null) return false; + if (mClient == null) { + return false; + } CustomTabsSession session = getSession(); - if (session == null) return false; + if (session == null) { + return false; + } return session.mayLaunchUrl(uri, extras, otherLikelyBundles); } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java b/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java index 68b10dca..2b16a58a 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java @@ -27,6 +27,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.support.design.widget.Snackbar; +import android.util.DisplayMetrics; import android.view.View; 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) { StringBuilder sb = new StringBuilder(); - String line = ""; + String line; BufferedReader br = null; linePrefix = linePrefix == null ? "" : linePrefix; linePostfix = linePostfix == null ? "" : linePostfix; @@ -149,4 +150,9 @@ public class Helpers { } return !isOnline; } + + public static int dpToPx(Context context, int dp) { + DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); + return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); + } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ColorPalette.java b/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ColorPalette.java index 160ea719..f9a1ce82 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ColorPalette.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ColorPalette.java @@ -8,6 +8,7 @@ import android.support.v4.graphics.ColorUtils; import com.github.dfa.diaspora_android.R; /** + * ColorPalette * Created by dnld on 24/02/16. */ public class ColorPalette { diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java index ff451e6c..616ba63c 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/theming/ThemeHelper.java @@ -22,17 +22,18 @@ package com.github.dfa.diaspora_android.util.theming; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.PorterDuff; -import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; import android.os.Build; import android.support.design.widget.TabLayout; import android.support.v4.content.ContextCompat; import android.support.v4.widget.CompoundButtonCompat; -import android.support.v7.app.ActionBar; import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.Toolbar; +import android.util.Log; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; +import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.RadioButton; import android.widget.RadioGroup; @@ -95,6 +96,14 @@ public class ThemeHelper { if (textView != null) { textView.setHighlightColor(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) { if (actionMenuView != null) { actionMenuView.setBackgroundColor(getInstance().appSettings.getPrimaryColor()); @@ -128,10 +143,8 @@ public class ThemeHelper { return ColorPalette.getObscuredColor(getPrimaryColor()); } - public static void updateActionBarColor(ActionBar actionBar) { - if (actionBar != null) { - actionBar.setBackgroundDrawable(new ColorDrawable(getInstance().appSettings.getPrimaryColor())); - } + public static int getNeutralGreyColor() { + return ContextCompat.getColor(getInstance().appSettings.getApplicationContext(), R.color.md_grey_800); } 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) { if(radioGroup != null && Build.VERSION.SDK_INT >= 21) { for (int i = 0; i < radioGroup.getChildCount(); ++i) { @@ -152,7 +175,16 @@ public class ThemeHelper { } } - public static int getNeutralGreyColor() { - return ContextCompat.getColor(getInstance().appSettings.getApplicationContext(), R.color.md_grey_800); + public static void updatePrimaryColorPreview(ImageView imageView) { + 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)); } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java b/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java index 759fc317..7fbb281f 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java @@ -25,6 +25,7 @@ import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.WebHelper; /** + * WebChromeClient for DiasporaStreams * Created by vanitas on 26.09.16. */ diff --git a/app/src/main/java/com/github/dfa/diaspora_android/webview/FileUploadWebChromeClient.java b/app/src/main/java/com/github/dfa/diaspora_android/webview/FileUploadWebChromeClient.java index 5e714211..1f3c26d5 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/webview/FileUploadWebChromeClient.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/webview/FileUploadWebChromeClient.java @@ -24,6 +24,7 @@ import android.webkit.WebView; import android.widget.ProgressBar; /** + * WebChromeClient that supports uploading images * Created by vanitas on 26.09.16. */ @@ -35,11 +36,6 @@ public class FileUploadWebChromeClient extends ProgressBarWebChromeClient { 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! @SuppressWarnings("unused") protected void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { diff --git a/app/src/main/res/drawable/circle.xml b/app/src/main/res/drawable/circle.xml new file mode 100644 index 00000000..f944640b --- /dev/null +++ b/app/src/main/res/drawable/circle.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/main__nav_header.xml b/app/src/main/res/layout/main__nav_header.xml index d3294497..c5e5a1fa 100644 --- a/app/src/main/res/layout/main__nav_header.xml +++ b/app/src/main/res/layout/main__nav_header.xml @@ -3,7 +3,6 @@ android:id="@+id/nav_drawer" android:layout_width="wrap_content" android:layout_height="110dp" - android:background="@color/colorPrimary" android:gravity="bottom" android:orientation="vertical" android:theme="@style/ThemeOverlay.AppCompat.Dark"> diff --git a/app/src/main/res/layout/preference__themed_checkbox.xml b/app/src/main/res/layout/preference__themed_checkbox.xml new file mode 100644 index 00000000..1dc5177a --- /dev/null +++ b/app/src/main/res/layout/preference__themed_checkbox.xml @@ -0,0 +1,32 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/preference__themed_edittext.xml b/app/src/main/res/layout/preference__themed_edittext.xml new file mode 100644 index 00000000..5412b4f2 --- /dev/null +++ b/app/src/main/res/layout/preference__themed_edittext.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/preference__themed_preference.xml b/app/src/main/res/layout/preference__themed_preference.xml new file mode 100644 index 00000000..6df4399d --- /dev/null +++ b/app/src/main/res/layout/preference__themed_preference.xml @@ -0,0 +1,31 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings__activity.xml b/app/src/main/res/layout/settings_activity.xml similarity index 96% rename from app/src/main/res/layout/settings__activity.xml rename to app/src/main/res/layout/settings_activity.xml index 99cd2afe..129bb787 100644 --- a/app/src/main/res/layout/settings__activity.xml +++ b/app/src/main/res/layout/settings_activity.xml @@ -22,7 +22,7 @@ diff --git a/app/src/main/res/layout/settings_activity__dialog_font_size.xml b/app/src/main/res/layout/settings_activity__dialog_font_size.xml new file mode 100644 index 00000000..8ac20a25 --- /dev/null +++ b/app/src/main/res/layout/settings_activity__dialog_font_size.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__dialog_proxy.xml b/app/src/main/res/layout/settings_activity__dialog_proxy.xml new file mode 100644 index 00000000..c6bb1fe4 --- /dev/null +++ b/app/src/main/res/layout/settings_activity__dialog_proxy.xml @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__overview.xml b/app/src/main/res/layout/settings_activity__overview.xml new file mode 100644 index 00000000..b6b741e6 --- /dev/null +++ b/app/src/main/res/layout/settings_activity__overview.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__section_appearance.xml b/app/src/main/res/layout/settings_activity__section_appearance.xml new file mode 100644 index 00000000..b1b9635a --- /dev/null +++ b/app/src/main/res/layout/settings_activity__section_appearance.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__section_more.xml b/app/src/main/res/layout/settings_activity__section_more.xml new file mode 100644 index 00000000..0ce3a406 --- /dev/null +++ b/app/src/main/res/layout/settings_activity__section_more.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__section_network.xml b/app/src/main/res/layout/settings_activity__section_network.xml new file mode 100644 index 00000000..3cb9c3e7 --- /dev/null +++ b/app/src/main/res/layout/settings_activity__section_network.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__section_pod_settings.xml b/app/src/main/res/layout/settings_activity__section_pod_settings.xml new file mode 100644 index 00000000..c61f12b9 --- /dev/null +++ b/app/src/main/res/layout/settings_activity__section_pod_settings.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__subsection_debugging.xml b/app/src/main/res/layout/settings_activity__subsection_debugging.xml new file mode 100644 index 00000000..312a2bfa --- /dev/null +++ b/app/src/main/res/layout/settings_activity__subsection_debugging.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__subsection_nav_slider.xml b/app/src/main/res/layout/settings_activity__subsection_nav_slider.xml new file mode 100644 index 00000000..02661a7a --- /dev/null +++ b/app/src/main/res/layout/settings_activity__subsection_nav_slider.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__subsection_proxy.xml b/app/src/main/res/layout/settings_activity__subsection_proxy.xml new file mode 100644 index 00000000..c6abf4fa --- /dev/null +++ b/app/src/main/res/layout/settings_activity__subsection_proxy.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__subsection_theming.xml b/app/src/main/res/layout/settings_activity__subsection_theming.xml new file mode 100644 index 00000000..356fe4fe --- /dev/null +++ b/app/src/main/res/layout/settings_activity__subsection_theming.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml new file mode 100644 index 00000000..0f94c192 --- /dev/null +++ b/app/src/main/res/values/attrs.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/color.xml b/app/src/main/res/values/color.xml index 7f16c9e6..795bb000 100644 --- a/app/src/main/res/values/color.xml +++ b/app/src/main/res/values/color.xml @@ -15,6 +15,8 @@ #B6B6B6 + #b6b6b6 + #ffffff #000000 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 35131109..493c5982 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -15,4 +15,9 @@ 11sp + + 5dp + 5dp + 10dp + 5dp diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml index dafbf2ff..c72c60ea 100644 --- a/app/src/main/res/values/strings-preferences.xml +++ b/app/src/main/res/values/strings-preferences.xml @@ -112,6 +112,7 @@ Port HTTP SOCKS5 + Orbot proxy settings applied