package com.amaze.filemanager.utils; import android.content.SharedPreferences; import android.graphics.Color; import com.amaze.filemanager.utils.color.ColorUsage; import java.util.Calendar; /** * Created by Vishal on 12-05-2015. */ public class PreferenceUtils { private static int primary = -1, accent = -1, folder = -1, primaryTwo = -1; public static final String KEY_PRIMARY_TWO = "skin_two"; public static final String KEY_PRIMARY = "skin"; public static final String KEY_ACCENT = "accent_skin"; public static final String KEY_ICON_SKIN = "icon_skin"; public static final String KEY_CURRENT_TAB = "current_tab"; public static final String KEY_ROOT = "rootmode"; public static final String KEY_PATH_COMPRESS = "zippath"; public static final int DEFAULT_PRIMARY = 4; public static final int DEFAULT_ACCENT = 1; public static final int DEFAULT_ICON = -1; public static final int DEFAULT_CURRENT_TAB = 1; public static int getStatusColor(String skin) { int c=darker(Color.parseColor(skin),0.6f); return c; } public static int getStatusColor(int skin) { int c=darker(skin,0.6f); return c; } public static int darker (int color, float factor) { int a = Color.alpha(color); int r = Color.red( color ); int g = Color.green( color ); int b = Color.blue( color ); return Color.argb( a, Math.max( (int)(r * factor), 0 ), Math.max( (int)(g * factor), 0 ), Math.max( (int)(b * factor), 0 ) ); } /** * @deprecated use {@link com.amaze.filemanager.activities.BaseActivity#getColorPreference()#getColor(int)} * and {@link ColorUsage#ACCENT} * @param Sp * @return */ public static int getAccent(SharedPreferences Sp) { if (accent == -1) accent = Sp.getInt(KEY_ACCENT, DEFAULT_ACCENT); return accent; } /** * Get primary color of second tab from preferences * @return the color position in color array; from the preferences */ public static int getPrimaryTwoColor(SharedPreferences Sp) { return primaryTwo==-1 ? Sp.getInt(KEY_PRIMARY_TWO, DEFAULT_PRIMARY) : null; } public static int getFolderColor(SharedPreferences Sp){ if(folder==DEFAULT_ICON) { int icon = Sp.getInt(KEY_ICON_SKIN, DEFAULT_ICON); folder = icon == DEFAULT_ICON ? Sp.getInt(KEY_ACCENT, DEFAULT_ACCENT) : icon; } return folder; } /** * @deprecated use {@link com.amaze.filemanager.activities.BaseActivity#getColorPreference()#getColor(int)} * and {@link ColorUsage#ACCENT} * @param Sp * @return */ public static String getAccentString(SharedPreferences Sp) { return (colors[getAccent(Sp)]); } public static void reset(){ primary=accent=folder=primaryTwo=-1; } /** * @deprecated use {@link com.amaze.filemanager.activities.BaseActivity#getColorPreference()#getColor(int)} * and {@link ColorUsage#ACCENT} */ public final static String[] colors = new String[]{ "#F44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196F3", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8bc34a", "#FFC107", "#FF9800", "#FF5722", "#795548", "#212121", "#607d8b", "#004d40" }; public static final String LICENCE_TERMS = "<html><body>" + "<h3>Notices for files:</h3>" + "<ul><li>nineoldandroids-2.4.0.jar</ul></li>" + //nineoldandroids "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Copyright 2012 Jake Wharton<br>" + " * <br>" + " * Licensed under the Apache License, Version 2.0 (the \"License\");<br>" + " * you may not use this file except in compliance with the License.<br>" + " * You may obtain a copy of the License at<br>" + " * <br>" + " *    http://www.apache.org/licenses/LICENSE-2.0<br>" + " * <br>" + " * Unless required by applicable law or agreed to in writing, software<br>" + " * distributed under the License is distributed on an \"AS IS\" BASIS,<br>" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>" + " * See the License for the specific language governing permissions and<br>" + " * limitations under the License.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3> " + "<ul><li>libsuperuser</ul></li>" + //libsupersu "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Apache License<br>" + " * Version 2.0, January 2004<br>" + " * http://www.apache.org/licenses/<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3> " + "<ul><li>CircularImageView</ul></li>" + //CircularImageView "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * The MIT License (MIT)<br>" + " *<br>" + " * Copyright (c) 2014 Pkmmte Xeleon<br>" + " *<br>" + " * Permission is hereby granted, free of charge, to any person obtaining a copy<br>" + " * of this software and associated documentation files (the \"Software\"), to deal<br>" + " * in the Software without restriction, including without limitation the rights<br>" + " * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br>" + " * copies of the Software, and to permit persons to whom the Software is<br>" + " * furnished to do so, subject to the following conditions:" + " *<br>" + " * The above copyright notice and this permission notice shall be included in<br>" + " * all copies or substantial portions of the Software.<br>" + " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>" + " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>" + " * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>" + " * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>" + " * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br>" + " * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br>" + " * THE SOFTWARE.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3> " + "<ul><li>FloatingActionButton</ul></li>" + //FloatingActionBar "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * The MIT License (MIT)<br>" + " *<br>" + " * Copyright (c) 2014 Oleksandr Melnykov<br>" + " *<br>" + " * Permission is hereby granted, free of charge, to any person obtaining a copy<br>" + " * of this software and associated documentation files (the \"Software\"), to deal<br>" + " * in the Software without restriction, including without limitation the rights<br>" + " * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br>" + " * copies of the Software, and to permit persons to whom the Software is<br>" + " * furnished to do so, subject to the following conditions:" + " *<br>" + " * The above copyright notice and this permission notice shall be included in<br>" + " * all copies or substantial portions of the Software.<br>" + " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>" + " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>" + " * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>" + " * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>" + " * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br>" + " * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br>" + " * THE SOFTWARE.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3>" + "<ul><li>Android System Bar Tint</ul></li>" + // SystemBar tint "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Copyright 2013 readyState Software Limited<br>" + " * <br>" + " * Licensed under the Apache License, Version 2.0 (the \"License\");<br>" + " * you may not use this file except in compliance with the License.<br>" + " * You may obtain a copy of the License at<br>" + " * <br>" + " *    http://www.apache.org/licenses/LICENSE-2.0<br>" + " * <br>" + " * Unless required by applicable law or agreed to in writing, software<br>" + " * distributed under the License is distributed on an \"AS IS\" BASIS,<br>" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>" + " * See the License for the specific language governing permissions and<br>" + " * limitations under the License.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3> " + "<ul><li>Material Dialogs</ul></li>" + //Material Dialogs "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * The MIT License (MIT)<br>" + " *<br>" + " * Copyright (c) 2014 Aidan Michael Follestad<br>" + " *<br>" + " * Permission is hereby granted, free of charge, to any person obtaining a copy<br>" + " * of this software and associated documentation files (the \"Software\"), to deal<br>" + " * in the Software without restriction, including without limitation the rights<br>" + " * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br>" + " * copies of the Software, and to permit persons to whom the Software is<br>" + " * furnished to do so, subject to the following conditions:" + " *<br>" + " * The above copyright notice and this permission notice shall be included in<br>" + " * all copies or substantial portions of the Software.<br>" + " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>" + " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>" + " * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>" + " * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>" + " * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br>" + " * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br>" + " * THE SOFTWARE.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3>" + "<ul><li>UnRAR</ul></li>" + // junRar "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * UnRAR - free utility for RAR archives<br>" + " * License for use and distribution of<br>" + " * FREE portable version<br>" + " */ " + "<br><br>" + "https://raw.githubusercontent.com/junrar/junrar/master/license.txt" + "<br><br></code></p>" + "<h3>Notices for libraries:</h3>" + "<ul><li>commons-compress</ul></li>" + // commons-compress "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Copyright [yyyy] [name of copyright owner]<br>" + " * <br>" + " * Licensed under the Apache License, Version 2.0 (the \"License\");<br>" + " * you may not use this file except in compliance with the License.<br>" + " * You may obtain a copy of the License at<br>" + " * <br>" + " *    http://www.apache.org/licenses/LICENSE-2.0<br>" + " * <br>" + " * Unless required by applicable law or agreed to in writing, software<br>" + " * distributed under the License is distributed on an \"AS IS\" BASIS,<br>" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>" + " * See the License for the specific language governing permissions and<br>" + " * limitations under the License.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3>" + "<ul><li>sticky-headers-recyclerview</ul></li>" + // stickyHeadersRecyclerView "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Copyright 2014 Jacob Tabak - Timehop<br>" + " * <br>" + " * Licensed under the Apache License, Version 2.0 (the \"License\");<br>" + " * you may not use this file except in compliance with the License.<br>" + " * You may obtain a copy of the License at<br>" + " * <br>" + " *    http://www.apache.org/licenses/LICENSE-2.0<br>" + " * <br>" + " * Unless required by applicable law or agreed to in writing, software<br>" + " * distributed under the License is distributed on an \"AS IS\" BASIS,<br>" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>" + " * See the License for the specific language governing permissions and<br>" + " * limitations under the License.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3>" + "<ul><li>JCIFS</ul></li>" + // jcifs "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Copyright (C) <year> <name of author><br>" + " * <br>" + " * This library is free software; you can redistribute it and/or<br>" + " * modify it under the terms of the GNU Lesser General Public<br>" + " * License as published by the Free Software Foundation; either<br>" + " * version 2.1 of the License, or (at your option) any later version.<br>" + " * <br>" + " * This library is distributed in the hope that it will be useful,<br>" + " * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>" + " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>" + " * Lesser General Public License for more details.<br>" + " * <br>" + " * You should have received a copy of the GNU Lesser General Public<br>" + " * License along with this library; if not, write to the Free Software<br>" + " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3>" + "<ul><li>Apache Mina</li> <li>Apache FtpServer</li></ul>" + // apache "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Copyright [yyyy] [name of copyright owner]<br>" + " * <br>" + " * Licensed under the Apache License, Version 2.0 (the \"License\");<br>" + " * you may not use this file except in compliance with the License.<br>" + " * You may obtain a copy of the License at<br>" + " * <br>" + " *    http://www.apache.org/licenses/LICENSE-2.0<br>" + " * <br>" + " * Unless required by applicable law or agreed to in writing, software<br>" + " * distributed under the License is distributed on an \"AS IS\" BASIS,<br>" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>" + " * See the License for the specific language governing permissions and<br>" + " * limitations under the License.<br>" + " */ " + "<br><br></code></p>" + "<h3>Notices for libraries:</h3>" + "<ul><li>MPAndroidChart</ul></li>" + // MPAndroidChart "<p style = 'background-color:#eeeeee;padding-left:1em'><code>" + "<br>/*<br>" + " * Copyright 2016 Philipp Jahoda<br>" + " * <br>" + " * Licensed under the Apache License, Version 2.0 (the \"License\");<br>" + " * you may not use this file except in compliance with the License.<br>" + " * You may obtain a copy of the License at<br>" + " * <br>" + " *    http://www.apache.org/licenses/LICENSE-2.0<br>" + " * <br>" + " * Unless required by applicable law or agreed to in writing, software<br>" + " * distributed under the License is distributed on an \"AS IS\" BASIS,<br>" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>" + " * See the License for the specific language governing permissions and<br>" + " * limitations under the License.<br>" + " */ " + "<br><br></code></p>" + "</body></html>"; @Deprecated public static int hourOfDay() { Calendar calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); if (hour <= 6 || hour >= 18) { return 1; } else return 0; } }